You are not logged in.

#1 2013-04-08 08:43:15

Boris Bolgradov
Member
From: Yambol, Bulgaria
Registered: 2008-07-27
Posts: 182
Website

[yaourt] patch to remove a lost pacman lockfile

I'm posting this for everyone who are lazy to remove a lost pacman lockfile.

I often misspell a package name or an option and interrupt pacman quickly before it syncs.
This ends up with pacman getting killed before it's lockfile can be removed.

I made a patch for yaourt to remove the lockfile if pacman is not running,
so I don't have to remove it manually every time.

--- lib/pacman.sh.in	2013-04-05 21:35:17.000000000 +0300
+++ pacman.sh.in.patched	2013-04-08 11:13:16.202378062 +0300
@@ -33,8 +33,13 @@
 pacman_queue() {
 	# from nesl247
 	if [[ -f ${P[lockfile]} ]]; then
-		msg $(gettext 'Pacman is currently in use, please wait.')
-		while [[ -f ${P[lockfile]} ]]; do sleep 3; done
+        if [[ -z `pidof pacman` ]]; then
+            msg $(gettext 'Pacman is not running, but a lockfile exists; removing it.')
+            launch_with_su rm ${P[lockfile]}
+        else
+            msg $(gettext 'Pacman is currently in use, please wait.')
+            while [[ -f ${P[lockfile]} ]]; do sleep 3; done
+        fi
 	fi
 }

Offline

Board footer

Powered by FluxBB