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
LAYER shared/alpine
LAYER shared/libxml
LAYER shared/python2
LAYER shared/python3
SCRIPT
apk --no-cache add python3

View File

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