Raphael Hertzog writes:
> On Thu, 08 Jun 2006, Raphael Hertzog wrote:
> > Matthias has been working on integrating python-central support in
> > dh_python and submitted #370833:
> >
> > http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=370833
> >
> > This dh_python will use python-central for any binary package with a
> > XB-Python-Version: field. There's no optional python-support either.
>
> Furthermore, if there's no "XS-Python-Version" then it will bail out. So
> it's not at all backwards compatible.
>
> dh_python: missing XS-PythonVersion for source package
>
> Introducing this dh_python in sid will instantly create dozens of FTBFS.
updated patch attached.
--- /usr/bin/dh_python 2006-04-24 20:09:12.000000000 +0000
+++ dh_python 2006-06-08 18:17:43.725917592 +0000
@@ -13,6 +13,7 @@
=head1 SYNOPSIS
B<dh_python> [S<I<debhelper options>>] [B<-n>] [B<-V> I<version>] [S<I<module
dirs ...>>]
+B<dh_python> [S<I<debhelper options>>] [B<-n>] [B<-add-provides>] [B<-no-move>]
=head1 DESCRIPTION
@@ -32,10 +33,20 @@
If you use this program, your package should build-depend on python.
+In pycentral mode (see below), the program will additionally generate
+the ${python:Versions} and (optionally) ${python:Provides} substitutions
+and move the files to the pycentral location for modules which are
+shared across python versions. If you use this mode, your package must
+build-depend on python-central.
+
=head1 OPTIONS
=over 4
+Some options are ignored when the control file has an XS-Python-Version
+attribute in the Source section and an XB-Python-Version attribute in
+the package section (pycentral mode).
+
=item I<module dirs>
If your package installs python modules in non-standard directories, you
@@ -47,12 +58,27 @@
Note: only /usr/lib/site-python, /usr/lib/python?.?/site-packages and the
extra names on the command line are searched for binary (.so) modules.
+Module directories are ignored in pycentral mode.
+
=item B<-V> I<version>
If the .py files your package ships are meant to be used by a specific
pythonX.Y version, you can use this option to specify the desired version,
such as 2.3. Do not use if you ship modules in /usr/lib/site-python.
+This option is ignored in pycentral mode.
+
+=item B<--add-provides>
+
+Add a substitution variable "${python:Provides}". Additional provides
+information is needed for packages depending on on a module or extension
+for a python version, which is not the default python version.
+
+=item B<--no-move>
+
+Do not move files from /usr/lib/python2.X to the pycentral area for
+files shared across python versions (pycentral mode only).
+
=item B<-n>, B<--noscripts>
Do not modify postinst/postrm scripts.
@@ -69,6 +95,73 @@
init();
+sub readpyversions {
+ my $type=shift;
+
+ my %version_fields=();
+
+ $type="" if ! defined $type;
+
+ # Look up the build arch if we need to.
+ my $buildarch='';
+ if ($type eq 'same') {
+ $buildarch=buildarch();
+ }
+
+ my $package="";
+ my $arch="";
+ my $pv_info="";
+ my @list=();
+ my %seen;
+ open (CONTROL, 'debian/control') ||
+ error("cannot read debian/control: $!\n");
+ while (<CONTROL>) {
+ chomp;
+ s/\s+$//;
+ if (/^Source:\s*(.*)/) {
+ $package="Source";
+ }
+ if (/^Package:\s*(.*)/) {
+ $package=$1;
+ # Detect duplicate package names in the same control
file.
+ if (! $seen{$package}) {
+ $seen{$package}=1;
+ }
+ else {
+ error("debian/control has a duplicate entry for
$package");
+ }
+ }
+ if (/^Architecture:\s*(.*)/) {
+ $arch=$1;
+ }
+ if (/^X.*S.*-Python-Version:\s*(.*)/) {
+ if ($package ne 'Source') {
+ error("debian/control: XS-Python-Version field
in binary package");
+ }
+ $pv_info=$1;
+ }
+ if (/^X.*B.*-Python-Version:\s*(.*)/) {
+ if ($package eq 'Source') {
+ error("debian/control: XB-Python-Version field
in source package");
+ }
+ $pv_info=$1;
+ }
+
+ if (!$_ or eof) { # end of stanza.
+ if ($package and $pv_info) {
+ $version_fields{$package}=$pv_info;
+ }
+ $package="";
+ $pv_info="";
+ }
+ }
+ close CONTROL;
+
+ return %version_fields;
+}
+
+my %version_fields = readpyversions();
+
my $python = 'python';
# The current python major version
@@ -88,7 +181,7 @@
my $python_nextversion = $python_version + 0.1;
my $python_nextmajor = $python_major + 1;
-my @python_allversions = ('1.5','2.1','2.2','2.3','2.4');
+my @python_allversions = ('1.5','2.1','2.2','2.3','2.4', '2.5');
foreach (@python_allversions) {
s/^/python/;
}
@@ -120,6 +213,8 @@
my $tmp = tmpdir($package);
delsubstvar($package, "python:Depends");
+ delsubstvar($package, "python:Provides");
+ delsubstvar($package, "python:Versions");
my @dirs = ("usr/lib/site-python", "usr/lib/$package",
"usr/share/$package", "usr/lib/games/$package", "usr/share/games/$package",
@ARGV );
my @dirs_so = ("usr/lib/site-python", @ARGV );
@@ -128,6 +223,42 @@
my $strong_dep = 0;
my $look_for_pythonXY = 1;
+ if ($version_fields{$package}) {
+ if (!$version_fields{"Source"}) {
+ error("XS-Python-Version attribute missing in source
package");
+ }
+ if (! -x "/usr/bin/pycentral") {
+ error("python-central misssing, please install");
+ }
+ my $pycmd = "pycentral debhelper --stdout";
+ if ($dh{ONLYSCRIPTS}) {
+ $pycmd = "$pycmd --no-act";
+ }
+ #if ($dh{ADD_PROVIDES}) {
+ # $pycmd = "$pycmd --provides";
+ #}
+ #if ($dh{NO_MOVE}) {
+ # $pycmd = "$pycmd --no-move";
+ #}
+ $pycmd = "$pycmd $package";
+ verbose_print("$pycmd");
+ open(PYCENTRAL, "$pycmd |") or die "cannot start pycentral";
+ while (<PYCENTRAL>) {
+ chomp;
+ if (/^([^=]+)=(.*)/) {
+ addsubstvar($package, "$1", $2);
+ } else {
+ error("internal pycentral error: $_");
+ }
+ }
+ close(PYCENTRAL) || exit $?;
+
+ if (! $dh{NOSCRIPTS}) {
+
autoscript($package,"postinst","postinst-pycentral","s%#PACKAGE#%$package%");
+
autoscript($package,"prerm","prerm-pycentral","s%#PACKAGE#%$package%");
+ }
+ } else {
+ # current behaviour of dh_python
# First, the case of python-foo and pythonX.Y-foo
if ($package =~ /^python-/) {
$dep_on_python = 1;
@@ -261,6 +392,7 @@
if ($need_prerm && ! $dh{NOSCRIPTS}) {
autoscript($package,"prerm","prerm-python","s%#PACKAGE#%$package%");
}
+ }# current behaviour of dh_python
}
=head1 SEE ALSO
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]