From d94d3972e8998f0249d1a4c81418bbf1b00d0d5d Mon Sep 17 00:00:00 2001
From: Matthias Klose <doko@debian.org>
Date: Sat, 16 Oct 2010 12:27:59 +0200
Subject: [PATCH] python-defaults (2.6.6-4) experimental; urgency=low

  * Add python2.7 as a supported Python version.
  * python-all{,-dev,-dbg}: Depend on the 2.7 packages.
  * Run the rtinstall script, when 2.7 became a supported version (2.6.6-4)
    and python2.7 is installed.

 -- Matthias Klose <doko@debian.org>  Sat, 16 Oct 2010 11:58:31 +0200
---
 debian/changelog          |  9 +++++++++
 debian/control            | 12 ++++++------
 debian/control.in         | 12 ++++++------
 debian/debian_defaults    |  2 +-
 debian/python.postinst.in | 33 ++++++++++++++++++++++++++++++---
 debian/python.preinst.in  |  8 ++++++++
 debpython/version.py      |  2 +-
 7 files changed, 61 insertions(+), 17 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index a91ea4e..66c4b61 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+python-defaults (2.6.6-4) experimental; urgency=low
+
+  * Add python2.7 as a supported Python version.
+  * python-all{,-dev,-dbg}: Depend on the 2.7 packages.
+  * Run the rtinstall script, when 2.7 became a supported version (2.6.6-4)
+    and python2.7 is installed.
+
+ -- Matthias Klose <doko@debian.org>  Sat, 16 Oct 2010 11:58:31 +0200
+
 python-defaults (2.6.6-3) unstable; urgency=low
 
   * Upload to unstable
diff --git a/debian/control b/debian/control
index 38fecbf..b61b9d2 100644
--- a/debian/control
+++ b/debian/control
@@ -110,9 +110,9 @@ Description: debug build of the Python Interpreter (version 2.6)
 
 Package: python-all
 Architecture: all
-Depends: ${misc:Depends}, python (= ${binary:Version}), python2.5 (>= 2.5.5-6), python2.6 (>= 2.6.5-2)
+Depends: ${misc:Depends}, python (= ${binary:Version}), python2.5 (>= 2.5.5-6), python2.6 (>= 2.6.5-2), python2.7 (>= 2.7-7)
 Description: package depending on all supported Python runtime versions
- The package currently depends on python2.5 and python2.6, in the future,
+ The package currently depends on python2.5, python2.6 and python2.7, in the future,
  dependencies on jython (Python for a JVM) and ironpython (Python for Mono)
  may be added.
  .
@@ -121,9 +121,9 @@ Description: package depending on all supported Python runtime versions
 
 Package: python-all-dev
 Architecture: all
-Depends: ${misc:Depends}, python (= ${binary:Version}), python-all (= ${binary:Version}), python-dev (= ${binary:Version}), python2.5-dev (>= 2.5.5-6), python2.6-dev (>= 2.6.5-2)
+Depends: ${misc:Depends}, python (= ${binary:Version}), python-all (= ${binary:Version}), python-dev (= ${binary:Version}), python2.5-dev (>= 2.5.5-6), python2.6-dev (>= 2.6.5-2), python2.7-dev (>= 2.7-7)
 Description: package depending on all supported Python development packages
- The package currently depends on python2.5-dev and python2.6-dev, in the
+ The package currently depends on python2.5-dev, python2.6-dev and python2.7-dev, in the
  future, dependencies on jython (Python for a JVM) and ironpython (Python
  for Mono) may be added.
  .
@@ -134,9 +134,9 @@ Package: python-all-dbg
 Architecture: all
 Section: debug
 Priority: extra
-Depends: ${misc:Depends}, python (= ${binary:Version}), python-all (= ${binary:Version}), python-dbg (= ${binary:Version}), python2.5-dbg (>= 2.5.5-6), python2.6-dbg (>= 2.6.5-2)
+Depends: ${misc:Depends}, python (= ${binary:Version}), python-all (= ${binary:Version}), python-dbg (= ${binary:Version}), python2.5-dbg (>= 2.5.5-6), python2.6-dbg (>= 2.6.5-2), python2.7-dbg (>= 2.7-7)
 Description: package depending on all supported Python debugging packages
- The package currently depends on python2.5-dbg and python2.6-dbg, in the
+ The package currently depends on python2.5-dbg, python2.6-dbg and python2.7-dbg, in the
  future, dependencies on jython (Python for a JVM) and ironpython (Python
  for Mono) may be added.
  .
diff --git a/debian/control.in b/debian/control.in
index a90bdb7..1f2b0c4 100644
--- a/debian/control.in
+++ b/debian/control.in
@@ -110,9 +110,9 @@ Description: debug build of the Python Interpreter (version @VER@)
 
 Package: python-all
 Architecture: all
-Depends: ${misc:Depends}, python (= ${binary:Version}), python2.5 (>= 2.5.5-6), python2.6 (>= 2.6.5-2)
+Depends: ${misc:Depends}, python (= ${binary:Version}), python2.5 (>= 2.5.5-6), python2.6 (>= 2.6.5-2), python2.7 (>= 2.7-7)
 Description: package depending on all supported Python runtime versions
- The package currently depends on python2.5 and python2.6, in the future,
+ The package currently depends on python2.5, python2.6 and python2.7, in the future,
  dependencies on jython (Python for a JVM) and ironpython (Python for Mono)
  may be added.
  .
@@ -121,9 +121,9 @@ Description: package depending on all supported Python runtime versions
 
 Package: python-all-dev
 Architecture: all
-Depends: ${misc:Depends}, python (= ${binary:Version}), python-all (= ${binary:Version}), python-dev (= ${binary:Version}), python2.5-dev (>= 2.5.5-6), python2.6-dev (>= 2.6.5-2)
+Depends: ${misc:Depends}, python (= ${binary:Version}), python-all (= ${binary:Version}), python-dev (= ${binary:Version}), python2.5-dev (>= 2.5.5-6), python2.6-dev (>= 2.6.5-2), python2.7-dev (>= 2.7-7)
 Description: package depending on all supported Python development packages
- The package currently depends on python2.5-dev and python2.6-dev, in the
+ The package currently depends on python2.5-dev, python2.6-dev and python2.7-dev, in the
  future, dependencies on jython (Python for a JVM) and ironpython (Python
  for Mono) may be added.
  .
@@ -134,9 +134,9 @@ Package: python-all-dbg
 Architecture: all
 Section: debug
 Priority: extra
-Depends: ${misc:Depends}, python (= ${binary:Version}), python-all (= ${binary:Version}), python-dbg (= ${binary:Version}), python2.5-dbg (>= 2.5.5-6), python2.6-dbg (>= 2.6.5-2)
+Depends: ${misc:Depends}, python (= ${binary:Version}), python-all (= ${binary:Version}), python-dbg (= ${binary:Version}), python2.5-dbg (>= 2.5.5-6), python2.6-dbg (>= 2.6.5-2), python2.7-dbg (>= 2.7-7)
 Description: package depending on all supported Python debugging packages
- The package currently depends on python2.5-dbg and python2.6-dbg, in the
+ The package currently depends on python2.5-dbg, python2.6-dbg and python2.7-dbg, in the
  future, dependencies on jython (Python for a JVM) and ironpython (Python
  for Mono) may be added.
  .
diff --git a/debian/debian_defaults b/debian/debian_defaults
index 60564eb..62f7353 100644
--- a/debian/debian_defaults
+++ b/debian/debian_defaults
@@ -3,7 +3,7 @@
 default-version = python2.6
 
 # all supported python versions
-supported-versions = python2.5, python2.6
+supported-versions = python2.5, python2.6, python2.7
 
 # formerly supported python versions
 old-versions = python2.3, python2.4
diff --git a/debian/python.postinst.in b/debian/python.postinst.in
index 83b5da5..826d9ce 100644
--- a/debian/python.postinst.in
+++ b/debian/python.postinst.in
@@ -18,7 +18,7 @@ case "$1" in
 	# run the rtinstall script, when 2.5 became a supported version
         if [ -x /usr/bin/python2.5 ] && [ -n "$2" ] && dpkg --compare-versions $2 lt 2.4.4-3; then
             if [ "$DEBIAN_FRONTEND" != noninteractive ]; then
-		echo "Linking and byte-compiling packages for runtime @PVER@..."
+		echo "Linking and byte-compiling packages for runtime python2.5..."
             fi
             version=$(dpkg -s python2.5-minimal | awk '/^Version:/ {print $2}')
             for hook in /usr/share/python/runtime.d/*.rtinstall; do
@@ -30,7 +30,7 @@ case "$1" in
 	# run the rtinstall script, when 2.6 became a supported version
         if [ -x /usr/bin/python2.6 ] && [ -n "$2" ] && dpkg --compare-versions $2 lt 2.5.4-6; then
             if [ "$DEBIAN_FRONTEND" != noninteractive ]; then
-		echo "Linking and byte-compiling packages for runtime @PVER@..."
+		echo "Linking and byte-compiling packages for runtime python2.6..."
             fi
             version=$(dpkg -s python2.6-minimal | awk '/^Version:/ {print $2}')
             for hook in /usr/share/python/runtime.d/*.rtinstall; do
@@ -39,6 +39,18 @@ case "$1" in
             done
 	fi
 
+	# run the rtinstall script, when 2.7 became a supported version
+        if [ -x /usr/bin/python2.7 ] && [ -n "$2" ] && dpkg --compare-versions $2 lt 2.6.6-4; then
+            if [ "$DEBIAN_FRONTEND" != noninteractive ]; then
+		echo "Linking and byte-compiling packages for runtime python2.7..."
+            fi
+            version=$(dpkg -s python2.7-minimal | awk '/^Version:/ {print $2}')
+            for hook in /usr/share/python/runtime.d/*.rtinstall; do
+		[ -x $hook ] || continue
+		$hook rtinstall python2.7 "$2" "$version"
+            done
+	fi
+
         if [ -n "$2" ] && dpkg --compare-versions $2 lt 2.6.4-1~; then
 	    oldv=$(echo $2 | sed 's/^\(...\).*/\1/')
 	    if [ "$DEBIAN_FRONTEND" != noninteractive ]; then
@@ -96,7 +108,22 @@ case "$1" in
 		$hook rtinstall python2.6 "$oldversion" "$newversion"
 	    done
 	fi
-	rm -f /var/lib/python/python2.5_already_installed
+	rm -f /var/lib/python/python2.6_already_installed
+
+	if [ -f /var/lib/python/python2.7_already_installed ] \
+	   && [ ! -f /var/lib/python/python2.7_installed ]
+	then
+	    if [ "$DEBIAN_FRONTEND" != noninteractive ]; then
+		echo "Linking and byte-compiling packages for runtime python2.7..."
+	    fi
+	    oldversion=$(cat /var/lib/python/python2.7_already_installed)
+	    newversion=$(dpkg -s python2.7-minimal | awk '/^Version:/ {print $2}')
+	    for hook in /usr/share/python/runtime.d/*.rtinstall; do
+		[ -x $hook ] || continue
+		$hook rtinstall python2.7 "$oldversion" "$newversion"
+	    done
+	fi
+	rm -f /var/lib/python/python2.7_already_installed
 
 	rmdir --ignore-fail-on-non-empty /var/lib/python 2>/dev/null || true
 esac
diff --git a/debian/python.preinst.in b/debian/python.preinst.in
index 720a6fe..47c7290 100644
--- a/debian/python.preinst.in
+++ b/debian/python.preinst.in
@@ -46,6 +46,14 @@ case "$1" in
 	    mkdir -p /var/lib/python
 	    echo "$version" > /var/lib/python/python2.6_already_installed
 	fi
+
+	# 2.6.6-4 is the first version, which adds python2.7 as supported
+	# version; need to run an rtinstall python2.7 in the postinst.
+        if dpkg --compare-versions $2 lt 2.6.6-4 && [ -x /usr/bin/python2.7 ]; then
+	    version=$(dpkg -s python2.7-minimal | awk '/^Version:/ {print $2}')
+	    mkdir -p /var/lib/python
+	    echo "$version" > /var/lib/python/python2.7_already_installed
+	fi
 esac
 
 #DEBHELPER#
diff --git a/debpython/version.py b/debpython/version.py
index 45792de..c7eda6d 100644
--- a/debpython/version.py
+++ b/debpython/version.py
@@ -23,7 +23,7 @@ import re
 from os.path import exists
 from types import GeneratorType
 
-SUPPORTED = [(2, 5), (2, 6)]
+SUPPORTED = [(2, 5), (2, 6), (2, 7)]
 DEFAULT = (2, 6)
 RANGE_PATTERN = r'(-)?(\d\.\d+)(?:(-)(\d\.\d+)?)?'
 RANGE_RE = re.compile(RANGE_PATTERN)
-- 
GitLab