Fix for #7040 - Support for /usr merge
v3 cover Fix for #7040 - Support for /usr merge
This set of patches implements the long-standing feature - merging of /bin, /sbin, /libs to their /usr counterparts.
It introduces a 'usrmerge' DISTRO_FEATURE, when it's enabled:
- other than native all base paths(base_{bin,sbin,lib}dir) points to ${exec_prefix}/{bin,sbin,lib}
- base-files package adds the needed root links(/bin, /sbin, /lib{32,64}) points to /usr counterparts
- As most of shell scripts refer "#!/bin/{sh,bash}" inside script, so makes sure that get added to RPROVIDES_ list by those packages to satisfy the build dependencies.
The assumption is that no recipe uses hard coded paths in recipes where pre-defined bitbake configuration variables are available. I have fixed quite many recipes that i found which violates this assumption. A sanity check is added for reporting these broken recipies.
I have tested this change on core-minimal, sato, windriver cube-desktop and intel-iot-refkit image builds. And i would prefer to run autobuilder tests prior to merging.
Changes in v2:
- Moved root links creation out from 'base-files' to pre-rootfs.
- Fixes to lsb, lttng-modules recipes., that are failed in autobuilder tests.
- Added insane check to usrmerge feature.
- Fixed typos in commit messages.
Changes in v3:
- Rebased against master and dropped patches those got already merged.
- As per review comments added new configuration variable ${root_prefix} that will be altered based on 'usrmerge' distro feature.
- Made use of ${root_prefix} in place of ${base_preix} both in systemd recipe and cross.bbclass
- Dropped patch that is touching nativesdk configuration.
Amarnath Valluri (8):
bitbake.conf: support for merged usr with DISTRO_FEATURE usrmerge cross.bbclass: merged /usr support
systemd: chagnes to support merged /usr
bash: changes to support merged /usr
busybox: changes to support merged /usr
sed: changes to support merged /usr
image: create symlinks needed for merged /usr insane.bbclass: Add package QA check for merged /usr.
meta/classes/cross.bbclass | 4 ++-- meta/classes/image.bbclass | 23 +++++++++++++++++++++++ meta/classes/insane.bbclass | 16 ++++++++++++++++ meta/conf/bitbake.conf | 10 ++++++---- meta/recipes-core/busybox/busybox.inc | 2 ++ meta/recipes-core/systemd/systemd_232.bb | 6 +++--- meta/recipes-extended/bash/bash.inc | 2 ++ meta/recipes-extended/sed/sed_4.2.2.bb | 1 + 8 files changed, 55 insertions(+), 9 deletions(-)
Signature · 1 line
2.7.4
PATCH v3 1/8 bitbake.conf: support for merged usr with DISTRO_FEATURE usrmerge
A new configuration variable ${root_prefix} added, which shall be used by all base_{lib,bin,sbin}dir variables. When usrmerge DISTRO_FEATURE is enabled ${root_prefix} points to ${exec_prefix} otherwise to ${base_prefix}
--- meta/conf/bitbake.conf | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
meta/conf/bitbake.conf +6 -4
@@ -17,11 +17,13 @@ export base_prefix = "" export prefix = "/usr" export exec_prefix = "${prefix}" +export root_prefix = "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '${exec_prefix}', '${base_prefix}', d)}" + # Base paths -export base_bindir = "${base_prefix}/bin" -export base_sbindir = "${base_prefix}/sbin" -export base_libdir = "${base_prefix}/${baselib}" -export nonarch_base_libdir = "${base_prefix}/lib" +export base_bindir = "${root_prefix}/bin" +export base_sbindir = "${root_prefix}/sbin" +export base_libdir = "${root_prefix}/${baselib}" +export nonarch_base_libdir = "${root_prefix}/lib" # Architecture independent paths export sysconfdir = "${base_prefix}/etc"
Signature · 1 line
2.7.4
PATCH v3 2/8 cross.bbclass: merged /usr support
In reply to Amarnath ValluriTo be align with base configuration change, use ${root_prefix} while preparing ${target_base_libdir}.
--- meta/classes/cross.bbclass | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/cross.bbclass +2 -2
@@ -50,10 +50,10 @@ SSTATE_SCAN_CMD ?= "${SSTATE_SCAN_CMD_NATIVE}" # Path mangling needed by the cross packaging # Note that we use := here to ensure that libdir and includedir are # target paths. -target_base_prefix := "${base_prefix}" +target_root_prefix := "${root_prefix}" target_prefix := "${prefix}" target_exec_prefix := "${exec_prefix}" -target_base_libdir = "${target_base_prefix}/${baselib}" +target_base_libdir = "${target_root_prefix}/${baselib}" target_libdir = "${target_exec_prefix}/${baselib}" target_includedir := "${includedir}"
Signature · 1 line
2.7.4
Re: [PATCH v3 2/8] cross.bbclass: merged /usr support
Quoted 22 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Amarnath Valluri
Sent: den 13 juni 2017 08:53
To: [email protected]
Subject: [OE-core] [PATCH v3 2/8] cross.bbclass: merged /usr supportTo be align with base configuration change, use ${root_prefix} while preparing
${target_base_libdir}.Signed-off-by Amarnath Valluri <[email protected]>--- meta/classes/cross.bbclass | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)meta/classes/cross.bbclass +0
-0
meta/classes/cross.bbclass SSTATE_SCAN_CMD ?= "${SSTATE_SCAN_CMD_NATIVE}" · line 53
Quoted 5 lines
meta/classes/cross.bbclass +1
-1@@ -50,10 +50,10 @@ SSTATE_SCAN_CMD ?= "${SSTATE_SCAN_CMD_NATIVE}" # Path mangling needed by the cross packaging # Note that we use := here to ensure that libdir and includedir are # target paths. -target_base_prefix := "${base_prefix}" +target_root_prefix := "${root_prefix}"
It is probably better to do:
target_base_prefix := "${root_prefix}"
I.e., maintain the target_base_prefix variable, in case it is used in some external layer.
Quoted 9 lines
meta/classes/cross.bbclass +1
-2target_prefix := "${prefix}" target_exec_prefix := "${exec_prefix}" -target_base_libdir = "${target_base_prefix}/${baselib}" +target_base_libdir = "${target_root_prefix}/${baselib}" target_libdir = "${target_exec_prefix}/${baselib}" target_includedir := "${includedir}" --2.7.4
//Peter
PATCH v4 2/8 cross.bbclass: merged /usr support
Use ${root_prefix} instead of ${base_prefix} while setting ${target_base_prefix}, otherwise we might loose the root prefix configuration change in case of 'usrmerge' distro feature is enabled.
--- meta/classes/cross.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/cross.bbclass +1 -1
@@ -50,7 +50,7 @@ SSTATE_SCAN_CMD ?= "${SSTATE_SCAN_CMD_NATIVE}" # Path mangling needed by the cross packaging # Note that we use := here to ensure that libdir and includedir are # target paths. -target_base_prefix := "${base_prefix}" +target_base_prefix := "${root_prefix}" target_prefix := "${prefix}" target_exec_prefix := "${exec_prefix}" target_base_libdir = "${target_base_prefix}/${baselib}"
Signature · 1 line
2.7.4
PATCH v3 3/8 systemd: chagnes to support merged /usr
In reply to Amarnath Valluri- Disable the split-usr support in systemd when 'usrmerge' DISTRO_FEATURE is enabled.
- Modify rootprefix to point to ${root_prefix}, rather than ${base_prefix}.
- And fixed firmware path to use ${nonarch_base_libdir} instead of hard-coded '/lib', because when 'usrmege' distro feature enabled this path would be '/usr/lib'.
--- meta/recipes-core/systemd/systemd_232.bb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
meta/recipes-core/systemd/systemd_232.bb +3 -3
@@ -131,7 +131,7 @@ CACHED_CONFIGUREVARS += "ac_cv_path_SULOGIN=${base_sbindir}/sulogin" # Helper variables to clarify locations. This mirrors the logic in systemd's # build system. -rootprefix ?= "${base_prefix}" +rootprefix ?= "${root_prefix}" rootlibdir ?= "${base_libdir}" rootlibexecdir = "${rootprefix}/lib"
@@ -149,10 +149,10 @@ CACHED_CONFIGUREVARS_class-target = "\ EXTRA_OECONF = " --with-rootprefix=${rootprefix} \ --with-rootlibdir=${rootlibdir} \ --with-roothomedir=${ROOT_HOME} \ - --enable-split-usr \ + ${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '--disable-split-usr', '--enable-split-usr', d)} \ --without-python \ --with-sysvrcnd-path=${sysconfdir} \ - --with-firmware-path=/lib/firmware \ + --with-firmware-path=${nonarch_base_libdir}/firmware \ --with-testdir=${PTEST_PATH} \ " # per the systemd README, define VALGRIND=1 to run under valgrind
Signature · 1 line
2.7.4
Re: [PATCH v3 3/8] systemd: chagnes to support merged /usr
Quoted 7 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Amarnath Valluri
Sent: den 13 juni 2017 08:53
To: [email protected]
Subject: [OE-core] [PATCH v3 3/8] systemd: chagnes to support merged
Change "chagnes" to "changes".
Quoted 30 lines
/usr
- Disable the split-usr support in systemd when 'usrmerge'
DISTRO_FEATUREis enabled.
- Modify rootprefix to point to ${root_prefix}, rather than ${base_prefix}.
- And fixed firmware path to use ${nonarch_base_libdir} instead of hard-coded '/lib', because when 'usrmege' distro feature enabled this path would be '/usr/lib'.Signed-off-by Amarnath Valluri <[email protected]>--- meta/recipes-core/systemd/systemd_232.bb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)meta/recipes- renamed from meta/recipes-core/systemd/systemd_232.bb +0
-0core/systemd/systemd_232.bb
index f843c58..22c7254 100644meta/recipes-core/systemd/systemd_232.bb +0
-0@@ -131,7 +131,7 @@ CACHED_CONFIGUREVARS +="ac_cv_path_SULOGIN=${base_sbindir}/sulogin"
# Helper variables to clarify locations. This mirrors the logic in systemd's
# build system.meta/recipes-core/systemd/systemd_232.bb +1
-1-rootprefix ?= "${base_prefix}" +rootprefix ?= "${root_prefix}" rootlibdir ?= "${base_libdir}" rootlibexecdir = "${rootprefix}/lib"
meta/recipes-core/systemd/systemd_232.bb CACHED_CONFIGUREVARS_class-target = "\ · line 152
Quoted 5 lines
meta/recipes-core/systemd/systemd_232.bb +1
-1@@ -149,10 +149,10 @@ CACHED_CONFIGUREVARS_class-target = "\ EXTRA_OECONF = " --with-rootprefix=${rootprefix} \ --with-rootlibdir=${rootlibdir} \ --with-roothomedir=${ROOT_HOME} \ - --enable-split-usr \ + ${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '--disable-split-usr', '--enable-split-usr', d)} \
I recommend that you add a PACKAGECONFIG for this instead:
PACKAGECONFIG[usrmerge] = "--disable-split-usr,--enable-split-usr"
And add 'usrmerge' to the bb.utils.filter() call in the definition of PACKAGECONFIG.
Quoted 9 lines
meta/recipes-core/systemd/systemd_232.bb +1
-2--without-python \ --with-sysvrcnd-path=${sysconfdir} \ - --with-firmware-path=/lib/firmware \ + --with-firmware-path=${nonarch_base_libdir}/firmware \ --with-testdir=${PTEST_PATH} \ " # per the systemd README, define VALGRIND=1 to run under valgrind --2.7.4
//Peter
PATCH v4 3/8 systemd: changes to support merged /usr
- Enable/disable the split-usr support in systemd based on 'usrmerge' DISTRO_FEATURE.
- Modify rootprefix to point to ${root_prefix}, rather than ${base_prefix}.
- And fixed firmware path to use ${nonarch_base_libdir} instead of hard-coded '/lib', because when 'usrmege' distro feature enabled this path would be '/usr/lib'.
--- meta/recipes-core/systemd/systemd_232.bb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
meta/recipes-core/systemd/systemd_232.bb +4 -4
@@ -41,7 +41,7 @@ SRC_URI_append_libc-uclibc = "\ SRC_URI_append_qemuall = " file://0001-core-device.c-Change-the-default-device-timeout-to-2.patch" PACKAGECONFIG ??= "xz \ - ${@bb.utils.filter('DISTRO_FEATURES', 'efi pam selinux ldconfig', d)} \ + ${@bb.utils.filter('DISTRO_FEATURES', 'efi pam selinux ldconfig usrmerge', d)} \ ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'xkbcommon', '', d)} \ ${@bb.utils.contains('DISTRO_FEATURES', 'wifi', 'rfkill', '', d)} \ binfmt \
@@ -122,6 +122,7 @@ PACKAGECONFIG[bzip2] = "--enable-bzip2,--disable-bzip2,bzip2" PACKAGECONFIG[lz4] = "--enable-lz4,--disable-lz4,lz4" PACKAGECONFIG[xz] = "--enable-xz,--disable-xz,xz" PACKAGECONFIG[zlib] = "--enable-zlib,--disable-zlib,zlib" +PACKAGECONFIG[usrmerge] = "--disable-split-usr, --enable-split-usr" CACHED_CONFIGUREVARS += "ac_cv_path_KILL=${base_bindir}/kill" CACHED_CONFIGUREVARS += "ac_cv_path_KMOD=${base_bindir}/kmod"
@@ -131,7 +132,7 @@ CACHED_CONFIGUREVARS += "ac_cv_path_SULOGIN=${base_sbindir}/sulogin" # Helper variables to clarify locations. This mirrors the logic in systemd's # build system. -rootprefix ?= "${base_prefix}" +rootprefix ?= "${root_prefix}" rootlibdir ?= "${base_libdir}" rootlibexecdir = "${rootprefix}/lib"
@@ -149,10 +150,9 @@ CACHED_CONFIGUREVARS_class-target = "\ EXTRA_OECONF = " --with-rootprefix=${rootprefix} \ --with-rootlibdir=${rootlibdir} \ --with-roothomedir=${ROOT_HOME} \ - --enable-split-usr \ --without-python \ --with-sysvrcnd-path=${sysconfdir} \ - --with-firmware-path=/lib/firmware \ + --with-firmware-path=${nonarch_base_libdir}/firmware \ --with-testdir=${PTEST_PATH} \ " # per the systemd README, define VALGRIND=1 to run under valgrind
Signature · 1 line
2.7.4
PATCH v3 4/8 bash: changes to support merged /usr
In reply to Amarnath ValluriMost of shell scripts refer to '#!/bin/{sh,bash}' inside the script. But when 'usrmege' feature is enabled this path will be /usr/bin/{sh, bash}.
so to satisify build dependency add '/bin/{sh,bash}' to its providers list.
--- meta/recipes-extended/bash/bash.inc | 2 ++ 1 file changed, 2 insertions(+)
meta/recipes-extended/bash/bash.inc +2 -0
@@ -69,3 +69,5 @@ pkg_postrm_${PN} () { PACKAGES += "${PN}-bashbug" FILES_${PN} = "${bindir}/bash ${base_bindir}/bash.bash" FILES_${PN}-bashbug = "${bindir}/bashbug" + +RPROVIDES_${PN} += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '/bin/sh /bin/bash', '', d)}"
Signature · 1 line
2.7.4
Re: [PATCH v3 4/8] bash: changes to support merged /usr
Quoted 2 lines · Amarnath Valluri
Most of shell scripts refer to '#!/bin/{sh,bash}' inside the script. But when 'usrmege' feature is enabled this path will be
/usr/bin/{sh, bash}.
usrmege -> usrmerge
Also in next patch.
Quoted 7 lines
so to satisify build dependency add '
/bin/{sh,bash}' to its providers list.Signed-off-by: Amarnath Valluri
<[email protected]>
---
Best Regards, Anton Eliasson
PATCH v3 5/8 busybox: changes to support merged /usr
In reply to Amarnath ValluriMost of the shell scripts refer to /bin/sh inside the script. When 'usrmege' feature is enabled, this path would be /usr/bin/sh. Hence, to satisfy build dependency add '/bin/sh' to it's providers list.
--- meta/recipes-core/busybox/busybox.inc | 2 ++ 1 file changed, 2 insertions(+)
meta/recipes-core/busybox/busybox.inc +2 -0
@@ -439,3 +439,5 @@ pkg_prerm_${PN}-syslog () { fi fi } + +RPROVIDES_${PN} += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '/bin/sh', '', d)}"
Signature · 1 line
2.7.4
PATCH v3 6/8 sed: changes to support merged /usr
In reply to Amarnath ValluriFew of the perl scripts referring '#!/bin/sed' inside the script. But when 'usrmerge' feature is enabled this path would be /usr/bin/sed. So to satisfy build dependency add '/bin/sed' to it's providers list.
--- meta/recipes-extended/sed/sed_4.2.2.bb | 1 + 1 file changed, 1 insertion(+)
meta/recipes-extended/sed/sed_4.2.2.bb +1 -0
@@ -44,3 +44,4 @@ do_install_ptest() { oe_runmake -C ${TESTDIR} install-ptest BUILDDIR=${B} DESTDIR=${D}${PTEST_PATH} TESTDIR=${TESTDIR} } +RPROVIDES_${PN} += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '/bin/sed', '', d)}"
Signature · 1 line
2.7.4
PATCH v3 7/8 image: create symlinks needed for merged /usr
In reply to Amarnath ValluriPrepare the symlinks required for merged /usr at the time of rootfs creation.
The links created in rootfs are:
/bin --> /usr/sbin
/sbin --> /usr/sbin
/lib --> /usr/lib
/lib64 --> /usr/lib64
We cannot make these symlinks as part of 'base-files' or some other package. Because at rootfs creation, installation of the package(say kernel) that depends on these root folders/links fails, if package manager installs this package prior to base-files.
These symbolic links in top level folder should present as long as
- kerenl tools use /lib/{module,firmware}
- shell scripts uses "#!/bin/sh"
--- meta/classes/image.bbclass | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
meta/classes/image.bbclass +23 -0
@@ -617,3 +617,26 @@ do_bundle_initramfs () { : } addtask bundle_initramfs after do_image_complete + +# Prepare the root links to point to the /usr counterparts. +create_merged_usr_symlinks() { + install -m 0755 -d ${IMAGE_ROOTFS}/${base_bindir} + install -m 0755 -d ${IMAGE_ROOTFS}/${base_sbindir} + install -m 0755 -d ${IMAGE_ROOTFS}/${base_libdir} + lnr ${IMAGE_ROOTFS}${base_bindir} ${IMAGE_ROOTFS}/bin + lnr ${IMAGE_ROOTFS}${base_sbindir} ${IMAGE_ROOTFS}/sbin + lnr ${IMAGE_ROOTFS}${base_libdir} ${IMAGE_ROOTFS}/${baselib} + + if [ "${nonarch_base_libdir}" != "${base_libdir}" ]; then + install -m 0755 -d ${IMAGE_ROOTFS}/${nonarch_base_libdir} + lnr ${IMAGE_ROOTFS}${nonarch_base_libdir} ${IMAGE_ROOTFS}/lib + fi + + # create base links for multilibs + multi_libdirs="${@d.getVar('MULTILIB_VARIANTS')}" + for d in $multi_libdirs; do + install -m 0755 -d ${IMAGE_ROOTFS}/${exec_prefix}/$d + lnr ${IMAGE_ROOTFS}/${exec_prefix}/$d ${IMAGE_ROOTFS}/$d + done +} +ROOTFS_PREPROCESS_COMMAND += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', 'create_merged_usr_symlinks; ', '',d)}"
Signature · 1 line
2.7.4
Re: [PATCH v3 7/8] image: create symlinks needed for merged /usr
Quoted 17 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Amarnath Valluri
Sent: den 13 juni 2017 08:53
To: [email protected]
Subject: [OE-core] [PATCH v3 7/8] image: create symlinks needed for merged /usrPrepare the symlinks required for merged /usr at the time of rootfs creation.
The links created in rootfs are:
/bin -->/usr/sbin
/sbin -->/usr/sbin
/lib -->/usr/lib
/lib64 -->/usr/lib64
Quoted 6 lines
We cannot make these symlinks as part of 'base-files' or some other package. Because at rootfs creation, installation of the package(say kernel) that depends on these root folders/links fails, if package manager installs this package prior to base-files.
These symbolic links in top level folder should present as long as
Change "should" to "should be".
Quoted 1 line
- kerenl tools use
/lib/{module,firmware}
Change "kerenl" to "kernel".
Quoted 12 lines
- shell scripts uses "#!/bin/sh"
Signed-off-by Amarnath Valluri <[email protected]>--- meta/classes/image.bbclass | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)meta/classes/image.bbclass +0
-0
meta/classes/image.bbclass do_bundle_initramfs () { · line 621
Quoted 5 lines
meta/classes/image.bbclass +2
-0@@ -617,3 +617,26 @@ do_bundle_initramfs () { : } addtask bundle_initramfs after do_image_complete + +# Prepare the root links to point to the /usr counterparts.
In the function below:
* You do not need to specify -m 0755 to install, it is the default.
* Change all "/${var}" to "${var}".
meta/classes/image.bbclass do_bundle_initramfs () { · line 625
Quoted 4 lines
meta/classes/image.bbclass +4
-0+create_merged_usr_symlinks() { + install -m 0755 -d ${IMAGE_ROOTFS}/${base_bindir} + install -m 0755 -d ${IMAGE_ROOTFS}/${base_sbindir} + install -m 0755 -d ${IMAGE_ROOTFS}/${base_libdir}
You can combine these three installs into one. Saves two forks.
meta/classes/image.bbclass do_bundle_initramfs () { · line 630
Quoted 5 lines
meta/classes/image.bbclass +5
-0+ lnr ${IMAGE_ROOTFS}${base_bindir} ${IMAGE_ROOTFS}/bin + lnr ${IMAGE_ROOTFS}${base_sbindir} ${IMAGE_ROOTFS}/sbin + lnr ${IMAGE_ROOTFS}${base_libdir} ${IMAGE_ROOTFS}/${baselib} + + if [ "${nonarch_base_libdir}" != "${base_libdir}" ]; then
Why do you check "${nonarch_base_libdir}" != "${base_libdir}" when you do not check the other three above?
Quoted 13 lines
meta/classes/image.bbclass +12
-1+ install -m 0755 -d ${IMAGE_ROOTFS}/${nonarch_base_libdir} + lnr ${IMAGE_ROOTFS}${nonarch_base_libdir} ${IMAGE_ROOTFS}/lib + fi + + # create base links for multilibs + multi_libdirs="${@d.getVar('MULTILIB_VARIANTS')}" + for d in $multi_libdirs; do + install -m 0755 -d ${IMAGE_ROOTFS}/${exec_prefix}/$d + lnr ${IMAGE_ROOTFS}/${exec_prefix}/$d ${IMAGE_ROOTFS}/$d + done +} +ROOTFS_PREPROCESS_COMMAND += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', 'create_merged_usr_symlinks; ', '',d)}" --
Quoted 1 line
2.7.4
//Peter
Re: [PATCH v3 7/8] image: create symlinks needed for merged /usr
Quoted 66 lines · Peter Kjellerstedt
Quoted 28 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of
Amarnath Valluri
Sent: den 13 juni 2017 08:53
To: [email protected]
Subject: [OE-core] [PATCH v3 7/8] image: create symlinks needed for merged /usrPrepare the symlinks required for merged /usr at the time of rootfs creation.
The links created in rootfs are:
/bin -->/usr/sbin
/sbin -->/usr/sbin
/lib -->/usr/lib
/lib64 -->/usr/lib64We cannot make these symlinks as part of 'base-files' or some other package.
Because at rootfs creation, installation of the package(say kernel) that depends
on these root folders/links fails, if package manager installs this package
prior to base-files.Quoted 1 line
These symbolic links in top level folder should present as long as
Change "should" to "should be".
Quoted 2 lines
- kerenl tools use
/lib/{module,firmware}Change "kerenl" to "kernel".
Quoted 17 lines
- shell scripts uses "#!/bin/sh"
Signed-off-by Amarnath Valluri <[email protected]>---
meta/classes/image.bbclass | 23 +++++++++++++++++++++++1 file changed, 23 insertions(+)meta/classes/image.bbclass +0
-0@@ -617,3 +617,26 @@ do_bundle_initramfs () {:
}
addtaskbundle_initramfsafterdo_image_completemeta/classes/image.bbclass do_bundle_initramfs () { · line 621
Quoted 2 lines
meta/classes/image.bbclass +2
-0+ +# Prepare the root links to point to the /usr counterparts.In the function below:
* You do not need to specify -m 0755 to install, it is the default.
* Change all "/${var}" to "${var}".Quoted 5 lines
+create_merged_usr_symlinks() {
+ install -m 0755 -d ${IMAGE_ROOTFS}/${base_bindir} + install -m 0755 -d ${IMAGE_ROOTFS}/${base_sbindir} + install -m 0755 -d ${IMAGE_ROOTFS}/${base_libdir}You can combine these three installs into one. Saves two forks.
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
+ lnr ${IMAGE_ROOTFS}${base_bindir} ${IMAGE_ROOTFS}/bin + lnr ${IMAGE_ROOTFS}${base_sbindir} ${IMAGE_ROOTFS}/sbin + lnr ${IMAGE_ROOTFS}${base_libdir} ${IMAGE_ROOTFS}/${baselib} +
+ if [ "${nonarch_base_libdir}" != "${base_libdir}" ]; thenWhy do you check "${nonarch_base_libdir}" != "${base_libdir}" when you do not check the other three above?
Our intention here is to create /lib -> ${noarch_base_libdir}. This might already been crated in the previous call :
lnr ${IMAGE_ROOTFS}${base_libdir} ${IMAGE_ROOTFS}/${baselib}
because, for non-multilib builds both ${nonarch_base_libdir} and ${base_libdir} points to ${exec_prefix}/lib.
The condition can be rephrased to:
if [ "${baselib}" != "lib" ]
This case does not apply for other two links., ie., /bin, /sbin.
- Amarnath
PATCH v4 7/8 image: create symlinks needed for merged /usr
In reply to Peter KjellerstedtPrepare the symlinks required for merged /usr at the time of rootfs creation.
The links created in rootfs are:
/bin --> /usr/sbin
/sbin --> /usr/sbin
/lib --> /usr/lib
/lib64 --> /usr/lib64
We cannot make these symlinks as part of 'base-files' or some other package. Because at rootfs creation, installation of the package(say kernel) that depends on these root folders/links fails, if package manager installs this package prior to base-files.
These symbolic links in top level folder should be present as long as
- kernel tools use /lib/{module,firmware}
- shell scripts uses "#!/bin/sh"
--- meta/classes/image.bbclass | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
meta/classes/image.bbclass +21 -0
@@ -617,3 +617,24 @@ do_bundle_initramfs () { : } addtask bundle_initramfs after do_image_complete + +# Prepare the root links to point to the /usr counterparts. +create_merged_usr_symlinks() { + install -d ${IMAGE_ROOTFS}${base_bindir} ${IMAGE_ROOTFS}${base_sbindir} ${IMAGE_ROOTFS}${base_libdir} + lnr ${IMAGE_ROOTFS}${base_bindir} ${IMAGE_ROOTFS}/bin + lnr ${IMAGE_ROOTFS}${base_sbindir} ${IMAGE_ROOTFS}/sbin + lnr ${IMAGE_ROOTFS}${base_libdir} ${IMAGE_ROOTFS}/${baselib} + + if [ "${nonarch_base_libdir}" != "${base_libdir}" ]; then + install -d ${IMAGE_ROOTFS}${nonarch_base_libdir} + lnr ${IMAGE_ROOTFS}${nonarch_base_libdir} ${IMAGE_ROOTFS}/lib + fi + + # create base links for multilibs + multi_libdirs="${@d.getVar('MULTILIB_VARIANTS')}" + for d in $multi_libdirs; do + install -d ${IMAGE_ROOTFS}${exec_prefix}/$d + lnr ${IMAGE_ROOTFS}${exec_prefix}/$d ${IMAGE_ROOTFS}/$d + done +} +ROOTFS_PREPROCESS_COMMAND += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', 'create_merged_usr_symlinks; ', '',d)}"
Signature · 1 line
2.7.4
Re: [PATCH v4 7/8] image: create symlinks needed for merged /usr
Quoted 40 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Amarnath Valluri
Sent: den 13 juni 2017 15:24
To: [email protected]
Subject: [OE-core] [PATCH v4 7/8] image: create symlinks needed for merged /usrPrepare the symlinks required for merged /usr at the time of rootfs creation.
The links created in rootfs are:
/bin -->/usr/sbin
/sbin -->/usr/sbin
/lib -->/usr/lib
/lib64 -->/usr/lib64We cannot make these symlinks as part of 'base-files' or some other package.
Because at rootfs creation, installation of the package(say kernel) that depends
on these root folders/links fails, if package manager installs this package
prior to base-files.These symbolic links in top level folder should be present as long as
- kernel tools use/lib/{module,firmware}
- shell scripts uses "#!/bin/sh"Signed-off-by Amarnath Valluri <[email protected]>--- meta/classes/image.bbclass | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)meta/classes/image.bbclass +0
-0
meta/classes/image.bbclass do_bundle_initramfs () { · line 626
Quoted 10 lines
meta/classes/image.bbclass +7
-0@@ -617,3 +617,24 @@ do_bundle_initramfs () { : } addtask bundle_initramfs after do_image_complete + +# Prepare the root links to point to the /usr counterparts. +create_merged_usr_symlinks() { + install -d ${IMAGE_ROOTFS}${base_bindir} ${IMAGE_ROOTFS}${base_sbindir} ${IMAGE_ROOTFS}${base_libdir} + lnr ${IMAGE_ROOTFS}${base_bindir} ${IMAGE_ROOTFS}/bin + lnr ${IMAGE_ROOTFS}${base_sbindir} ${IMAGE_ROOTFS}/sbin + lnr ${IMAGE_ROOTFS}${base_libdir} ${IMAGE_ROOTFS}/${baselib}
You missed one. Change "/${baselib}" to "${baselib}".
Quoted 15 lines
meta/classes/image.bbclass +14
-1+ + if [ "${nonarch_base_libdir}" != "${base_libdir}" ]; then + install -d ${IMAGE_ROOTFS}${nonarch_base_libdir} + lnr ${IMAGE_ROOTFS}${nonarch_base_libdir} ${IMAGE_ROOTFS}/lib + fi + + # create base links for multilibs + multi_libdirs="${@d.getVar('MULTILIB_VARIANTS')}" + for d in $multi_libdirs; do + install -d ${IMAGE_ROOTFS}${exec_prefix}/$d + lnr ${IMAGE_ROOTFS}${exec_prefix}/$d ${IMAGE_ROOTFS}/$d + done +} +ROOTFS_PREPROCESS_COMMAND += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', 'create_merged_usr_symlinks; ', '',d)}" --
Quoted 1 line
2.7.4
//Peter
Re: [PATCH v4 7/8] image: create symlinks needed for merged /usr
Quoted 44 lines · Peter Kjellerstedt
Quoted 44 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Amarnath Valluri
Sent: den 13 juni 2017 15:24
To: [email protected]
Subject: [OE-core] [PATCH v4 7/8] image: create symlinks needed for merged /usrPrepare the symlinks required for merged /usr at the time of rootfs creation.
The links created in rootfs are:
/bin -->/usr/sbin
/sbin -->/usr/sbin
/lib -->/usr/lib
/lib64 -->/usr/lib64We cannot make these symlinks as part of 'base-files' or some other package.
Because at rootfs creation, installation of the package(say kernel) that depends
on these root folders/links fails, if package manager installs this package
prior to base-files.These symbolic links in top level folder should be present as long as
- kernel tools use/lib/{module,firmware}
- shell scripts uses "#!/bin/sh"Signed-off-by Amarnath Valluri <[email protected]>--- meta/classes/image.bbclass | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)meta/classes/image.bbclass +1
-0@@ -617,3 +617,24 @@ do_bundle_initramfs () { : } addtask bundle_initramfs after do_image_complete +
Quoted 8 lines
meta/classes/image.bbclass do_bundle_initramfs () { · line 626
Quoted 6 lines
meta/classes/image.bbclass +6
-0+# Prepare the root links to point to the /usr counterparts. +create_merged_usr_symlinks() { + install -d ${IMAGE_ROOTFS}${base_bindir} ${IMAGE_ROOTFS}${base_sbindir} ${IMAGE_ROOTFS}${base_libdir} + lnr ${IMAGE_ROOTFS}${base_bindir} ${IMAGE_ROOTFS}/bin + lnr ${IMAGE_ROOTFS}${base_sbindir} ${IMAGE_ROOTFS}/sbin + lnr ${IMAGE_ROOTFS}${base_libdir} ${IMAGE_ROOTFS}/${baselib}You missed one. Change "/${baselib}" to "${baselib}".
${baselib} is not directory path and does not prefix with '/' unlike ${base_libdir}, so its valid here.
- Amarnath
PATCH v3 8/8 insane.bbclass: Add package QA check for merged /usr.
In reply to Amarnath ValluriThis check makes sure that, when usrmerge distro feature enabled, no package installs files to root (/bin, /sbin, /lib, /lib64) folders.
--- meta/classes/insane.bbclass | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
meta/classes/insane.bbclass +16 -0
@@ -40,6 +40,9 @@ ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \ version-going-backwards expanded-d invalid-chars \ license-checksum dev-elf file-rdeps \ " +# Add usrmerge QA check based on distro feature +ERROR_QA_append = "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', ' usrmerge', '', d)}" + FAKEROOT_QA = "host-user-contaminated" FAKEROOT_QA[doc] = "QA tests which need to run under fakeroot. If any \ enabled tests are listed here, the do_package_qa task will run under fakeroot."
@@ -993,6 +996,18 @@ def package_qa_check_deps(pkg, pkgdest, skip, d): check_valid_deps('RREPLACES') check_valid_deps('RCONFLICTS') +QAPKGTEST[usrmerge] = "package_qa_check_usrmerge" +def package_qa_check_usrmerge(pkg, d, messages): + pkgdest = d.getVar('PKGDEST') + pkg_dir = pkgdest + os.sep + pkg + os.sep + merged_dirs = ['bin', 'sbin', 'lib'] + d.getVar('MULTILIB_VARIANTS').split() + for f in merged_dirs: + if os.path.exists(pkg_dir + f) and not os.path.islink(pkg_dir + f): + msg = "%s package is not obeying usrmerge distro feature. /%s should be relocated to /usr." % (pkg, f) + package_qa_add_message(messages, "usrmerge", msg) + return False + return True + QAPKGTEST[expanded-d] = "package_qa_check_expanded_d" def package_qa_check_expanded_d(package, d, messages): """
@@ -1066,6 +1081,7 @@ def package_qa_check_host_user(path, name, d, elf, messages): return False return True + # The PACKAGE FUNC to scan each package python do_package_qa () { import subprocess
Signature · 1 line
2.7.4