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>
This commit is contained in:
parent
2a6323d300
commit
bcb24c013d
|
@ -29,16 +29,28 @@ def sort_file(filename, mapping):
|
||||||
f.write(b''.join(lines))
|
f.write(b''.join(lines))
|
||||||
return new_mapping
|
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):
|
def sort_passwd(sysconfdir):
|
||||||
"""
|
"""
|
||||||
Sorts passwd and group files in a rootfs /etc directory by ID.
|
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'),
|
||||||
for main, shadow in (('passwd', 'shadow'),
|
('group', 'gshadow')):
|
||||||
('group', 'gshadow')):
|
filename = os.path.join(sysconfdir, main)
|
||||||
filename = os.path.join(sysconfdir, main + suffix)
|
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):
|
if os.path.exists(filename):
|
||||||
mapping = sort_file(filename, None)
|
sort_file(filename, mapping)
|
||||||
filename = os.path.join(sysconfdir, shadow + suffix)
|
|
||||||
if os.path.exists(filename):
|
|
||||||
sort_file(filename, mapping)
|
|
||||||
|
|
Loading…
Reference in New Issue