How can I change the installation path of an autotools-based Bitbake recipe?

和自甴很熟 提交于 2019-12-07 16:12:17

问题


I have an autotools-based BitBake recipe which I would like to have binaries installed in /usr/local/bin and libraries installed in /usr/local/lib (instead of /usr/bin and /usr/lib, which are the default target directories).

Here's a part of the autotools.bbclass file which I found important.

CONFIGUREOPTS = " --build=${BUILD_SYS} \
                  --host=${HOST_SYS} \
                  --target=${TARGET_SYS} \
                  --prefix=${prefix} \
                  --exec_prefix=${exec_prefix} \
                  --bindir=${bindir} \
                  --sbindir=${sbindir} \
                  --libexecdir=${libexecdir} \
                  --datadir=${datadir} \
                  --sysconfdir=${sysconfdir} \
                  --sharedstatedir=${sharedstatedir} \
                  --localstatedir=${localstatedir} \
                  --libdir=${libdir} \
                  ...

I thought that the easiest way to accomplish what I wanted to do would be to simply change ${bindir} and ${libdir}, or perhaps change ${prefix} to /usr/local, but I haven't had any success in this area. Is there a way to change these installation variables, or am I thinking about this in the wrong way?


Update:

Strategy 1

As per Ross Burton's suggestion, I've tried adding the following to my recipe:

prefix="/usr/local"
exec_prefix="/usr/local"

but this causes the build to fail during that recipe's do_configure() task, and returns the following:

| checking for GLIB... no
| configure: error: Package requirements (glib-2.0 >= 2.12.3) were not met:
| 
| No package 'glib-2.0' found

This package can be found during a normal build without these modified variables. I thought that adding the following line might allow the system to find the package metadata for glib:

PKG_CONFIG_PATH = " ${STAGING_DIR_HOST}/usr/lib/pkgconfig  "

but this seems to have made no difference.

Strategy 2

I've also tried Ross Burton's other suggestion to add these variable assignments into my distribution's configuration file, but this causes it to fail during meta/recipes-extended/tzdata's do_install() task. It returns that DEFAULT_TIMEZONE is set to an invalid value. Here's the source of the error from tzdata_2015g.bb

# Install default timezone
if [ -e ${D}${datadir}/zoneinfo/${DEFAULT_TIMEZONE} ]; then
    install -d ${D}${sysconfdir}
    echo ${DEFAULT_TIMEZONE} > ${D}${sysconfdir}/timezone
    ln -s ${datadir}/zoneinfo/${DEFAULT_TIMEZONE}      ${D}${sysconfdir}/localtime
else
    bberror "DEFAULT_TIMEZONE is set to an invalid value."
    exit 1
fi

I'm assuming that I've got a problem with ${datadir}, which references ${prefix}.


回答1:


Do you want to change paths for everything or just one recipe? Not sure why you'd want to change just one recipe to /usr/local, but whatever.

If you want to change all of them, then the simple way is to set prefix in your local.conf or distro configuration (prefix = "/usr/local").

If you want to do it in a particular recipe, then just assigning prefix="/usr/local" and exec_prefix="/usr/local" in the recipe will work.

These variables are defined in meta/conf/bitbake.conf, where you can see that bindir is $exec_prefix/bin, which is probably why assigning prefix didn't work for you.




回答2:


Your first strategy was on the right track, but you were clobbering more than you wanted by changing only "prefix". If you look in sources/poky/meta/conf/bitbake.conf you'll find everything you are clobbering when you set the variable "prefix" to something other than "/usr" (like it was in my case). In order to modify only the install path with what would manually be the "--prefix" option to configure, I needed to set all the variables listed here in that recipe:

prefix="/your/install/path/here"
datadir="/usr/share"
sharedstatedir="/usr/com"
exec_prefix="/usr"


来源:https://stackoverflow.com/questions/35206207/how-can-i-change-the-installation-path-of-an-autotools-based-bitbake-recipe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!