Refactor and fix umounts

This commit is contained in:
jpic 2020-01-26 12:41:39 +01:00
parent 9475d8b9af
commit 7d14d488da
2 changed files with 2 additions and 6 deletions

View File

@ -16,15 +16,14 @@ class BuildScript(Script):
umounts() { umounts() {
for i in "${mounts[@]}"; do for i in "${mounts[@]}"; do
umount $i umount $i
echo $mounts
mounts=("${mounts[@]/$i}") mounts=("${mounts[@]/$i}")
echo $mounts
done done
buildah unmount $ctr
trap - 0
} }
trap umounts 0 trap umounts 0
ctr=$(buildah from $base) ctr=$(buildah from $base)
mnt=$(buildah mount $ctr) mnt=$(buildah mount $ctr)
mounts=("$mnt" "${mounts[@]}")
''') ''')
def config(self, line): def config(self, line):
@ -49,5 +48,3 @@ class BuildScript(Script):
self.run('sudo mkdir -p ' + dst) self.run('sudo mkdir -p ' + dst)
self.append('mkdir -p ' + src) self.append('mkdir -p ' + src)
self.append(f'mount -o bind {src} $mnt{dst}') self.append(f'mount -o bind {src} $mnt{dst}')
# for unmount trap
self.append('mounts=("$mnt%s" "${mounts[@]}")' % dst)

View File

@ -40,7 +40,6 @@ class Commit:
script.append(f''' script.append(f'''
umounts umounts
trap - 0
buildah commit --format={self.format} $ctr {self.repo} buildah commit --format={self.format} $ctr {self.repo}
''') ''')