diff options
author | torben | 2016-02-09 11:22:43 +0100 |
---|---|---|
committer | torben | 2016-02-09 11:22:43 +0100 |
commit | 8bf46c59fda997134f7d12af54b65cb81a22ec60 (patch) | |
tree | 86982c269cabf8d045c0b28d48c021447447b1bb | |
parent | Sync. (diff) | |
download | systemd-init-8bf46c59fda997134f7d12af54b65cb81a22ec60.tar.gz systemd-init-8bf46c59fda997134f7d12af54b65cb81a22ec60.tar.xz systemd-init-8bf46c59fda997134f7d12af54b65cb81a22ec60.zip |
Adding cleanup routines.
-rwxr-xr-x | builder/build-initramfs.sh | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/builder/build-initramfs.sh b/builder/build-initramfs.sh index 6a956a7f..ab4c4242 100755 --- a/builder/build-initramfs.sh +++ b/builder/build-initramfs.sh @@ -368,13 +368,11 @@ if [[ "$target" != '' ]]; then if [[ -f "$target" ]]; then _target="$(mktemp --directory)" _xmount_mountpoint_target="$(mktemp --directory)" - xmount --in qemu "$target" --out raw \ - "$_xmount_mountpoint_target" + xmount --in qemu "$target" --out raw "$_xmount_mountpoint_target" _xmount_device_target="$(losetup --find)" losetup "$_xmount_device_target" loopdev \ "${_xmount_mountpoint_target}/"*.dd - mount "$_xmount_device_target" \ - "$_target" + mount "$_xmount_device_target" "$_target" fi if [[ -d "$_target" ]]; then _temporary_working_directory="$(chroot "$_target" mktemp --directory)" @@ -409,6 +407,15 @@ if [[ "$target" != '' ]]; then "${_temporary_working_directory}/${BASH_SOURCE[0]}" \ ${_parameter_to_forward[*]} mv "${_target}/$file_path" "$file_path" + # Do cleanup procedures. + umount "${_target}${_temporary_working_directory}" + rm --recursive --force "${_target}${_temporary_working_directory}" + if [[ -f "$target" ]]; then + umount "$_target" + losetup --detach "$_xmount_device_target" + umount "$_xmount_mountpoint_target" + rm --recursive --force "$_target" "$_xmount_mountpoint_target" + fi fi exit 0 fi |