diff --git a/Makefile b/Makefile index 0bdb5d9..87371d7 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,7 @@ dist: $(PACKAGE)-$(VERSION)/src/Makefile \ $(PACKAGE)-$(VERSION)/src/deforaos-build.sh \ $(PACKAGE)-$(VERSION)/src/deforaos-document.sh \ + $(PACKAGE)-$(VERSION)/src/deforaos-lock.sh \ $(PACKAGE)-$(VERSION)/src/deforaos-package.sh \ $(PACKAGE)-$(VERSION)/src/deforaos-release.sh \ $(PACKAGE)-$(VERSION)/src/deforaos-update.sh \ diff --git a/src/Makefile b/src/Makefile index ae300a3..ff6af40 100644 --- a/src/Makefile +++ b/src/Makefile @@ -17,6 +17,8 @@ install: $(MKDIR) $(DESTDIR)$(PREFIX)/bin $(INSTALL) -m 0755 deforaos-document.sh $(DESTDIR)$(PREFIX)/bin/deforaos-document.sh $(MKDIR) $(DESTDIR)$(PREFIX)/bin + $(INSTALL) -m 0755 deforaos-lock.sh $(DESTDIR)$(PREFIX)/bin/deforaos-lock.sh + $(MKDIR) $(DESTDIR)$(PREFIX)/bin $(INSTALL) -m 0755 deforaos-package.sh $(DESTDIR)$(PREFIX)/bin/deforaos-package.sh $(MKDIR) $(DESTDIR)$(PREFIX)/bin $(INSTALL) -m 0755 deforaos-release.sh $(DESTDIR)$(PREFIX)/bin/deforaos-release.sh @@ -26,6 +28,7 @@ install: uninstall: $(RM) -- $(DESTDIR)$(PREFIX)/bin/deforaos-build.sh $(RM) -- $(DESTDIR)$(PREFIX)/bin/deforaos-document.sh + $(RM) -- $(DESTDIR)$(PREFIX)/bin/deforaos-lock.sh $(RM) -- $(DESTDIR)$(PREFIX)/bin/deforaos-package.sh $(RM) -- $(DESTDIR)$(PREFIX)/bin/deforaos-release.sh $(RM) -- $(DESTDIR)$(PREFIX)/bin/deforaos-update.sh diff --git a/src/deforaos-lock.sh b/src/deforaos-lock.sh new file mode 100755 index 0000000..3d5b611 --- /dev/null +++ b/src/deforaos-lock.sh @@ -0,0 +1,65 @@ +#!/bin/sh +#$Id$ +#Copyright (c) 2014 Pierre Pronchery +#This file is part of DeforaOS Devel scripts +#This program is free software: you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +#along with this program. If not, see . + + + +#variables +#executables +LOCK="mkdir" +UNLOCK="rmdir" + + +#functions +#lock +_lock() +{ + lockfile="/var/tmp/deforaos-lock.$1" + + $LOCK -- "$lockfile" || return 2 + "$@" + ret=$? + $UNLOCK -- "$lockfile" + return $ret +} + + +#usage +_usage() +{ + echo "Usage: deforaos-lock.sh -- command [arguments...]" 1>&2 + return 1 +} + + +#main +#parse the arguments +while getopts "" name; do + case $name in + *) + _usage + exit $? + ;; + esac +done + +#check the usage +shift $(($OPTIND - 1)) +if [ $# -eq 0 ]; then + _usage + exit $? +fi + +_lock "$@" diff --git a/src/project.conf b/src/project.conf index 80c2058..147c123 100644 --- a/src/project.conf +++ b/src/project.conf @@ -1,4 +1,4 @@ -dist=Makefile,deforaos-build.sh,deforaos-document.sh,deforaos-package.sh,deforaos-release.sh,deforaos-update.sh +dist=Makefile,deforaos-build.sh,deforaos-document.sh,deforaos-lock.sh,deforaos-package.sh,deforaos-release.sh,deforaos-update.sh [deforaos-build.sh] install=$(PREFIX)/bin @@ -8,6 +8,10 @@ mode=0755 install=$(PREFIX)/bin mode=0755 +[deforaos-lock.sh] +install=$(PREFIX)/bin +mode=0755 + [deforaos-package.sh] install=$(PREFIX)/bin mode=0755