diff --git a/debian/README.Debian b/debian/README.Debian index 429308a..11f1e69 100644 --- a/debian/README.Debian +++ b/debian/README.Debian @@ -1,12 +1,36 @@ -lsb for Debian +lsb for Ubuntu -------------- -This package used to provide the Linux Standard Base on Debian systems. -The LSB is a specification for allowing the same binary package to be used -on multiple distributions. +This package provides the Linux Standard Base on Ubuntu systems. The +LSB is a specification for allowing the same binary package to be used +on multiple distributions. -Since version 9.20150826, this package stopped providing the compatibility -LSB packages and only provides two otherwise important packages: +INSTALLING LSB PACKAGES + +The "alien" package supports LSB packages on Ubuntu. For example, to +install an LSB package "lsb-mozilla-1.2-1_i386.rpm", type (as root): + +alien -i lsb-mozilla-1.2-1_i386.rpm + +Ideally, the package should be converted to an Ubuntu package and then +installed by dpkg. If this fails, there may be a problem with either +the lsb package (most likely) or alien (less likely), and you should +contact the vendor of the lsb package to resolve the problem. + +PACKAGE LAYOUT + +The LSB implementation in Ubuntu is currently divided into two +packages: + +* The "lsb-core" package depends on the Ubuntu packages that are + required to comply with the LSB-Core 4.1 specification. It also + includes some subroutines that are used by LSB-compliant applications + when they are being installed or removed. + +* The "lsb-printing" package depends on the CUPS libraries (libcups2 + and libcupsimage2), foomatic-filters, and Ghostscript. + +Other modules of the LSB implementation are no longer available in Ubuntu. * The "lsb-base" package includes a number of functions used by init.d scripts in some LSB packages. @@ -16,3 +40,8 @@ LSB packages and only provides two otherwise important packages: * The "lsb-release" package includes the lsb_release command, which provides information about the installed LSB modules and the underlying distribution. + +The LSB module packages are architecture-specific because of +differences in the requirements of the LSB on various binary +architectures. In particular, each package provides +lsb-{module}-noarch and lsb-{module}-{arch} virtual packages. diff --git a/debian/changelog b/debian/changelog index fb394ae..cf907a5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +lsb (11.5ubuntu1) lunar; urgency=medium + + * Merge from Debian unstable (LP: #2002318). Remaining changes: + - Re-added LSB compatibility packages, so that auto-downloadable LSB-based + printer driver packages work. + - lsb_release.py: restore support for querying the list of installed + modules, since for the moment some modules are still supported. + - Make the 'lsb' package depend on libjpeg62 as well, known to be needed + by printer driver packages. + + -- Dave Jones Mon, 09 Jan 2023 14:53:04 +0000 + lsb (11.5) unstable; urgency=medium * Team upload. @@ -20,6 +32,18 @@ lsb (11.3) unstable; urgency=medium -- Adam Borowski Mon, 12 Sep 2022 20:54:36 +0200 +lsb (11.2ubuntu1) kinetic; urgency=low + + * Merge from Debian unstable. Remaining changes: + - Re-added LSB compatibility packages, so that auto-downloadable + LSB-based printer driver packages work. + - lsb_release.py: restore support for querying the list of installed + modules, since for the moment some modules are still supported. + - Make the 'lsb' package depend on libjpeg62 as well, known to be needed + by printer driver packages. + + -- Steve Langasek Thu, 18 Aug 2022 08:54:53 -0700 + lsb (11.2) unstable; urgency=medium * d/control: update to Standards Version 4.6.1 (no changes). @@ -53,6 +77,36 @@ lsb (11.2~rc1) experimental; urgency=medium -- Mark Hindley Tue, 10 May 2022 17:57:45 +0100 +lsb (11.1.0ubuntu4) jammy; urgency=high + + * No change rebuild for ppc64el baseline bump. + + -- Julian Andres Klode Thu, 24 Mar 2022 17:16:14 +0100 + +lsb (11.1.0ubuntu3) impish; urgency=medium + + * No-change rebuild to build packages with zstd compression. + + -- Matthias Klose Thu, 07 Oct 2021 12:20:20 +0200 + +lsb (11.1.0ubuntu2) focal; urgency=medium + + * Drop lsb-core and lsb-printing packages on i386. + + -- Steve Langasek Mon, 23 Dec 2019 11:14:23 -0600 + +lsb (11.1.0ubuntu1) focal; urgency=low + + * Merge from Debian unstable. Remaining changes: + - Re-added LSB compatibility packages, so that auto-downloadable + LSB-based printer driver packages work. + - lsb_release.py: restore support for querying the list of installed + modules, since for the moment some modules are still supported. + - Make the 'lsb' package depend on libjpeg62 as well, known to be needed + by printer driver packages. + + -- Steve Langasek Fri, 18 Oct 2019 14:14:10 -0700 + lsb (11.1.0) unstable; urgency=medium * Drop cursor-moving code from init-functions @@ -60,6 +114,18 @@ lsb (11.1.0) unstable; urgency=medium -- Dmitry Bogatov Fri, 16 Aug 2019 05:20:52 +0000 +lsb (11.0.1ubuntu1) eoan; urgency=low + + * Merge from Debian unstable. Remaining changes: + - Re-added LSB compatibility packages, so that auto-downloadable + LSB-based printer driver packages work. + - lsb_release.py: restore support for querying the list of installed + modules, since for the moment some modules are still supported. + - Make the 'lsb' package depend on libjpeg62 as well, known to be needed + by printer driver packages. + + -- Steve Langasek Fri, 16 Aug 2019 00:26:10 -0700 + lsb (11.0.1) unstable; urgency=medium * Improve portability of init-functions.d/00-verbose. @@ -82,6 +148,18 @@ lsb (11.0.0) unstable; urgency=medium -- Dmitry Bogatov Tue, 13 Aug 2019 18:24:19 +0000 +lsb (10.2019051400ubuntu1) eoan; urgency=low + + * Merge from Debian unstable. Remaining changes: + - Re-added LSB compatibility packages, so that auto-downloadable + LSB-based printer driver packages work. + - lsb_release.py: restore support for querying the list of installed + modules, since for the moment some modules are still supported. + - Make the 'lsb' package depend on libjpeg62 as well, known to be needed + by printer driver packages. + + -- Steve Langasek Thu, 06 Jun 2019 13:48:00 -0700 + lsb (10.2019051400) unstable; urgency=medium [ Harald Dunkel ] @@ -90,6 +168,18 @@ lsb (10.2019051400) unstable; urgency=medium -- Didier Raboud Tue, 14 May 2019 08:50:39 +0200 +lsb (10.2019031300ubuntu1) disco; urgency=medium + + * Merge from Debian unstable. Remaining changes: + - Re-added LSB compatibility packages, so that auto-downloadable + LSB-based printer driver packages work. + - lsb_release.py: restore support for querying the list of installed + modules, since for the moment some modules are still supported. + - Make the 'lsb' package depend on libjpeg62 as well, known to be needed + by printer driver packages. + + -- Adam Conrad Tue, 02 Apr 2019 13:17:44 -0600 + lsb (10.2019031300) unstable; urgency=low [ Dmitry Bogatov ] @@ -98,6 +188,22 @@ lsb (10.2019031300) unstable; urgency=low -- Didier Raboud Wed, 13 Mar 2019 21:42:26 +0100 +lsb (10.2018112800ubuntu1) disco; urgency=low + + * Merge from Debian unstable. Remaining changes: + - Re-added LSB compatibility packages, so that auto-downloadable + LSB-based printer driver packages work. + - lsb_release.py: restore support for querying the list of installed + modules, since for the moment some modules are still supported. + - Make the 'lsb' package depend on libjpeg62 as well, known to be needed + by printer driver packages. + * Dropped changes, no longer needed: + - Added Conflicts/Replaces against cups-filters-invalid-mta and + cups-filters-lsb for upgrade compatibility from the Xenial development + cycle. + + -- Steve Langasek Fri, 01 Feb 2019 13:07:26 -0800 + lsb (10.2018112800) unstable; urgency=medium * Remove support for /etc/lsb-release in favour of /usr/lib/os-release @@ -113,6 +219,23 @@ lsb (10.2018112800) unstable; urgency=medium -- Didier Raboud Wed, 28 Nov 2018 20:21:37 +0100 +lsb (9.20170808ubuntu1) bionic; urgency=low + + * Merge from Debian unstable. Remaining changes: + - Re-added LSB compatibility packages, so that auto-downloadable + LSB-based printer driver packages work. + - Added Conflicts/Replaces against cups-filters-invalid-mta and + cups-filters-lsb for upgrade compatibility from the Xenial development + cycle. + - lsb_release.py: restore support for querying the list of installed + modules, since for the moment some modules are still supported. + - Make the 'lsb' package depend on libjpeg62 as well, known to be needed + by printer driver packages. + * Dropped changes: + - 01-upstart-lsb: obsoleted upstream, no longer used in Ubuntu. + + -- Steve Langasek Tue, 05 Dec 2017 14:54:13 -0800 + lsb (9.20170808) unstable; urgency=medium * Remove Jeff Licquia from Uploaders, with thanks for his past work @@ -178,6 +301,49 @@ lsb (9.20160601) unstable; urgency=medium -- Didier Raboud Wed, 01 Jun 2016 08:46:56 +0200 +lsb (9.20160110ubuntu5) yakkety; urgency=medium + + * Revert changes to python2 vs. python3 installation of lsb_release.py, + inadvertently breaking imports of lsb_release in python2. LP: #1596638. + + -- Steve Langasek Wed, 06 Jul 2016 08:20:18 -0700 + +lsb (9.20160110ubuntu4) yakkety; urgency=medium + + * Make the 'lsb' package depend on libjpeg62 as well, known to be needed + by printer driver packages. + + -- Steve Langasek Wed, 22 Jun 2016 01:26:31 +0000 + +lsb (9.20160110ubuntu3) yakkety; urgency=medium + + * lsb_release.py: restore support for querying the list of installed + modules, since for the moment some modules are still supported. + + -- Steve Langasek Tue, 21 Jun 2016 21:25:00 +0000 + +lsb (9.20160110ubuntu2) yakkety; urgency=medium + + [ Till Kamppeter ] + * Re-added LSB compatibility packages, so that auto-downloadable + LSB-based printer driver packages work. Thanks to Till Kammpeter + for the patch. LP: #1536353 + * Added Conflicts/Replaces against cups-filters-invalid-mta and + cups-filters-lsb for upgrade compatibility from the Xenial development + cycle. + + -- Steve Langasek Sat, 18 Jun 2016 17:16:59 +0000 + +lsb (9.20160110ubuntu1) yakkety; urgency=medium + + * 01-upstart-lsb: when diverting an init script to an upstart job, we + can't directly map the 'status' subcommand to /sbin/status because the + return value of the latter is always 0 if we communicated successfully + with upstart. Instead, parse the output of the command to correctly map + this to the LSB return codes. LP: #1582813. + + -- Steve Langasek Tue, 17 May 2016 17:04:06 -0700 + lsb (9.20160110) unstable; urgency=medium * Merge the last Ubuntu diff @@ -1623,3 +1789,4 @@ lsb (1.1.0-1) unstable; urgency=low * Initial Release. (Closes: #134658) -- Chris Lawrence Sun, 17 Feb 2002 14:07:32 -0600 + diff --git a/debian/control b/debian/control index 86b3dd5..27318ef 100644 --- a/debian/control +++ b/debian/control @@ -1,22 +1,204 @@ Source: lsb Section: misc Priority: optional -Maintainer: Debian sysvinit maintainers +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Debian sysvinit maintainers Uploaders: Mark Hindley Build-Depends: - debhelper-compat (= 12) + python3-all:any, + dh-python, + distro-info-data, + debhelper-compat (= 12), Standards-Version: 4.6.1 Homepage: https://wiki.linuxfoundation.org/lsb/start Vcs-Browser: https://salsa.debian.org/debian/lsb Vcs-Git: https://salsa.debian.org/debian/lsb.git +Package: lsb-core +Architecture: amd64 armhf arm64 ppc64el s390x +Multi-Arch: foreign +Depends: lsb-release (>= ${source:Version}), + ${glibc}, + libz1, + libncurses5, + libpam0g, + lsb-invalid-mta (>= ${source:Version}) | default-mta | mail-transport-agent, + at, + bc, + binutils, + bsdmainutils, + bsdutils, + cpio, + cron | cron-daemon, + ed, + file, + libc6-dev | libc-dev, + locales, + cups-bsd | lpr, + lprng | cups-client, + m4, + bsd-mailx | mailutils, + make, + man-db, + mawk | gawk, + ncurses-term, + passwd, + patch, + pax, + procps, + psmisc, + rsync, + alien (>= 8.36), + python3, + ${python3:Depends}, + ${misc:Depends}, + ${depends}, + lsb-base (>= ${source:Version}), + lsb-security (>= ${source:Version}), + time +Provides: lsb-core-noarch, ${provides} +Description: Linux Standard Base core support package + The Linux Standard Base (http://www.linuxbase.org/) is a standard + core system that third-party applications written for Linux can + depend upon. + . + This package provides an implementation of the core of the Linux Standard + Base for Ubuntu on the Intel x86, Intel ia64 (Itanium), IBM S390, and + PowerPC 32-bit architectures with the Linux kernel. Future revisions of the + specification and this package may support the LSB on additional + architectures and kernels. + . + The intent of this package is to provide a best current practice way of + installing and running LSB packages on Ubuntu. Its presence does not imply + that Ubuntu fully complies with the Linux Standard Base, and should not be + construed as a statement that Ubuntu is LSB-compliant. + +Package: lsb-printing +Architecture: amd64 armhf arm64 ppc64el s390x +Depends: lsb-core (>= ${source:Version}), + libcups2, + libcupsimage2, + foomatic-filters, + ghostscript, + cups-filters (>= 1.0.36) | ghostscript-cups, + ${misc:Depends} +Provides: lsb-printing-noarch, ${provides} +Description: Linux Standard Base Printing package + The Linux Standard Base (http://www.linuxbase.org/) is a standard + core system that third-party applications written for Linux can + depend upon. + . + This package provides an implementation of the Linux Standard Base + Printing specification for Ubuntu on the Intel x86, Intel ia64 (Itanium), + IBM S390, and PowerPC 32-bit architectures with the Linux kernel. Future + revisions of the specification and this package may support the LSB on + additional architectures and kernels. + . + The intent of this package is to provide a best current practice way of + installing and running LSB packages on Ubuntu. Its presence does not imply + that Ubuntu fully complies with the Linux Standard Base, and should not be + construed as a statement that Ubuntu is LSB-compliant. + +Package: lsb-security +Architecture: any +Depends: libnss3, + libnspr4, + ${misc:Depends} +Recommends: lsb-core (>= ${source:Version}), +Provides: lsb-security-noarch, + ${provides} +Description: Linux Standard Base Security package + The Linux Standard Base (http://www.linuxbase.org/) is a standard + core system that third-party applications written for Linux can + depend upon. + . + This package provides an implementation of the Linux Standard Base Security + specification for Ubuntu on the Intel x86, Intel ia64 (Itanium), IBM S390, + and PowerPC 32-bit architectures with the Linux kernel. Future revisions of + the specification and this package may support the LSB on additional + architectures and kernels. + . + The intent of this package is to provide a best current practice way of + installing and running LSB packages on Ubuntu. Its presence does not imply + that Ubuntu fully complies with the Linux Standard Base, and should not be + construed as a statement that Ubuntu is LSB-compliant. + +Package: lsb +Architecture: all +Depends: lsb-core (>= ${source:Version}), + lsb-printing (>= ${source:Version}), + ${misc:Depends}, libjpeg62 +Description: Linux Standard Base support package + The Linux Standard Base (http://www.linuxbase.org/) is a standard + core system that third-party applications written for Linux can + depend upon. + . + This package provides an implementation of only the printing and core + modules of the Linux Standard Base for Ubuntu. Recent versions of Ubuntu + do not implement the full LSB interfaces; this package is provided only for + compatibility with third-party printer driver packages which depend on the + lsb package. + . + The intent of this package is to provide a best current practice way of + installing and running LSB packages on Ubuntu. Its presence does not imply + that Ubuntu fully complies with the Linux Standard Base, and should not be + construed as a statement that Ubuntu is LSB-compliant. + Package: lsb-base Architecture: all Multi-Arch: foreign Depends: ${misc:Depends}, sysvinit-utils (>= 3.05-4~) Pre-Depends: ${misc:Pre-Depends} Section: oldlibs -Priority: optional Description: transitional package for Linux Standard Base init script functionality This is an empty package; it's needed only because of Provides: not being supported in debootstrap. It can be safely removed. + +Package: lsb-release +Architecture: all +Multi-Arch: foreign +Depends: ${python3:Depends}, + ${misc:Depends}, + distro-info-data, +Recommends: apt +Description: Linux Standard Base version reporting utility + The Linux Standard Base (http://www.linuxbase.org/) is a standard + core system that third-party applications written for Linux can + depend upon. + . + The lsb-release command is a simple tool to help identify the Linux + distribution being used and its compliance with the Linux Standard Base. + LSB conformance will not be reported unless the required metapackages are + installed. + . + While it is intended for use by LSB packages, this command may also + be useful for programmatically distinguishing between a pure Debian + installation and derived distributions. + +Package: lsb-invalid-mta +Architecture: all +Depends: ${misc:Depends} +Suggests: lsb +Provides: mail-transport-agent +Conflicts: mail-transport-agent +Description: Linux Standard Base sendmail dummy + The Linux Standard Base (http://www.linuxbase.org/) is a standard + core system that third-party applications written for Linux can + depend upon. + . + This package contains nothing else than a fake /usr/sbin/sendmail + command to fulfill the LSB's requirement of providing this command without + requiring an MTA to get installed, which once introduces a daemon which + can cause security problems and second, users get asked questions about + how they want their MTA configured when in reality they simply wanted to + install a desktop application or a printer driver, but the dependency on + LSB compliance pulls in an MTA with the installation. + . + The LSB requirement on /usr/sbin/sendmail comes from old times where Linux + and Unix machines had all fixed IPs and did server tasks in data centers. + Today's typical desktop Linux machines do not do local e-mail any more as + users use external e-mail services. + . + The /usr/sbin/sendmail always exits with exit status -1 (255) and sends a + warning message to stderr, so that if a program actually tries to send e-mail + via the sendmail command the user gets note. diff --git a/debian/copyright b/debian/copyright index ae649d5..0590cf6 100644 --- a/debian/copyright +++ b/debian/copyright @@ -5,37 +5,6 @@ Files: * Copyright: 2002-2010, Chris Lawrence License: GPL-2 -Files: init-functions.d/50-ubuntu-logging -Copyright: 2005-2011, Canonical Ltd. -License: GPL-2 - -Files: init-functions -Copyright: 2002-2009, Chris Lawrence -License: BSD-3-clause - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the author nor the names of other contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - . - THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - License: GPL-2 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public diff --git a/debian/lsb-core.dirs b/debian/lsb-core.dirs new file mode 100644 index 0000000..d3d8c10 --- /dev/null +++ b/debian/lsb-core.dirs @@ -0,0 +1,3 @@ +usr/lib/lsb +var/lib/lsb +etc/profile.d diff --git a/debian/lsb-core.install b/debian/lsb-core.install new file mode 100644 index 0000000..eaee1e9 --- /dev/null +++ b/debian/lsb-core.install @@ -0,0 +1,4 @@ +initdutils.py /usr/lib/lsb +install_initd /usr/lib/lsb +remove_initd /usr/lib/lsb +lsbinstall /usr/lib/lsb diff --git a/debian/lsb-core.lintian-overrides b/debian/lsb-core.lintian-overrides new file mode 100644 index 0000000..64ccc82 --- /dev/null +++ b/debian/lsb-core.lintian-overrides @@ -0,0 +1,6 @@ +# The purpose of LSB is to ensure that those packages are present. Being explicit cannot hurt. +depends-on-essential-package-without-using-version Depends: bsdutils + +# LSB provides its own (minimal, deliberately invalid) MTA implementation which +# comes first +default-mta-dependency-not-listed-first Depends: * diff --git a/debian/lsb-core.manpages b/debian/lsb-core.manpages new file mode 100644 index 0000000..44c423d --- /dev/null +++ b/debian/lsb-core.manpages @@ -0,0 +1 @@ +lsb.8 diff --git a/debian/lsb-core.postinst b/debian/lsb-core.postinst new file mode 100644 index 0000000..ba736bf --- /dev/null +++ b/debian/lsb-core.postinst @@ -0,0 +1,63 @@ +#!/bin/sh + +set -e + +setup_ldso_symlink () { + ARCH=$DPKG_MAINTSCRIPT_ARCH + if [ -z "$ARCH" ]; then + ARCH=$(dpkg --print-architecture) + fi + case "$ARCH" in + s390|ppc64|sparc|sparc64|alpha|hppa|m68k|mipsel) + ln -sf ld.so.1 /lib/ld-lsb-$ARCH.so.1 + ln -sf ld.so.1 /lib/ld-lsb-$ARCH.so.2 + ln -sf ld.so.1 /lib/ld-lsb-$ARCH.so.3 + ;; + powerpc) + ln -sf ld.so.1 /lib/ld-lsb-ppc32.so.1 + ln -sf ld.so.1 /lib/ld-lsb-ppc32.so.2 + ln -sf ld.so.1 /lib/ld-lsb-ppc32.so.3 + ;; + i386) + ln -sf ld-linux.so.2 /lib/ld-lsb.so.1 + ln -sf ld-linux.so.2 /lib/ld-lsb.so.2 + ln -sf ld-linux.so.2 /lib/ld-lsb.so.3 + ;; + amd64) + ln -sf ld-linux.so.2 /lib/ld-lsb.so.1 + ln -sf ld-linux.so.2 /lib/ld-lsb.so.2 + ln -sf ld-linux.so.2 /lib/ld-lsb.so.3 + ln -sf ld-linux-x86-64.so.2 /lib64/ld-lsb-x86-64.so.2 + ln -sf ld-linux-x86-64.so.2 /lib64/ld-lsb-x86-64.so.3 + ;; + ia64) + ln -sf ld-linux-ia64.so.2 /lib/ld-lsb-ia64.so.1 + ln -sf ld-linux-ia64.so.2 /lib/ld-lsb-ia64.so.2 + ln -sf ld-linux-ia64.so.2 /lib/ld-lsb-ia64.so.3 + ;; + *) + echo "ld-lsb-*.so.1 symlink for $ARCH is unknown!" + ;; + esac +} + +PATH=/sbin:/usr/sbin:$PATH +export PATH + +case "$1" in + configure) + if dpkg --compare-versions "$2" lt "3.2+Debian30" ; then + [ -L /lib/ld-lsb-x86-64.so.2 ] && rm /lib/ld-lsb-x86-64.so.2 || true + [ -L /lib/ld-lsb-x86-64.so.3 ] && rm /lib/ld-lsb-x86-64.so.3 || true + fi + setup_ldso_symlink + ;; + abort-upgrade|abort-remove|abort-deconfigure) + ;; + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# diff --git a/debian/lsb-core.prerm b/debian/lsb-core.prerm new file mode 100644 index 0000000..8b1f535 --- /dev/null +++ b/debian/lsb-core.prerm @@ -0,0 +1,47 @@ +#!/bin/sh + +set -e + +remove_ldso_symlink () { + ARCH=$DPKG_MAINTSCRIPT_ARCH + if [ -z "$ARCH" ]; then + ARCH=$(dpkg --print-architecture) + fi + case "$ARCH" in + s390|ia64|ppc64|sparc|sparc64|alpha|hppa|m68k|mipsel) + rm -f /lib/ld-lsb-$ARCH.so.[123] + ;; + powerpc) + rm -f /lib/ld-lsb-ppc32.so.[123] + ;; + i386) + rm -f /lib/ld-lsb.so.[123] + ;; + amd64) + rm -f /lib/ld-lsb.so.[123] /lib64/ld-lsb-x86-64.so.[23] + ;; + *) + echo "ld-lsb-*.so.1 symlink for $ARCH is unknown; not removed." + ;; + esac +} + +PATH=/sbin:/usr/sbin:$PATH +export PATH + +case "$1" in + remove) + remove_ldso_symlink + rm -f /var/lib/lsb/facilities + rm -f /var/lib/lsb/depends + ;; + failed-upgrade|upgrade|deconfigure) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + + +#DEBHELPER# diff --git a/debian/lsb-invalid-mta.install b/debian/lsb-invalid-mta.install new file mode 100644 index 0000000..68ee82e --- /dev/null +++ b/debian/lsb-invalid-mta.install @@ -0,0 +1 @@ +sendmail /usr/sbin/ diff --git a/debian/lsb-invalid-mta.links b/debian/lsb-invalid-mta.links new file mode 100644 index 0000000..4d0e823 --- /dev/null +++ b/debian/lsb-invalid-mta.links @@ -0,0 +1 @@ +usr/sbin/sendmail usr/lib/sendmail diff --git a/debian/lsb-invalid-mta.lintian-overrides b/debian/lsb-invalid-mta.lintian-overrides new file mode 100644 index 0000000..5114383 --- /dev/null +++ b/debian/lsb-invalid-mta.lintian-overrides @@ -0,0 +1,2 @@ +# Dummy sendmail needs no manpage +no-manual-page [usr/sbin/sendmail] diff --git a/debian/lsb-printing.lintian-overrides b/debian/lsb-printing.lintian-overrides new file mode 100644 index 0000000..2e9065b --- /dev/null +++ b/debian/lsb-printing.lintian-overrides @@ -0,0 +1,2 @@ +# LSB packages are empty on purpose +empty-binary-package diff --git a/debian/lsb-release.install b/debian/lsb-release.install new file mode 100644 index 0000000..5dccfd9 --- /dev/null +++ b/debian/lsb-release.install @@ -0,0 +1,2 @@ +lsb_release /usr/bin +lsb_release.py /usr/lib/python3/dist-packages/ diff --git a/debian/lsb-release.manpages b/debian/lsb-release.manpages new file mode 100644 index 0000000..c610296 --- /dev/null +++ b/debian/lsb-release.manpages @@ -0,0 +1 @@ +lsb_release.1 diff --git a/debian/lsb-security.lintian-overrides b/debian/lsb-security.lintian-overrides new file mode 100644 index 0000000..2e9065b --- /dev/null +++ b/debian/lsb-security.lintian-overrides @@ -0,0 +1,2 @@ +# LSB packages are empty on purpose +empty-binary-package diff --git a/debian/lsb.lintian-overrides b/debian/lsb.lintian-overrides new file mode 100644 index 0000000..2e9065b --- /dev/null +++ b/debian/lsb.lintian-overrides @@ -0,0 +1,2 @@ +# LSB packages are empty on purpose +empty-binary-package diff --git a/debian/rules b/debian/rules index cbe925d..d2e5985 100755 --- a/debian/rules +++ b/debian/rules @@ -1,3 +1,74 @@ #!/usr/bin/make -f + +PY3VERSIONS=$(shell [ -x /usr/bin/py3versions ] && py3versions -vr) + %: - dh $@ + dh $@ --with=python3 + +# These are used for cross-compiling and for saving the configure script +# from having to guess our platform (since we know it already) +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) +DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) + +# Map Debian architectures to LSB architectures +lsbarch=${DEB_HOST_ARCH} +ifeq (${lsbarch}, i386) +lsbarch=ia32 +endif +ifeq (${lsbarch}, powerpc) +lsbarch=ppc32 +endif + +LIBC=libc6 (>> 2.3.5) +ifeq (${lsbarch}, amd64) +LIBC=libc6 (>= 2.13-17) +endif +ifeq (${lsbarch}, hurd-i386) +LIBC=libc0.3 (>> 2.3.5) +endif +ifeq (${lsbarch}, kfreebsd-amd64) +LIBC=libc0.1 (>> 2.3.5) +endif +ifeq (${lsbarch}, kfreebsd-i386) +LIBC=libc0.1 (>> 2.3.5) +endif +ifeq (${lsbarch}, ia64) +LIBC=libc6.1 (>> 2.3.5) +endif +ifeq (${lsbarch}, alpha) +LIBC=libc6.1 (>> 2.3.5) +endif + +override_dh_clean: + dh_clean + rm -f *.py[co] + rm -rf debian/lsb-*.substvars + rm -rf __pycache__ + rm -rf test/__pycache__ + +ifneq ($(filter nocheck,$(DEB_BUILD_OPTIONS)),) +override_dh_auto_test: +else +override_dh_auto_test: $(PY3VERSIONS:%=test-python%) +endif + +test-python%: + PATH=test/:$${PATH} PYTHONPATH=. python$* test/test_lsb_release.py -vv + PYTHONPATH=. python$* test/test_initdutils.py -vv + rm -rf __pycache__ + rm -rf test/__pycache__ + rm -f test/debian_version_* + +override_dh_python3: + dh_python3 + dh_python3 /usr/lib/lsb + +override_dh_gencontrol: + @echo >> debian/lsb-core.substvars "glibc=${LIBC}" + @echo >> debian/lsb-core.substvars "provides=lsb-core-${lsbarch}" + @echo >> debian/lsb-printing.substvars "provides=lsb-printing-${lsbarch}" + @echo >> debian/lsb-security.substvars "provides=lsb-security-${lsbarch}" + @[ ${DEB_HOST_ARCH} = 'amd64' ] && echo >> debian/lsb-core.substvars "depends=libc6:i386 | libc6-i386, zlib1g:i386 | libz32z1" || true + dh_gencontrol + diff --git a/init-functions b/init-functions deleted file mode 100644 index e25c32a..0000000 --- a/init-functions +++ /dev/null @@ -1,423 +0,0 @@ -# /lib/lsb/init-functions for Debian -*- shell-script -*- -# -#Copyright (c) 2002-08 Chris Lawrence -#All rights reserved. -# -#Redistribution and use in source and binary forms, with or without -#modification, are permitted provided that the following conditions -#are met: -#1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -#2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -#3. Neither the name of the author nor the names of other contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -#THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -#IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -#ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE -#LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -#CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -#SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -#BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -#WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -#OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -#EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -start_daemon () { - local force nice pidfile exec args OPTIND - force="" - nice=0 - pidfile=/dev/null - - OPTIND=1 - while getopts fn:p: opt ; do - case "$opt" in - f) force="force";; - n) nice="$OPTARG";; - p) pidfile="$OPTARG";; - esac - done - - shift $(($OPTIND - 1)) - if [ "$1" = '--' ]; then - shift - fi - - exec="$1"; shift - - args="--start --nicelevel $nice --quiet --oknodo" - if [ "$force" ]; then - /sbin/start-stop-daemon $args \ - --chdir "$PWD" --startas $exec --pidfile /dev/null -- "$@" - elif [ $pidfile ]; then - /sbin/start-stop-daemon $args \ - --chdir "$PWD" --exec $exec --oknodo --pidfile "$pidfile" -- "$@" - else - /sbin/start-stop-daemon $args --chdir "$PWD" --exec $exec -- "$@" - fi -} - -pidofproc () { - local pidfile base status specified pid OPTIND - pidfile= - specified= - - OPTIND=1 - while getopts p: opt ; do - case "$opt" in - p) pidfile="$OPTARG" - specified="specified" - ;; - esac - done - shift $(($OPTIND - 1)) - if [ $# -ne 1 ]; then - echo "$0: invalid arguments" >&2 - return 4 - fi - - base=${1##*/} - if [ ! "$specified" ]; then - pidfile="/var/run/$base.pid" - fi - - if [ -n "${pidfile:-}" ]; then - if [ -e "$pidfile" ]; then - if [ -r "$pidfile" ]; then - read pid < "$pidfile" - if [ -n "${pid:-}" ]; then - if $(kill -0 "${pid:-}" 2> /dev/null); then - echo "$pid" || true - return 0 - elif ps "${pid:-}" >/dev/null 2>&1; then - echo "$pid" || true - return 0 # program is running, but not owned by this user - else - return 1 # program is dead and /var/run pid file exists - fi - fi - else - return 4 # pid file not readable, hence status is unknown. - fi - else - # pid file doesn't exist, try to find the pid nevertheless - if [ -x /bin/pidof ] && [ ! "$specified" ]; then - status="0" - /bin/pidof -c -o %PPID -x $1 || status="$?" - if [ "$status" = 1 ]; then - return 3 # program is not running - fi - return 0 - fi - return 3 # specified pid file doesn't exist, program probably stopped - fi - fi - if [ "$specified" ]; then - return 3 # almost certain it's not running - fi - return 4 # Unable to determine status -} - -# start-stop-daemon uses the same algorithm as "pidofproc" above. -killproc () { - local pidfile sig status base name_param is_term_sig OPTIND - pidfile= - name_param= - is_term_sig= - - OPTIND=1 - while getopts p: opt ; do - case "$opt" in - p) pidfile="$OPTARG";; - esac - done - shift $(($OPTIND - 1)) - - base=${1##*/} - if [ ! $pidfile ]; then - name_param="--name $base --pidfile /var/run/$base.pid" - else - name_param="--name $base --pidfile $pidfile" - fi - - sig=${2:-} sig=${sig#-} sig=${sig#SIG} - if [ "$sig" = 15 ] || [ "$sig" = TERM ]; then - is_term_sig="terminate_signal" - fi - status=0 - if [ ! "$is_term_sig" ]; then - if [ -n "$sig" ]; then - /sbin/start-stop-daemon --stop --signal "$sig" \ - --quiet $name_param || status="$?" - else - /sbin/start-stop-daemon --stop \ - --retry 5 \ - --quiet $name_param || status="$?" - fi - else - /sbin/start-stop-daemon --stop --quiet \ - --oknodo $name_param || status="$?" - fi - if [ "$status" = 1 ]; then - if [ -z "$sig" ]; then - return 0 - fi - return 3 # program is not running - fi - - if [ "$status" = 0 ] && [ "$is_term_sig" ] && [ "$pidfile" ]; then - pidofproc -p "$pidfile" "$1" >/dev/null || rm -f "$pidfile" - fi - return 0 -} - -# Return LSB status -status_of_proc () { - local pidfile daemon name status OPTIND - - pidfile= - OPTIND=1 - while getopts p: opt ; do - case "$opt" in - p) pidfile="$OPTARG";; - esac - done - shift $(($OPTIND - 1)) - - if [ -n "$pidfile" ]; then - pidfile="-p $pidfile" - fi - daemon="$1" - name="$2" - - status="0" - pidofproc $pidfile $daemon >/dev/null || status="$?" - if [ "$status" = 0 ]; then - log_success_msg "$name is running" - return 0 - elif [ "$status" = 4 ]; then - log_failure_msg "could not access PID file for $name" - return $status - else - log_failure_msg "$name is not running" - return $status - fi -} - -log_use_fancy_output () { - if [ -t 1 ] && - [ "x${TERM:-}" != "x" ] && - [ "x${TERM:-}" != "xdumb" ] - then - [ -z $FANCYTTY ] && return 0 || true - else - return 1 - fi - case "$FANCYTTY" in - 1|Y|yes|true) true;; - *) false;; - esac -} - -log_success_msg () { - if [ -n "${1:-}" ]; then - log_begin_msg "$@" - fi - log_end_msg 0 -} - -log_failure_msg () { - if [ -n "${1:-}" ]; then - log_begin_msg "$@" "..." - fi - log_end_msg 1 || true -} - -log_warning_msg () { - if [ -n "${1:-}" ]; then - log_begin_msg "$@" "..." - fi - log_end_msg 255 || true -} - -# -# NON-LSB HELPER FUNCTIONS -# -# int get_lsb_header_val (char *scriptpathname, char *key) -get_lsb_header_val () { - if [ ! -f "$1" ] || [ -z "${2:-}" ]; then - return 1 - fi - LSB_S="### BEGIN INIT INFO" - LSB_E="### END INIT INFO" - sed -n "/$LSB_S/,/$LSB_E/ s/# $2: \+\(.*\)/\1/p" "$1" -} - -# If the currently running init daemon is upstart, return zero; if the -# calling init script belongs to a package which also provides a native -# upstart job, it should generally exit non-zero in this case. -init_is_upstart() -{ - if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | /bin/grep -q upstart; then - return 0 - fi - return 1 -} - -# int log_begin_message (char *message) -log_begin_msg () { - log_begin_msg_pre "$@" - if [ -z "${1:-}" ]; then - return 1 - fi - echo -n "$@" || true - log_begin_msg_post "$@" -} - -# Sample usage: -# log_daemon_msg "Starting GNOME Login Manager" "gdm" -# -# On Debian, would output "Starting GNOME Login Manager: gdm" -# On Ubuntu, would output " * Starting GNOME Login Manager..." -# -# If the second argument is omitted, logging suitable for use with -# log_progress_msg() is used: -# -# log_daemon_msg "Starting remote filesystem services" -# -# On Debian, would output "Starting remote filesystem services:" -# On Ubuntu, would output " * Starting remote filesystem services..." - -log_daemon_msg () { - if [ -z "${1:-}" ]; then - return 1 - fi - log_daemon_msg_pre "$@" - - if [ -z "${2:-}" ]; then - echo -n "$1:" || true - return - fi - - echo -n "$1: $2" || true - log_daemon_msg_post "$@" -} - -# #319739 -# -# Per policy docs: -# -# log_daemon_msg "Starting remote file system services" -# log_progress_msg "nfsd"; start-stop-daemon --start --quiet nfsd -# log_progress_msg "mountd"; start-stop-daemon --start --quiet mountd -# log_progress_msg "ugidd"; start-stop-daemon --start --quiet ugidd -# log_end_msg 0 -# -# You could also do something fancy with log_end_msg here based on the -# return values of start-stop-daemon; this is left as an exercise for -# the reader... -# -# On Ubuntu, one would expect log_progress_msg to be a no-op. -log_progress_msg () { - if [ -z "${1:-}" ]; then - return 1 - fi - echo -n " $@" || true -} - - -# int log_end_message (int exitstatus) -log_end_msg () { - # If no arguments were passed, return - if [ -z "${1:-}" ]; then - return 1 - fi - - log_end_msg_pre "$@" - - # Only do the fancy stuff if we have an appropriate terminal - if log_use_fancy_output; then - esc='' # escape character, printf '\033' - red="$esc[31m" # ANSI color escapes - yellow="$esc[33m" - normal="$esc[0m" - else - red= yellow= normal= - fi - - if [ $1 -eq 0 ]; then - echo "." || true - elif [ $1 -eq 255 ]; then - echo " ${yellow}(warning).${normal}" || true - else - echo " ${red}failed!${normal}" || true - fi - log_end_msg_post "$@" - return $1 -} - -log_action_msg () { - log_action_msg_pre "$@" - echo "$@." || true - log_action_msg_post "$@" -} - -log_action_begin_msg () { - log_action_begin_msg_pre "$@" - echo -n "$@..." || true - log_action_begin_msg_post "$@" -} - -log_action_cont_msg () { - echo -n "$@..." || true -} - -log_action_end_msg () { - local end - log_action_end_msg_pre "$@" - if [ -z "${2:-}" ]; then - end="." - else - end=" ($2)." - fi - - if [ $1 -eq 0 ]; then - echo "done${end}" || true - else - if log_use_fancy_output; then - esc='' # escape character, printf '\033' - red="$esc[31m" # ANSI color escapes - normal="$esc[0m" - echo "${red}failed${end}${normal}" || true - else - echo "failed${end}" || true - fi - fi - log_action_end_msg_post "$@" -} - -# Pre&Post empty function declaration, to be overriden from /lib/lsb/init-functions.d/* -log_daemon_msg_pre () { :; } -log_daemon_msg_post () { :; } -log_begin_msg_pre () { :; } -log_begin_msg_post () { :; } -log_end_msg_pre () { :; } -log_end_msg_post () { :; } -log_action_msg_pre () { :; } -log_action_msg_post () { :; } -log_action_begin_msg_pre () { :; } -log_action_begin_msg_post () { :; } -log_action_end_msg_pre () { :; } -log_action_end_msg_post () { :; } - -# Include hooks from other packages in /lib/lsb/init-functions.d -for hook in $(run-parts --lsbsysinit --list /lib/lsb/init-functions.d 2>/dev/null); do - [ -r $hook ] && . $hook || true -done - -FANCYTTY= -[ -e /etc/lsb-base-logging.sh ] && . /etc/lsb-base-logging.sh || true diff --git a/init-functions.d/00-verbose.jinja b/init-functions.d/00-verbose.jinja deleted file mode 100644 index 99d4a6c..0000000 --- a/init-functions.d/00-verbose.jinja +++ /dev/null @@ -1,20 +0,0 @@ -## Generated automatically. Do not edit! -*- shell-script -*- -{% for fn in log_functions %} -v{{ fn }}() { - if test x"${VERBOSE:-yes}" != x"no" ; then - {{ fn }} "$@" - else - true - fi -} -{% endfor %} -{% for fn in log_end_functions %} -v{{ fn }}() { - if test x"${VERBOSE:-yes}" != x"no" ; then - {{ fn }} "$@" - else - return ${1:-1} - fi -} -{% endfor %} -# vim: ft=sh diff --git a/init-functions.d/50-ubuntu-logging b/init-functions.d/50-ubuntu-logging deleted file mode 100644 index 32bd160..0000000 --- a/init-functions.d/50-ubuntu-logging +++ /dev/null @@ -1,144 +0,0 @@ -# Default init script logging functions suitable for Ubuntu. -# See /lib/lsb/init-functions for usage help. -LOG_DAEMON_MSG="" - -log_use_plymouth () { - if [ "${loop:-n}" = y ]; then - return 1 - fi - plymouth --ping >/dev/null 2>&1 -} - -log_success_msg () { - echo " * $@" || true -} - -log_failure_msg () { - if log_use_fancy_output; then - esc='' # escape character, printf '\033' - red="$esc[31m" # ANSI color escapes - normal="$esc[0m" - echo " $red*$normal $@" || true - else - echo " * $@" || true - fi -} - -log_warning_msg () { - if log_use_fancy_output; then - esc='' # escape character, printf '\033' - yellow="$esc[33m" # ANSI color escapes - normal="$esc[0m" - echo " $yellow*$normal $@" || true - else - echo " * $@" || true - fi -} - -log_begin_msg () { - log_daemon_msg "$1" -} - -log_daemon_msg () { - if [ -z "$1" ]; then - return 1 - fi - - TPUT=/usr/bin/tput - if log_use_fancy_output && $TPUT xenl >/dev/null 2>&1; then - COLS=`$TPUT cols` - if [ "$COLS" ] && [ "$COLS" -gt 6 ]; then - COL=$(( COLS - 7 )) - else - COLS=80 - COL=73 - fi - - if log_use_plymouth; then - # If plymouth is running, don't output anything at this time - # to avoid buffering problems (LP: #752393) - if [ -z "$LOG_DAEMON_MSG" ]; then - LOG_DAEMON_MSG=$* - return - fi - fi - - # We leave the cursor `hanging' about-to-wrap (see terminfo(5) - # xenl, which is approximately right). That way if the script - # prints anything then we will be on the next line and not - # overwrite part of the message. - - # Previous versions of this code attempted to colour-code the - # asterisk but this can't be done reliably because in practice - # init scripts sometimes print messages even when they succeed - # and we won't be able to reliably know where the colourful - # asterisk ought to go. - - printf " * $* " || true - # Enough trailing spaces for ` [fail]' to fit in; if the message - # is too long it wraps here rather than later, which is what we - # want. - esc='' # escape character, printf '\033' - movecur="$esc[${COLS}G" # ANSI horizontal position absolute - printf "$movecur " || true - else - echo " * $@" || true - COL= - fi -} - -log_progress_msg () { - : -} - -log_end_msg () { - if [ -z "$1" ]; then - return 1 - fi - - if [ "$COL" ] && [ -x "$TPUT" ]; then - # If plymouth is running, print previously stored output - # to avoid buffering problems (LP: #752393) - if log_use_plymouth; then - if [ -n "$LOG_DAEMON_MSG" ]; then - log_daemon_msg $LOG_DAEMON_MSG - LOG_DAEMON_MSG="" - fi - fi - - esc='' # escape character, printf '\033' - movecur="$esc[$(( COL + 1 ))G" # ANSI horizontal position absolute - printf "\r$movecur" || true - if [ "$1" -eq 0 ]; then - echo "[ OK ]" || true - else - red="$esc[31m" # ANSI color escapes - normal="$esc[0m" - echo "[${red}fail${normal}]" || true - fi - else - if [ "$1" -eq 0 ]; then - echo " ...done." || true - else - echo " ...fail!" || true - fi - fi - return $1 -} - -log_action_msg () { - echo " * $@" || true -} - -log_action_begin_msg () { - log_daemon_msg "$@..." || true -} - -log_action_cont_msg () { - log_daemon_msg "$@..." || true -} - -log_action_end_msg () { - # In the future this may do something with $2 as well. - log_end_msg "$1" || true -} diff --git a/initdutils.py b/initdutils.py index 9276047..3f0e214 100644 --- a/initdutils.py +++ b/initdutils.py @@ -2,6 +2,7 @@ from __future__ import print_function import re, sys, os +import errno import pickle from io import StringIO @@ -9,13 +10,13 @@ from io import StringIO class RFC822Parser(dict): "A dictionary-like object." __linere = re.compile(r'([^:]+):\s*(.*)$') - + def __init__(self, fileob=None, strob=None, startcol=0, basedict=None): if fileob is None and strob is None: raise ValueError('need a file or string') if not basedict: basedict = {} - + super(RFC822Parser, self).__init__(basedict) if not fileob: @@ -57,22 +58,23 @@ endre = re.compile(re.escape('### END INIT INFO')) def scan_initfile(initfile): headerlines = '' scanning = False - - for line in open(initfile): - line = line.rstrip() - if beginre.match(line): - scanning = True - continue - elif scanning and endre.match(line): - scanning = False - continue - elif not scanning: - continue - if line.startswith('# '): - headerlines += line[2:] + '\n' - elif line.startswith('#\t'): - headerlines += line[1:] + '\n' + with open(initfile) as fh: + for line in fh: + line = line.rstrip() + if beginre.match(line): + scanning = True + continue + elif scanning and endre.match(line): + scanning = False + continue + elif not scanning: + continue + + if line.startswith('# '): + headerlines += line[2:] + '\n' + elif line.startswith('#\t'): + headerlines += line[1:] + '\n' inheaders = RFC822Parser(strob=headerlines) headers = {} @@ -80,9 +82,12 @@ def scan_initfile(initfile): # Ignore empty headers if not body.strip(): continue - + if header in ('Default-Start', 'Default-Stop'): - headers[header] = list(map(int, body.split())) + headers[header] = [ + int(s) if s.isdigit() else s + for s in body.split() + ] elif header in ('Required-Start', 'Required-Stop', 'Provides', 'Should-Start', 'Should-Stop'): headers[header] = body.split() @@ -95,62 +100,63 @@ def save_facilities(facilities): if not facilities: try: os.unlink(FACILITIES) - except OSError: + except FileNotFoundError: pass return - - fh = open(FACILITIES, 'w') - for facility, entries in facilities.items(): - # Ignore system facilities - if facility.startswith('$'): continue - for (scriptname, pri) in entries.items(): - start, stop = pri - print("%(scriptname)s %(facility)s %(start)d %(stop)d" % locals(), file=fh) - fh.close() + + with open(FACILITIES, 'w') as fh: + for facility, entries in facilities.items(): + # Ignore system facilities + if facility.startswith('$'): continue + for (scriptname, pri) in entries.items(): + start, stop = pri + print(f"{scriptname} {facility} {start:d} {stop:d}", file=fh) def load_facilities(): facilities = {} if os.path.exists(FACILITIES): - for line in open(FACILITIES): - try: - scriptname, name, start, stop = line.strip().split() - facilities.setdefault(name, {})[scriptname] = (int(start), - int(stop)) - except ValueError as x: - print('Invalid facility line', line, file=sys.stderr) + with open(FACILITIES) as fh: + for line in fh: + try: + scriptname, name, start, stop = line.strip().split() + facilities.setdefault(name, {})[scriptname] = (int(start), + int(stop)) + except ValueError as x: + print('Invalid facility line', line, file=sys.stderr) return facilities def load_depends(): depends = {} - if os.path.exists(DEPENDS): - independs = RFC822Parser(fileob=open(DEPENDS)) - for initfile, facilities in independs.items(): - depends[initfile] = facilities.split() + try: + with open(DEPENDS) as fh: + independs = RFC822Parser(fileob=fh) + for initfile, facilities in independs.items(): + depends[initfile] = facilities.split() + except FileNotFoundError: + pass return depends def save_depends(depends): if not depends: try: os.unlink(DEPENDS) - except OSError: + except FileNotFoundError: pass return - - fh = open(DEPENDS, 'w') - for initfile, facilities in depends.items(): - print('%s: %s' % (initfile, ' '.join(facilities)), file=fh) - fh.close() + + with open(DEPENDS, 'w') as fh: + for initfile, facilities in depends.items(): + print(f"{initfile}: {' '.join(facilities)}", file=fh) # filemap entries are mappings, { (package, filename) : instloc } def load_lsbinstall_info(): - if not os.path.exists(LSBINSTALL): + try: + with open(LSBINSTALL, 'rb') as fh: + filemap = pickle.load(fh) + except FileNotFoundError: return {} - - fh = open(LSBINSTALL, 'rb') - filemap = cPickle.load(fh) - fh.close() # Just in case it's corrupted somehow if not isinstance(filemap, dict): @@ -162,13 +168,12 @@ def save_lsbinstall_info(filemap): if not filemap: try: os.unlink(LSBINSTALL) - except OSError: + except FileNotFoundError: pass return - - fh = open(LSBINSTALL, 'wb') - cPickle.dump(fh, filemap) - fh.close() + + with open(LSBINSTALL, 'wb') as fh: + pickle.dump(filemap, fh) if __name__ == '__main__': print(scan_initfile('init-fragment')) diff --git a/lsb_release.py b/lsb_release.py index fc2a98f..37fe914 100644 --- a/lsb_release.py +++ b/lsb_release.py @@ -58,6 +58,11 @@ def lookup_codename(release, unknown=None): shortrelease = '%s' % m.group(1) return RELEASE_CODENAME_LOOKUP.get(shortrelease, unknown) +# LSB compliance packages... may grow eventually +PACKAGES = 'lsb-core lsb-cxx lsb-graphics lsb-desktop lsb-languages lsb-multimedia lsb-printing lsb-security' + +modnamere = re.compile(r'lsb-(?P[a-z0-9]+)-(?P[^ ]+)(?: \(= (?P[0-9.]+)\))?') + def valid_lsb_versions(version, module): # If a module is ever released that only appears in >= version, deal # with that here @@ -119,7 +124,44 @@ except NameError: # This is Debian-specific at present def check_modules_installed(): - return [] + # Find which LSB modules are installed on this system + C_env = os.environ.copy(); C_env['LC_ALL'] = 'C' + output = subprocess.Popen(['dpkg-query','-f',"${Version} ${Provides}\n",'-W'] + PACKAGES.split(), + env=C_env, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + close_fds=True).communicate()[0].decode('utf-8') + + if not output: + return [] + + modules = set() + for line in output.split(os.linesep): + if not line: + break + version, provides = line.split(' ', 1) + # Debian package versions can be 3.2-$REV, 3.2+$REV or 3.2~$REV. + version = re.split('[-+~]', version, 1)[0] + for pkg in provides.split(','): + mob = modnamere.search(pkg) + if not mob: + continue + + mgroups = mob.groupdict() + # If no versioned provides... + if mgroups.get('version'): + module = '%(module)s-%(version)s-%(arch)s' % mgroups + modules.add(module) + else: + module = mgroups['module'] + for v in valid_lsb_versions(version, module): + mgroups['version'] = v + module = '%(module)s-%(version)s-%(arch)s' % mgroups + modules.add(module) + + modules = list(modules) + modules.sort() + return modules longnames = {'v' : 'version', 'o': 'origin', 'a': 'suite', 'c' : 'component', 'l': 'label'} diff --git a/test/test_initdutils.py b/test/test_initdutils.py index 07952d8..3f263e8 100644 --- a/test/test_initdutils.py +++ b/test/test_initdutils.py @@ -1,31 +1,100 @@ #!/usr/bin/python3 +import os import unittest +import tempfile import initdutils as iu class TestInitdUtils(unittest.TestCase): + to_patch = {'LSBLIB', 'FACILITIES', 'DEPENDS', 'LSBINSTALL'} - @unittest.skip('Test not implemented.') - def test_scan_initfile(): - raise NotImplementedError() - @unittest.skip('Test not implemented.') - def test_save_facilities(): - raise NotImplementedError() - @unittest.skip('Test not implemented.') - def test_load_facilities(): - raise NotImplementedError() - @unittest.skip('Test not implemented.') - def test_load_depends(): - raise NotImplementedError() - @unittest.skip('Test not implemented.') - def test_save_depends(): - raise NotImplementedError() - @unittest.skip('Test not implemented.') - def test_load_lsbinstall_info(): - raise NotImplementedError() - @unittest.skip('Test not implemented.') - def test_save_lsbinstall_info(): - raise NotImplementedError() + def setUp(self): + tempdir = tempfile.mkdtemp() + self.save_paths = { + name: getattr(iu, name) + for name in self.to_patch + } + print(repr(self.save_paths)) + for name in self.to_patch: + old_name = getattr(iu, name)[len(self.save_paths['LSBLIB']):] + new_path = os.path.join(tempdir, old_name.lstrip('/')) + setattr(iu, name, new_path) + + def tearDown(self): + for name in self.to_patch: + setattr(iu, name, self.save_paths[name]) + + def test_scan_initfile(self): + food_init_script = """\ +#!/usr/bin/env /lib/init/init-d-script +### BEGIN INIT INFO +# Provides: food +# Required-Start: $syslog $time udev +# Required-Stop: $syslog $time +# Default-Start: S 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: foo daemon +# Description: Debian init script to start the foo daemon +### END INIT INFO + +INTERFACE=127.0.0.1 +PORT=61453 + +NAME=food +START_ARGS="--background" +DAEMON=/usr/bin/food +DAEMON_ARGS="--listen=${INTERFACE} --port=${PORT}" +""" + with tempfile.NamedTemporaryFile(mode='w') as f: + f.write(food_init_script) + f.flush() + self.assertEqual(iu.scan_initfile(f.name), { + 'Provides': ['food'], + 'Required-Start': ['$syslog', '$time', 'udev'], + 'Required-Stop': ['$syslog', '$time'], + 'Default-Start': ['S', 2, 3, 4, 5], + 'Default-Stop': [0, 1, 6], + 'Short-Description': 'foo daemon', + 'Description': 'Debian init script to start the foo daemon', + }) + + def test_facilities_storage(self): + os_facilities = { + "$local_fs" : {'lsb' : (0, 100)}, + "$network" : {'lsb' : (10, 50)}, + "$remote_fs" : {'lsb': (19, 20)}, + "$named" : {'lsb': (19, 19)}, + "$syslog" : {'lsb' : (10, 89)}, + "$portmap" : {'lsb' : (19, 34)}, + "$time" : {'lsb' : (24, 21)}, + } + local_facilities = { + 'dbus': {'dbus': (20, 19)}, + 'food': {'food': (25, 20)}, + } + test_facilities = local_facilities.copy() + test_facilities.update(os_facilities) + iu.save_facilities(test_facilities) + check_facilities = iu.load_facilities() + # OS facilities are deliberately ignored by save_facilities + self.assertEqual(check_facilities, local_facilities) + + def test_depends_storage(self): + test_dependencies = { + 'dbus': ['$remote_fs', '$syslog'], + 'food': ['$syslog', '$time', 'dbus'], + } + iu.save_depends(test_dependencies) + check_dependencies = iu.load_depends() + self.assertEqual(check_dependencies, test_dependencies) + + def test_lsbinstall_info_storage(self): + test_filemap = { + ('food', 'food'): '/etc/init.d', + } + iu.save_lsbinstall_info(test_filemap) + check_filemap = iu.load_lsbinstall_info() + self.assertEqual(check_filemap, test_filemap) if __name__ == '__main__': - unittest.main() + unittest.main()