more fixes
This commit is contained in:
parent
dd955c5e59
commit
824af776d9
@ -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
|
||||||
|
14
lxc-build
14
lxc-build
@ -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,14 +92,16 @@ 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:
|
||||||
script.append(line)
|
if line and not line.startswith('#'):
|
||||||
|
script.append(line)
|
||||||
elif line == 'SCRIPT':
|
elif line == 'SCRIPT':
|
||||||
script = []
|
script = []
|
||||||
in_script = True
|
in_script = True
|
||||||
@ -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()
|
||||||
|
Loading…
Reference in New Issue
Block a user