From 827991d7ace690313e0107e833f0a0bdc48c74a8 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Sun, 17 Nov 2019 16:28:49 +0100 Subject: [PATCH] Revert order of layers for MERGE --- build/usr/bin/lxcmerge | 31 +++++++++---------- .../lib/python3.6/lxcbuild/imagebuilder.py | 2 +- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/build/usr/bin/lxcmerge b/build/usr/bin/lxcmerge index 234bb04..e3bdb29 100755 --- a/build/usr/bin/lxcmerge +++ b/build/usr/bin/lxcmerge @@ -28,7 +28,7 @@ def makedirs(path, mode=0o755, uid=100000, gid=100000): except FileExistsError: pass -def merge_apk_world(): +def merge_apk_world(layers): world = [] for layer in layers: try: @@ -43,7 +43,7 @@ def merge_apk_world(): f.writelines(world) os.chown(os.path.join(layers[-1], APK_WORLD), 100000, 100000) -def merge_apk_installed(): +def merge_apk_installed(layers): installed = [] for layer in layers: try: @@ -66,7 +66,7 @@ def merge_apk_installed(): f.writelines(installed) os.chown(os.path.join(layers[-1], APK_INSTALLED), 100000, 100000) -def merge_apk_scripts(): +def merge_apk_scripts(layers): tmp_tar_path = tempfile.mkstemp()[1] files_in_tar = [] with tarfile.open(tmp_tar_path, 'w:') as tmp_tar: @@ -86,7 +86,7 @@ def merge_apk_scripts(): else: os.unlink(tmp_tar_path) -def merge_apk_triggers(): +def merge_apk_triggers(layers): triggers = [] for layer in layers: try: @@ -101,7 +101,7 @@ def merge_apk_triggers(): f.writelines(triggers) os.chown(os.path.join(layers[-1], APK_TRIGGERS), 100000, 100000) -def merge_etc_passwd(): +def merge_etc_passwd(layers): passwd = {} for layer in layers: try: @@ -115,7 +115,7 @@ def merge_etc_passwd(): f.writelines(passwd.values()) os.chown(os.path.join(layers[-1], ETC_PASSWD), 100000, 100000) -def merge_etc_group(): +def merge_etc_group(layers): groups = {} for layer in layers: try: @@ -141,7 +141,7 @@ def merge_etc_group(): f.writelines([':'.join(group) for group in groups.values()]) os.chown(os.path.join(layers[-1], ETC_GROUP), 100000, 100000) -def merge_etc_shadow(): +def merge_etc_shadow(layers): shadow = {} for layer in layers: try: @@ -159,17 +159,16 @@ def merge_etc_shadow(): parser = argparse.ArgumentParser(description='APK database merge script') parser.add_argument('layers', help='Path to LXC layers to be merged', nargs=argparse.REMAINDER) -if len(sys.argv) < 2: +if len(sys.argv) < 3: parser.print_usage() sys.exit(1) args = parser.parse_args() -layers = args.layers[::-1] -merge_apk_world() -merge_apk_installed() -merge_apk_scripts() -merge_apk_triggers() +merge_apk_world(args.layers) +merge_apk_installed(args.layers) +merge_apk_scripts(args.layers) +merge_apk_triggers(args.layers) -merge_etc_passwd() -merge_etc_group() -merge_etc_shadow() +merge_etc_passwd(args.layers) +merge_etc_group(args.layers) +merge_etc_shadow(args.layers) diff --git a/build/usr/lib/python3.6/lxcbuild/imagebuilder.py b/build/usr/lib/python3.6/lxcbuild/imagebuilder.py index 8681437..e77c782 100644 --- a/build/usr/lib/python3.6/lxcbuild/imagebuilder.py +++ b/build/usr/lib/python3.6/lxcbuild/imagebuilder.py @@ -94,7 +94,7 @@ class ImageBuilder: def merge_layers(self, cmd): layers = [self.get_layer_path(layer) for layer in self.image.conf['layers']] - subprocess.run(cmd + layers, check=True) + subprocess.run(cmd + layers[::-1], check=True) def copy_files(self, src, dst): dst = os.path.join(LXC_STORAGE_DIR, self.image.name, dst)