For the moment, my only proposal is a naïve implementation of a lock
system. The corresponding patch (for devtools) is attached. I still
don't understand my problems, since they don't seem to come from the
"rm -rf" step nor from the "rsync -a --delete" step.

-- 
Rémy
diff --git a/makechrootpkg b/makechrootpkg
index 572a215..b1ca145 100755
--- a/makechrootpkg
+++ b/makechrootpkg
@@ -103,6 +103,12 @@ if [ ! -d "$chrootdir/root" ]; then
 	usage
 fi
 
+if [ -f "$chrootdir/copy/.lock" ]; then
+	echo 'Chroot working copy is locked.'
+	echo "Exit the chroot first or remove '$chrootdir/copy/.lock'"
+        exit 1
+fi
+
 umask 0022
 if [ ! -d "$copydir" -o "$clean_first" -eq "1" ]; then
 	echo -n 'creating clean working copy...'
diff --git a/mkarchroot b/mkarchroot
index fe436f7..c95f8f7 100755
--- a/mkarchroot
+++ b/mkarchroot
@@ -85,6 +85,8 @@ fi
 # {{{ functions 
 
 chroot_mount() {
+        touch "${working_dir}/.lock"
+
 	[ -e "${working_dir}/sys" ] || mkdir "${working_dir}/sys"
 	mount -t sysfs sysfs "${working_dir}/sys"
 
@@ -127,6 +129,8 @@ chroot_umount () {
 	umount "${working_dir}/dev"
 	umount "${working_dir}/${cache_dir}"
 	[ -n "${host_mirror_path}" ] && umount "${working_dir}/${host_mirror_path}"
+
+        rm -f "${working_dir}/.lock"
 }
 # }}}
 
@@ -140,6 +144,12 @@ if [ "$RUN" != "" ]; then
 		exit 1
 	fi
 
+	if [ -f "${working_dir}/.lock" ]; then
+		echo "error: '${working_dir}' already in use"
+		echo "       please finish operations or remove '${working_dir}/.lock'"
+		exit 1
+	fi
+
 	chroot_mount
 	copy_hostconf
 

Reply via email to