Accepting request 311998 from home:poeml
- update to 0.4 - lockfile cleanup fix upstream (Thanks Martin Caj and Martin Vidner. Good Catch!) (cosmetical bug which didn't affect the locking strategy) - man page added - license file added - use the now provided Makefile - moved to github.com OBS-URL: https://build.opensuse.org/request/show/311998 OBS-URL: https://build.opensuse.org/package/show/Base:System/withlock?expand=0&rev=9
This commit is contained in:
parent
fe9d84134b
commit
4d8c42a67a
@ -1,56 +0,0 @@
|
||||
Index: withlock-0.3/withlock
|
||||
===================================================================
|
||||
--- withlock-0.3.orig/withlock
|
||||
+++ withlock-0.3/withlock
|
||||
@@ -64,12 +64,21 @@ for name in 'SIGBREAK', 'SIGHUP', 'SIGTE
|
||||
if num: signal.signal(num, catchterm)
|
||||
|
||||
|
||||
-def cleanup(lockfile):
|
||||
+def cleanup(lockfile, verbose):
|
||||
+ global got_lock
|
||||
+ if verbose:
|
||||
+ sys.stderr.write('got_lock is set to: %r\n' % got_lock)
|
||||
+
|
||||
+ if verbose:
|
||||
+ sys.stderr.write('removing lockfile: %r\n' % lockfile)
|
||||
+
|
||||
if got_lock:
|
||||
try:
|
||||
os.unlink(lockfile)
|
||||
except:
|
||||
pass
|
||||
+ else:
|
||||
+ sys.stderr.write('the lockfile was not removed !\n')
|
||||
|
||||
|
||||
def main():
|
||||
@@ -132,6 +141,7 @@ def main():
|
||||
|
||||
lock = open(lockfile, 'w')
|
||||
|
||||
+ global got_lock
|
||||
while 1 + 1 == 2:
|
||||
|
||||
try:
|
||||
@@ -174,7 +184,7 @@ def main():
|
||||
% lockfile)
|
||||
|
||||
|
||||
- atexit.register(cleanup, lockfile)
|
||||
+ atexit.register(cleanup, lockfile, options.verbose)
|
||||
os.umask(prev_umask)
|
||||
|
||||
import subprocess
|
||||
@@ -184,10 +194,7 @@ def main():
|
||||
|
||||
if options.verbose:
|
||||
sys.stderr.write('command terminated with exit code %s\n' % rc)
|
||||
-
|
||||
- if options.verbose:
|
||||
- sys.stderr.write('removing lockfile\n')
|
||||
-
|
||||
+
|
||||
sys.exit(rc)
|
||||
|
||||
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:be7b0b86848c4d3aa014839b9e407fbf0832af899160d88a88c3a72cdb884939
|
||||
size 2352
|
3
withlock-0.4.tar.gz
Normal file
3
withlock-0.4.tar.gz
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8f2a83a3646742a1a6d85d829853b3a352d50cf42bf9d54fbb53dac757651655
|
||||
size 12314
|
@ -1,23 +0,0 @@
|
||||
= About =
|
||||
|
||||
withlock is a locking wrapper script to make sure that some program isn't run
|
||||
more than once. It is ideal to prevent periodic jobs spawned by cron from
|
||||
stacking up.
|
||||
|
||||
The locks created are valid only while the wrapper is running, and thus will
|
||||
never require a cleanup, as after a reboot. Thus, the wrapper is safe and easy
|
||||
to use, and much better than implementing half-hearted locking within scripts.
|
||||
|
||||
= Usage =
|
||||
|
||||
Usage is simple. Instead of your command
|
||||
CMD ARGS...
|
||||
you simply use
|
||||
withlock LOCKFILE CMD ARGS...
|
||||
Run withlock --help to see more options.
|
||||
|
||||
Note: the lockfile LOCKFILE must not be placed in a publicly writable
|
||||
directory, because that would allow a symlink attack. For that reason,
|
||||
withlock disallows lockfiles in such locations.
|
||||
|
||||
|
@ -1,3 +1,14 @@
|
||||
-------------------------------------------------------------------
|
||||
Mon Jun 15 00:27:25 UTC 2015 - poeml@cmdline.net
|
||||
|
||||
- update to 0.4
|
||||
- lockfile cleanup fix upstream (Thanks Martin Caj and Martin Vidner. Good
|
||||
Catch!) (cosmetical bug which didn't affect the locking strategy)
|
||||
- man page added
|
||||
- license file added
|
||||
- use the now provided Makefile
|
||||
- moved to github.com
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Aug 14 13:23:11 UTC 2014 - mcaj@suse.com
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package withlock
|
||||
#
|
||||
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -17,17 +17,14 @@
|
||||
|
||||
|
||||
Name: withlock
|
||||
Version: 0.3
|
||||
Version: 0.4
|
||||
Release: 0
|
||||
Summary: A locking wrapper script
|
||||
License: Apache-2.0
|
||||
Group: System/Management
|
||||
Url: http://code.google.com/p/withlock/
|
||||
Url: https://github.com/poeml/withlock
|
||||
Requires: python
|
||||
Source0: http://mirrorbrain.org/files/releases/%{name}-%{version}.tar.gz
|
||||
Source1: %name-README.SuSE
|
||||
# fixed trouble with not removed lock file bacuse got-lock was not global variable.
|
||||
Patch0: got-lock.patch
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
BuildArch: noarch
|
||||
|
||||
@ -43,14 +40,10 @@ to use, and much better than implementing half-hearted locking within scripts.
|
||||
%prep
|
||||
%setup
|
||||
|
||||
%patch0 -p1
|
||||
|
||||
%build
|
||||
#
|
||||
%install
|
||||
install -Dm755 withlock %{buildroot}%{_bindir}/%{name}
|
||||
install -Dm644 %{SOURCE1} %{buildroot}%{_defaultdocdir}/%{name}/README.SuSE
|
||||
sed -i "s|/usr/bin/env python|%{_bindir}/python|g" %{buildroot}%{_bindir}/%{name}
|
||||
make DESTDIR=%{buildroot} prefix=%{_prefix} install
|
||||
|
||||
%clean
|
||||
rm -rf %{buildroot}
|
||||
@ -59,5 +52,6 @@ rm -rf %{buildroot}
|
||||
%defattr(-, root, root)
|
||||
%doc %{_defaultdocdir}/%{name}
|
||||
%{_bindir}/%{name}
|
||||
%doc %{_mandir}/man1/*
|
||||
|
||||
%changelog
|
||||
|
Loading…
x
Reference in New Issue
Block a user