diff options
author | André Draszik <adraszik@tycoint.com> | 2017-01-12 10:34:39 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-01-16 18:05:14 +0000 |
commit | 08fd7c4fc27b83f921d76dbb152f83394f68f1c2 (patch) | |
tree | dbc7302248520c49291867247cdb4ea8d3dcea49 | |
parent | 6bb64c8fa489851b939150fea06a8f71cc6f1d72 (diff) | |
download | poky-08fd7c4fc27b83f921d76dbb152f83394f68f1c2.tar.gz |
lib/oe/rootfs: reliably handle alternative symlinks
When removing unneeded packages from a (read-only) rootfs
during rootfs creation, alternative symlinks from those
packages may or may not be removed.
The reason is as follows:
update-alternatives(-native) is used during package
installation as part of the image creation. It uses
a database which contains entries for all the
alternative symlinks possible, and the -native version
uses the target's database by means of $OPKG_OFFLINE_ROOT,
i.e. the rootfs we're in the process of creating.
Once the rootfs has been created, OE removes certain
packages because we have a read-only rootfs - in
particular ROOTFS_RO_UNNEEDED which includes
VIRTUAL-RUNTIME_update-alternatives, i.e. the
update-alternatives. Recently, a change was made in
OE, where uninstallation of update-alternatives from the
rootfs causes removal of its database, too, to save space
(700KiB (uncompressed) in a busybox system)
b24a63d71b517af701dfedbc7f7b541d25af708f
http://git.openembedded.org/openembedded-core/commit/meta/recipes-devtools/opkg-utils/opkg-utils_git.bb?id=b24a63d71b517af701dfedbc7f7b541d25af708f
Following from that, if update-alternatives is removed
from the target file system, update-alternatives-native
has no database anymore, meaning it can't manage any of
the alternative symlinks anymore.
Because the order of packages to uninstall is
non-deterministic, and update-alternatives could well
be removed before any packages that use the mechanism
provided, sometimes the extra symlinks are removed,
sometimes not.
By sorting the list of packages to be removed such that
update-alternatives is removed last, we can ensure that
that tings work reliably. (Certainly opkg seems to
uninstall packages in the order given on the command
line.)
[YOCTO #10916]
(From OE-Core rev: 5263dd3eac9d9fbdb7ef654d0cd532c192baed16)
Signed-off-by: André Draszik <adraszik@tycoint.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/oe/rootfs.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/meta/lib/oe/rootfs.py b/meta/lib/oe/rootfs.py index 274ddb8105..5b842ba46a 100644 --- a/meta/lib/oe/rootfs.py +++ b/meta/lib/oe/rootfs.py | |||
@@ -262,7 +262,12 @@ class Rootfs(object, metaclass=ABCMeta): | |||
262 | # Remove components that we don't need if it's a read-only rootfs | 262 | # Remove components that we don't need if it's a read-only rootfs |
263 | unneeded_pkgs = self.d.getVar("ROOTFS_RO_UNNEEDED").split() | 263 | unneeded_pkgs = self.d.getVar("ROOTFS_RO_UNNEEDED").split() |
264 | pkgs_installed = image_list_installed_packages(self.d) | 264 | pkgs_installed = image_list_installed_packages(self.d) |
265 | pkgs_to_remove = [pkg for pkg in pkgs_installed if pkg in unneeded_pkgs] | 265 | # Make sure update-alternatives is last on the command line, so |
266 | # that it is removed last. This makes sure that its database is | ||
267 | # available while uninstalling packages, allowing alternative | ||
268 | # symlinks of packages to be uninstalled to be managed correctly. | ||
269 | provider = self.d.getVar("VIRTUAL-RUNTIME_update-alternatives") | ||
270 | pkgs_to_remove = sorted([pkg for pkg in pkgs_installed if pkg in unneeded_pkgs], key=lambda x: x == provider) | ||
266 | 271 | ||
267 | if len(pkgs_to_remove) > 0: | 272 | if len(pkgs_to_remove) > 0: |
268 | self.pm.remove(pkgs_to_remove, False) | 273 | self.pm.remove(pkgs_to_remove, False) |