[Python-modules-commits] r4035 - in packages/python-pysizer/trunk (6 files)
stew-guest at users.alioth.debian.org
stew-guest at users.alioth.debian.org
Mon Dec 24 18:55:44 UTC 2007
Date: Monday, December 24, 2007 @ 18:55:44
Author: stew-guest
Revision: 4035
* add build-patched-pysizer to bulid a patched version of python
* add README.Debian explaining about the patch
* clean the autogenerated crules.c (and remove crules.c from source control)
Added:
packages/python-pysizer/trunk/debian/README.Debian
packages/python-pysizer/trunk/debian/build-patched-pysizer
packages/python-pysizer/trunk/debian/examples
Modified:
packages/python-pysizer/trunk/debian/control
packages/python-pysizer/trunk/debian/rules
Deleted:
packages/python-pysizer/trunk/src/
Added: packages/python-pysizer/trunk/debian/README.Debian
===================================================================
--- packages/python-pysizer/trunk/debian/README.Debian (rev 0)
+++ packages/python-pysizer/trunk/debian/README.Debian 2007-12-24 18:55:44 UTC (rev 4035)
@@ -0,0 +1,13 @@
+pysizer for Debian:
+-------------------
+
+pysizer comes with a patch to python itself which allows it to collect
+additional information. This patch is not included in Debian's
+shipped python versions, however pysizer is still useful without it.
+
+The examples directory contians both the patch (named cpython.patch)
+and a script (named build-patched-pysizer). The script will download
+the source to debian's python packages and build a patched version
+debian's python packages.
+
+- Mike O'Connor (Mon Dec 24 14:49:34 EST 2007)
\ No newline at end of file
Added: packages/python-pysizer/trunk/debian/build-patched-pysizer
===================================================================
--- packages/python-pysizer/trunk/debian/build-patched-pysizer (rev 0)
+++ packages/python-pysizer/trunk/debian/build-patched-pysizer 2007-12-24 18:55:44 UTC (rev 4035)
@@ -0,0 +1,250 @@
+#!/usr/bin/python
+
+import os, os.path, sys, re, shutil, glob
+from time import gmtime, strftime
+import tempfile
+
+from debian_bundle import deb822, changelog
+import apt_pkg
+import traceback
+import subprocess
+
+def fetch_python_versions():
+ """
+ find the available python versions in the deb-src's
+ """
+ py_re = re.compile( '^python2.[3-5]$' )
+ pkgs = {}
+
+ for source in glob.glob( '/var/lib/apt/lists/*Sources' ):
+ for pkg in deb822.Packages.iter_paragraphs( open( source ),
+ ['Package', 'Version' ],
+ False ):
+ if py_re.match( pkg['Package'] ):
+ pkgs[ pkg['Version'] ] = pkg
+
+ return pkgs
+
+def fetch_source( pkg ):
+ """
+ use 'apt-get source' to fetch the source of a package
+ """
+ cmd = "apt-get source %s=%s" % ( pkg['Package'], pkg['Version'] )
+ if os.system( cmd ):
+ print( "unable to download source package" )
+ return None
+
+ version = pkg['Version' ]
+ idash = version.rfind( '-' )
+ if idash != -1:
+ version = version[ 0: idash ]
+ return "%s-%s" % ( pkg['Package'], version )
+
+def ask_user_which_package( pkgs, keys ):
+ """
+ have the user select a python version to patch
+ """
+
+ which = 0
+ while which < 1 or which > len( keys ):
+
+ for i in range( len( keys ) ):
+ pkg = pkgs[ keys[ i ] ]
+ print "%d: %s version %s" % ( i+1, pkg[ 'Package' ], pkg[ 'Version' ] )
+ which = raw_input("Which version of python should we build? [1] ")
+
+ try:
+ if which == "":
+ which = 1
+ else:
+ which = int( which )
+ except:
+ print( "error parsing input" )
+ which = 0
+
+ return pkgs[ keys [ which - 1 ] ]
+
+def build_pkg( pkg ):
+ """
+ have the user select a python version to patch
+ """
+ possibilities = [ 'sudo apt-get build-dep %s && debuild' % pkg[ 'Package' ],
+ 'pdebuild',
+ 'pdebuild --pbuilder cowbuilder',
+ None ]
+
+ which = 0
+ while which < 1 or which > len( possibilities ):
+
+ for i in range( len( possibilities ) ):
+ print( "%d. %s" % (i+1,possibilities[i]))
+
+ which = raw_input("Which version of python should we build? [1] ")
+
+ try:
+ if which == "":
+ which = 1
+ else:
+ which = int( which )
+ except:
+ print( "error parsing input" )
+ which = 0
+
+ if( possibilities[ which - 1 ] ):
+ os.system( possibilities[ which - 1 ] )
+
+def ask_user_which_email():
+ """
+ have the user tell us who to put as the author of this change in the changelog
+ """
+ result = get_default_debemail()
+ response = raw_input( "What author should show up in the changelog for the patched package? [%s] " % result)
+
+ if response:
+ result = response
+
+ return result
+
+
+def create_patch():
+ """
+ take the patch from the examples directory, and add it to the
+ source package's dpatch directory
+ """
+ patchfile = "debian/patches/00-pysizer"
+
+ patch = open( patchfile, "w" )
+ patch.write( """#! /bin/sh -e
+# Adds patch from python-pysizer
+
+dir=
+if [ $# -eq 3 -a "$2" = '-d' ]; then
+ pdir="-d $3"
+ dir="$3/"
+elif [ $# -ne 1 ]; then
+ echo >&2 "usage: `basename $0`: -patch|-unpatch [-d <srcdir>]"
+ exit 1
+fi
+case "$1" in
+ -patch)
+ patch $pdir -f --no-backup-if-mismatch -p0 < $0
+ ;;
+ -unpatch)
+ patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
+ ;;
+ *)
+ echo >&2 "usage: `basename $0`: -patch|-unpatch [-d <srcdir>]"
+ exit 1
+esac
+exit 0
+
+""" )
+ orig_patch = open( "/usr/share/doc/python-pysizer/examples/cpython.patch", "r" )
+ for line in orig_patch:
+ patch.write( line )
+
+ orig_patch.close()
+ patch.close()
+
+def get_default_debemail():
+ """
+ determine what the default author should be for the changelog of
+ our patched package.
+ """
+ email = os.getenv( "DEBEMAIL" )
+ if not email:
+ email = os.getenv( "EMAIL" )
+ if not email:
+ domain=None
+ try:
+ if os.path.exists( "/etc/mailname" ):
+ f = open( "/etc/mailname" )
+ domain = f.readline().strip()
+ except:
+ pass
+ if not domain:
+ p = subprocess.Popen( ["hostname","--fqdn"], stdout=subprocess.PIPE)
+ domain = p.stdout.readline().strip()
+ if domain:
+ email = os.getlogin() + "@" + domain
+
+ name = os.getenv( "DEBFULLNAME" )
+ if not name:
+ name = os.getenv( "NAME" )
+ if not name:
+ try:
+ p = subprocess.Popen( ["getent","passwd", str( os.getuid() )],
+ stdout=subprocess.PIPE )
+ name = p.stdout.readline().strip().split( ':' )[4].split( ',' )[0]
+ except:
+ traceback.print_exc()
+ pass
+ return "%s <%s>" % ( name, email )
+
+
+def bump_changelog( pkg, email ):
+ """
+ add a changelog block to the top which bumps the version adding +pysizer0
+ """
+ clFile = open( "debian/changelog", "r" )
+ cl = changelog.Changelog( clFile.read() )
+ clFile.close()
+ lastVersion = cl.versions[0]
+ lastPackage = cl.package
+ if not str(lastVersion).endswith( "pysizer0" ):
+ cl.new_block()
+ cl.version += "+pysizer0"
+ cl.package = lastPackage
+ cl.version = str(lastVersion)
+ cl.distributions = 'UNRELEASED'
+ cl.urgency = 'low'
+ cl.add_change(' * Adding Pysizer Patch' )
+ cl.add_change(' * Automatically built by build-patched-pysizer' )
+ cl.author = email
+ cl.date = strftime( "%a, %d %b %Y %H:%M:%S +0000", gmtime() )
+
+ clFile = open( "debian/changelog", "w" )
+
+ cl.write_to_open_file( clFile )
+
+def build():
+ """
+ actually build the package
+ """
+ return os.system( "dpkg-buildpackage -nc -ns -rfakeroot" )
+
+def main():
+ pkgs = fetch_python_versions()
+ apt_pkg.init()
+
+ if pkgs:
+
+ # create a list of packages sorted by version number
+ keys = pkgs.keys()
+ keys.sort( apt_pkg.VersionCompare, reverse=False )
+
+# pkgs = map( lambda x: pkgs[ x ], keys )
+
+ #have the user choose from the list of packages
+ pkg = ask_user_which_package( pkgs, keys )
+
+ # fetch the source package and extract it to a teporary directory
+ packagedirectory = fetch_source( pkg )
+
+ print( "STU: got directory: %s" % packagedirectory )
+
+ os.chdir( packagedirectory )
+ # add a dpatch to the debian/patches directory
+ create_patch()
+
+ bump_changelog( pkg, ask_user_which_email() )
+
+ build_pkg( pkg )
+
+ else:
+ print "no availabe python sources found."
+ sys.exit( 1 )
+
+
+if __name__ == "__main__":
+ main()
Property changes on: packages/python-pysizer/trunk/debian/build-patched-pysizer
___________________________________________________________________
Name: svn:executable
+ *
Modified: packages/python-pysizer/trunk/debian/control
===================================================================
--- packages/python-pysizer/trunk/debian/control 2007-12-24 07:43:06 UTC (rev 4034)
+++ packages/python-pysizer/trunk/debian/control 2007-12-24 18:55:44 UTC (rev 4035)
@@ -3,8 +3,7 @@
Priority: extra
Maintainer: Debian Python Modules Team <python-modules-team at lists.alioth.debian.org>
Uploaders: Mike O'Connor <stew at vireo.org>
-Build-Depends: debhelper (>= 5.0.37.2), python-all-dev (>= 2.3.5-11), python-pyrex
-Build-Depends-Indep: python-support (>= 0.3)
+Build-Depends: debhelper (>= 5.0.37.2), python-all-dev (>= 2.3.5-11), python-pyrex, python-support (>= 0.3)
Standards-Version: 3.7.3
Homepage: http://pysizer.8325.org/
Vcs-Svn: svn://svn.debian.org/python-modules/packages/python-sizer/trunk/
Added: packages/python-pysizer/trunk/debian/examples
===================================================================
--- packages/python-pysizer/trunk/debian/examples (rev 0)
+++ packages/python-pysizer/trunk/debian/examples 2007-12-24 18:55:44 UTC (rev 4035)
@@ -0,0 +1,2 @@
+src/cpython/patch
+debian/build-patched-pysizer
\ No newline at end of file
Modified: packages/python-pysizer/trunk/debian/rules
===================================================================
--- packages/python-pysizer/trunk/debian/rules 2007-12-24 07:43:06 UTC (rev 4034)
+++ packages/python-pysizer/trunk/debian/rules 2007-12-24 18:55:44 UTC (rev 4035)
@@ -26,6 +26,7 @@
done
rm -f install-stamp build-stamp
find . -name \*.pyc | xargs rm -f
+ rm src/cpython/crules.c
rm -rf build
dh_clean
@@ -39,8 +40,10 @@
for py in $(PYVERS); do \
$$py setup.py install --root=debian/python-pysizer; \
done
- dh_installdocs -A
+ dh_installdocs
dh_installexamples
+ mv debian/python-pysizer/usr/share/doc/python-pysizer/examples/patch \
+ debian/python-pysizer/usr/share/doc/python-pysizer/examples/cpython.patch
touch install-stamp
@@ -48,7 +51,7 @@
dh_testdir
dh_testroot
dh_installchangelogs
- dh_compress -X.py
+ dh_compress -X.py -X cpython.patch
dh_fixperms
dh_pysupport
dh_strip
More information about the Python-modules-commits
mailing list