aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2016-04-06 08:53:04 +0200
committerJoshua Lock <joshua.g.lock@intel.com>2016-04-06 12:14:35 +0100
commitb6f078e453bade6954467ae5e8a8d2fdcc811417 (patch)
treecb8d7313e3315a0fe6e316101ed9619f7d1dbc0b
parent655e5af1b80938a2852b7c652c47810986e26a99 (diff)
downloadmeta-swupd-b6f078e453bade6954467ae5e8a8d2fdcc811417.tar.gz
meta-swupd-b6f078e453bade6954467ae5e8a8d2fdcc811417.tar.bz2
meta-swupd-b6f078e453bade6954467ae5e8a8d2fdcc811417.zip
swupd-image.bbclass: fix remove of symlinks to directories
remove_unlisted_files_from_directory() failed to remove unwanted symlinks to directories because it only looked at files, whereas Python lists symlinks to directories as directories. In Ostro OS, that affected for example /usr/lib/perl5 -> perl and was found when adding a QA check for dangling symlinks. Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
-rw-r--r--classes/swupd-image.bbclass14
1 files changed, 12 insertions, 2 deletions
diff --git a/classes/swupd-image.bbclass b/classes/swupd-image.bbclass
index 2a4ac00..5729875 100644
--- a/classes/swupd-image.bbclass
+++ b/classes/swupd-image.bbclass
@@ -237,6 +237,7 @@ def swupd_create_rootfs(d):
rootfs_contents.append(entry[1:])
# Prune the items not in the manifest
+ bb.debug(3, 'Desired content of rootfs:\n' + '\n'.join(rootfs_contents))
remove_unlisted_files_from_directory(rootfs_contents, rootfs)
# Create .rootfs.manifest for bundle images as the union of all
@@ -339,11 +340,20 @@ def remove_unlisted_files_from_directory (file_list, directory, fullprune=False)
replace = ''
relroot = root.replace(directory, replace)
#bb.debug(1, 'Substituting "%s" for %s in root of %s to give %s' % (replace, directory, root, relroot))
+ # Beware that os.walk() treats symlinks to directories like directories.
+ # We need to treat them like files because they get removed with os.remove().
for f in files:
fpath = os.path.join(relroot, f)
if fpath not in file_list:
- bb.debug(3, 'Pruning %s from the bundle (%s)' % (fpath, os.path.join(root, f)))
- os.remove(os.path.join(root, f))
+ fpath_absolute = os.path.join(root, f)
+ bb.debug(3, 'Pruning %s from the bundle (%s)' % (fpath, fpath_absolute))
+ os.remove(fpath_absolute)
+ for d in dirs:
+ dpath = os.path.join(relroot, d)
+ dpath_absolute = os.path.join(root, d)
+ if os.path.islink(dpath_absolute) and dpath not in file_list:
+ bb.debug(3, 'Pruning %s from the bundle (%s)' % (dpath, dpath_absolute))
+ os.remove(dpath_absolute)
# Now need to clean up empty directories, unless they were listed in the
# the bundle's manifest