From 981c4ab071bf3a0901cb61637a7e0ffd72b38675 Mon Sep 17 00:00:00 2001 From: Matthias Klose <doko@timbuktu> Date: Mon, 17 May 2010 12:57:55 +0200 Subject: [PATCH] package version python-defaults-2.4.3-6 --- debian/changelog | 24 +++++ debian/control | 12 ++- debian/control.in | 12 ++- debian/python-minimal.postinst | 23 ----- debian/python-minimal.preinst | 10 -- debian/python.postinst.in | 47 +++++++++ ...python-minimal.postrm => python.postrm.in} | 0 debian/python.preinst | 5 - debian/python.preinst.in | 29 ++++++ .../{python-minimal.prerm => python.prerm.in} | 0 debian/pyversions.1 | 13 ++- debian/pyversions.py | 97 ++++++++++++++++--- debian/rules | 5 +- 13 files changed, 209 insertions(+), 68 deletions(-) delete mode 100644 debian/python-minimal.postinst delete mode 100644 debian/python-minimal.preinst create mode 100644 debian/python.postinst.in rename debian/{python-minimal.postrm => python.postrm.in} (100%) delete mode 100644 debian/python.preinst create mode 100644 debian/python.preinst.in rename debian/{python-minimal.prerm => python.prerm.in} (100%) diff --git a/debian/changelog b/debian/changelog index ebcf864..ddaa36c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,27 @@ +python-defaults (2.4.3-6) experimental; urgency=low + + * Remove python's dependency on python-central. Closes: #372658. + * On upgrade of the runtime to a new major version, call the hooks + (executable files) in /usr/share/python/runtime.d/*.rtupdate. + - in python.preinst, call the script with parameters + pre-rtupdate <old runtime> <new runtime>. + run all hooks, then return exit with the correct exit status. + - in python.postinst, call the script with parameters + rtupdate <old runtime> <new runtime>. + run all hooks, then return exit with the correct exit status. + - in python.postinst, call the script with parameters + post-rtupdate <old runtime> <new runtime>. + run all hooks, then return exit with the correct exit status. + * pyversions -r: If the XS-Python-Version field cannot be found in + debian/control, fall back to debian/pyversions for the version + information. Return with an error code, if the intersection of + the versions in debian/pyversions and the supported python versions + is empty. Fall back to the supported versions if no version + information can be found. Based on a patch from Raphael Hertzog. + * Reflect renaming of the docutils binaries. Closes: #377601. + + -- Matthias Klose <doko@debian.org> Sat, 5 Aug 2006 17:54:43 +0200 + python-defaults (2.4.3-5) experimental; urgency=low * Tighten dependencies between packages built from this source. diff --git a/debian/control b/debian/control index 723eb81..aaccf94 100644 --- a/debian/control +++ b/debian/control @@ -2,14 +2,15 @@ Source: python-defaults Section: python Priority: optional Maintainer: Matthias Klose <doko@debian.org> -Build-Depends-Indep: debhelper (>= 4), libhtml-tree-perl, debiandoc-sgml, python-docutils, python, python2.4 +Build-Depends-Indep: debhelper (>= 4), libhtml-tree-perl, debiandoc-sgml, python-docutils (>= 0.4-3), python Standards-Version: 3.7.2 Package: python Architecture: all Priority: standard +Pre-Depends: python-minimal (>= 2.4) Depends: python2.4 (>= 2.4.3-7), python-minimal (= ${Source-Version}) -Conflicts: python2.3 (<< 2.3.5-14), python2.1 (<= 2.1.2), python-xmlbase, python-csv, python-bz2, python-base, python-central (<< 0.4.17) +Conflicts: python2.3 (<< 2.3.5-14), python2.1 (<= 2.1.2), python-xmlbase, python-csv, python-bz2, python-base, python-central (<< 0.5.3) Replaces: python2.3 (<= 2.3.2-6), python-xmlbase, python-base Provides: python-email, python-xmlbase Suggests: python-doc, python-tk, python-profiler @@ -24,8 +25,8 @@ Description: An interactive high-level object-oriented language (default version Package: python-minimal Architecture: all Priority: standard -Depends: python2.4-minimal (>= 2.4.3-7), python-central (>= 0.4.11), dpkg (>= 1.13.20) -Conflicts: python (<= 2.4-1), python-central (<< 0.4.8) +Depends: python2.4-minimal (>= 2.4.3-7), dpkg (>= 1.13.20) +Conflicts: python (<= 2.4-1), python-central (<< 0.5) Replaces: python (<= 2.4-1) Description: A minimal subset of the Python language (default version) This package contains the interpreter and some essential modules. It's used @@ -35,7 +36,7 @@ Description: A minimal subset of the Python language (default version) Package: python-examples Architecture: all -Depends: python (= ${Source-Version}), python (<< 2.5), python2.4-examples (>= 2.4.3-7) +Depends: python (= ${Source-Version}), python2.4-examples (>= 2.4.3-7) Description: Examples for the Python language (default version) Examples, Demos and Tools for Python. These are files included in the upstream Python distribution. @@ -60,6 +61,7 @@ Description: Header files and a static library for Python (default) Package: idle Architecture: all Depends: python (= ${Source-Version}), idle-python2.4 (>= 2.4.3-7) +Enhances: python Description: An IDE for Python using Tkinter (default version) IDLE is an Integrated Development Environment for Python. IDLE is written using Tkinter and therefore quite platform-independent. diff --git a/debian/control.in b/debian/control.in index 43bcffe..6c44a67 100644 --- a/debian/control.in +++ b/debian/control.in @@ -2,14 +2,15 @@ Source: python-defaults Section: python Priority: optional Maintainer: Matthias Klose <doko@debian.org> -Build-Depends-Indep: debhelper (>= 4), libhtml-tree-perl, debiandoc-sgml, python-docutils, python, python2.4 +Build-Depends-Indep: debhelper (>= 4), libhtml-tree-perl, debiandoc-sgml, python-docutils (>= 0.4-3), python Standards-Version: 3.7.2 Package: python Architecture: all Priority: standard +Pre-Depends: python-minimal (>= 2.4) Depends: @PVER@ (>= @PREVVER@), python-minimal (= ${Source-Version}) -Conflicts: python2.3 (<< 2.3.5-14), python2.1 (<= 2.1.2), python-xmlbase, python-csv, python-bz2, python-base, python-central (<< 0.4.17) +Conflicts: python2.3 (<< 2.3.5-14), python2.1 (<= 2.1.2), python-xmlbase, python-csv, python-bz2, python-base, python-central (<< 0.5.3) Replaces: python2.3 (<= 2.3.2-6), python-xmlbase, python-base Provides: python-email, python-xmlbase Suggests: python-doc, python-tk, python-profiler @@ -24,8 +25,8 @@ Description: An interactive high-level object-oriented language (default version Package: python-minimal Architecture: all Priority: standard -Depends: @PVER@-minimal (>= @PREVVER@), python-central (>= 0.4.11), dpkg (>= 1.13.20) -Conflicts: python (<= 2.4-1), python-central (<< 0.4.8) +Depends: @PVER@-minimal (>= @PREVVER@), dpkg (>= 1.13.20) +Conflicts: python (<= 2.4-1), python-central (<< 0.5) Replaces: python (<= 2.4-1) Description: A minimal subset of the Python language (default version) This package contains the interpreter and some essential modules. It's used @@ -35,7 +36,7 @@ Description: A minimal subset of the Python language (default version) Package: python-examples Architecture: all -Depends: python (= ${Source-Version}), python (<< @NVER@), @PVER@-examples (>= @PREVVER@) +Depends: python (= ${Source-Version}), @PVER@-examples (>= @PREVVER@) Description: Examples for the Python language (default version) Examples, Demos and Tools for Python. These are files included in the upstream Python distribution. @@ -60,6 +61,7 @@ Description: Header files and a static library for Python (default) Package: idle Architecture: all Depends: python (= ${Source-Version}), idle-@PVER@ (>= @PREVVER@) +Enhances: python Description: An IDE for Python using Tkinter (default version) IDLE is an Integrated Development Environment for Python. IDLE is written using Tkinter and therefore quite platform-independent. diff --git a/debian/python-minimal.postinst b/debian/python-minimal.postinst deleted file mode 100644 index 9ac1be6..0000000 --- a/debian/python-minimal.postinst +++ /dev/null @@ -1,23 +0,0 @@ -#! /bin/sh -e - -new_config_file() -{ - cat > /etc/python/debian_config <<-EOF - [DEFAULT] - # how to byte-compile (comma separated: standard, optimize) - byte-compile = standard - EOF -} - -case "$1" in - configure) - [ -d /etc/python ] || mkdir /etc/python - [ -f /etc/python/debian_config ] || new_config_file - - if [ -n "$2" ] && dpkg --compare-versions $2 lt 2.4; then - oldv=$(echo $2 | sed 's/^\(...\).*/\1/') - pycentral updatedefault python$oldv python2.4 - fi -esac - -#DEBHELPER# diff --git a/debian/python-minimal.preinst b/debian/python-minimal.preinst deleted file mode 100644 index 977f58f..0000000 --- a/debian/python-minimal.preinst +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/sh -e - -# remove the python alternatives before installing our own python link - -update-alternatives --auto /usr/bin/python >/dev/null 2>&1 || true -update-alternatives --remove python /usr/bin/python1.5 || true -update-alternatives --remove python /usr/bin/python2.1 || true -update-alternatives --remove python /usr/bin/python2.2 || true - -#DEBHELPER# diff --git a/debian/python.postinst.in b/debian/python.postinst.in new file mode 100644 index 0000000..ccfae0a --- /dev/null +++ b/debian/python.postinst.in @@ -0,0 +1,47 @@ +#! /bin/sh -e + +new_config_file() +{ + cat > /etc/python/debian_config <<-EOF + [DEFAULT] + # how to byte-compile (comma separated: standard, optimize) + byte-compile = standard + EOF +} + +case "$1" in + configure) + [ -d /etc/python ] || mkdir /etc/python + [ -f /etc/python/debian_config ] || new_config_file + + if [ -n "$2" ] && dpkg --compare-versions $2 lt 2.4; then + oldv=$(echo $2 | sed 's/^\(...\).*/\1/') + if [ "$DEBIAN_FRONTEND" != noninteractive ]; then + echo "running python rtupdate hooks for @PVER@..." + fi + for hook in /usr/share/python/runtime.d/*.rtupdate; do + [ -x $hook ] || continue + if ! $hook rtupdate python$oldv @PVER@; then + hb=$(basename $hook .rtupdate) + echo >&2 "error running python rtupdate hook $hb" + errors=yes + fi + done + [ -z "$errors" ] || exit 4 + + if [ "$DEBIAN_FRONTEND" != noninteractive ]; then + echo "running python post-rtupdate hooks for @PVER@..." + fi + for hook in /usr/share/python/runtime.d/*.rtupdate; do + [ -x $hook ] || continue + if ! $hook post-rtupdate python$oldv @PVER@; then + hb=$(basename $hook .rtupdate) + echo >&2 "error running python post-rtupdate hook $hb" + errors=yes + fi + done + [ -z "$errors" ] || exit 5 + fi +esac + +#DEBHELPER# diff --git a/debian/python-minimal.postrm b/debian/python.postrm.in similarity index 100% rename from debian/python-minimal.postrm rename to debian/python.postrm.in diff --git a/debian/python.preinst b/debian/python.preinst deleted file mode 100644 index b76ec49..0000000 --- a/debian/python.preinst +++ /dev/null @@ -1,5 +0,0 @@ -#! /bin/sh -e - -[ -L /usr/share/doc/python/html ] || rm -rf /usr/share/doc/python/html - -#DEBHELPER# diff --git a/debian/python.preinst.in b/debian/python.preinst.in new file mode 100644 index 0000000..9bb357b --- /dev/null +++ b/debian/python.preinst.in @@ -0,0 +1,29 @@ +#! /bin/sh -e + +# remove the python alternatives before installing our own python link + +update-alternatives --auto /usr/bin/python >/dev/null 2>&1 || true +update-alternatives --remove python /usr/bin/python1.5 || true +update-alternatives --remove python /usr/bin/python2.1 || true +update-alternatives --remove python /usr/bin/python2.2 || true + +[ -L /usr/share/doc/python/html ] || rm -rf /usr/share/doc/python/html + +case "$1" in + upgrade) + if dpkg --compare-versions $2 lt 2.4; then + oldv=$(echo $2 | sed 's/^\(...\).*/\1/') + if [ "$DEBIAN_FRONTEND" != noninteractive ]; then + echo "running python pre-rtupdate hooks for @PVER@..." + fi + for hook in /usr/share/python/runtime.d/*.rtupdate; do + [ -x $hook ] || continue + if ! $hook pre-rtupdate python$oldv @PVER@; then + hb=$(basename $hook .rtupdate) + echo >&2 "error running python pre-rtupdate hook $hb" + errors=yes + fi + done + [ -z "$errors" ] || exit 3 + +#DEBHELPER# diff --git a/debian/python-minimal.prerm b/debian/python.prerm.in similarity index 100% rename from debian/python-minimal.prerm rename to debian/python.prerm.in diff --git a/debian/pyversions.1 b/debian/pyversions.1 index 9ca8d02..9d911ee 100644 --- a/debian/pyversions.1 +++ b/debian/pyversions.1 @@ -19,12 +19,15 @@ Show the default python version. .I -s, --supported Show the supported python versions. .TP -.I -r, --requested <version string> | <control file> -Reads the +.I -r, --requested [<version string> | <control file>] +Reads the value of the .B XS-Python-Version -value in the source section of a control file and shows all -matching python versions. The parameter is interpreted as -a version string, if it is not the name of a file. +field in the source section of a control file and shows all matching +python versions. The parameter is interpreted as a version string, if +it is not the name of a file. If the XS-Python-Version field is +missing, get the version information from debian/pyversions. +Without any parameter, it will fall back to list the supported Python +versions after checking debian/control and debian/pyversions. .TP .I -i, --installed Show the installed supported python versions. diff --git a/debian/pyversions.py b/debian/pyversions.py index b92fab5..e6e3643 100644 --- a/debian/pyversions.py +++ b/debian/pyversions.py @@ -128,6 +128,11 @@ def installed_versions(version_only=False): else: return versions +class ControlFileValueError(ValueError): + pass +class MissingVersionValueError(ValueError): + pass + def extract_pyversion_attribute(fn, pkg): """read the debian/control file, extract the XS-Python-Version field; check that XB-Python-Version exists for the package.""" @@ -138,11 +143,13 @@ def extract_pyversion_attribute(fn, pkg): for line in file(fn): line = line.strip() if line == '': + if pkg == 'Source': + break section = None elif line.startswith('Source:'): section = 'Source' elif line.startswith('Package: ' + pkg): - section = self.name + section = pkg elif line.startswith('XS-Python-Version:'): if section != 'Source': raise ValueError, \ @@ -151,15 +158,55 @@ def extract_pyversion_attribute(fn, pkg): elif line.startswith('XB-Python-Version:'): if section == pkg: version = line.split(':', 1)[1].strip() + if section == None: + raise ControlFileValueError, 'not a control file' if pkg == 'Source': if sversion == None: - raise ValueError, 'missing XS-Python-Version in control file' + raise MissingVersionValueError, \ + 'missing XS-Python-Version in control file' return sversion if version == None: - raise ValueError, \ + raise MissingVersionValueError, \ 'missing XB-Python-Version for package `%s' % pkg return version +# compatibility functions to parse debian/pyversions + +def version_cmp(ver1,ver2): + v1=[int(i) for i in ver1.split('.')] + v2=[int(i) for i in ver2.split('.')] + return cmp(v1,v2) + +def requested_versions_bis(vstring, version_only=False): + versions = [] + py_supported_short = supported_versions(version_only=True) + for item in vstring.split(','): + v=item.split('-') + if len(v)>1: + if not v[0]: + v[0] = py_supported_short[0] + if not v[1]: + v[1] = py_supported_short[-1] + for ver in py_supported_short: + try: + if version_cmp(ver,v[0]) >= 0 \ + and version_cmp(ver,v[1]) <= 0: + versions.append(ver) + except ValueError: + pass + else: + if v[0] in py_supported_short: + versions.append(v[0]) + versions.sort(version_cmp) + if not versions: + raise ValueError, 'empty set of versions' + if not version_only: + versions=['python'+i for i in versions] + return versions + +def extract_pyversion_attribute_bis(fn): + vstring = file(fn).readline().rstrip('\n') + return vstring def main(): from optparse import OptionParser @@ -173,7 +220,7 @@ def main(): action='store_true', dest='supported') parser.add_option('-r', '--requested', help='print the python versions requested by a build; the argument is either the name of a control file or the value of the XS-Python-Version attribute', - action='store', dest='versions') + action='store_true', dest='requested') parser.add_option('-i', '--installed', help='print the installed supported python versions', action='store_true', dest='installed') @@ -183,24 +230,46 @@ def main(): opts, args = parser.parse_args() program = os.path.basename(sys.argv[0]) - if opts.default: + if opts.default and len(args) == 0: print default_version(opts.version_only) - elif opts.supported: + elif opts.supported and len(args) == 0: print ' '.join(supported_versions(opts.version_only)) - elif opts.installed: + elif opts.installed and len(args) == 0: print ' '.join(installed_versions(opts.version_only)) - elif opts.versions: + elif opts.requested and len(args) <= 1: + if len(args) == 0: + versions = 'debian/control' + else: + versions = args[0] try: - if os.path.isfile(opts.versions): - vs = extract_pyversion_attribute(opts.versions, 'Source') + if os.path.isfile(versions): + fn = versions + try: + vstring = extract_pyversion_attribute(fn, 'Source') + vs = requested_versions(vstring, opts.version_only) + except ControlFileValueError: + sys.stderr.write("%s: not a control file: %s, " \ + % (program, fn)) + sys.exit(1) + except MissingVersionValueError: + fn = os.path.join(os.path.dirname(fn), 'pyversions') + sys.stderr.write("%s: missing XS-Python-Version in control file, fall back to %s\n" \ + % (program, fn)) + try: + vstring = extract_pyversion_attribute_bis(fn) + vs = requested_versions_bis(vstring, opts.version_only) + except IOError: + sys.stderr.write("%s: missing debian/pyversions file, fall back to supported versions\n" \ + % program) + vs = supported_versions(opts.version_only) else: - vs = opts.versions - print ' '.join(requested_versions(vs, opts.version_only)) + vs = requested_versions(versions, opts.version_only) + print ' '.join(vs) except ValueError, msg: - print "%s: %s" % (program, msg) + sys.stderr.write("%s: %s\n" % (program, msg)) sys.exit(1) else: - print "usage: %s %s" % (program, usage) + sys.stderr.write("usage: %s %s\n" % (program, usage)) sys.exit(1) if __name__ == '__main__': diff --git a/debian/rules b/debian/rules index 7fcb9a0..f5c6fce 100755 --- a/debian/rules +++ b/debian/rules @@ -25,9 +25,12 @@ scriptdir = usr/share/python$(VER) scriptdir = usr/lib/python$(VER) rst2html = $(PVER) /usr/share/python-docutils/rst2html.py +rst2html = rst2html with_doc = no -NOPKGS = -Npython-doc +ifneq ($(with_doc),yes) + NOPKGS = -Npython-doc +endif build: stamp-build stamp-build: -- GitLab