From dcdf9deae35b4d456ab3f3fbe6769db64352e136 Mon Sep 17 00:00:00 2001 From: joeyh Date: Sun, 8 Jan 2006 04:29:54 +0000 Subject: [PATCH] r1844: merge python and gconf changes from python-support --- autoscripts/postinst-python | 1 - debian/changelog | 11 +++++- dh_gconf | 54 ++++++++++++++++++++++++---- dh_python | 70 +++++++++++++++++++++---------------- 4 files changed, 97 insertions(+), 39 deletions(-) diff --git a/autoscripts/postinst-python b/autoscripts/postinst-python index c48d1aa..5a1943e 100644 --- a/autoscripts/postinst-python +++ b/autoscripts/postinst-python @@ -2,7 +2,6 @@ PYTHON=#PYVER# if which $PYTHON >/dev/null 2>&1 && [ -e /usr/lib/$PYTHON/compileall.py ]; then DIRLIST="#DIRLIST#" for i in $DIRLIST ; do - $PYTHON -O /usr/lib/$PYTHON/compileall.py -q $i $PYTHON /usr/lib/$PYTHON/compileall.py -q $i done fi diff --git a/debian/changelog b/debian/changelog index 05490a9..2097150 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,11 +1,20 @@ debhelper (5.0.13) UNRELEASED; urgency=low + [ Joey Hess ] * debhelper(7): document previous dh_install v5 change re wildcarding. * dh_link: add special case handling for paths to a directory containing the link. Closes: #346405 * dh_link: add special case handling for link to / - -- Joey Hess Sat, 7 Jan 2006 23:06:43 -0500 + [ Josselin Mouette ] + * dh_python: make use of python-support for packages providing private + modules or python-only modules. This should greatly reduce the + number of packages needing to transition together with python. + * postinst-python: don't build the .pyo files, they aren't even used! + * dh_gconf: add support for debian/package.gconf-defaults, to provide + defaults for a package without patching the schemas. + + -- Joey Hess Sat, 7 Jan 2006 23:28:44 -0500 debhelper (5.0.12) unstable; urgency=low diff --git a/dh_gconf b/dh_gconf index bd74342..6275b73 100755 --- a/dh_gconf +++ b/dh_gconf @@ -19,20 +19,61 @@ dh_gconf is a debhelper program that is responsible for registering GConf schemas. It automatically generates the postinst and prerm fragments needed -to register and unregister the schemas in usr/share/gconf/schemas. -These fragments will use gconftool-2, so the package should depend on -gconf2. This program will add an appropriate dependency to ${misc:Depends}. +to register and unregister the schemas in usr/share/gconf/schemas, using +gconf-schemas. -The postinst script will also signal gconfd-2 so that the newly installed -schemas are available straight away. +If a file named debian/package.gconf-defaults exists, then it is +installed into usr/share/gconf/defaults/10_package in the package build +directory, with "package" replaced by the package name. Some postinst and +postrm fragments will be generated to launch update-gconf-defaults. The +syntax of this file consists of lines containing the key name, some +white space, and the key value, which can be an integer, a boolean, a +float, a string or a list of strings. Example: + + /apps/myprogram/frob_number 42 + /apps/myprogram/do_foo true + /apps/myprogram/priority 1.25 + /apps/myprogram/name "Gotcha !" + /apps/myprogram/names [Ha ha!,Let's keep serious,Ho ho!] + +The gconf-schemas and update-gconf-defaults scripts are provided by the +gconf2 package. An appropriate dependency will be generated in +${misc:Depends}. + +=head1 OPTIONS + +=over 4 + +=item B<--priority> I + +Use I (which should be a 2-digit number) as the defaults +priority instead of 10. Children distributions are encouraged to use 20 +for their branding, CDD distributions to use 50, and site-specific +packages should use 90 or more. =cut init(); +my $priority=10; +if (defined $dh{PRIORITY}) { + $priority=$dh{PRIORITY}; +} foreach my $package (@{$dh{DOPACKAGES}}) { my $tmp=tmpdir($package); + + my $gconf_dep = 0; + my $defaults = pkgfile($package,"gconf-defaults"); + if ($defaults ne '') { + doit("mkdir","-p","$tmp/usr/share/gconf/defaults"); + doit("install","-p","-m644",$defaults,"$tmp/usr/share/gconf/defaults/${priority}_$package"); + autoscript($package,"postinst","postinst-gconf-defaults"); + autoscript($package,"postrm","postrm-gconf-defaults"); + addsubstvar($package, "misc:Depends", "gconf2 (>= 2.12.1-1)"); + $gconf_dep = 1; + } + my $old_schemas_dir = "$tmp/etc/gconf/schemas"; my $new_schemas_dir = "$tmp/usr/share/gconf/schemas"; @@ -50,7 +91,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) { autoscript($package,"postinst","postinst-gconf","s%#SCHEMAS#%$schemas%"); autoscript($package,"prerm","prerm-gconf","s%#SCHEMAS#%$schemas%"); autoscript($package,"postrm","postrm-gconf","s%#SCHEMAS#%$schemas%"); - addsubstvar($package, "misc:Depends", "gconf2 (>= 2.10.1-2)"); + addsubstvar($package, "misc:Depends", "gconf2 (>= 2.10.1-2)") unless $gconf_dep; } } } @@ -64,5 +105,6 @@ This program is a part of debhelper. =head1 AUTHOR Ross Burton +Josselin Mouette =cut diff --git a/dh_python b/dh_python index 6a1f78f..65127e8 100755 --- a/dh_python +++ b/dh_python @@ -40,18 +40,15 @@ If you use this program, your package should build-depend on python. If your package installs python modules in non-standard directories, you can make dh_python check those directories by passing their names on the -command line. By default, it will check /usr/lib/site-python, -/usr/lib/$PACKAGE, /usr/share/$PACKAGE, /usr/lib/games/$PACKAGE, -/usr/share/games/$PACKAGE and /usr/lib/python?.?/site-packages. - -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. +command line. By default, it will check /usr/lib/$PACKAGE, +/usr/share/$PACKAGE, /usr/lib/games/$PACKAGE, /usr/share/games/$PACKAGE +and /usr/lib/python?.?/site-packages. =item B<-V> I 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. +such as 2.3. =item B<-n>, B<--noscripts> @@ -71,22 +68,19 @@ init(); my $python = 'python'; -# The current python major version -my $python_major; +# The current python version my $python_version = `$python -V 2>&1`; if (! defined $python_version || $python_version eq "") { error("Python is not installed, aborting. (Probably forgot to Build-Depend on python.)"); } elsif ($python_version =~ m/^Python\s+(\d+)\.(\d+)(\.\d+)*/) { $python_version = "$1.$2" ; - $python_major = $1 ; } else { error("Unable to parse python version out of \"$python_version\"."); } # The next python version 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'); foreach (@python_allversions) { @@ -121,11 +115,11 @@ foreach my $package (@{$dh{DOPACKAGES}}) { delsubstvar($package, "python:Depends"); - 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 ); + my @dirs = ("usr/lib/$package", "usr/share/$package", "usr/lib/games/$package", "usr/share/games/$package", @ARGV ); my $dep_on_python = 0; my $strong_dep = 0; + my $dep_on_py_support = 0; my $look_for_pythonXY = 1; # First, the case of python-foo and pythonX.Y-foo @@ -140,12 +134,10 @@ foreach my $package (@{$dh{DOPACKAGES}}) { } if ($package !~ /^python[0-9].[0-9]-/) { push @dirs, "usr/lib/$usepython/site-packages"; - push @dirs_so, "usr/lib/$usepython/site-packages"; $look_for_pythonXY = 0; } @dirs = grep -d, map "$tmp/$_", @dirs; - @dirs_so = grep -d, map "$tmp/$_", @dirs_so; my $deps = 0; my %verdeps = (); @@ -169,19 +161,35 @@ foreach my $package (@{$dh{DOPACKAGES}}) { }, $tmp; # Look for python modules - my $dirlist=""; + my $dirlist = ""; + my $gen_dirlist = ""; + my $moved_module = 0; + my $move_dir = "/usr/share/python-support/$package"; if (@dirs) { foreach my $curdir (@dirs) { my $has_module = 0; + my $has_bin_module = 0; $curdir =~ s%^$tmp/%%; find sub { return unless -f; if (/\.py$/) { $has_module = 1; doit(("rm","-f",$_."c",$_."o")); + } elsif (/\.so$/) { + $has_bin_module = 1; } }, "$tmp/$curdir" ; - if ($has_module) { + if ($has_module && $has_bin_module == 0) { + $dep_on_py_support = 1; + if ($curdir eq "usr/lib/$usepython/site-packages") { + doit(("mkdir","-p","$tmp$move_dir")); + complex_doit("mv \"$tmp/$curdir/\"* \"$tmp$move_dir\"/"); + doit(("rmdir","-p","--ignore-fail-on-non-empty","$tmp/$curdir")); + $moved_module=1; + } else { + $gen_dirlist="$gen_dirlist /$curdir"; + } + } elsif ($has_module) { # We have both kinds of modules if ($dh{V_FLAG_SET}) { $verdeps{$usepython} |= PY_MODULE_NONSTANDARD; } else { @@ -189,17 +197,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) { } $dirlist="$dirlist /$curdir"; } - } - } - if (@dirs_so) { - foreach my $curdir (@dirs_so) { - my $has_module = 0; - $curdir =~ s%^$tmp/%%; - find sub { - return unless -f; - $has_module = 1 if /\.so$/; - }, "$tmp/$curdir" ; - if ($has_module) { + if ($has_bin_module) { if ($dh{V_FLAG_SET}) { $verdeps{$usepython} |= SO_MODULE_NONSTANDARD; } @@ -212,14 +210,24 @@ foreach my $package (@{$dh{DOPACKAGES}}) { # Dependencies on current python $dep_on_python = 1 if $deps; - $strong_dep = 1 if($deps & (PY_MODULE|SO_MODULE)); + $strong_dep = 1 if($deps & SO_MODULE); if ($dep_on_python) { addsubstvar($package, "python:Depends", $python, ">= $python_version"); if ($strong_dep) { addsubstvar($package, "python:Depends", $python, "<< $python_nextversion"); - } else { - addsubstvar($package, "python:Depends", $python, "<< $python_nextmajor"); + } + } + + if ($dep_on_py_support) { + addsubstvar($package, "python:Depends", "python-support"); + if ($gen_dirlist ne "") { + autoscript($package, "postinst", "postinst-python-support", "s,#OPTIONS#,-b,;s,#DIRS#,$gen_dirlist,"); + autoscript($package, "prerm", "prerm-python-support", "s,#OPTIONS#,-b,;s,#DIRS#,$gen_dirlist,"); + } + if ($moved_module) { + autoscript($package, "postinst", "postinst-python-support", "s,#OPTIONS#,-i,;s,#DIRS#,$move_dir,"); + autoscript($package, "prerm", "prerm-python-support", "s,#OPTIONS#,-i,;s,#DIRS#,$move_dir,"); } } -- 2.39.2