# strip any trailing slash from our dbroot
dbroot="${dbroot%/}"
-# form the path to our lockfile location
-lockfile="${dbroot}/db.lck"
+# form the path to our db lock
+lock="${dbroot}/db.lck"
# make sure pacman isn't running
-if [[ -f $lockfile ]]; then
+if ! mkdir "$lock"; then
die "$(gettext "Pacman lock file was found. Cannot run while pacman is running.")"
fi
-# do not let pacman run while we do this
-touch "$lockfile"
workdir=$(mktemp -d /tmp/pacman-optimize.XXXXXXXXXX) ||
die_r "$(gettext "ERROR: Can not create temp directory for database building.")
" >&2
@@ -174,7 +172,7 @@ fi
rm -rf "$dbroot.old"
# remove the lock file and our working directory with sums and tarfile
-rm -f "$lockfile"
+rm -rf "$lock"
rm -rf "$workdir"