[Lunar-commits] CVS: theedge/var/lib/lunar/functions check.lunar,
1.21, 1.22 locking.lunar, 1.10, 1.11
Auke Kok
sofar at lunar-linux.org
Sun Mar 20 14:57:02 UTC 2005
Update of /var/cvs/lunar/theedge/var/lib/lunar/functions
In directory espresso.foo-projects.org:/tmp/cvs-serv4318/var/lib/lunar/functions
Modified Files:
check.lunar locking.lunar
Log Message:
This allows 'lunar fixdepends' to rebuild the depends/depends.backup files if they are nonexistant, and thus empty too!
Index: check.lunar
===================================================================
RCS file: /var/cvs/lunar/theedge/var/lib/lunar/functions/check.lunar,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- check.lunar 18 Mar 2005 10:01:24 -0000 1.21
+++ check.lunar 20 Mar 2005 14:57:00 -0000 1.22
@@ -280,9 +280,9 @@
# remove whatever depends was residing in the depends state file and
# append the new output:
+ remove_depends $MOD_V_SNAME &&
lock_file $DEPENDS_STATUS &&
lock_file $DEPENDS_STATUS_BACKUP &&
- grep -v "^$MOD_V_SNAME:" $DEPENDS_STATUS_BACKUP > $DEPENDS_STATUS &&
run_depends $MOD_V_SNAME >> $DEPENDS_STATUS &&
cat $DEPENDS_STATUS > $DEPENDS_STATUS_BACKUP &&
unlock_file $DEPENDS_STATUS &&
Index: locking.lunar
===================================================================
RCS file: /var/cvs/lunar/theedge/var/lib/lunar/functions/locking.lunar,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- locking.lunar 13 Dec 2004 15:43:52 -0000 1.10
+++ locking.lunar 20 Mar 2005 14:57:00 -0000 1.11
@@ -29,38 +29,47 @@
TEMPFILE="$1.$$"
LOCKFILE="$1.lock"
- echo $$ > $TEMPFILE 2>/dev/null ||
- {
- message "${PROBLEM_COLOR}You don't have permission to access" \
- "$TEMPFILE ${DEFAULT_COLOR}"
- exit 1
- }
- ln $TEMPFILE $LOCKFILE 2>/dev/null &&
- {
- rm -f $TEMPFILE
- return 0
- }
- [ -f "$LOCKFILE" ] || return 1
+ # test permission
+ if ! echo $$ > $TEMPFILE 2>/dev/null; then
+ message "${PROBLEM_COLOR}You don't have permission to access" \
+ "$TEMPFILE ${DEFAULT_COLOR}"
+ exit 1
+ fi
+
+ # file exists?
+ if [ ! -f "$1" ]; then
+ touch "$1"
+ fi
+
+ # set lockfile
+ if ln $TEMPFILE $LOCKFILE 2>/dev/null ; then
+ rm -f $TEMPFILE
+ return 0
+ # failed due to other lock?
+ elif [ ! -f "$LOCKFILE" ]; then
+ return 1
+ fi
+ # stale lock?
STALE_PID=`< $LOCKFILE`
- [ "$STALE_PID" -gt "0" ] || return 1
- kill -0 $STALE_PID 2>/dev/null &&
- {
- rm -f $TEMPFILE
- return 1
- }
+ if [ "$STALE_PID" -le "0" ]; then
+ return 1
+ fi
+ if kill -0 $STALE_PID 2>/dev/null; then
+ rm -f $TEMPFILE
+ return 1
+ fi
+ # yes, stale
rm -f $LOCKFILE 2>/dev/null &&
- echo "Removed stale lock file of process $STALE_PID"
- ln $TEMPFILE $LOCKFILE 2>/dev/null &&
- {
- rm -f $TEMPFILE
- return 0
- }
+ echo "Removed stale lock file of process $STALE_PID"
+ if ln $TEMPFILE $LOCKFILE 2>/dev/null; then
+ rm -f $TEMPFILE
+ return 0
+ fi
rm -f $TEMPFILE
return 1
}
- while ! file_lock $1
- do
+ while ! file_lock $1; do
message "${MESSAGE_COLOR}Waiting to lock the file $1${DEFAULT_COLOR}"
sleep 1
done
More information about the Lunar-commits
mailing list