Hello community, here is the log from the commit of package withlock for openSUSE:Factory checked in at 2020-09-01 20:08:51 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/withlock (Old) and /work/SRC/openSUSE:Factory/.withlock.new.3399 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "withlock" Tue Sep 1 20:08:51 2020 rev:9 rq:830850 version:0.5 Changes: -------- --- /work/SRC/openSUSE:Factory/withlock/withlock.changes 2015-06-15 17:50:59.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.withlock.new.3399/withlock.changes 2020-09-01 20:09:37.388655686 +0200 @@ -1,0 +2,9 @@ +Thu Oct 3 08:54:21 UTC 2019 - [email protected] + +- update to version 0.5 +- modernize for Python 2 and 3 compatibility + thanks to Patch by Jan Beran jberan|redhat.com + (2.7 or newer; 0.4 for Python 2.4+2.5 is archived in attic/) + Added: fix-use-python3.patch + +------------------------------------------------------------------- Old: ---- withlock-0.4.tar.gz New: ---- fix-use-python3.patch withlock-0.5.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ withlock.spec ++++++ --- /var/tmp/diff_new_pack.rOWR3h/_old 2020-09-01 20:09:38.560656235 +0200 +++ /var/tmp/diff_new_pack.rOWR3h/_new 2020-09-01 20:09:38.564656237 +0200 @@ -1,7 +1,7 @@ # # spec file for package withlock # -# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,20 +12,20 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # Name: withlock -Version: 0.4 +Version: 0.5 Release: 0 Summary: A locking wrapper script License: Apache-2.0 Group: System/Management -Url: https://github.com/poeml/withlock -Requires: python -Source0: http://mirrorbrain.org/files/releases/%{name}-%{version}.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-build +URL: https://github.com/poeml/withlock +Source0: %{name}-%{version}.tar.gz +Patch0: fix-use-python3.patch +Requires: python3 BuildArch: noarch %description @@ -38,20 +38,19 @@ to use, and much better than implementing half-hearted locking within scripts. %prep -%setup +%autosetup -p1 %build -# -%install -make DESTDIR=%{buildroot} prefix=%{_prefix} install +# nop -%clean -rm -rf %{buildroot} +%install +install -D -m 0755 -t %{buildroot}%{_bindir}/ %{name} +install -D -m 0644 -t %{buildroot}%{_mandir}/man1/ %{name}.1 %files -%defattr(-, root, root) -%doc %{_defaultdocdir}/%{name} +%license LICENSE-2.0.txt +%doc README.md withlock.1.html %{_bindir}/%{name} -%doc %{_mandir}/man1/* +%{_mandir}/man1/%{name}.1%{?ext_man} %changelog ++++++ fix-use-python3.patch ++++++ --- a/withlock +++ b/withlock @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python3 # Copyright 2009-2016 Peter Poeml # ++++++ withlock-0.4.tar.gz -> withlock-0.5.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/withlock-0.4/README.md new/withlock-0.5/README.md --- old/withlock-0.4/README.md 2015-06-15 02:24:25.000000000 +0200 +++ new/withlock-0.5/README.md 2016-03-02 11:28:46.000000000 +0100 @@ -134,6 +134,12 @@ ## Revision history +0.5, 2016: + +- modernize for Python 2 and 3 compatibility + thanks to Patch by Jan Beran jberan|redhat.com + (2.7 or newer; 0.4 for Python 2.4+2.5 is archived in attic/) + 0.4, 2015: - fix lockfile cleanup (Thanks Martin Caj and Martin Vidner. Good Catch!) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/withlock-0.4/attic/python-2.4,2.5/withlock new/withlock-0.5/attic/python-2.4,2.5/withlock --- old/withlock-0.4/attic/python-2.4,2.5/withlock 1970-01-01 01:00:00.000000000 +0100 +++ new/withlock-0.5/attic/python-2.4,2.5/withlock 2016-03-02 11:28:46.000000000 +0100 @@ -0,0 +1,206 @@ +#!/usr/bin/env python + +# Copyright 2009-2015 Peter Poeml +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# withlock -- https://github.com/poeml/withlock +# +# +# A locking wrapper that make sure that a program isn't run more than once. +# It creates locks that are valid only while the wrapper is running, and thus +# will never require a cleanup, e.g. after a reboot. + +# Parts of the locking strategy, and parts of the usage semantics, of this +# script were inspired from with-lock-ex.c, which was written by Ian Jackson and +# placed in the public domain by him. +# +# +# Usage is simple. Instead of your command +# CMD ARGS... +# you simply use +# withlock LOCKFILE CMD ARGS... +# +# See --help output for more options. + + +__version__ = '0.4' + +import os +import os.path +import errno +import sys +import time +import stat +import fcntl +import signal +import atexit +from optparse import OptionParser + +got_lock = False + +class SignalInterrupt(Exception): + """Exception raised on SIGTERM and SIGHUP.""" + + +def catchterm(*args): + raise SignalInterrupt + + +for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': + num = getattr(signal, name, None) + if num: signal.signal(num, catchterm) + + +def cleanup(lockfile, verbose): + global got_lock + if got_lock: + if verbose: + sys.stderr.write('removing lockfile: %r\n' % lockfile) + + try: + os.unlink(lockfile) + except: + pass + + +def main(): + + usage = 'usage: %prog [options] LOCKFILE CMD ARGS...' + version = '%prog ' + __version__ + + parser = OptionParser(usage=usage, version=version) + parser.disable_interspersed_args() + + parser.add_option('-w', '--wait', + dest='wait', + help="wait for maximum SECONDS until the lock is acquired", + metavar="SECONDS") + + parser.add_option("-q", "--quiet", + action="store_true", dest="quiet", default=False, + help="if lock can't be acquired immediately, silently " + "quit without error") + + parser.add_option("-v", "--verbose", + action="store_true", dest="verbose", default=False, + help="print debug messages to stderr") + + + + (options, args) = parser.parse_args() + + usage = usage.replace('%prog', os.path.basename(sys.argv[0])) + + + if len(args) < 2: + sys.exit(usage) + + lockfile = args[0] + cmd = args[1:] + waited = 0 + if options.wait: + options.wait = int(options.wait) + + if options.verbose: + sys.stderr.write('lockfile: %r\n' % lockfile) + sys.stderr.write('cmd: %r\n' % cmd) + + # check that symlink attacks in the lockfile directory are not possible + lockdir = os.path.dirname(os.path.realpath(lockfile)) or os.curdir + lockdir_mode = stat.S_IMODE(os.stat(lockdir).st_mode) + if options.verbose: + sys.stderr.write('lockdir: %r\n' % lockdir) + sys.stderr.write('lockdir mode: %s\n' % oct(lockdir_mode)) + if (lockdir_mode & stat.S_IWGRP) or (lockdir_mode & stat.S_IWOTH): + sys.stderr.write('withlock: the destination directory for %r is %r, \n' + ' which is writable by other users. That allows for symlink attacks. \n' + ' Choose another directory.\n' \ + % (lockfile, lockdir)) + sys.exit(3) + + + prev_umask = os.umask(0066) + + lock = open(lockfile, 'w') + + global got_lock + while 1 + 1 == 2: + + try: + fcntl.lockf(lock, fcntl.LOCK_EX | fcntl.LOCK_NB) + got_lock = True + break + except IOError, e: + if e.errno in [ errno.EAGAIN, + errno.EACCES, + errno.EWOULDBLOCK, + errno.EBUSY ]: + if options.wait: + if waited >= options.wait: + if options.quiet: + if options.verbose: + sys.stderr.write('quitting silently\n') + sys.exit(0) + else: + sys.stderr.write('could not acquire lock\n') + sys.exit(1) + if options.verbose and waited == 0: + sys.stderr.write('waiting up to %ss for lock\n' \ + % options.wait) + time.sleep(1) + waited += 1 + continue + elif options.quiet: + if options.verbose: + sys.stderr.write('quitting silently\n') + sys.exit(0) + else: + sys.exit('could not acquire lock') + + try: + os.stat(lockfile) + break + except OSError, e: + if e.errno == errno.ENOENT: + sys.exit('====== could not stat %s, which we have just locked' \ + % lockfile) + + + atexit.register(cleanup, lockfile, options.verbose) + os.umask(prev_umask) + + import subprocess + rc = subprocess.call(' '.join(cmd), shell=True) + sys.stdout.flush() + sys.stderr.flush() + + if options.verbose: + sys.stderr.write('command terminated with exit code %s\n' % rc) + + sys.exit(rc) + + +if __name__ == '__main__': + + try: + main() + + except SignalInterrupt: + print >>sys.stderr, 'killed!' + + except KeyboardInterrupt: + print >>sys.stderr, 'interrupted!' + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/withlock-0.4/withlock new/withlock-0.5/withlock --- old/withlock-0.4/withlock 2015-06-15 02:24:25.000000000 +0200 +++ new/withlock-0.5/withlock 2016-03-02 11:28:46.000000000 +0100 @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2009-2015 Peter Poeml +# Copyright 2009-2016 Peter Poeml # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -35,8 +35,11 @@ # # See --help output for more options. +# Modernize features for Python 2 and 3 compatibility +from __future__ import absolute_import +from __future__ import print_function -__version__ = '0.4' +__version__ = '0.5' import os import os.path @@ -132,7 +135,7 @@ sys.exit(3) - prev_umask = os.umask(0066) + prev_umask = os.umask(0o066) lock = open(lockfile, 'w') @@ -143,7 +146,7 @@ fcntl.lockf(lock, fcntl.LOCK_EX | fcntl.LOCK_NB) got_lock = True break - except IOError, e: + except IOError as e: if e.errno in [ errno.EAGAIN, errno.EACCES, errno.EWOULDBLOCK, @@ -173,7 +176,7 @@ try: os.stat(lockfile) break - except OSError, e: + except OSError as e: if e.errno == errno.ENOENT: sys.exit('====== could not stat %s, which we have just locked' \ % lockfile) @@ -199,8 +202,8 @@ main() except SignalInterrupt: - print >>sys.stderr, 'killed!' + print('killed!', file=sys.stderr) except KeyboardInterrupt: - print >>sys.stderr, 'interrupted!' + print('interrupted!', file=sys.stderr)
