diff --git a/scripts/build_image/build_alpine.bash b/scripts/build_image/build_alpine.bash index 3542f0b..f3a2140 100755 --- a/scripts/build_image/build_alpine.bash +++ b/scripts/build_image/build_alpine.bash @@ -8,25 +8,22 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" function cleanup { sync - for f in "${gpgagents[@]}"; do - >&2 echo "Killing gpg-agent $f" - GNUPGHOME="$f" gpgconf --kill gpg-agent - done + kill_gpg_agent for f in "${jails[@]}"; do - >&2 echo "Stopping jail $f" + log "Stopping jail $f" jail -r "$f" done for (( idx=${#mountedfolders[@]}-1 ; idx>=0 ; idx-- )) ; do - >&2 echo "Unmounting folder ${mountedfolders[idx]}" + log "Unmounting folder ${mountedfolders[idx]}" umount "${mountedfolders[idx]}" done for f in "${memorydevices[@]}"; do - >&2 echo "Removing memory device $f" + log "Removing memory device $f" mdconfig -d -u "$f" done for f in "${folders[@]}"; do - >&2 echo "Deleting $f" - # rm -rf "$f" + log "Deleting $f" + rm -rf "$f" done } folders=() @@ -222,6 +219,18 @@ function make_image { mountedfolders+=("$boot_directory") } +function kill_gpg_agent { + for f in "${gpgagents[@]}"; do + log "Killing gpg-agent $f" + GNUPGHOME="$f" gpgconf --kill gpg-agent + done + unset gpgagents +} + +function unmount_image { + echo "foo" +} + function main { precheck @@ -243,6 +252,8 @@ function main { log "Building chroot in $chroot" make_chroot + kill_gpg_agent + log "Copying final image to $DIR" cp "$image_file" "$DIR" }