diff options
-rw-r--r-- | .travis.yml | 4 | ||||
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | debian/changelog | 34 | ||||
-rw-r--r-- | debian/compat | 1 | ||||
-rw-r--r-- | debian/control | 7 | ||||
-rw-r--r-- | debian/postinst | 22 | ||||
-rw-r--r-- | debian/pyversions | 1 | ||||
-rwxr-xr-x | debian/rules | 4 | ||||
-rw-r--r-- | man/whatmaps.pod | 2 | ||||
-rwxr-xr-x | run.py | 7 | ||||
-rw-r--r-- | setup.cfg | 3 | ||||
-rw-r--r-- | setup.py | 18 | ||||
-rwxr-xr-x | whatmaps/command.py | 9 | ||||
-rw-r--r-- | whatmaps/debiandistro.py | 26 | ||||
-rw-r--r-- | whatmaps/debianpkg.py | 2 | ||||
-rw-r--r-- | whatmaps/distro.py | 5 | ||||
-rw-r--r-- | whatmaps/redhatdistro.py | 4 | ||||
-rw-r--r-- | whatmaps/rpmpkg.py | 2 |
19 files changed, 99 insertions, 60 deletions
diff --git a/.travis.yml b/.travis.yml index 838cd99..ce0f500 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,4 +4,6 @@ python: - "3.4" - "3.5" install: "pip install -r requirements.txt" -script: flake8 +script: + - flake8 + - nosetests diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..dce5d92 --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +check: + flake8 + nosetests3 @@ -0,0 +1,5 @@ +whatmaps 0.0.13 +--------------- +Released December 2022 +* Run without lsb python modules +* Make flake8 happy diff --git a/debian/changelog b/debian/changelog index 728fca1..9f006a3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,37 @@ +whatmaps (0.0.13-1) unstable; urgency=medium + + * New upstream version 0.13.0 + * [365cae4] distro: Discard stderr. + Otherwise it can mess up our parsing (Closes: #1027317) + + -- Guido Günther <agx@sigxcpu.org> Fri, 30 Dec 2022 13:28:01 +0100 + +whatmaps (0.0.12-4) unstable; urgency=medium + + * [3030430] d/postinst: Don't fail in container without apt + (Closes: #1020895) + * [dbd0843] Bump debhelper compat to 13 + * [b2b1e7b] d/control: Drop X-Python3-Version + * [de2a09d] Bump standards version to 4.6.1. + No changes needed + * [b0f56a6] Drop unused pyversions. + Thanks linitian + * [75a2d0b] d/rules: Use dh_execute_after. + This ensures that DEB_BUILD_OPTIONS=nocheck gets honored automatically + * [6b68c87] d/control: Switch priority to optional. + It's prefereed over `extra` + + -- Guido Günther <agx@sigxcpu.org> Fri, 28 Oct 2022 09:59:38 +0200 + +whatmaps (0.0.12-3) unstable; urgency=medium + + * [f2095d5] Fix vcs-git url + * [eeaefc0] Build-depend on dh-python (Closes: #896742) + * [ddb6eda] Bump standards version to 4.1.4 + * [c12ed6b] gbp.conf: set id-length to have git commit ids in the changelog + + -- Guido Günther <agx@sigxcpu.org> Wed, 02 May 2018 09:42:16 +0200 + whatmaps (0.0.12-2) unstable; urgency=medium * [affd69d] Simplify smoke test diff --git a/debian/compat b/debian/compat deleted file mode 100644 index ec63514..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/debian/control b/debian/control index 3c94ed2..ed9e44b 100644 --- a/debian/control +++ b/debian/control @@ -1,19 +1,18 @@ Source: whatmaps Section: admin -Priority: extra +Priority: optional Maintainer: Guido Günther <agx@sigxcpu.org> Build-Depends: - debhelper (>= 9~), + debhelper-compat (= 13), dh-python, lsb-release, python3, python3-mock, python3-nose, python3-setuptools, -Standards-Version: 4.1.4 +Standards-Version: 4.6.1 Homepage: https://honk.sigxcpu.org/piki/projects/whatmaps Vcs-Git: https://git.sigxcpu.org/cgit/whatmaps/ -X-Python3-Version: >= 3.4 Package: whatmaps Architecture: all diff --git a/debian/postinst b/debian/postinst index 8a56265..cc9b9dd 100644 --- a/debian/postinst +++ b/debian/postinst @@ -12,10 +12,17 @@ case "$1" in db_get whatmaps/enable_service_restarts || true DBVAL="$RET" - # Configuration file doesn't exist but user wants updates enabled so - # recreate it: - if [ ! -f $APT_CONF ] && [ $DBVAL = "true" ]; then - cat << EOF > $APT_CONF + if [ -f $APT_CONF ]; then + case $DBVAL in + "true") VAL=1;; + *) VAL=0;; + esac + sed -i -e "s,^\(\s*Whatmaps::Enable-Restart\s\+\"\)\S\+\(\"\s*;\),\1${VAL}\2," $APT_CONF + else + # Configuration file doesn't exist but user wants updates enabled so + # recreate it: + if [ $DBVAL = "true" ]; then + cat << EOF > $APT_CONF // Set to 1 or true to enable service restarts on security updates Whatmaps::Enable-Restart "1"; @@ -25,12 +32,7 @@ Whatmaps::Security-Update-Origins { "\${distro_id} \${distro_codename}-security"; }; EOF - else - case $DBVAL in - "true") VAL=1;; - *) VAL=0;; - esac - sed -i -e "s,^\(\s*Whatmaps::Enable-Restart\s\+\"\)\S\+\(\"\s*;\),\1${VAL}\2," $APT_CONF + fi fi ;; abort-upgrade|abort-remove|abort-deconfigure) diff --git a/debian/pyversions b/debian/pyversions deleted file mode 100644 index b3dc41e..0000000 --- a/debian/pyversions +++ /dev/null @@ -1 +0,0 @@ -2.5- diff --git a/debian/rules b/debian/rules index f387774..ba473b0 100755 --- a/debian/rules +++ b/debian/rules @@ -16,10 +16,10 @@ override_dh_installman: pod2man man/whatmaps.pod man/whatmaps.8 dh_installman man/whatmaps.8 -override_dh_auto_test: +execute_after_dh_auto_test: python3 setup.py nosetests dh_auto_test -override_dh_auto_clean: +execute_after_dh_auto_clean: rm -f man/whatmaps.8 dh_auto_clean diff --git a/man/whatmaps.pod b/man/whatmaps.pod index 408e75d..c1d8d6b 100644 --- a/man/whatmaps.pod +++ b/man/whatmaps.pod @@ -26,7 +26,7 @@ prompting and with the I<--prind-cmds> option the restart commands are written t a file for later execution. On Debian systems B<whatmaps> can also be run automatically by apt-get. See -L</usr/share/doc/whatmaps/README.Debian> for details. +L<//usr/share/doc/whatmaps/README> for details. =head1 SEE ALSO @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 + +import sys +from whatmaps.command import run + +if __name__ == '__main__': + sys.exit(run()) @@ -3,4 +3,5 @@ cover-package=whatmaps [flake8] # E501: ignore line length -ignore=E501 +# E265: block comment should start with '# ' +ignore=E501,E265,W504
\ No newline at end of file @@ -20,18 +20,12 @@ from setuptools import setup data_files = [] -try: - import lsb_release - if (lsb_release.get_distro_information()['ID'] in ['Debian'] or - os.path.exists('/etc/debian_version')): - data_files = [('../etc/apt/apt.conf.d/', - ['apt/50whatmaps_apt']), - ('../etc/apt/apt.conf.d/', - ['apt/20services']), - ] -except ImportError: - pass - +if os.path.exists('/etc/debian_version'): + data_files = [('../etc/apt/apt.conf.d/', + ['apt/50whatmaps_apt']), + ('../etc/apt/apt.conf.d/', + ['apt/20services']), + ] setup(name="whatmaps", author='Guido Günther', diff --git a/whatmaps/command.py b/whatmaps/command.py index e28a8b9..70e0587 100755 --- a/whatmaps/command.py +++ b/whatmaps/command.py @@ -197,8 +197,8 @@ def main(argv): for pkg in pkgs: try: shared_objects += pkg.shared_objects - except PkgError: - logging.error("Cannot parse contents of %s - skipping it" % pkg.name) + except PkgError as e: + logging.error("%s - skipping package %s" % (e, pkg.name)) ret = 1 logging.debug("Found shared objects:") for so in shared_objects: @@ -257,9 +257,6 @@ def main(argv): def run(): - return(main(sys.argv)) - -if __name__ == '__main__': - sys.exit(main(sys.argv)) + return main(sys.argv) # vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: diff --git a/whatmaps/debiandistro.py b/whatmaps/debiandistro.py index 4fcce54..aaa981a 100644 --- a/whatmaps/debiandistro.py +++ b/whatmaps/debiandistro.py @@ -20,11 +20,6 @@ try: except ImportError: apt_pkg = None -try: - import lsb_release -except ImportError: - lsb_release = None - import logging import os import subprocess @@ -63,8 +58,11 @@ class DebianDistro(Distro): service_blacklist = set(['kvm', 'qemu-kvm', 'qemu-system-x86']) # Per distro regex filter - service_blacklist_re = set([ - '^user@[0-9]+.service$', # Restarting systemd user service aborts the session + service_blacklist_re = set([ # Restarting these aborts the users session + "^dbus(.service)?$", + "^user@[0-9]+.service$", + "^systemd-logind.service$", + "^(g|k|light|no|sd|w|x)dm(.service)?$", ]) @classmethod @@ -116,10 +114,10 @@ class DebianDistro(Distro): aptconfig = sys.stdin.readline() if not aptconfig or aptconfig == '\n': break - if aptconfig.startswith('Whatmaps::Enable-Restart=') and \ - aptconfig.strip().split('=', 1)[1].lower() in ["true", "1"]: - logging.debug("Service restarts enabled") - whatmaps_enabled = True + if (aptconfig.startswith('Whatmaps::Enable-Restart=') and + aptconfig.strip().split('=', 1)[1].lower() in ["true", "1"]): + logging.debug("Service restarts enabled") + whatmaps_enabled = True if not whatmaps_enabled: return None @@ -140,10 +138,8 @@ class DebianDistro(Distro): def _security_update_origins(klass): "Determine security update origins from apt configuration" - if lsb_release is None: - raise PkgError("lsb_release not found, can't determine security updates") - - codename = lsb_release.get_distro_information()['CODENAME'] + with open("/etc/debian_version") as f: + codename = f.read().strip() def _subst(line): mapping = {'distro_codename': codename, diff --git a/whatmaps/debianpkg.py b/whatmaps/debianpkg.py index 0192513..0e1301f 100644 --- a/whatmaps/debianpkg.py +++ b/whatmaps/debianpkg.py @@ -22,7 +22,7 @@ from . pkg import Pkg class DebianPkg(Pkg): type = 'Debian' - _init_script_re = re.compile('/etc/init.d/[\w\-\.]') + _init_script_re = re.compile(r'/etc/init.d/[\w\-\.]') _list_contents = ['dpkg-query', '-L', '${pkg_name}'] def __init__(self, name): diff --git a/whatmaps/distro.py b/whatmaps/distro.py index 29d2dc2..d4f991b 100644 --- a/whatmaps/distro.py +++ b/whatmaps/distro.py @@ -112,6 +112,7 @@ class Distro(object): def detect(): return detect() + import whatmaps.debiandistro # noqa: E402 import whatmaps.redhatdistro # noqa: E402 @@ -129,10 +130,10 @@ def detect(): try: lsb_cmd = subprocess.Popen(['lsb_release', '--id', '-s'], stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + stderr=subprocess.DEVNULL) output = lsb_cmd.communicate()[0] if not lsb_cmd.returncode: - id = output.strip() + id = output.decode().split('\n')[0].strip() except OSError: # id is None in this case pass diff --git a/whatmaps/redhatdistro.py b/whatmaps/redhatdistro.py index 4b17f3c..12336e6 100644 --- a/whatmaps/redhatdistro.py +++ b/whatmaps/redhatdistro.py @@ -23,9 +23,9 @@ from . rpmpkg import RpmPkg class RedHatDistro(Distro): - "RPM based distribution""" + """RPM based distribution""" _pkg_re = re.compile(r'(?P<pkg>[\w\-\+]+)-(?P<ver>[\w\.]+)' - '-(?P<rel>[\w\.]+)\.(?P<arch>.+)') + r'-(?P<rel>[\w\.]+)\.(?P<arch>.+)') @classmethod def pkg(klass, name): diff --git a/whatmaps/rpmpkg.py b/whatmaps/rpmpkg.py index 493dd5a..3940931 100644 --- a/whatmaps/rpmpkg.py +++ b/whatmaps/rpmpkg.py @@ -22,7 +22,7 @@ from . pkg import Pkg class RpmPkg(Pkg): type = 'RPM' - _init_script_re = re.compile('/etc/rc.d/init.d/[\w\-\.]') + _init_script_re = re.compile(r'/etc/rc.d/init.d/[\w\-\.]') _list_contents = ['rpm', '-ql', '$pkg_name'] def __init__(self, name): |