From: Peter Palfrader Date: Wed, 8 May 2013 09:14:53 +0000 (+0200) Subject: Replace the target tarfile atomically X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=caed4e8a72ed8ee23236d1b9d6829dd935f599a5;p=mirror%2Fdsa-puppet.git Replace the target tarfile atomically --- diff --git a/modules/porterbox/files/setup-dchroot b/modules/porterbox/files/setup-dchroot index db27d5a15..6fa9e66c3 100755 --- a/modules/porterbox/files/setup-dchroot +++ b/modules/porterbox/files/setup-dchroot @@ -231,4 +231,6 @@ chroot "$rootdir" apt-get install -y --no-install-recommends zsh locales-all bui rm -f "$rootdir/etc/apt/sources.list" "$rootdir/etc/apt/sources.list.d/*" umount "$rootdir/sys" || true -(cd "$rootdir" && tar caf "$target" .) +tartmp=$(tempfile --directory "$basedir" --suffix=".tar.gz") +cleanup+=("rm -f $tartmp") +(cd "$rootdir" && tar caf "$tartmp" . && mv "$tartmp" "$target")