Revert order of layers for MERGE

This commit is contained in:
Disassembler 2019-11-17 16:28:49 +01:00
parent 56af4a0b66
commit 827991d7ac
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
2 changed files with 16 additions and 17 deletions

View File

@ -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)

View File

@ -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)