summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2017-02-10 12:29:14 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-02-19 06:16:58 -0800
commitbcb24c013d9724dde3d3c742443ee5bfa944c83f (patch)
treeac928e03c3060ad3a3856b8ebf0c32d24fcfdbee
parent2a6323d3007f43e6b8c149043ab68476839ac2ad (diff)
downloadopenembedded-core-contrib-bcb24c013d9724dde3d3c742443ee5bfa944c83f.tar.gz
openembedded-core-contrib-bcb24c013d9724dde3d3c742443ee5bfa944c83f.tar.bz2
openembedded-core-contrib-bcb24c013d9724dde3d3c742443ee5bfa944c83f.zip
rootfspostcommands: remove shadow backup files instead of trying to sort
Backup are files sometimes are inconsistent and then cannot be sorted (YOCTO #11043), and more importantly, are not needed in the initial rootfs, so they get deleted. Fixes: [YOCTO #11007] (From OE-Core rev: e5628c80a52f3caeea9d9dc7f67d1b8a61222aef) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/rootfspostcommands.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/meta/lib/rootfspostcommands.py b/meta/lib/rootfspostcommands.py
index 6a9b8b47b7..4742e0613c 100644
--- a/meta/lib/rootfspostcommands.py
+++ b/meta/lib/rootfspostcommands.py
@@ -29,16 +29,28 @@ def sort_file(filename, mapping):
f.write(b''.join(lines))
return new_mapping
+def remove_backup(filename):
+ """
+ Removes the backup file for files like /etc/passwd.
+ """
+ backup_filename = filename + '-'
+ if os.path.exists(backup_filename):
+ os.unlink(backup_filename)
+
def sort_passwd(sysconfdir):
"""
Sorts passwd and group files in a rootfs /etc directory by ID.
+ Backup files are sometimes are inconsistent and then cannot be
+ sorted (YOCTO #11043), and more importantly, are not needed in
+ the initial rootfs, so they get deleted.
"""
- for suffix in '', '-':
- for main, shadow in (('passwd', 'shadow'),
- ('group', 'gshadow')):
- filename = os.path.join(sysconfdir, main + suffix)
+ for main, shadow in (('passwd', 'shadow'),
+ ('group', 'gshadow')):
+ filename = os.path.join(sysconfdir, main)
+ remove_backup(filename)
+ if os.path.exists(filename):
+ mapping = sort_file(filename, None)
+ filename = os.path.join(sysconfdir, shadow)
+ remove_backup(filename)
if os.path.exists(filename):
- mapping = sort_file(filename, None)
- filename = os.path.join(sysconfdir, shadow + suffix)
- if os.path.exists(filename):
- sort_file(filename, mapping)
+ sort_file(filename, mapping)