| 12 |
|
|
| 13 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
| 14 |
|
|
| 15 |
B<dh_pysupport> [S<I<debhelper options>>] [-V I<X.Y>] [-X I<item> [...]] [-n] [S<I<module dirs ...>>] |
B<dh_pysupport> [I<debhelper options>] [-V I<X.Y>] [-X I<item> [...]] [-n] [I<module dirs ...>] |
| 16 |
|
|
| 17 |
=head1 DESCRIPTION |
=head1 DESCRIPTION |
| 18 |
|
|
| 19 |
dh_pysupport is a debhelper program that will scan your package, detect |
dh_pysupport is a debhelper program that will scan your package, detect |
| 20 |
public modules in I</usr/share/python-support> and generate appropriate |
public modules in I</usr/lib/pythonX.Y/site-packages>, and move them to |
| 21 |
|
the shared Python modules location. It will generate appropriate |
| 22 |
postinst/prerm scripts to byte-compile modules installed there for all |
postinst/prerm scripts to byte-compile modules installed there for all |
| 23 |
available python versions. |
available python versions. |
| 24 |
|
|
| 26 |
with the current Python version. You may have to list the directories |
with the current Python version. You may have to list the directories |
| 27 |
containing private Python modules. |
containing private Python modules. |
| 28 |
|
|
| 29 |
If a file named I<debian/pyversions> exists, it is installed in |
If a file named I<debian/pyversions> exists, it is used to determine the |
| 30 |
I</usr/share/python-support/$PACKAGE/.version>. |
python versions with which the package can work. |
| 31 |
|
|
| 32 |
Appropriate dependencies on python-support, python and pythonI<X.Y> are |
Appropriate dependencies on python-support, python and pythonI<X.Y> are |
| 33 |
put in ${python:Depends}. The ${python:Versions} and ${python:Provides} |
put in ${python:Depends}. The ${python:Versions} and ${python:Provides} |
| 59 |
=item B<-X> I<item>, B<--exclude=>I<item> |
=item B<-X> I<item>, B<--exclude=>I<item> |
| 60 |
|
|
| 61 |
Exclude files that contain "item" anywhere in their filename from being |
Exclude files that contain "item" anywhere in their filename from being |
| 62 |
taken into account to generate the python dependency. You may use this |
taken into account to generate the python dependency. It also excludes |
| 63 |
option multiple times to build up a list of things to exclude. |
them from byte-compilation. You may use this option multiple times to |
| 64 |
|
build up a list of things to exclude. |
| 65 |
|
|
| 66 |
=back |
=back |
| 67 |
|
|
| 127 |
$default =~ s/^python//; |
$default =~ s/^python//; |
| 128 |
chomp $default; |
chomp $default; |
| 129 |
|
|
| 130 |
|
my $privdir="/usr/share/python-support/private"; |
| 131 |
# All supported versions |
# All supported versions |
| 132 |
my $allversions_string=`pysupport-parseversions --all`; |
my $allversions_string=`$privdir/parseversions --all`; |
| 133 |
chomp $allversions_string; |
chomp $allversions_string; |
| 134 |
my @allversions=split " ", $allversions_string; |
my @allversions=split " ", $allversions_string; |
| 135 |
|
|
| 151 |
|
|
| 152 |
# 1) Handle public python modules |
# 1) Handle public python modules |
| 153 |
# Move them to the python-support directories |
# Move them to the python-support directories |
| 154 |
doit (("pysupport-movemodules",$tmp)); |
my $verfile = "debian/pyversions"; |
| 155 |
|
my $versions = ""; |
| 156 |
|
if (-f $verfile) { |
| 157 |
|
# TODO: debian/package.pyversions ? |
| 158 |
|
$versions=`cat $verfile`; |
| 159 |
|
chomp $versions; |
| 160 |
|
} else { |
| 161 |
|
my $doko_versions=`$privdir/parseversions --raw --pycentral debian/control`; |
| 162 |
|
chomp $doko_versions; |
| 163 |
|
if ($doko_versions !~ /not found/) { |
| 164 |
|
print "Compatibility mode: using detected XS-Python-Version.\n"; |
| 165 |
|
$versions=$doko_versions; |
| 166 |
|
} |
| 167 |
|
} |
| 168 |
|
if ($versions) { |
| 169 |
|
doit (("$privdir/movemodules","-V", $versions, $tmp)) |
| 170 |
|
} else { |
| 171 |
|
doit (("$privdir/movemodules",$tmp)); |
| 172 |
|
} |
| 173 |
|
|
| 174 |
# Then look for what the script found |
# Then look for what the script found |
| 175 |
foreach my $ps_dir (glob("$tmp/usr/share/python-support/*")) { |
foreach my $list_file (glob("$tmp/usr/share/python-support/*.public")) { |
| 176 |
if (-d $ps_dir && ! excludefile($ps_dir)) { |
if (-f $list_file) { |
| 177 |
my $verfile = "debian/pyversions"; |
my $supported=`$privdir/parseversions --minmax $list_file`; |
| 178 |
if (-f $verfile) { |
|
|
# TODO: debian/package.pyversions ? |
|
|
doit("install","-p","-m644",$verfile,"$ps_dir/.version"); |
|
|
} |
|
|
my $ext_dir=$ps_dir; |
|
|
$ext_dir =~ s,/usr/share/,/usr/lib/,; |
|
|
my $supported; |
|
|
if (-d $ext_dir) { |
|
|
if (-f "$ps_dir/.version") { |
|
|
# Just ignore the .version file when there are extensions. |
|
|
# The extensions dictate which versions to handle. |
|
|
doit(("rm","-f","$ps_dir/.version")); |
|
|
} |
|
|
my @provides; |
|
|
foreach my $pydir (glob("$ext_dir/python*")) { |
|
|
if (-d $pydir && $pydir =~ m/python(\d+).(\d+)/) { |
|
|
push @provides, "$1.$2"; |
|
|
} |
|
|
} |
|
|
my $a=join ",",@provides; |
|
|
error("$ext_dir doesn't contain modules for any supported python version") if (! $a); |
|
|
$supported=`echo $a | pysupport-parseversions --minmax`; |
|
|
} elsif (-f "$ps_dir/.version") { |
|
|
$supported=`pysupport-parseversions --minmax $ps_dir/.version`; |
|
|
} else { |
|
|
my $doko_versions=`pysupport-parseversions --raw --pycentral debian/control`; |
|
|
chomp $doko_versions; |
|
|
if ($doko_versions !~ /not found/) { |
|
|
print "Compatibility mode: using detected XS-Python-Version.\n"; |
|
|
complex_doit("echo $doko_versions > $ps_dir/.version"); |
|
|
$supported=`pysupport-parseversions --minmax --pycentral debian/control`; |
|
|
} else { |
|
|
$supported=`echo - | pysupport-parseversions --minmax`; |
|
|
} |
|
|
} |
|
| 179 |
# Add the packages explicitly asked by the maintainer |
# Add the packages explicitly asked by the maintainer |
| 180 |
foreach my $dep (@specified_deps) { |
foreach my $dep (@specified_deps) { |
| 181 |
$dep = trim $dep; |
$dep = trim $dep; |
| 222 |
addsubstvar($package, "python:Depends", "python (<< $maxversion)"); |
addsubstvar($package, "python:Depends", "python (<< $maxversion)"); |
| 223 |
$have_pydep=1; |
$have_pydep=1; |
| 224 |
} |
} |
| 225 |
$ps_dir =~ s,^$tmp/usr/share/python-support/,,; |
$list_file =~ s,^$tmp/usr/share/python-support/,,; |
| 226 |
$do_scripts = "$do_scripts $ps_dir"; |
$do_scripts = "$do_scripts $list_file"; |
| 227 |
} |
} |
| 228 |
} |
} |
| 229 |
|
|
| 231 |
my @dirs = ("/usr/lib/$package", "/usr/share/$package", |
my @dirs = ("/usr/lib/$package", "/usr/share/$package", |
| 232 |
"/usr/lib/games/$package", "/usr/share/games/$package", @ARGV ); |
"/usr/lib/games/$package", "/usr/share/games/$package", @ARGV ); |
| 233 |
@dirs = grep -d, map "$tmp$_", @dirs; |
@dirs = grep -d, map "$tmp$_", @dirs; |
| 234 |
my @dirlist; |
my @filelist; |
| 235 |
|
my $file; |
| 236 |
|
my $has_module = 0; |
| 237 |
|
my $has_extension = 0; |
| 238 |
my $need_pydep=0; |
my $need_pydep=0; |
| 239 |
my $strong_pydep=0; |
my $strong_pydep=0; |
| 240 |
my %need_verdep = (); |
my %need_verdep = (); |
| 243 |
} |
} |
| 244 |
if (@dirs) { |
if (@dirs) { |
| 245 |
foreach my $curdir (@dirs) { |
foreach my $curdir (@dirs) { |
|
my $has_module = 0; |
|
|
my $has_extension = 0; |
|
| 246 |
find sub { |
find sub { |
| 247 |
return unless -f; |
return unless -f; |
| 248 |
return if excludefile($File::Find::name); |
return if excludefile($File::Find::name); |
| 249 |
if (/.py$/) { |
if (/.py$/) { |
| 250 |
$has_module=1; |
$has_module=1; |
| 251 |
doit(("rm","-f",$_."c",$_."o")); |
doit(("rm","-f",$_."c",$_."o")); |
| 252 |
|
( $file=$File::Find::name ) =~ s%^$tmp%%; |
| 253 |
|
push @filelist, $file; |
| 254 |
} |
} |
| 255 |
if (/.so$/ && |
if (/.so$/ && |
| 256 |
`nm -Du "$_" | grep "U Py_InitModule"` && |
`nm -Du "$_" | grep "U Py_InitModule"` && |
| 258 |
$has_extension=1; |
$has_extension=1; |
| 259 |
} |
} |
| 260 |
}, $curdir ; |
}, $curdir ; |
|
if ( ($has_module or $has_extension) and not grep { $_ eq "$curdir" } @dirlist ) { |
|
|
if ( $useversion ) { |
|
|
# Create .pyversion to tell update-python-modules for which |
|
|
# version to compile |
|
|
open(VERFILE, "> $curdir/.pyversion") || |
|
|
error("Can't create $curdir/.pyversion: $!"); |
|
|
print VERFILE "$useversion\n"; |
|
|
close(VERFILE); |
|
|
$need_verdep{$useversion}=1; |
|
|
} else { |
|
|
$need_pydep=1; |
|
|
$strong_pydep=1 if $has_extension; |
|
|
} |
|
|
$curdir =~ s%^$tmp%%; |
|
|
push @dirlist, "$curdir" if $has_module; |
|
|
} |
|
| 261 |
} |
} |
| 262 |
} |
} |
| 263 |
if (@dirlist) { |
|
| 264 |
|
if ( ($has_module or $has_extension) ) { |
| 265 |
|
if ( $useversion ) { |
| 266 |
|
$need_verdep{$useversion}=1; |
| 267 |
|
} else { |
| 268 |
|
$need_pydep=1; |
| 269 |
|
$strong_pydep=1 if $has_extension; |
| 270 |
|
} |
| 271 |
|
} |
| 272 |
|
|
| 273 |
|
if (@filelist) { |
| 274 |
# We have private python modules |
# We have private python modules |
| 275 |
# Use python-support to ensure that they are always |
# Use python-support to ensure that they are always |
| 276 |
# byte-compiled for the current version |
# byte-compiled for the current version |
| 277 |
mkdir("$tmp/usr/share/python-support"); |
mkdir("$tmp/usr/share/python-support"); |
| 278 |
open(DIRLIST, "> $tmp/usr/share/python-support/$package.dirs") || |
open(FILELIST, "> $tmp/usr/share/python-support/$package.private") || |
| 279 |
error("Can't create $tmp/usr/share/python-support/$package.dirs: $!"); |
error("Can't create $tmp/usr/share/python-support/$package.private: $!"); |
| 280 |
print DIRLIST map "$_\n", @dirlist; |
if ( $useversion ) { |
| 281 |
close(DIRLIST); |
print FILELIST "pyversion=$useversion\n\n"; |
| 282 |
$do_scripts = "$do_scripts $package.dirs"; |
} |
| 283 |
|
print FILELIST map "$_\n", @filelist; |
| 284 |
|
close(FILELIST); |
| 285 |
|
$do_scripts = "$do_scripts $package.private"; |
| 286 |
} |
} |
| 287 |
|
|
| 288 |
# 3) Add python-support dependency depending on what we found |
# 3) Add python-support dependency depending on what we found |
| 289 |
if (-d "$tmp/usr/share/python-support") { |
if (-d "$tmp/usr/share/python-support") { |
| 290 |
if (`find $tmp/usr/share/python-support -name .noinit`) { |
addsubstvar($package, "python:Depends", "python-support (>= 0.90.0)"); |
|
# Excluding namespace packages, introduced in 0.8.5 |
|
|
addsubstvar($package, "python:Depends", "python-support (>= 0.8.5)"); |
|
|
} else { |
|
|
# Latest non-detectable feature: namespace packages in 0.7.1 |
|
|
addsubstvar($package, "python:Depends", "python-support (>= 0.7.1)"); |
|
|
} |
|
| 291 |
} |
} |
| 292 |
|
|
| 293 |
# 4) Look for python scripts |
# 4) Look for python scripts |
| 318 |
my $maxversion = next_minor_version($default); |
my $maxversion = next_minor_version($default); |
| 319 |
addsubstvar($package, "python:Depends", "python (<< $maxversion)"); |
addsubstvar($package, "python:Depends", "python (<< $maxversion)"); |
| 320 |
$have_pydep=1; |
$have_pydep=1; |
| 321 |
} elsif ($need_pydep and -f "debian/pyversions") { |
} elsif ($need_pydep and $versions) { |
| 322 |
my $supported=`pysupport-parseversions --minmax debian/pyversions`; |
my $supported=`echo $versions | $privdir/parseversions --minmax`; |
| 323 |
my @ar=split "\n",$supported; |
my @ar=split "\n",$supported; |
| 324 |
my @minmax=split " ",$ar[1]; |
my @minmax=split " ",$ar[1]; |
| 325 |
my $minversion=$minmax[0]; |
my $minversion=$minmax[0]; |