more fixes

This commit is contained in:
Disassembler 2018-09-05 19:44:23 +02:00
parent dd955c5e59
commit 824af776d9
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
2 changed files with 9 additions and 7 deletions

View File

@ -1,7 +1,7 @@
IMAGE build IMAGE build
LAYER shared/alpine LAYER shared/alpine
LAYER shared/libxml LAYER shared/libxml
LAYER shared/python2 LAYER shared/python3
SCRIPT SCRIPT
apk --no-cache add python3 apk --no-cache add python3

View File

@ -81,8 +81,7 @@ def fix_world():
def run_script(): def run_script():
script_filename = os.path.join(LXC_ROOT, layers[-1], 'run.sh') script_filename = os.path.join(LXC_ROOT, layers[-1], 'run.sh')
with open(script_filename, 'w') as fd: with open(script_filename, 'w') as fd:
fd.write('#!/bin/sh\nset -ev\n') fd.write('#!/bin/sh\nset -ev\n\n{}\n'.format('\n'.join(script)))
fd.write(' && '.join([s for s in script]))
os.chmod(script_filename, 0o700) os.chmod(script_filename, 0o700)
subprocess.run(['lxc-execute', '-n', image, '--', '/bin/sh', '-lc', '/run.sh'], check=True) subprocess.run(['lxc-execute', '-n', image, '--', '/bin/sh', '-lc', '/run.sh'], check=True)
os.unlink(script_filename) os.unlink(script_filename)
@ -93,13 +92,15 @@ def copy_files(src, dst):
shutil.copytree(src, dst) shutil.copytree(src, dst)
with open(lxcfile, 'r') as fd: with open(lxcfile, 'r') as fd:
recipe = fd.read().splitlines() recipe = fd.readlines()
for line in recipe: for line in recipe:
line = line.strip()
if line == 'RUN': if line == 'RUN':
in_script = False in_script = False
run_script() run_script()
elif in_script and line and not line.startswith('#'): elif in_script:
if line and not line.startswith('#'):
script.append(line) script.append(line)
elif line == 'SCRIPT': elif line == 'SCRIPT':
script = [] script = []
@ -113,7 +114,8 @@ for line in recipe:
elif line == 'FIXWORLD': elif line == 'FIXWORLD':
fix_world() fix_world()
elif line.startswith('COPY'): elif line.startswith('COPY'):
copy_files(*line.split()[1:2]) srcdst = line.split()
copy_files(srcdst[1], srcdst[2])
elif line.startswith('MOUNT'): elif line.startswith('MOUNT'):
mounts.append(line.split()[1]) mounts.append(line.split()[1])
rebuild_config() rebuild_config()