diff options
Diffstat (limited to 'meta/lib/rootfspostcommands.py')
-rw-r--r-- | meta/lib/rootfspostcommands.py | 28 |
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): | |||
29 | f.write(b''.join(lines)) | 29 | f.write(b''.join(lines)) |
30 | return new_mapping | 30 | return new_mapping |
31 | 31 | ||
32 | def remove_backup(filename): | ||
33 | """ | ||
34 | Removes the backup file for files like /etc/passwd. | ||
35 | """ | ||
36 | backup_filename = filename + '-' | ||
37 | if os.path.exists(backup_filename): | ||
38 | os.unlink(backup_filename) | ||
39 | |||
32 | def sort_passwd(sysconfdir): | 40 | def sort_passwd(sysconfdir): |
33 | """ | 41 | """ |
34 | Sorts passwd and group files in a rootfs /etc directory by ID. | 42 | Sorts passwd and group files in a rootfs /etc directory by ID. |
43 | Backup files are sometimes are inconsistent and then cannot be | ||
44 | sorted (YOCTO #11043), and more importantly, are not needed in | ||
45 | the initial rootfs, so they get deleted. | ||
35 | """ | 46 | """ |
36 | for suffix in '', '-': | 47 | for main, shadow in (('passwd', 'shadow'), |
37 | for main, shadow in (('passwd', 'shadow'), | 48 | ('group', 'gshadow')): |
38 | ('group', 'gshadow')): | 49 | filename = os.path.join(sysconfdir, main) |
39 | filename = os.path.join(sysconfdir, main + suffix) | 50 | remove_backup(filename) |
51 | if os.path.exists(filename): | ||
52 | mapping = sort_file(filename, None) | ||
53 | filename = os.path.join(sysconfdir, shadow) | ||
54 | remove_backup(filename) | ||
40 | if os.path.exists(filename): | 55 | if os.path.exists(filename): |
41 | mapping = sort_file(filename, None) | 56 | sort_file(filename, mapping) |
42 | filename = os.path.join(sysconfdir, shadow + suffix) | ||
43 | if os.path.exists(filename): | ||
44 | sort_file(filename, mapping) | ||