add rsync safety checks (defconfigs change often)

This commit is contained in:
parazyd 2016-10-12 14:55:50 +02:00
parent af6960725d
commit 2ea6563962
No known key found for this signature in database
GPG Key ID: F0CB28FCF78637DE
2 changed files with 17 additions and 4 deletions

View File

@ -133,7 +133,9 @@ image_raw_mount() {
ckreq || return 1 ckreq || return 1
mkdir -p $workdir/boot $workdir/root mkdir -p $workdir/boot $workdir/root
sudo mount $bootpart $workdir/boot && act "mounted boot partition" || zerr if [[ $parted_type = dos ]]; then
sudo mount $bootpart $workdir/boot && act "mounted boot partition" || zerr
fi
sudo mount $rootpart $workdir/root && act "mounted root partition" || zerr sudo mount $rootpart $workdir/root && act "mounted root partition" || zerr
} }
@ -142,6 +144,8 @@ image_raw_umount() {
req=(workdir bootpart rootpart) req=(workdir bootpart rootpart)
ckreq || return 1 ckreq || return 1
sudo umount $workdir/boot && act "unmounted boot partition" || zerr if [[ $parted_type = dos ]]; then
sudo umount $workdir/boot && act "unmounted boot partition" || zerr
fi
sudo umount $workdir/root && act "unmounted root partition" || zerr sudo umount $workdir/root && act "unmounted root partition" || zerr
} }

View File

@ -22,6 +22,7 @@
rsync_to_raw_image() { rsync_to_raw_image() {
fn rsync_to_raw_image fn rsync_to_raw_image
req=(workdir strapdir bootpart rootpart) req=(workdir strapdir bootpart rootpart)
ckreq || return 1
notice "rsyncing strapdir to raw image..." notice "rsyncing strapdir to raw image..."
image_raw_mount image_raw_mount
@ -29,9 +30,17 @@ rsync_to_raw_image() {
silly silly
pushd $strapdir pushd $strapdir
sudo rm -f .done sudo rm -f .done
sudo rsync -HPavz -q --exclude={./boot} ./* $workdir/root sudo rsync -HPavz -q --exclude={./boot} ./* $workdir/root || {
image_raw_umount
die "not enough space. report a bug please"
zerr
}
if [[ $parted_type = dos ]]; then if [[ $parted_type = dos ]]; then
sudo rsync -HPavz -q ./boot/* $workdir/boot sudo rsync -HPavz -q ./boot/* $workdir/boot || {
image_raw_umount
die "not enough space. report a bug please"
zerr
}
fi fi
popd popd