From 775d1ca63964312b7f519edfe0cce476669617f6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 21 Sep 2013 13:16:34 -0400 Subject: debhelper (9.20130921) unstable; urgency=low * dh: Call dh_installxfonts after dh_link, so that it will notice fonts installed via symlinks. Closes: #721264 * Fix FTBFS with perl 5.18. Closes: #722501 * dh_installchangelogs: Add changelog.md to the list of common changelog filenames. # imported from the archive --- Debian/Debhelper/Buildsystem.pm | 415 + Debian/Debhelper/Buildsystem/ant.pm | 37 + Debian/Debhelper/Buildsystem/autoconf.pm | 75 + Debian/Debhelper/Buildsystem/cmake.pm | 77 + Debian/Debhelper/Buildsystem/makefile.pm | 152 + Debian/Debhelper/Buildsystem/perl_build.pm | 77 + Debian/Debhelper/Buildsystem/perl_makemaker.pm | 80 + Debian/Debhelper/Buildsystem/python_distutils.pm | 210 + Debian/Debhelper/Buildsystem/qmake.pm | 83 + Debian/Debhelper/Buildsystem/qmake_qt4.pm | 18 + Debian/Debhelper/Dh_Buildsystems.pm | 228 + Debian/Debhelper/Dh_Getopt.pm | 288 + Debian/Debhelper/Dh_Lib.pm | 983 +++ Debian/Debhelper/Sequence/python_support.pm | 15 + GPL | 340 + Makefile | 106 + autoscripts/maintscript-helper | 1 + autoscripts/postinst-emacsen | 4 + autoscripts/postinst-icons | 3 + autoscripts/postinst-init | 4 + autoscripts/postinst-init-nostart | 3 + autoscripts/postinst-init-restart | 9 + autoscripts/postinst-init-tmpfiles | 5 + autoscripts/postinst-makeshlibs | 3 + autoscripts/postinst-menu | 3 + autoscripts/postinst-menu-method | 7 + autoscripts/postinst-modules | 5 + autoscripts/postinst-moveconffile | 9 + autoscripts/postinst-python | 7 + autoscripts/postinst-suid | 8 + autoscripts/postinst-ucf | 4 + autoscripts/postinst-usrlocal | 16 + autoscripts/postinst-wm | 6 + autoscripts/postinst-wm-noman | 4 + autoscripts/postinst-xfonts | 3 + autoscripts/postrm-debconf | 4 + autoscripts/postrm-icons | 3 + autoscripts/postrm-init | 10 + autoscripts/postrm-makeshlibs | 3 + autoscripts/postrm-menu | 1 + autoscripts/postrm-menu-method | 3 + autoscripts/postrm-modules | 3 + autoscripts/postrm-sgmlcatalog | 3 + autoscripts/postrm-suid | 4 + autoscripts/postrm-ucf | 12 + autoscripts/postrm-xfonts | 3 + autoscripts/preinst-moveconffile | 9 + autoscripts/preinst-sgmlcatalog | 8 + autoscripts/prerm-emacsen | 3 + autoscripts/prerm-init | 3 + autoscripts/prerm-init-norestart | 3 + autoscripts/prerm-python | 3 + autoscripts/prerm-usrlocal | 7 + autoscripts/prerm-wm | 3 + debhelper.pod | 701 ++ debian/changelog | 7410 ++++++++++++++++++ debian/compat | 1 + debian/control | 23 + debian/copyright | 95 + debian/docs | 1 + debian/examples | 1 + debian/manpages | 2 + debian/rules | 14 + dh | 979 +++ dh_auto_build | 57 + dh_auto_clean | 60 + dh_auto_configure | 62 + dh_auto_install | 102 + dh_auto_test | 73 + dh_bugfiles | 136 + dh_builddeb | 134 + dh_clean | 152 + dh_compress | 218 + dh_desktop | 41 + dh_fixperms | 137 + dh_gconf | 112 + dh_gencontrol | 92 + dh_icons | 83 + dh_install | 270 + dh_installcatalogs | 132 + dh_installchangelogs | 249 + dh_installcron | 89 + dh_installdeb | 150 + dh_installdebconf | 138 + dh_installdirs | 98 + dh_installdocs | 344 + dh_installemacsen | 136 + dh_installexamples | 118 + dh_installgsettings | 98 + dh_installifupdown | 81 + dh_installinfo | 87 + dh_installinit | 344 + dh_installlogcheck | 90 + dh_installlogrotate | 62 + dh_installman | 273 + dh_installmanpages | 207 + dh_installmenu | 101 + dh_installmime | 73 + dh_installmodules | 125 + dh_installpam | 71 + dh_installppp | 77 + dh_installudev | 127 + dh_installwm | 120 + dh_installxfonts | 99 + dh_link | 238 + dh_lintian | 71 + dh_listpackages | 40 + dh_makeshlibs | 268 + dh_md5sums | 100 + dh_movefiles | 180 + dh_perl | 158 + dh_prep | 70 + dh_scrollkeeper | 38 + dh_shlibdeps | 185 + dh_strip | 252 + dh_suidregister | 127 + dh_testdir | 63 + dh_testroot | 37 + dh_ucf | 96 + dh_undocumented | 38 + dh_usrlocal | 126 + doc/PROGRAMMING | 318 + doc/README | 1 + doc/TODO | 33 + examples/rules.tiny | 3 + man/po4a/add.de | 23 + man/po4a/add.fr | 15 + man/po4a/add1.es | 8 + man/po4a/add2.es | 8 + man/po4a/add3.es | 8 + man/po4a/po/de.po | 7815 +++++++++++++++++++ man/po4a/po/debhelper.pot | 5691 ++++++++++++++ man/po4a/po/es.po | 8735 +++++++++++++++++++++ man/po4a/po/fr.po | 8985 ++++++++++++++++++++++ man/po4a/po4a.cfg | 62 + run | 19 + t/buildsystems/autoconf/configure | 74 + t/buildsystems/buildsystem_tests | 641 ++ t/buildsystems/debian/changelog | 5 + t/buildsystems/debian/compat | 1 + t/buildsystems/debian/control | 10 + t/buildsystems/parallel.mk | 21 + t/dh-lib | 31 + t/dh_install | 88 + t/dh_link | 45 + t/maintscript | 19 + t/override_target | 22 + t/pod | 10 + t/size | 29 + t/syntax | 12 + 150 files changed, 52640 insertions(+) create mode 100644 Debian/Debhelper/Buildsystem.pm create mode 100644 Debian/Debhelper/Buildsystem/ant.pm create mode 100644 Debian/Debhelper/Buildsystem/autoconf.pm create mode 100644 Debian/Debhelper/Buildsystem/cmake.pm create mode 100644 Debian/Debhelper/Buildsystem/makefile.pm create mode 100644 Debian/Debhelper/Buildsystem/perl_build.pm create mode 100644 Debian/Debhelper/Buildsystem/perl_makemaker.pm create mode 100644 Debian/Debhelper/Buildsystem/python_distutils.pm create mode 100644 Debian/Debhelper/Buildsystem/qmake.pm create mode 100644 Debian/Debhelper/Buildsystem/qmake_qt4.pm create mode 100644 Debian/Debhelper/Dh_Buildsystems.pm create mode 100644 Debian/Debhelper/Dh_Getopt.pm create mode 100644 Debian/Debhelper/Dh_Lib.pm create mode 100644 Debian/Debhelper/Sequence/python_support.pm create mode 100644 GPL create mode 100644 Makefile create mode 100644 autoscripts/maintscript-helper create mode 100644 autoscripts/postinst-emacsen create mode 100644 autoscripts/postinst-icons create mode 100644 autoscripts/postinst-init create mode 100644 autoscripts/postinst-init-nostart create mode 100644 autoscripts/postinst-init-restart create mode 100644 autoscripts/postinst-init-tmpfiles create mode 100644 autoscripts/postinst-makeshlibs create mode 100644 autoscripts/postinst-menu create mode 100644 autoscripts/postinst-menu-method create mode 100644 autoscripts/postinst-modules create mode 100644 autoscripts/postinst-moveconffile create mode 100644 autoscripts/postinst-python create mode 100644 autoscripts/postinst-suid create mode 100644 autoscripts/postinst-ucf create mode 100644 autoscripts/postinst-usrlocal create mode 100644 autoscripts/postinst-wm create mode 100644 autoscripts/postinst-wm-noman create mode 100644 autoscripts/postinst-xfonts create mode 100644 autoscripts/postrm-debconf create mode 100644 autoscripts/postrm-icons create mode 100644 autoscripts/postrm-init create mode 100644 autoscripts/postrm-makeshlibs create mode 100644 autoscripts/postrm-menu create mode 100644 autoscripts/postrm-menu-method create mode 100644 autoscripts/postrm-modules create mode 100644 autoscripts/postrm-sgmlcatalog create mode 100644 autoscripts/postrm-suid create mode 100644 autoscripts/postrm-ucf create mode 100644 autoscripts/postrm-xfonts create mode 100644 autoscripts/preinst-moveconffile create mode 100644 autoscripts/preinst-sgmlcatalog create mode 100644 autoscripts/prerm-emacsen create mode 100644 autoscripts/prerm-init create mode 100644 autoscripts/prerm-init-norestart create mode 100644 autoscripts/prerm-python create mode 100644 autoscripts/prerm-usrlocal create mode 100644 autoscripts/prerm-wm create mode 100644 debhelper.pod create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/docs create mode 100644 debian/examples create mode 100644 debian/manpages create mode 100755 debian/rules create mode 100755 dh create mode 100755 dh_auto_build create mode 100755 dh_auto_clean create mode 100755 dh_auto_configure create mode 100755 dh_auto_install create mode 100755 dh_auto_test create mode 100755 dh_bugfiles create mode 100755 dh_builddeb create mode 100755 dh_clean create mode 100755 dh_compress create mode 100755 dh_desktop create mode 100755 dh_fixperms create mode 100755 dh_gconf create mode 100755 dh_gencontrol create mode 100755 dh_icons create mode 100755 dh_install create mode 100755 dh_installcatalogs create mode 100755 dh_installchangelogs create mode 100755 dh_installcron create mode 100755 dh_installdeb create mode 100755 dh_installdebconf create mode 100755 dh_installdirs create mode 100755 dh_installdocs create mode 100755 dh_installemacsen create mode 100755 dh_installexamples create mode 100755 dh_installgsettings create mode 100755 dh_installifupdown create mode 100755 dh_installinfo create mode 100755 dh_installinit create mode 100755 dh_installlogcheck create mode 100755 dh_installlogrotate create mode 100755 dh_installman create mode 100755 dh_installmanpages create mode 100755 dh_installmenu create mode 100755 dh_installmime create mode 100755 dh_installmodules create mode 100755 dh_installpam create mode 100755 dh_installppp create mode 100755 dh_installudev create mode 100755 dh_installwm create mode 100755 dh_installxfonts create mode 100755 dh_link create mode 100755 dh_lintian create mode 100755 dh_listpackages create mode 100755 dh_makeshlibs create mode 100755 dh_md5sums create mode 100755 dh_movefiles create mode 100755 dh_perl create mode 100755 dh_prep create mode 100755 dh_scrollkeeper create mode 100755 dh_shlibdeps create mode 100755 dh_strip create mode 100755 dh_suidregister create mode 100755 dh_testdir create mode 100755 dh_testroot create mode 100755 dh_ucf create mode 100755 dh_undocumented create mode 100755 dh_usrlocal create mode 100644 doc/PROGRAMMING create mode 100644 doc/README create mode 100644 doc/TODO create mode 100755 examples/rules.tiny create mode 100644 man/po4a/add.de create mode 100644 man/po4a/add.fr create mode 100644 man/po4a/add1.es create mode 100644 man/po4a/add2.es create mode 100644 man/po4a/add3.es create mode 100644 man/po4a/po/de.po create mode 100644 man/po4a/po/debhelper.pot create mode 100644 man/po4a/po/es.po create mode 100644 man/po4a/po/fr.po create mode 100644 man/po4a/po4a.cfg create mode 100755 run create mode 100755 t/buildsystems/autoconf/configure create mode 100755 t/buildsystems/buildsystem_tests create mode 100644 t/buildsystems/debian/changelog create mode 100644 t/buildsystems/debian/compat create mode 100644 t/buildsystems/debian/control create mode 100644 t/buildsystems/parallel.mk create mode 100755 t/dh-lib create mode 100755 t/dh_install create mode 100755 t/dh_link create mode 100644 t/maintscript create mode 100755 t/override_target create mode 100755 t/pod create mode 100755 t/size create mode 100755 t/syntax diff --git a/Debian/Debhelper/Buildsystem.pm b/Debian/Debhelper/Buildsystem.pm new file mode 100644 index 00000000..8fde2159 --- /dev/null +++ b/Debian/Debhelper/Buildsystem.pm @@ -0,0 +1,415 @@ +# Defines debhelper build system class interface and implementation +# of common functionality. +# +# Copyright: © 2008-2009 Modestas Vainius +# License: GPL-2+ + +package Debian::Debhelper::Buildsystem; + +use strict; +use warnings; +use Cwd (); +use File::Spec; +use Debian::Debhelper::Dh_Lib; + +# Build system name. Defaults to the last component of the class +# name. Do not override this method unless you know what you are +# doing. +sub NAME { + my $this=shift; + my $class = ref($this) || $this; + if ($class =~ m/^.+::([^:]+)$/) { + return $1; + } + else { + error("ınvalid build system class name: $class"); + } +} + +# Description of the build system to be shown to the users. +sub DESCRIPTION { + error("class lacking a DESCRIPTION"); +} + +# Default build directory. Can be overriden in the derived +# class if really needed. +sub DEFAULT_BUILD_DIRECTORY { + "obj-" . dpkg_architecture_value("DEB_HOST_GNU_TYPE"); +} + +# Constructs a new build system object. Named parameters: +# - sourcedir- specifies source directory (relative to the current (top) +# directory) where the sources to be built live. If not +# specified or empty, defaults to the current directory. +# - builddir - specifies build directory to use. Path is relative to the +# current (top) directory. If undef or empty, +# DEFAULT_BUILD_DIRECTORY directory will be used. +# - parallel - max number of parallel processes to be spawned for building +# sources (-1 = unlimited; 1 = no parallel) +# Derived class can override the constructor to initialize common object +# parameters. Do NOT use constructor to execute commands or otherwise +# configure/setup build environment. There is absolutely no guarantee the +# constructed object will be used to build something. Use pre_building_step(), +# $build_step() or post_building_step() methods for this. +sub new { + my ($class, %opts)=@_; + + my $this = bless({ sourcedir => '.', + builddir => undef, + parallel => undef, + cwd => Cwd::getcwd() }, $class); + + if (exists $opts{sourcedir}) { + # Get relative sourcedir abs_path (without symlinks) + my $abspath = Cwd::abs_path($opts{sourcedir}); + if (! -d $abspath || $abspath !~ /^\Q$this->{cwd}\E/) { + error("invalid or non-existing path to the source directory: ".$opts{sourcedir}); + } + $this->{sourcedir} = File::Spec->abs2rel($abspath, $this->{cwd}); + } + if (exists $opts{builddir}) { + $this->_set_builddir($opts{builddir}); + } + if (defined $opts{parallel}) { + $this->{parallel} = $opts{parallel}; + } + return $this; +} + +# Private method to set a build directory. If undef, use default. +# Do $this->{builddir} = undef or pass $this->get_sourcedir() to +# unset the build directory. +sub _set_builddir { + my $this=shift; + my $builddir=shift || $this->DEFAULT_BUILD_DIRECTORY; + + if (defined $builddir) { + $builddir = $this->canonpath($builddir); # Canonicalize + + # Sanitize $builddir + if ($builddir =~ m#^\.\./#) { + # We can't handle those as relative. Make them absolute + $builddir = File::Spec->catdir($this->{cwd}, $builddir); + } + elsif ($builddir =~ /\Q$this->{cwd}\E/) { + $builddir = File::Spec->abs2rel($builddir, $this->{cwd}); + } + + # If build directory ends up the same as source directory, drop it + if ($builddir eq $this->get_sourcedir()) { + $builddir = undef; + } + } + $this->{builddir} = $builddir; + return $builddir; +} + +# This instance method is called to check if the build system is able +# to build a source package. It will be called during the build +# system auto-selection process, inside the root directory of the debian +# source package. The current build step is passed as an argument. +# Return 0 if the source is not buildable, or a positive integer +# otherwise. +# +# Generally, it is enough to look for invariant unique build system +# files shipped with clean source to determine if the source might +# be buildable or not. However, if the build system is derived from +# another other auto-buildable build system, this method +# may also check if the source has already been built with this build +# system partitially by looking for temporary files or other common +# results the build system produces during the build process. The +# latter checks must be unique to the current build system and must +# be very unlikely to be true for either its parent or other build +# systems. If it is determined that the source has already built +# partitially with this build system, the value returned must be +# greater than the one of the SUPER call. +sub check_auto_buildable { + my $this=shift; + my ($step)=@_; + return 0; +} + +# Derived class can call this method in its constructor +# to enforce in source building even if the user requested otherwise. +sub enforce_in_source_building { + my $this=shift; + if ($this->get_builddir()) { + $this->{warn_insource} = 1; + $this->{builddir} = undef; + } +} + +# Derived class can call this method in its constructor to *prefer* +# out of source building. Unless build directory has already been +# specified building will proceed in the DEFAULT_BUILD_DIRECTORY or +# the one specified in the 'builddir' named parameter (which may +# match the source directory). Typically you should pass @_ from +# the constructor to this call. +sub prefer_out_of_source_building { + my $this=shift; + my %args=@_; + if (!defined $this->get_builddir()) { + if (!$this->_set_builddir($args{builddir}) && !$args{builddir}) { + # If we are here, DEFAULT_BUILD_DIRECTORY matches + # the source directory, building might fail. + error("default build directory is the same as the source directory." . + " Please specify a custom build directory"); + } + } +} + +# Enhanced version of File::Spec::canonpath. It collapses .. +# too so it may return invalid path if symlinks are involved. +# On the other hand, it does not need for the path to exist. +sub canonpath { + my ($this, $path)=@_; + my @canon; + my $back=0; + foreach my $comp (split(m%/+%, $path)) { + if ($comp eq '.') { + next; + } + elsif ($comp eq '..') { + if (@canon > 0) { pop @canon; } else { $back++; } + } + else { + push @canon, $comp; + } + } + return (@canon + $back > 0) ? join('/', ('..')x$back, @canon) : '.'; +} + +# Given both $path and $base are relative to the $root, converts and +# returns path of $path being relative to the $base. If either $path or +# $base is absolute, returns another $path (converted to) absolute. +sub _rel2rel { + my ($this, $path, $base, $root)=@_; + $root = $this->{cwd} unless defined $root; + + if (File::Spec->file_name_is_absolute($path)) { + return $path; + } + elsif (File::Spec->file_name_is_absolute($base)) { + return File::Spec->rel2abs($path, $root); + } + else { + return File::Spec->abs2rel( + File::Spec->rel2abs($path, $root), + File::Spec->rel2abs($base, $root) + ); + } +} + +# Get path to the source directory +# (relative to the current (top) directory) +sub get_sourcedir { + my $this=shift; + return $this->{sourcedir}; +} + +# Convert path relative to the source directory to the path relative +# to the current (top) directory. +sub get_sourcepath { + my ($this, $path)=@_; + return File::Spec->catfile($this->get_sourcedir(), $path); +} + +# Get path to the build directory if it was specified +# (relative to the current (top) directory). undef if the same +# as the source directory. +sub get_builddir { + my $this=shift; + return $this->{builddir}; +} + +# Convert path that is relative to the build directory to the path +# that is relative to the current (top) directory. +# If $path is not specified, always returns build directory path +# relative to the current (top) directory regardless if builddir was +# specified or not. +sub get_buildpath { + my ($this, $path)=@_; + my $builddir = $this->get_builddir() || $this->get_sourcedir(); + if (defined $path) { + return File::Spec->catfile($builddir, $path); + } + return $builddir; +} + +# When given a relative path to the source directory, converts it +# to the path that is relative to the build directory. If $path is +# not given, returns a path to the source directory that is relative +# to the build directory. +sub get_source_rel2builddir { + my $this=shift; + my $path=shift; + + my $dir = '.'; + if ($this->get_builddir()) { + $dir = $this->_rel2rel($this->get_sourcedir(), $this->get_builddir()); + } + if (defined $path) { + return File::Spec->catfile($dir, $path); + } + return $dir; +} + +sub get_parallel { + my $this=shift; + return $this->{parallel}; +} + +# When given a relative path to the build directory, converts it +# to the path that is relative to the source directory. If $path is +# not given, returns a path to the build directory that is relative +# to the source directory. +sub get_build_rel2sourcedir { + my $this=shift; + my $path=shift; + + my $dir = '.'; + if ($this->get_builddir()) { + $dir = $this->_rel2rel($this->get_builddir(), $this->get_sourcedir()); + } + if (defined $path) { + return File::Spec->catfile($dir, $path); + } + return $dir; +} + +# Creates a build directory. +sub mkdir_builddir { + my $this=shift; + if ($this->get_builddir()) { + doit("mkdir", "-p", $this->get_builddir()); + } +} + +sub _cd { + my ($this, $dir)=@_; + verbose_print("cd $dir"); + if (! $dh{NO_ACT}) { + chdir $dir or error("error: unable to chdir to $dir"); + } +} + +# Changes working directory to the source directory (if needed), +# calls doit(@_) and changes working directory back to the top +# directory. +sub doit_in_sourcedir { + my $this=shift; + if ($this->get_sourcedir() ne '.') { + my $sourcedir = $this->get_sourcedir(); + $this->_cd($sourcedir); + doit(@_); + $this->_cd($this->_rel2rel($this->{cwd}, $sourcedir)); + } + else { + doit(@_); + } + return 1; +} + +# Changes working directory to the build directory (if needed), +# calls doit(@_) and changes working directory back to the top +# directory. +sub doit_in_builddir { + my $this=shift; + if ($this->get_buildpath() ne '.') { + my $buildpath = $this->get_buildpath(); + $this->_cd($buildpath); + doit(@_); + $this->_cd($this->_rel2rel($this->{cwd}, $buildpath)); + } + else { + doit(@_); + } + return 1; +} + +# In case of out of source tree building, whole build directory +# gets wiped (if it exists) and 1 is returned. If build directory +# had 2 or more levels, empty parent directories are also deleted. +# If build directory does not exist, nothing is done and 0 is returned. +sub rmdir_builddir { + my $this=shift; + my $only_empty=shift; + if ($this->get_builddir()) { + my $buildpath = $this->get_buildpath(); + if (-d $buildpath) { + my @dir = File::Spec->splitdir($this->get_build_rel2sourcedir()); + my $peek; + if (not $only_empty) { + doit("rm", "-rf", $buildpath); + pop @dir; + } + # If build directory is relative and had 2 or more levels, delete + # empty parent directories until the source or top directory level. + if (not File::Spec->file_name_is_absolute($buildpath)) { + while (($peek=pop @dir) && $peek ne '.' && $peek ne '..') { + my $dir = $this->get_sourcepath(File::Spec->catdir(@dir, $peek)); + doit("rmdir", "--ignore-fail-on-non-empty", $dir); + last if -d $dir; + } + } + } + return 1; + } + return 0; +} + +# Instance method that is called before performing any step (see below). +# Action name is passed as an argument. Derived classes overriding this +# method should also call SUPER implementation of it. +sub pre_building_step { + my $this=shift; + my ($step)=@_; + + # Warn if in source building was enforced but build directory was + # specified. See enforce_in_source_building(). + if ($this->{warn_insource}) { + warning("warning: " . $this->NAME() . + " does not support building out of source tree. In source building enforced."); + delete $this->{warn_insource}; + } +} + +# Instance method that is called after performing any step (see below). +# Action name is passed as an argument. Derived classes overriding this +# method should also call SUPER implementation of it. +sub post_building_step { + my $this=shift; + my ($step)=@_; +} + +# The instance methods below provide support for configuring, +# building, testing, install and cleaning source packages. +# In case of failure, the method may just error() out. +# +# These methods should be overriden by derived classes to +# implement build system specific steps needed to build the +# source. Arbitary number of custom step arguments might be +# passed. Default implementations do nothing. +sub configure { + my $this=shift; +} + +sub build { + my $this=shift; +} + +sub test { + my $this=shift; +} + +# destdir parameter specifies where to install files. +sub install { + my $this=shift; + my $destdir=shift; +} + +sub clean { + my $this=shift; +} + +1 diff --git a/Debian/Debhelper/Buildsystem/ant.pm b/Debian/Debhelper/Buildsystem/ant.pm new file mode 100644 index 00000000..52def4f6 --- /dev/null +++ b/Debian/Debhelper/Buildsystem/ant.pm @@ -0,0 +1,37 @@ +# A debhelper build system class for handling Ant based projects. +# +# Copyright: © 2009 Joey Hess +# License: GPL-2+ + +package Debian::Debhelper::Buildsystem::ant; + +use strict; +use base 'Debian::Debhelper::Buildsystem'; + +sub DESCRIPTION { + "Ant (build.xml)" +} + +sub check_auto_buildable { + my $this=shift; + return (-e $this->get_sourcepath("build.xml")) ? 1 : 0; +} + +sub new { + my $class=shift; + my $this=$class->SUPER::new(@_); + $this->enforce_in_source_building(); + return $this; +} + +sub build { + my $this=shift; + $this->doit_in_sourcedir("ant", @_); +} + +sub clean { + my $this=shift; + $this->doit_in_sourcedir("ant", "clean", @_); +} + +1 diff --git a/Debian/Debhelper/Buildsystem/autoconf.pm b/Debian/Debhelper/Buildsystem/autoconf.pm new file mode 100644 index 00000000..20b9fd44 --- /dev/null +++ b/Debian/Debhelper/Buildsystem/autoconf.pm @@ -0,0 +1,75 @@ +# A debhelper build system class for handling Autoconf based projects +# +# Copyright: © 2008 Joey Hess +# © 2008-2009 Modestas Vainius +# License: GPL-2+ + +package Debian::Debhelper::Buildsystem::autoconf; + +use strict; +use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value sourcepackage compat); +use base 'Debian::Debhelper::Buildsystem::makefile'; + +sub DESCRIPTION { + "GNU Autoconf (configure)" +} + +sub check_auto_buildable { + my $this=shift; + my ($step)=@_; + + # Handle configure; the rest - next class (compat with 7.0.x code path) + if ($step eq "configure") { + return 1 if -x $this->get_sourcepath("configure"); + } + return 0; +} + +sub configure { + my $this=shift; + + # Standard set of options for configure. + my @opts; + push @opts, "--build=" . dpkg_architecture_value("DEB_BUILD_GNU_TYPE"); + push @opts, "--prefix=/usr"; + push @opts, "--includedir=\${prefix}/include"; + push @opts, "--mandir=\${prefix}/share/man"; + push @opts, "--infodir=\${prefix}/share/info"; + push @opts, "--sysconfdir=/etc"; + push @opts, "--localstatedir=/var"; + my $multiarch=dpkg_architecture_value("DEB_HOST_MULTIARCH"); + if (! compat(8)) { + if (defined $multiarch) { + push @opts, "--libdir=\${prefix}/lib/$multiarch"; + push @opts, "--libexecdir=\${prefix}/lib/$multiarch"; + } + else { + push @opts, "--libexecdir=\${prefix}/lib"; + } + } + else { + push @opts, "--libexecdir=\${prefix}/lib/" . sourcepackage(); + } + push @opts, "--disable-maintainer-mode"; + push @opts, "--disable-dependency-tracking"; + # Provide --host only if different from --build, as recommended in + # autotools-dev README.Debian: When provided (even if equal) + # autoconf 2.52+ switches to cross-compiling mode. + if (dpkg_architecture_value("DEB_BUILD_GNU_TYPE") + ne dpkg_architecture_value("DEB_HOST_GNU_TYPE")) { + push @opts, "--host=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE"); + } + + $this->mkdir_builddir(); + eval { + $this->doit_in_builddir($this->get_source_rel2builddir("configure"), @opts, @_); + }; + if ($@) { + if (-e $this->get_buildpath("config.log")) { + $this->doit_in_builddir("tail -v -n +0 config.log"); + } + die $@; + } +} + +1 diff --git a/Debian/Debhelper/Buildsystem/cmake.pm b/Debian/Debhelper/Buildsystem/cmake.pm new file mode 100644 index 00000000..d47821ca --- /dev/null +++ b/Debian/Debhelper/Buildsystem/cmake.pm @@ -0,0 +1,77 @@ +# A debhelper build system class for handling CMake based projects. +# It prefers out of source tree building. +# +# Copyright: © 2008-2009 Modestas Vainius +# License: GPL-2+ + +package Debian::Debhelper::Buildsystem::cmake; + +use strict; +use Debian::Debhelper::Dh_Lib qw(compat); +use base 'Debian::Debhelper::Buildsystem::makefile'; + +sub DESCRIPTION { + "CMake (CMakeLists.txt)" +} + +sub check_auto_buildable { + my $this=shift; + my ($step)=@_; + if (-e $this->get_sourcepath("CMakeLists.txt")) { + my $ret = ($step eq "configure" && 1) || + $this->SUPER::check_auto_buildable(@_); + # Existence of CMakeCache.txt indicates cmake has already + # been used by a prior build step, so should be used + # instead of the parent makefile class. + $ret++ if ($ret && -e $this->get_buildpath("CMakeCache.txt")); + return $ret; + } + return 0; +} + +sub new { + my $class=shift; + my $this=$class->SUPER::new(@_); + $this->prefer_out_of_source_building(@_); + return $this; +} + +sub configure { + my $this=shift; + my @flags; + + # Standard set of cmake flags + push @flags, "-DCMAKE_INSTALL_PREFIX=/usr"; + push @flags, "-DCMAKE_VERBOSE_MAKEFILE=ON"; + push @flags, "-DCMAKE_BUILD_TYPE=RelWithDebInfo"; + + # CMake doesn't respect CPPFLAGS, see #653916. + if ($ENV{CPPFLAGS} && ! compat(8)) { + $ENV{CFLAGS} .= ' ' . $ENV{CPPFLAGS}; + $ENV{CXXFLAGS} .= ' ' . $ENV{CPPFLAGS}; + } + + $this->mkdir_builddir(); + eval { + $this->doit_in_builddir("cmake", $this->get_source_rel2builddir(), @flags, @_); + }; + if ($@) { + if (-e $this->get_buildpath("CMakeCache.txt")) { + $this->doit_in_builddir("tail -v -n +0 CMakeCache.txt"); + } + die $@; + } +} + +sub test { + my $this=shift; + + # Unlike make, CTest does not have "unlimited parallel" setting (-j implies + # -j1). So in order to simulate unlimited parallel, allow to fork a huge + # number of threads instead. + my $parallel = ($this->get_parallel() > 0) ? $this->get_parallel() : 999; + $ENV{CTEST_OUTPUT_ON_FAILURE} = 1; + return $this->SUPER::test(@_, "ARGS+=-j$parallel"); +} + +1 diff --git a/Debian/Debhelper/Buildsystem/makefile.pm b/Debian/Debhelper/Buildsystem/makefile.pm new file mode 100644 index 00000000..dcc5da87 --- /dev/null +++ b/Debian/Debhelper/Buildsystem/makefile.pm @@ -0,0 +1,152 @@ +# A debhelper build system class for handling simple Makefile based projects. +# +# Copyright: © 2008 Joey Hess +# © 2008-2009 Modestas Vainius +# License: GPL-2+ + +package Debian::Debhelper::Buildsystem::makefile; + +use strict; +use Debian::Debhelper::Dh_Lib qw(escape_shell clean_jobserver_makeflags); +use base 'Debian::Debhelper::Buildsystem'; + +# make makes things difficult by not providing a simple way to test +# whether a Makefile target exists. Using -n and checking for a nonzero +# exit status is not good enough, because even with -n, make will +# run commands needed to eg, generate include files -- and those commands +# could fail even though the target exists -- and we should let the target +# run and propagate any failure. +# +# Using -n and checking for at least one line of output is better. +# That will indicate make either wants to run one command, or +# has output a "nothing to be done" message if the target exists but is a +# noop. +# +# However, that heuristic is also not good enough, because a Makefile +# could run code that outputs something, even though the -n is asking +# it not to run anything. (Again, done for includes.) To detect this false +# positive, there is unfortunately only one approach left: To +# look for the error message printed by make when a target does not exist. +# +# This could break if make's output changes. It would only break a minority +# of packages where this latter test is needed. The best way to avoid that +# problem would be to fix make to have this simple and highly useful +# missing feature. +# +# A final option would be to use -p and parse the output data base. +# It's more practical for dh to use that method, since it operates on +# only special debian/rules files, and not arbitrary Makefiles which +# can be arbitrarily complicated, use implicit targets, and so on. +sub exists_make_target { + my $this=shift; + my $target=shift; + + my @opts=("-s", "-n", "--no-print-directory"); + my $buildpath = $this->get_buildpath(); + unshift @opts, "-C", $buildpath if $buildpath ne "."; + + my $pid = open(MAKE, "-|"); + defined($pid) || die "can't fork: $!"; + if (! $pid) { + open(STDERR, ">&STDOUT"); + $ENV{LC_ALL}='C'; + exec($this->{makecmd}, @opts, $target, @_); + exit(1); + } + + local $/=undef; + my $output=; + chomp $output; + close MAKE; + + return defined $output + && length $output + && $output !~ /\*\*\* No rule to make target `\Q$target\E'/; +} + +sub do_make { + my $this=shift; + + # Avoid possible warnings about unavailable jobserver, + # and force make to start a new jobserver. + clean_jobserver_makeflags(); + + # Note that this will override any -j settings in MAKEFLAGS. + unshift @_, "-j" . ($this->get_parallel() > 0 ? $this->get_parallel() : ""); + + $this->doit_in_builddir($this->{makecmd}, @_); +} + +sub make_first_existing_target { + my $this=shift; + my $targets=shift; + + foreach my $target (@$targets) { + if ($this->exists_make_target($target, @_)) { + $this->do_make($target, @_); + return $target; + } + } + return undef; +} + +sub DESCRIPTION { + "simple Makefile" +} + +sub new { + my $class=shift; + my $this=$class->SUPER::new(@_); + $this->{makecmd} = (exists $ENV{MAKE}) ? $ENV{MAKE} : "make"; + return $this; +} + +sub check_auto_buildable { + my $this=shift; + my ($step) = @_; + + if (-e $this->get_buildpath("Makefile") || + -e $this->get_buildpath("makefile") || + -e $this->get_buildpath("GNUmakefile")) + { + # This is always called in the source directory, but generally + # Makefiles are created (or live) in the build directory. + return 1; + } elsif ($step eq "clean" && defined $this->get_builddir() && + $this->check_auto_buildable("configure")) + { + # Assume that the package can be cleaned (i.e. the build directory can + # be removed) as long as it is built out-of-source tree and can be + # configured. This is useful for derivative buildsystems which + # generate Makefiles. + return 1; + } + return 0; +} + +sub build { + my $this=shift; + $this->do_make(@_); +} + +sub test { + my $this=shift; + $this->make_first_existing_target(['test', 'check'], @_); +} + +sub install { + my $this=shift; + my $destdir=shift; + $this->make_first_existing_target(['install'], + "DESTDIR=$destdir", + "AM_UPDATE_INFO_DIR=no", @_); +} + +sub clean { + my $this=shift; + if (!$this->rmdir_builddir()) { + $this->make_first_existing_target(['distclean', 'realclean', 'clean'], @_); + } +} + +1 diff --git a/Debian/Debhelper/Buildsystem/perl_build.pm b/Debian/Debhelper/Buildsystem/perl_build.pm new file mode 100644 index 00000000..bfe1c08e --- /dev/null +++ b/Debian/Debhelper/Buildsystem/perl_build.pm @@ -0,0 +1,77 @@ +# A build system class for handling Perl Build based projects. +# +# Copyright: © 2008-2009 Joey Hess +# © 2008-2009 Modestas Vainius +# License: GPL-2+ + +package Debian::Debhelper::Buildsystem::perl_build; + +use strict; +use Debian::Debhelper::Dh_Lib qw(compat); +use base 'Debian::Debhelper::Buildsystem'; +use Config; + +sub DESCRIPTION { + "Perl Module::Build (Build.PL)" +} + +sub check_auto_buildable { + my ($this, $step) = @_; + + # Handles everything + my $ret = -e $this->get_sourcepath("Build.PL"); + if ($step ne "configure") { + $ret &&= -e $this->get_sourcepath("Build"); + } + return $ret ? 1 : 0; +} + +sub do_perl { + my $this=shift; + $this->doit_in_sourcedir("perl", @_); +} + +sub new { + my $class=shift; + my $this= $class->SUPER::new(@_); + $this->enforce_in_source_building(); + return $this; +} + +sub configure { + my $this=shift; + my @flags; + $ENV{PERL_MM_USE_DEFAULT}=1; + if ($ENV{CFLAGS} && ! compat(8)) { + push @flags, "--config", "optimize=$ENV{CFLAGS} $ENV{CPPFLAGS}"; + } + if ($ENV{LDFLAGS} && ! compat(8)) { + push @flags, "--config", "ld=$Config{ld} $ENV{CFLAGS} $ENV{LDFLAGS}"; + } + $this->do_perl("Build.PL", "--installdirs", "vendor", @flags, @_); +} + +sub build { + my $this=shift; + $this->do_perl("Build", @_); +} + +sub test { + my $this=shift; + $this->do_perl("Build", "test", @_); +} + +sub install { + my $this=shift; + my $destdir=shift; + $this->do_perl("Build", "install", "--destdir", "$destdir", "--create_packlist", 0, @_); +} + +sub clean { + my $this=shift; + if (-e $this->get_sourcepath("Build")) { + $this->do_perl("Build", "distclean", "--allow_mb_mismatch", 1, @_); + } +} + +1 diff --git a/Debian/Debhelper/Buildsystem/perl_makemaker.pm b/Debian/Debhelper/Buildsystem/perl_makemaker.pm new file mode 100644 index 00000000..60cda3d0 --- /dev/null +++ b/Debian/Debhelper/Buildsystem/perl_makemaker.pm @@ -0,0 +1,80 @@ +# A debhelper build system class for handling Perl MakeMaker based projects. +# +# Copyright: © 2008-2009 Joey Hess +# © 2008-2009 Modestas Vainius +# License: GPL-2+ + +package Debian::Debhelper::Buildsystem::perl_makemaker; + +use strict; +use Debian::Debhelper::Dh_Lib qw(compat); +use base 'Debian::Debhelper::Buildsystem::makefile'; +use Config; + +sub DESCRIPTION { + "Perl ExtUtils::MakeMaker (Makefile.PL)" +} + +sub check_auto_buildable { + my $this=shift; + my ($step)=@_; + + # Handles everything if Makefile.PL exists. Otherwise - next class. + if (-e $this->get_sourcepath("Makefile.PL")) { + if ($step eq "configure") { + return 1; + } + else { + return $this->SUPER::check_auto_buildable(@_); + } + } + return 0; +} + +sub new { + my $class=shift; + my $this=$class->SUPER::new(@_); + $this->enforce_in_source_building(); + return $this; +} + +sub configure { + my $this=shift; + my @flags; + # If set to a true value then MakeMaker's prompt function will + # # always return the default without waiting for user input. + $ENV{PERL_MM_USE_DEFAULT}=1; + # This prevents Module::Install from interactive behavior. + $ENV{PERL_AUTOINSTALL}="--skipdeps"; + + if ($ENV{CFLAGS} && ! compat(8)) { + push @flags, "OPTIMIZE=$ENV{CFLAGS} $ENV{CPPFLAGS}"; + } + if ($ENV{LDFLAGS} && ! compat(8)) { + push @flags, "LD=$Config{ld} $ENV{CFLAGS} $ENV{LDFLAGS}"; + } + + $this->doit_in_sourcedir("perl", "Makefile.PL", "INSTALLDIRS=vendor", + # if perl_build is not tested first, need to pass packlist + # option to handle fallthrough case + (compat(7) ? "create_packlist=0" : ()), + @flags, @_); +} + +sub install { + my $this=shift; + my $destdir=shift; + + # Special case for Makefile.PL that uses + # Module::Build::Compat. PREFIX should not be passed + # for those; it already installs into /usr by default. + my $makefile=$this->get_sourcepath("Makefile"); + if (system(qq{grep -q "generated automatically by MakeMaker" $makefile}) != 0) { + $this->SUPER::install($destdir, @_); + } + else { + $this->SUPER::install($destdir, "PREFIX=/usr", @_); + } +} + +1 diff --git a/Debian/Debhelper/Buildsystem/python_distutils.pm b/Debian/Debhelper/Buildsystem/python_distutils.pm new file mode 100644 index 00000000..c3d58cc0 --- /dev/null +++ b/Debian/Debhelper/Buildsystem/python_distutils.pm @@ -0,0 +1,210 @@ +# A debhelper build system class for building Python Distutils based +# projects. It prefers out of source tree building. +# +# Copyright: © 2008 Joey Hess +# © 2008-2009 Modestas Vainius +# License: GPL-2+ + +package Debian::Debhelper::Buildsystem::python_distutils; + +use strict; +use Cwd (); +use Debian::Debhelper::Dh_Lib qw(error); +use base 'Debian::Debhelper::Buildsystem'; + +sub DESCRIPTION { + "Python Distutils (setup.py)" +} + +sub DEFAULT_BUILD_DIRECTORY { + my $this=shift; + return $this->canonpath($this->get_sourcepath("build")); +} + +sub new { + my $class=shift; + my $this=$class->SUPER::new(@_); + # Out of source tree building is preferred. + $this->prefer_out_of_source_building(@_); + return $this; +} + +sub check_auto_buildable { + my $this=shift; + return -e $this->get_sourcepath("setup.py") ? 1 : 0; +} + +sub not_our_cfg { + my $this=shift; + my $ret; + if (open(my $cfg, $this->get_buildpath(".pydistutils.cfg"))) { + $ret = not "# Created by dh_auto\n" eq <$cfg>; + close $cfg; + } + return $ret; +} + +sub create_cfg { + my $this=shift; + if (open(my $cfg, ">", $this->get_buildpath(".pydistutils.cfg"))) { + print $cfg "# Created by dh_auto", "\n"; + print $cfg "[build]\nbuild-base=", $this->get_build_rel2sourcedir(), "\n"; + close $cfg; + return 1; + } + return 0; +} + +sub pre_building_step { + my $this=shift; + my $step=shift; + + return unless grep /$step/, qw(build install clean); + + if ($this->get_buildpath() ne $this->DEFAULT_BUILD_DIRECTORY()) { + # --build-base can only be passed to the build command. However, + # it is always read from the config file (really weird design). + # Therefore create such a cfg config file. + # See http://bugs.python.org/issue818201 + # http://bugs.python.org/issue1011113 + not $this->not_our_cfg() or + error("cannot set custom build directory: .pydistutils.cfg is in use"); + $this->mkdir_builddir(); + $this->create_cfg() or + error("cannot set custom build directory: unwritable .pydistutils.cfg"); + # Distutils reads $HOME/.pydistutils.cfg + $ENV{HOME} = Cwd::abs_path($this->get_buildpath()); + } + + $this->SUPER::pre_building_step($step); +} + +sub dbg_build_needed { + my $this=shift; + my $act=shift; + + # Return a list of python-dbg package which are listed + # in the build-dependencies. This is kinda ugly, but building + # dbg extensions without checking if they're supposed to be + # built may result in various FTBFS if the package is not + # built in a clean chroot. + + my @dbg; + open (CONTROL, 'debian/control') || + error("cannot read debian/control: $!\n"); + foreach my $builddeps (join('', ) =~ + /^Build-Depends[^:]*:.*\n(?:^[^\w\n].*\n)*/gmi) { + while ($builddeps =~ /(python[^, ]*-dbg)/g) { + push @dbg, $1; + } + } + + close CONTROL; + return @dbg; + +} + +sub setup_py { + my $this=shift; + my $act=shift; + + # We need to to run setup.py with the default python last + # as distutils/setuptools modifies the shebang lines of scripts. + # This ensures that #!/usr/bin/python is installed last and + # not pythonX.Y + # Take into account that the default Python must not be in + # the requested Python versions. + # Then, run setup.py with each available python, to build + # extensions for each. + + my $python_default = `pyversions -d`; + if ($? == -1) { + error("failed to run pyversions") + } + my $ecode = $? >> 8; + if ($ecode != 0) { + error("pyversions -d failed [$ecode]") + } + $python_default =~ s/^\s+//; + $python_default =~ s/\s+$//; + my @python_requested = split ' ', `pyversions -r`; + if ($? == -1) { + error("failed to run pyversions") + } + $ecode = $? >> 8; + if ($ecode != 0) { + error("pyversions -r failed [$ecode]") + } + if (grep /^\Q$python_default\E/, @python_requested) { + @python_requested = ( + grep(!/^\Q$python_default\E/, @python_requested), + "python", + ); + } + + my @python_dbg; + my @dbg_build_needed = $this->dbg_build_needed(); + foreach my $python (map { $_."-dbg" } @python_requested) { + if (grep /^(python-all-dbg|\Q$python\E)/, @dbg_build_needed) { + push @python_dbg, $python; + } + elsif (($python eq "python-dbg") + and (grep /^\Q$python_default\E/, @dbg_build_needed)) { + push @python_dbg, $python_default."-dbg"; + } + } + + foreach my $python (@python_dbg, @python_requested) { + if (-x "/usr/bin/".$python) { + # To allow backports of debhelper we don't pass + # --install-layout=deb to 'setup.py install` for + # those Python versions where the option is + # ignored by distutils/setuptools. + if ( $act eq "install" and not + ( ($python =~ /^python(?:-dbg)?$/ + and $python_default =~ /^python2\.[2345]$/) + or $python =~ /^python2\.[2345](?:-dbg)?$/ )) { + $this->doit_in_sourcedir($python, "setup.py", + $act, @_, "--install-layout=deb"); + } + else { + $this->doit_in_sourcedir($python, "setup.py", + $act, @_); + } + } + } +} + +sub build { + my $this=shift; + $this->setup_py("build", + "--force", + @_); +} + +sub install { + my $this=shift; + my $destdir=shift; + $this->setup_py("install", + "--force", + "--root=$destdir", + "--no-compile", + "-O0", + @_); +} + +sub clean { + my $this=shift; + $this->setup_py("clean", "-a", @_); + + # Config file will remain if it was created by us + if (!$this->not_our_cfg()) { + unlink($this->get_buildpath(".pydistutils.cfg")); + $this->rmdir_builddir(1); # only if empty + } + # The setup.py might import files, leading to python creating pyc + # files. + $this->doit_in_sourcedir('find', '.', '-name', '*.pyc', '-exec', 'rm', '{}', '+'); +} + +1 diff --git a/Debian/Debhelper/Buildsystem/qmake.pm b/Debian/Debhelper/Buildsystem/qmake.pm new file mode 100644 index 00000000..91e817f8 --- /dev/null +++ b/Debian/Debhelper/Buildsystem/qmake.pm @@ -0,0 +1,83 @@ +# A debhelper build system class for Qt projects +# (based on the makefile class). +# +# Copyright: © 2010 Kelvin Modderman +# License: GPL-2+ + +package Debian::Debhelper::Buildsystem::qmake; + +use strict; +use warnings; +use Debian::Debhelper::Dh_Lib qw(error); +use base 'Debian::Debhelper::Buildsystem::makefile'; + +our $qmake="qmake"; + +sub DESCRIPTION { + "qmake (*.pro)"; +} + +sub check_auto_buildable { + my $this=shift; + my @projects=glob($this->get_sourcepath('*.pro')); + my $ret=0; + + if (@projects > 0) { + $ret=1; + # Existence of a Makefile generated by qmake indicates qmake + # class has already been used by a prior build step, so should + # be used instead of the parent makefile class. + my $mf=$this->get_buildpath("Makefile"); + if (-e $mf) { + $ret = $this->SUPER::check_auto_buildable(@_); + open(my $fh, '<', $mf) + or error("unable to open Makefile: $mf"); + while(<$fh>) { + if (m/^# Generated by qmake/i) { + $ret++; + last; + } + } + close($fh); + } + } + + return $ret; +} + +sub configure { + my $this=shift; + my @options; + my @flags; + + push @options, '-makefile'; + push @options, '-nocache'; + + if ($ENV{CFLAGS}) { + push @flags, "QMAKE_CFLAGS_RELEASE=$ENV{CFLAGS} $ENV{CPPFLAGS}"; + push @flags, "QMAKE_CFLAGS_DEBUG=$ENV{CFLAGS} $ENV{CPPFLAGS}"; + } + if ($ENV{CXXFLAGS}) { + push @flags, "QMAKE_CXXFLAGS_RELEASE=$ENV{CXXFLAGS} $ENV{CPPFLAGS}"; + push @flags, "QMAKE_CXXFLAGS_DEBUG=$ENV{CXXFLAGS} $ENV{CPPFLAGS}"; + } + if ($ENV{LDFLAGS}) { + push @flags, "QMAKE_LFLAGS_RELEASE=$ENV{LDFLAGS}"; + push @flags, "QMAKE_LFLAGS_DEBUG=$ENV{LDFLAGS}"; + } + push @flags, "QMAKE_STRIP=:"; + push @flags, "PREFIX=/usr"; + + $this->doit_in_builddir($qmake, @options, @flags, @_); +} + +sub install { + my $this=shift; + my $destdir=shift; + + # qmake generated Makefiles use INSTALL_ROOT in install target + # where one would expect DESTDIR to be used. + $this->SUPER::install($destdir, "INSTALL_ROOT=$destdir", @_); +} + +1 diff --git a/Debian/Debhelper/Buildsystem/qmake_qt4.pm b/Debian/Debhelper/Buildsystem/qmake_qt4.pm new file mode 100644 index 00000000..d5bac585 --- /dev/null +++ b/Debian/Debhelper/Buildsystem/qmake_qt4.pm @@ -0,0 +1,18 @@ +package Debian::Debhelper::Buildsystem::qmake_qt4; + +use strict; +use warnings; +use Debian::Debhelper::Dh_Lib qw(error); +use base 'Debian::Debhelper::Buildsystem::qmake'; + +sub DESCRIPTION { + "qmake for QT 4 (*.pro)"; +} + +sub configure { + my $this=shift; + $Debian::Debhelper::Buildsystem::qmake::qmake="qmake-qt4"; + $this->SUPER::configure(@_); +} + +1 diff --git a/Debian/Debhelper/Dh_Buildsystems.pm b/Debian/Debhelper/Dh_Buildsystems.pm new file mode 100644 index 00000000..0a51a4d2 --- /dev/null +++ b/Debian/Debhelper/Dh_Buildsystems.pm @@ -0,0 +1,228 @@ +# A module for loading and managing debhelper build system classes. +# This module is intended to be used by all dh_auto_* programs. +# +# Copyright: © 2009 Modestas Vainius +# License: GPL-2+ + +package Debian::Debhelper::Dh_Buildsystems; + +use strict; +use warnings; +use Debian::Debhelper::Dh_Lib; +use File::Spec; + +use base 'Exporter'; +our @EXPORT=qw(&buildsystems_init &buildsystems_do &load_buildsystem &load_all_buildsystems); + +use constant BUILD_STEPS => qw(configure build test install clean); + +# Historical order must be kept for backwards compatibility. New +# build systems MUST be added to the END of the list. +our @BUILDSYSTEMS = ( + "autoconf", + (! compat(7) ? "perl_build" : ()), + "perl_makemaker", + "makefile", + "python_distutils", + (compat(7) ? "perl_build" : ()), + "cmake", + "ant", + "qmake", + "qmake_qt4", +); + +my $opt_buildsys; +my $opt_sourcedir; +my $opt_builddir; +my $opt_list; +my $opt_parallel; + +sub create_buildsystem_instance { + my $system=shift; + my %bsopts=@_; + my $module = "Debian::Debhelper::Buildsystem::$system"; + + eval "use $module"; + if ($@) { + error("unable to load build system class '$system': $@"); + } + + if (!exists $bsopts{builddir} && defined $opt_builddir) { + $bsopts{builddir} = ($opt_builddir eq "") ? undef : $opt_builddir; + } + if (!exists $bsopts{sourcedir} && defined $opt_sourcedir) { + $bsopts{sourcedir} = ($opt_sourcedir eq "") ? undef : $opt_sourcedir; + } + if (!exists $bsopts{parallel}) { + $bsopts{parallel} = $opt_parallel; + } + return $module->new(%bsopts); +} + +# Autoselect a build system from the list of instances +sub autoselect_buildsystem { + my $step=shift; + my $selected; + my $selected_level = 0; + + foreach my $inst (@_) { + # Only derived (i.e. more specific) build system can be + # considered beyond the currently selected one. + next if defined $selected && !$inst->isa(ref $selected); + + # If the build system says it is auto-buildable at the current + # step and it can provide more specific information about its + # status than its parent (if any), auto-select it. + my $level = $inst->check_auto_buildable($step); + if ($level > $selected_level) { + $selected = $inst; + $selected_level = $level; + } + } + return $selected; +} + +# Similar to create_build system_instance(), but it attempts to autoselect +# a build system if none was specified. In case autoselection fails, undef +# is returned. +sub load_buildsystem { + my $system=shift; + my $step=shift; + if (defined $system) { + my $inst = create_buildsystem_instance($system, @_); + return $inst; + } + else { + # Try to determine build system automatically + my @buildsystems; + foreach $system (@BUILDSYSTEMS) { + push @buildsystems, create_buildsystem_instance($system, @_); + } + return autoselect_buildsystem($step, @buildsystems); + } +} + +sub load_all_buildsystems { + my $incs=shift || \@INC; + my (%buildsystems, @buildsystems); + + foreach my $inc (@$incs) { + my $path = File::Spec->catdir($inc, "Debian/Debhelper/Buildsystem"); + if (-d $path) { + foreach my $module_path (glob "$path/*.pm") { + my $name = basename($module_path); + $name =~ s/\.pm$//; + next if exists $buildsystems{$name}; + $buildsystems{$name} = create_buildsystem_instance($name, @_); + } + } + } + + # Standard debhelper build systems first + foreach my $name (@BUILDSYSTEMS) { + error("standard debhelper build system '$name' could not be found/loaded") + if not exists $buildsystems{$name}; + push @buildsystems, $buildsystems{$name}; + delete $buildsystems{$name}; + } + + # The rest are 3rd party build systems + foreach my $name (keys %buildsystems) { + my $inst = $buildsystems{$name}; + $inst->{thirdparty} = 1; + push @buildsystems, $inst; + } + + return @buildsystems; +} + +sub buildsystems_init { + my %args=@_; + + my $max_parallel=1; + + # Available command line options + my %options = ( + "D=s" => \$opt_sourcedir, + "sourcedirectory=s" => \$opt_sourcedir, + + "B:s" => \$opt_builddir, + "builddirectory:s" => \$opt_builddir, + + "S=s" => \$opt_buildsys, + "buildsystem=s" => \$opt_buildsys, + + "l" => \$opt_list, + "list" => \$opt_list, + + "parallel" => sub { $max_parallel = -1 }, + "max-parallel=i" => \$max_parallel, + ); + $args{options}{$_} = $options{$_} foreach keys(%options); + Debian::Debhelper::Dh_Lib::init(%args); + Debian::Debhelper::Dh_Lib::set_buildflags(); + set_parallel($max_parallel); +} + +sub set_parallel { + my $max=shift; + + # Get number of processes from parallel=n option, limiting it + # with $max if needed + $opt_parallel=get_buildoption("parallel") || 1; + + if ($max > 0 && $opt_parallel > $max) { + $opt_parallel = $max; + } +} + +sub buildsystems_list { + my $step=shift; + + my @buildsystems = load_all_buildsystems(); + my $auto = autoselect_buildsystem($step, grep { ! $_->{thirdparty} } @buildsystems); + my $specified; + + # List build systems (including auto and specified status) + foreach my $inst (@buildsystems) { + if (! defined $specified && defined $opt_buildsys && $opt_buildsys eq $inst->NAME()) { + $specified = $inst; + } + printf("%-20s %s", $inst->NAME(), $inst->DESCRIPTION()); + print " [3rd party]" if $inst->{thirdparty}; + print "\n"; + } + print "\n"; + print "Auto-selected: ", $auto->NAME(), "\n" if defined $auto; + print "Specified: ", $specified->NAME(), "\n" if defined $specified; + print "No system auto-selected or specified\n" + if ! defined $auto && ! defined $specified; +} + +sub buildsystems_do { + my $step=shift; + + if (!defined $step) { + $step = basename($0); + $step =~ s/^dh_auto_//; + } + + if (grep(/^\Q$step\E$/, BUILD_STEPS) == 0) { + error("unrecognized build step: " . $step); + } + + if ($opt_list) { + buildsystems_list($step); + exit 0; + } + + my $buildsystem = load_buildsystem($opt_buildsys, $step); + if (defined $buildsystem) { + $buildsystem->pre_building_step($step); + $buildsystem->$step(@_, @{$dh{U_PARAMS}}); + $buildsystem->post_building_step($step); + } + return 0; +} + +1 diff --git a/Debian/Debhelper/Dh_Getopt.pm b/Debian/Debhelper/Dh_Getopt.pm new file mode 100644 index 00000000..e4f3e471 --- /dev/null +++ b/Debian/Debhelper/Dh_Getopt.pm @@ -0,0 +1,288 @@ +#!/usr/bin/perl -w +# +# Debhelper option processing library. +# +# Joey Hess GPL copyright 1998-2002 + +package Debian::Debhelper::Dh_Getopt; +use strict; + +use Debian::Debhelper::Dh_Lib; +use Getopt::Long; + +my %exclude_package; + +sub showhelp { + my $prog=basename($0); + print "Usage: $prog [options]\n\n"; + print " $prog is a part of debhelper. See debhelper(7)\n"; + print " and $prog(1) for complete usage instructions.\n"; + exit(1); +} + +# Passed an option name and an option value, adds packages to the list +# of packages. We need this so the list will be built up in the right +# order. +sub AddPackage { my($option,$value)=@_; + if ($option eq 'i' or $option eq 'indep') { + push @{$dh{DOPACKAGES}}, getpackages('indep'); + $dh{DOINDEP}=1; + } + elsif ($option eq 'a' or $option eq 'arch' or + $option eq 's' or $option eq 'same-arch') { + push @{$dh{DOPACKAGES}}, getpackages('arch'); + $dh{DOARCH}=1; + } + elsif ($option eq 'p' or $option eq 'package') { + push @{$dh{DOPACKAGES}}, $value; + } + else { + error("bad option $option - should never happen!\n"); + } +} + +# Adds packages to the list of debug packages. +sub AddDebugPackage { my($option,$value)=@_; + push @{$dh{DEBUGPACKAGES}}, $value; +} + +# Add a package to a list of packages that should not be acted on. +sub ExcludePackage { my($option,$value)=@_; + $exclude_package{$value}=1; +} + +# Add another item to the exclude list. +sub AddExclude { my($option,$value)=@_; + push @{$dh{EXCLUDE}},$value; +} + +# Add a file to the ignore list. +sub AddIgnore { my($option,$file)=@_; + $dh{IGNORE}->{$file}=1; +} + +# This collects non-options values. +sub NonOption { + push @{$dh{ARGV}}, @_; +} + +sub getoptions { + my $array=shift; + my %params=@_; + + if (! exists $params{bundling} || $params{bundling}) { + Getopt::Long::config("bundling"); + } + + my @test; + my %options=( + "v" => \$dh{VERBOSE}, + "verbose" => \$dh{VERBOSE}, + + "no-act" => \$dh{NO_ACT}, + + "i" => \&AddPackage, + "indep" => \&AddPackage, + + "a" => \&AddPackage, + "arch" => \&AddPackage, + + "p=s" => \&AddPackage, + "package=s" => \&AddPackage, + + "N=s" => \&ExcludePackage, + "no-package=s" => \&ExcludePackage, + + "remaining-packages" => \$dh{EXCLUDE_LOGGED}, + + "dbg-package=s" => \&AddDebugPackage, + + "s" => \&AddPackage, + "same-arch" => \&AddPackage, + + "n" => \$dh{NOSCRIPTS}, + "noscripts" => \$dh{NOSCRIPTS}, + "o" => \$dh{ONLYSCRIPTS}, + "onlyscripts" => \$dh{ONLYSCRIPTS}, + + "X=s" => \&AddExclude, + "exclude=s" => \&AddExclude, + + "d" => \$dh{D_FLAG}, + + "k" => \$dh{K_FLAG}, + "keep" => \$dh{K_FLAG}, + + "P=s" => \$dh{TMPDIR}, + "tmpdir=s" => \$dh{TMPDIR}, + + "u=s", => \$dh{U_PARAMS}, + + "V:s", => \$dh{V_FLAG}, + + "A" => \$dh{PARAMS_ALL}, + "all" => \$dh{PARAMS_ALL}, + + "priority=s" => \$dh{PRIORITY}, + + "h|help" => \&showhelp, + + "mainpackage=s" => \$dh{MAINPACKAGE}, + + "name=s" => \$dh{NAME}, + + "error-handler=s" => \$dh{ERROR_HANDLER}, + + "ignore=s" => \&AddIgnore, + + "O=s" => sub { push @test, $_[1] }, + + (ref $params{options} ? %{$params{options}} : ()) , + + "<>" => \&NonOption, + ); + + if ($params{test}) { + foreach my $key (keys %options) { + $options{$key}=sub {}; + } + } + + my $oldwarn; + if ($params{test} || $params{ignore_unknown_options}) { + $oldwarn=$SIG{__WARN__}; + $SIG{__WARN__}=sub {}; + } + my $ret=Getopt::Long::GetOptionsFromArray($array, %options); + if ($oldwarn) { + $SIG{__WARN__}=$oldwarn; + } + + foreach my $opt (@test) { + # Try to parse an option, and skip it + # if it is not known. + if (getoptions([$opt], %params, + ignore_unknown_options => 0, + test => 1)) { + getoptions([$opt], %params); + } + } + + return 1 if $params{ignore_unknown_options}; + return $ret; +} + +sub split_options_string { + my $str=shift; + $str=~s/^\s+//; + return split(/\s+/,$str); +} + +# Parse options and set %dh values. +sub parseopts { + my %params=@_; + + my @ARGV_extra; + + # DH_INTERNAL_OPTIONS is used to pass additional options from + # dh through an override target to a command. + if (defined $ENV{DH_INTERNAL_OPTIONS}) { + @ARGV_extra=split(/\x1e/, $ENV{DH_INTERNAL_OPTIONS}); + getoptions(\@ARGV_extra, %params); + + # Avoid forcing acting on packages specified in + # DH_INTERNAL_OPTIONS. This way, -p can be specified + # at the command line to act on a specific package, but when + # nothing is specified, the excludes will cause the set of + # packages DH_INTERNAL_OPTIONS specifies to be acted on. + if (defined $dh{DOPACKAGES}) { + foreach my $package (getpackages()) { + if (! grep { $_ eq $package } @{$dh{DOPACKAGES}}) { + $exclude_package{$package}=1; + } + } + } + delete $dh{DOPACKAGES}; + delete $dh{DOINDEP}; + delete $dh{DOARCH}; + } + + # DH_OPTIONS can contain additional options to be parsed like @ARGV + if (defined $ENV{DH_OPTIONS}) { + @ARGV_extra=split_options_string($ENV{DH_OPTIONS}); + my $ret=getoptions(\@ARGV_extra, %params); + if (!$ret) { + warning("warning: ignored unknown options in DH_OPTIONS"); + } + } + + my $ret=getoptions(\@ARGV, %params); + if (!$ret) { + if (! compat(7)) { + error("unknown option; aborting"); + } + } + + # Check to see if -V was specified. If so, but no parameters were + # passed, the variable will be defined but empty. + if (defined($dh{V_FLAG})) { + $dh{V_FLAG_SET}=1; + } + + # If we have not been given any packages to act on, assume they + # want us to act on them all. Note we have to do this before excluding + # packages out, below. + if (! defined $dh{DOPACKAGES} || ! @{$dh{DOPACKAGES}}) { + if ($dh{DOINDEP} || $dh{DOARCH}) { + # User specified that all arch (in)dep package be + # built, and there are none of that type. + if (! $dh{BLOCK_NOOP_WARNINGS}) { + warning("You asked that all arch in(dep) packages be built, but there are none of that type."); + } + exit(0); + } + push @{$dh{DOPACKAGES}},getpackages("both"); + } + + # Remove excluded packages from the list of packages to act on. + # Also unique the list, in case some options were specified that + # added a package to it twice. + my @package_list; + my $package; + my %packages_seen; + foreach $package (@{$dh{DOPACKAGES}}) { + if (defined($dh{EXCLUDE_LOGGED}) && + grep { $_ eq basename($0) } load_log($package)) { + $exclude_package{$package}=1; + } + if (! $exclude_package{$package}) { + if (! exists $packages_seen{$package}) { + $packages_seen{$package}=1; + push @package_list, $package; + } + } + } + @{$dh{DOPACKAGES}}=@package_list; + + if (! defined $dh{DOPACKAGES} || ! @{$dh{DOPACKAGES}}) { + if (! $dh{BLOCK_NOOP_WARNINGS}) { + warning("No packages to build."); + } + exit(0); + } + + if (defined $dh{U_PARAMS}) { + # Split the U_PARAMS up into an array. + my $u=$dh{U_PARAMS}; + undef $dh{U_PARAMS}; + push @{$dh{U_PARAMS}}, split(/\s+/,$u); + } + + # Anything left in @ARGV is options that appeared after a -- + # These options are added to the U_PARAMS array, while the + # non-option values we collected replace them in @ARGV; + push @{$dh{U_PARAMS}}, @ARGV, @ARGV_extra; + @ARGV=@{$dh{ARGV}} if exists $dh{ARGV}; +} + +1 diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm new file mode 100644 index 00000000..2acfad9b --- /dev/null +++ b/Debian/Debhelper/Dh_Lib.pm @@ -0,0 +1,983 @@ +#!/usr/bin/perl -w +# +# Library functions for debhelper programs, perl version. +# +# Joey Hess, GPL copyright 1997-2008. + +package Debian::Debhelper::Dh_Lib; +use strict; + +use Exporter; +use vars qw(@ISA @EXPORT %dh); +@ISA=qw(Exporter); +@EXPORT=qw(&init &doit &complex_doit &verbose_print &error &warning &tmpdir + &pkgfile &pkgext &pkgfilename &isnative &autoscript &filearray + &filedoublearray &getpackages &basename &dirname &xargs %dh + &compat &addsubstvar &delsubstvar &excludefile &package_arch + &is_udeb &udeb_filename &debhelper_script_subst &escape_shell + &inhibit_log &load_log &write_log &commit_override_log + &dpkg_architecture_value &sourcepackage + &is_make_jobserver_unavailable &clean_jobserver_makeflags + &cross_command &set_buildflags &get_buildoption); + +my $max_compat=10; + +# The Makefile changes this if debhelper is installed in a PREFIX. +my $prefix="/usr"; + +sub init { + my %params=@_; + + # Check to see if an option line starts with a dash, + # or DH_OPTIONS is set. + # If so, we need to pass this off to the resource intensive + # Getopt::Long, which I'd prefer to avoid loading at all if possible. + if ((defined $ENV{DH_OPTIONS} && length $ENV{DH_OPTIONS}) || + (defined $ENV{DH_INTERNAL_OPTIONS} && length $ENV{DH_INTERNAL_OPTIONS}) || + grep /^-/, @ARGV) { + eval "use Debian::Debhelper::Dh_Getopt"; + error($@) if $@; + Debian::Debhelper::Dh_Getopt::parseopts(%params); + } + + # Another way to set excludes. + if (exists $ENV{DH_ALWAYS_EXCLUDE} && length $ENV{DH_ALWAYS_EXCLUDE}) { + push @{$dh{EXCLUDE}}, split(":", $ENV{DH_ALWAYS_EXCLUDE}); + } + + # Generate EXCLUDE_FIND. + if ($dh{EXCLUDE}) { + $dh{EXCLUDE_FIND}=''; + foreach (@{$dh{EXCLUDE}}) { + my $x=$_; + $x=escape_shell($x); + $x=~s/\./\\\\./g; + $dh{EXCLUDE_FIND}.="-regex .\\*$x.\\* -or "; + } + $dh{EXCLUDE_FIND}=~s/ -or $//; + } + + # Check to see if DH_VERBOSE environment variable was set, if so, + # make sure verbose is on. + if (defined $ENV{DH_VERBOSE} && $ENV{DH_VERBOSE} ne "") { + $dh{VERBOSE}=1; + } + + # Check to see if DH_NO_ACT environment variable was set, if so, + # make sure no act mode is on. + if (defined $ENV{DH_NO_ACT} && $ENV{DH_NO_ACT} ne "") { + $dh{NO_ACT}=1; + } + + # Get the name of the main binary package (first one listed in + # debian/control). Only if the main package was not set on the + # command line. + if (! exists $dh{MAINPACKAGE} || ! defined $dh{MAINPACKAGE}) { + my @allpackages=getpackages(); + $dh{MAINPACKAGE}=$allpackages[0]; + } + + # Check if packages to build have been specified, if not, fall back to + # the default, building all relevant packages. + if (! defined $dh{DOPACKAGES} || ! @{$dh{DOPACKAGES}}) { + push @{$dh{DOPACKAGES}}, getpackages('both'); + } + + # Check to see if -P was specified. If so, we can only act on a single + # package. + if ($dh{TMPDIR} && $#{$dh{DOPACKAGES}} > 0) { + error("-P was specified, but multiple packages would be acted on (".join(",",@{$dh{DOPACKAGES}}).")."); + } + + # Figure out which package is the first one we were instructed to build. + # This package gets special treatement: files and directories specified on + # the command line may affect it. + $dh{FIRSTPACKAGE}=${$dh{DOPACKAGES}}[0]; + + # If no error handling function was specified, just propagate + # errors out. + if (! exists $dh{ERROR_HANDLER} || ! defined $dh{ERROR_HANDLER}) { + $dh{ERROR_HANDLER}='exit \$?'; + } +} + +# Run at exit. Add the command to the log files for the packages it acted +# on, if it's exiting successfully. +my $write_log=1; +sub END { + if ($? == 0 && $write_log) { + write_log(basename($0), @{$dh{DOPACKAGES}}); + } +} + +sub logfile { + my $package=shift; + my $ext=pkgext($package); + return "debian/${ext}debhelper.log" +} + +sub add_override { + my $line=shift; + $line="override_$ENV{DH_INTERNAL_OVERRIDE} $line" + if defined $ENV{DH_INTERNAL_OVERRIDE}; + return $line; +} + +sub remove_override { + my $line=shift; + $line=~s/^\Qoverride_$ENV{DH_INTERNAL_OVERRIDE}\E\s+// + if defined $ENV{DH_INTERNAL_OVERRIDE}; + return $line; +} + +sub load_log { + my ($package, $db)=@_; + + my @log; + open(LOG, "<", logfile($package)) || return; + while () { + chomp; + my $command=remove_override($_); + push @log, $command; + $db->{$package}{$command}=1 if defined $db; + } + close LOG; + return @log; +} + +sub write_log { + my $cmd=shift; + my @packages=@_; + + return if $dh{NO_ACT}; + + foreach my $package (@packages) { + my $log=logfile($package); + open(LOG, ">>", $log) || error("failed to write to ${log}: $!"); + print LOG add_override($cmd)."\n"; + close LOG; + } +} + +sub commit_override_log { + my @packages=@_; + + return if $dh{NO_ACT}; + + foreach my $package (@packages) { + my @log=map { remove_override($_) } load_log($package); + my $log=logfile($package); + open(LOG, ">", $log) || error("failed to write to ${log}: $!"); + print LOG $_."\n" foreach @log; + close LOG; + } +} + +sub inhibit_log { + $write_log=0; +} + +# Pass it an array containing the arguments of a shell command like would +# be run by exec(). It turns that into a line like you might enter at the +# shell, escaping metacharacters and quoting arguments that contain spaces. +sub escape_shell { + my @args=@_; + my $line=""; + my @ret; + foreach my $word (@args) { + if ($word=~/\s/) { + # Escape only a few things since it will be quoted. + # Note we use double quotes because you cannot + # escape ' in single quotes, while " can be escaped + # in double. + # This does make -V"foo bar" turn into "-Vfoo bar", + # but that will be parsed identically by the shell + # anyway.. + $word=~s/([\n`\$"\\])/\\$1/g; + push @ret, "\"$word\""; + } + else { + # This list is from _Unix in a Nutshell_. (except '#') + $word=~s/([\s!"\$()*+#;<>?@\[\]\\`|~])/\\$1/g; + push @ret,$word; + } + } + return join(' ', @ret); +} + +# Run a command, and display the command to stdout if verbose mode is on. +# All commands that modifiy files in $TMP should be ran via this +# function. +# +# Note that this cannot handle complex commands, especially anything +# involving redirection. Use complex_doit instead. +sub doit { + verbose_print(escape_shell(@_)); + + if (! $dh{NO_ACT}) { + system(@_) == 0 || _error_exitcode(join(" ", @_)); + } +} + +# Run a command and display the command to stdout if verbose mode is on. +# Use doit() if you can, instead of this function, because this function +# forks a shell. However, this function can handle more complicated stuff +# like redirection. +sub complex_doit { + verbose_print(join(" ",@_)); + + if (! $dh{NO_ACT}) { + # The join makes system get a scalar so it forks off a shell. + system(join(" ", @_)) == 0 || _error_exitcode(join(" ", @_)) + } +} + +sub _error_exitcode { + my $command=shift; + if ($? == -1) { + error("$command failed to to execute: $!"); + } + elsif ($? & 127) { + error("$command died with signal ".($? & 127)); + } + else { + error("$command returned exit code ".($? >> 8)); + } +} + +# Run a command that may have a huge number of arguments, like xargs does. +# Pass in a reference to an array containing the arguments, and then other +# parameters that are the command and any parameters that should be passed to +# it each time. +sub xargs { + my $args=shift; + + # The kernel can accept command lines up to 20k worth of characters. + my $command_max=20000; # LINUX SPECIFIC!! + # (And obsolete; it's bigger now.) + # I could use POSIX::ARG_MAX, but that would be slow. + + # Figure out length of static portion of command. + my $static_length=0; + foreach (@_) { + $static_length+=length($_)+1; + } + + my @collect=(); + my $length=$static_length; + foreach (@$args) { + if (length($_) + 1 + $static_length > $command_max) { + error("This command is greater than the maximum command size allowed by the kernel, and cannot be split up further. What on earth are you doing? \"@_ $_\""); + } + $length+=length($_) + 1; + if ($length < $command_max) { + push @collect, $_; + } + else { + doit(@_,@collect) if $#collect > -1; + @collect=($_); + $length=$static_length + length($_) + 1; + } + } + doit(@_,@collect) if $#collect > -1; +} + +# Print something if the verbose flag is on. +sub verbose_print { + my $message=shift; + + if ($dh{VERBOSE}) { + print "\t$message\n"; + } +} + +# Output an error message and die (can be caught). +sub error { + my $message=shift; + + die basename($0).": $message\n"; +} + +# Output a warning. +sub warning { + my $message=shift; + + print STDERR basename($0).": $message\n"; +} + +# Returns the basename of the argument passed to it. +sub basename { + my $fn=shift; + + $fn=~s/\/$//g; # ignore trailing slashes + $fn=~s:^.*/(.*?)$:$1:; + return $fn; +} + +# Returns the directory name of the argument passed to it. +sub dirname { + my $fn=shift; + + $fn=~s/\/$//g; # ignore trailing slashes + $fn=~s:^(.*)/.*?$:$1:; + return $fn; +} + +# Pass in a number, will return true iff the current compatibility level +# is less than or equal to that number. +{ + my $warned_compat=0; + my $c; + + sub compat { + my $num=shift; + my $nowarn=shift; + + if (! defined $c) { + $c=1; + if (-e 'debian/compat') { + open (COMPAT_IN, "debian/compat") || error "debian/compat: $!"; + my $l=; + close COMPAT_IN; + if (! defined $l || ! length $l) { + warning("debian/compat is empty, assuming level $c") + unless defined $ENV{DH_COMPAT}; + } + else { + chomp $l; + $c=$l; + } + } + else { + warning("No compatibility level specified in debian/compat"); + warning("This package will soon FTBFS; time to fix it!"); + } + + if (defined $ENV{DH_COMPAT}) { + $c=$ENV{DH_COMPAT}; + } + } + + if ($c <= 4 && ! $warned_compat && ! $nowarn) { + warning("Compatibility levels before 5 are deprecated (level $c in use)"); + $warned_compat=1; + } + + if ($c > $max_compat) { + error("Sorry, but $max_compat is the highest compatibility level supported by this debhelper."); + } + + return ($c <= $num); + } +} + +# Pass it a name of a binary package, it returns the name of the tmp dir to +# use, for that package. +sub tmpdir { + my $package=shift; + + if ($dh{TMPDIR}) { + return $dh{TMPDIR}; + } + elsif (compat(1) && $package eq $dh{MAINPACKAGE}) { + # This is for back-compatibility with the debian/tmp tradition. + return "debian/tmp"; + } + else { + return "debian/$package"; + } +} + +# Pass this the name of a binary package, and the name of the file wanted +# for the package, and it will return the actual existing filename to use. +# +# It tries several filenames: +# * debian/package.filename.buildarch +# * debian/package.filename.buildos +# * debian/package.filename +# * debian/filename (if the package is the main package) +# If --name was specified then the files +# must have the name after the package name: +# * debian/package.name.filename.buildarch +# * debian/package.name.filename.buildos +# * debian/package.name.filename +# * debian/name.filename (if the package is the main package) +sub pkgfile { + my $package=shift; + my $filename=shift; + + if (defined $dh{NAME}) { + $filename="$dh{NAME}.$filename"; + } + + # First, check for files ending in buildarch and buildos. + my $match; + foreach my $file (glob("debian/$package.$filename.*")) { + next if ! -f $file; + next if $dh{IGNORE} && exists $dh{IGNORE}->{$file}; + if ($file eq "debian/$package.$filename.".buildarch()) { + $match=$file; + # buildarch files are used in preference to buildos files. + last; + } + elsif ($file eq "debian/$package.$filename.".buildos()) { + $match=$file; + } + } + return $match if defined $match; + + my @try=("debian/$package.$filename"); + if ($package eq $dh{MAINPACKAGE}) { + push @try, "debian/$filename"; + } + + foreach my $file (@try) { + if (-f $file && + (! $dh{IGNORE} || ! exists $dh{IGNORE}->{$file})) { + return $file; + } + + } + + return ""; + +} + +# Pass it a name of a binary package, it returns the name to prefix to files +# in debian/ for this package. +sub pkgext { + my $package=shift; + + if (compat(1) and $package eq $dh{MAINPACKAGE}) { + return ""; + } + return "$package."; +} + +# Pass it the name of a binary package, it returns the name to install +# files by in eg, etc. Normally this is the same, but --name can override +# it. +sub pkgfilename { + my $package=shift; + + if (defined $dh{NAME}) { + return $dh{NAME}; + } + return $package; +} + +# Returns 1 if the package is a native debian package, null otherwise. +# As a side effect, sets $dh{VERSION} to the version of this package. +{ + # Caches return code so it only needs to run dpkg-parsechangelog once. + my %isnative_cache; + + sub isnative { + my $package=shift; + + return $isnative_cache{$package} if defined $isnative_cache{$package}; + + # Make sure we look at the correct changelog. + my $isnative_changelog=pkgfile($package,"changelog"); + if (! $isnative_changelog) { + $isnative_changelog="debian/changelog"; + } + # Get the package version. + my $version=`dpkg-parsechangelog -l$isnative_changelog`; + ($dh{VERSION})=$version=~m/Version:\s*(.*)/m; + # Did the changelog parse fail? + if (! defined $dh{VERSION}) { + error("changelog parse failure"); + } + + # Is this a native Debian package? + if ($dh{VERSION}=~m/.*-/) { + return $isnative_cache{$package}=0; + } + else { + return $isnative_cache{$package}=1; + } + } +} + +# Automatically add a shell script snippet to a debian script. +# Only works if the script has #DEBHELPER# in it. +# +# Parameters: +# 1: package +# 2: script to add to +# 3: filename of snippet +# 4: either text: shell-quoted sed to run on the snippet. Ie, 's/#PACKAGE#/$PACKAGE/' +# or a sub to run on each line of the snippet. Ie sub { s/#PACKAGE#/$PACKAGE/ } +sub autoscript { + my $package=shift; + my $script=shift; + my $filename=shift; + my $sed=shift || ""; + + # This is the file we will modify. + my $outfile="debian/".pkgext($package)."$script.debhelper"; + + # Figure out what shell script snippet to use. + my $infile; + if (defined($ENV{DH_AUTOSCRIPTDIR}) && + -e "$ENV{DH_AUTOSCRIPTDIR}/$filename") { + $infile="$ENV{DH_AUTOSCRIPTDIR}/$filename"; + } + else { + if (-e "$prefix/share/debhelper/autoscripts/$filename") { + $infile="$prefix/share/debhelper/autoscripts/$filename"; + } + else { + error("$prefix/share/debhelper/autoscripts/$filename does not exist"); + } + } + + if (-e $outfile && ($script eq 'postrm' || $script eq 'prerm') + && !compat(5)) { + # Add fragments to top so they run in reverse order when removing. + complex_doit("echo \"# Automatically added by ".basename($0)."\"> $outfile.new"); + autoscript_sed($sed, $infile, "$outfile.new"); + complex_doit("echo '# End automatically added section' >> $outfile.new"); + complex_doit("cat $outfile >> $outfile.new"); + complex_doit("mv $outfile.new $outfile"); + } + else { + complex_doit("echo \"# Automatically added by ".basename($0)."\">> $outfile"); + autoscript_sed($sed, $infile, $outfile); + complex_doit("echo '# End automatically added section' >> $outfile"); + } +} + +sub autoscript_sed { + my $sed = shift; + my $infile = shift; + my $outfile = shift; + if (ref($sed) eq 'CODE') { + open(IN, $infile) or die "$infile: $!"; + open(OUT, ">>$outfile") or die "$outfile: $!"; + while () { $sed->(); print OUT } + close(OUT) or die "$outfile: $!"; + close(IN) or die "$infile: $!"; + } + else { + complex_doit("sed \"$sed\" $infile >> $outfile"); + } +} + +# Removes a whole substvar line. +sub delsubstvar { + my $package=shift; + my $substvar=shift; + + my $ext=pkgext($package); + my $substvarfile="debian/${ext}substvars"; + + if (-e $substvarfile) { + complex_doit("grep -s -v '^${substvar}=' $substvarfile > $substvarfile.new || true"); + doit("mv", "$substvarfile.new","$substvarfile"); + } +} + +# Adds a dependency on some package to the specified +# substvar in a package's substvar's file. +sub addsubstvar { + my $package=shift; + my $substvar=shift; + my $deppackage=shift; + my $verinfo=shift; + my $remove=shift; + + my $ext=pkgext($package); + my $substvarfile="debian/${ext}substvars"; + my $str=$deppackage; + $str.=" ($verinfo)" if defined $verinfo && length $verinfo; + + # Figure out what the line will look like, based on what's there + # now, and what we're to add or remove. + my $line=""; + if (-e $substvarfile) { + my %items; + open(SUBSTVARS_IN, "$substvarfile") || error "read $substvarfile: $!"; + while () { + chomp; + if (/^\Q$substvar\E=(.*)/) { + %items = map { $_ => 1} split(", ", $1); + + last; + } + } + close SUBSTVARS_IN; + if (! $remove) { + $items{$str}=1; + } + else { + delete $items{$str}; + } + $line=join(", ", sort keys %items); + } + elsif (! $remove) { + $line=$str; + } + + if (length $line) { + complex_doit("(grep -s -v ${substvar} $substvarfile; echo ".escape_shell("${substvar}=$line").") > $substvarfile.new"); + doit("mv", "$substvarfile.new", $substvarfile); + } + else { + delsubstvar($package,$substvar); + } +} + +# Reads in the specified file, one line at a time. splits on words, +# and returns an array of arrays of the contents. +# If a value is passed in as the second parameter, then glob +# expansion is done in the directory specified by the parameter ("." is +# frequently a good choice). +sub filedoublearray { + my $file=shift; + my $globdir=shift; + + # executable config files are a v9 thing. + my $x=! compat(8) && -x $file; + if ($x) { + require Cwd; + my $cmd=Cwd::abs_path($file); + open (DH_FARRAY_IN, "$cmd |") || error("cannot run $file: $!"); + } + else { + open (DH_FARRAY_IN, $file) || error("cannot read $file: $!"); + } + + my @ret; + while () { + chomp; + # Only ignore comments and empty lines in v5 mode. + if (! compat(4) && ! $x) { + next if /^#/ || /^$/; + } + my @line; + # Only do glob expansion in v3 mode. + # + # The tricky bit is that the glob expansion is done + # as if we were in the specified directory, so the + # filenames that come out are relative to it. + if (defined $globdir && ! compat(2) && ! $x) { + foreach (map { glob "$globdir/$_" } split) { + s#^$globdir/##; + push @line, $_; + } + } + else { + @line = split; + } + push @ret, [@line]; + } + + close DH_FARRAY_IN || error("problem reading $file: $!"); + + return @ret; +} + +# Reads in the specified file, one word at a time, and returns an array of +# the result. Can do globbing as does filedoublearray. +sub filearray { + return map { @$_ } filedoublearray(@_); +} + +# Passed a filename, returns true if -X says that file should be excluded. +sub excludefile { + my $filename = shift; + foreach my $f (@{$dh{EXCLUDE}}) { + return 1 if $filename =~ /\Q$f\E/; + } + return 0; +} + +{ + my %dpkg_arch_output; + sub dpkg_architecture_value { + my $var = shift; + if (! exists($dpkg_arch_output{$var})) { + local $_; + open(PIPE, '-|', 'dpkg-architecture') + or error("dpkg-architecture failed"); + while () { + chomp; + my ($k, $v) = split(/=/, $_, 2); + $dpkg_arch_output{$k} = $v; + } + close(PIPE); + } + return $dpkg_arch_output{$var}; + } +} + +# Returns the build architecture. +sub buildarch { + dpkg_architecture_value('DEB_HOST_ARCH'); +} + +# Returns the build OS. +sub buildos { + dpkg_architecture_value("DEB_HOST_ARCH_OS"); +} + +# Passed an arch and a list of arches to match against, returns true if matched +{ + my %knownsame; + + sub samearch { + my $arch=shift; + my @archlist=split(/\s+/,shift); + + foreach my $a (@archlist) { + # Avoid expensive dpkg-architecture call to compare + # with a simple architecture name. "linux-any" and + # other architecture wildcards are (currently) + # always hypenated. + if ($a !~ /-/) { + return 1 if $arch eq $a; + } + elsif (exists $knownsame{$arch}{$a}) { + return 1 if $knownsame{$arch}{$a}; + } + elsif (system("dpkg-architecture", "-a$arch", "-i$a") == 0) { + return $knownsame{$arch}{$a}=1; + } + else { + $knownsame{$arch}{$a}=0; + } + } + + return 0; + } +} + +# Returns source package name +sub sourcepackage { + open (CONTROL, 'debian/control') || + error("cannot read debian/control: $!\n"); + while () { + chomp; + s/\s+$//; + if (/^Source:\s*(.*)/) { + close CONTROL; + return $1; + } + } + + close CONTROL; + error("could not find Source: line in control file."); +} + +# Returns a list of packages in the control file. +# Pass "arch" or "indep" to specify arch-dependant (that will be built +# for the system's arch) or independant. If nothing is specified, +# returns all packages. Also, "both" returns the union of "arch" and "indep" +# packages. +# As a side effect, populates %package_arches and %package_types with the +# types of all packages (not only those returned). +my (%package_types, %package_arches); +sub getpackages { + my $type=shift; + + %package_types=(); + %package_arches=(); + + $type="" if ! defined $type; + + my $package=""; + my $arch=""; + my $package_type; + my @list=(); + my %seen; + open (CONTROL, 'debian/control') || + error("cannot read debian/control: $!\n"); + while () { + chomp; + s/\s+$//; + 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"); + } + $package_type="deb"; + } + if (/^Architecture:\s*(.*)/) { + $arch=$1; + } + if (/^(?:X[BC]*-)?Package-Type:\s*(.*)/) { + $package_type=$1; + } + + if (!$_ or eof) { # end of stanza. + if ($package) { + $package_types{$package}=$package_type; + $package_arches{$package}=$arch; + } + + if ($package && + ((($type eq 'indep' || $type eq 'both') && $arch eq 'all') || + (($type eq 'arch' || $type eq 'both') && ($arch eq 'any' || + ($arch ne 'all' && + samearch(buildarch(), $arch)))) || + ! $type)) { + push @list, $package; + $package=""; + $arch=""; + } + } + } + close CONTROL; + + return @list; +} + +# Returns the arch a package will build for. +sub package_arch { + my $package=shift; + + if (! exists $package_arches{$package}) { + warning "package $package is not in control info"; + return buildarch(); + } + return $package_arches{$package} eq 'all' ? "all" : buildarch(); +} + +# Return true if a given package is really a udeb. +sub is_udeb { + my $package=shift; + + if (! exists $package_types{$package}) { + warning "package $package is not in control info"; + return 0; + } + return $package_types{$package} eq 'udeb'; +} + +# Generates the filename that is used for a udeb package. +sub udeb_filename { + my $package=shift; + + my $filearch=package_arch($package); + isnative($package); # side effect + my $version=$dh{VERSION}; + $version=~s/^[0-9]+://; # strip any epoch + return "${package}_${version}_$filearch.udeb"; +} + +# Handles #DEBHELPER# substitution in a script; also can generate a new +# script from scratch if none exists but there is a .debhelper file for it. +sub debhelper_script_subst { + my $package=shift; + my $script=shift; + + my $tmp=tmpdir($package); + my $ext=pkgext($package); + my $file=pkgfile($package,$script); + + if ($file ne '') { + if (-f "debian/$ext$script.debhelper") { + # Add this into the script, where it has #DEBHELPER# + complex_doit("perl -pe 's~#DEBHELPER#~qx{cat debian/$ext$script.debhelper}~eg' < $file > $tmp/DEBIAN/$script"); + } + else { + # Just get rid of any #DEBHELPER# in the script. + complex_doit("sed s/#DEBHELPER#// < $file > $tmp/DEBIAN/$script"); + } + doit("chown","0:0","$tmp/DEBIAN/$script"); + doit("chmod",755,"$tmp/DEBIAN/$script"); + } + elsif ( -f "debian/$ext$script.debhelper" ) { + complex_doit("printf '#!/bin/sh\nset -e\n' > $tmp/DEBIAN/$script"); + complex_doit("cat debian/$ext$script.debhelper >> $tmp/DEBIAN/$script"); + doit("chown","0:0","$tmp/DEBIAN/$script"); + doit("chmod",755,"$tmp/DEBIAN/$script"); + } +} + +# Checks if make's jobserver is enabled via MAKEFLAGS, but +# the FD used to communicate with it is actually not available. +sub is_make_jobserver_unavailable { + if (exists $ENV{MAKEFLAGS} && + $ENV{MAKEFLAGS} =~ /(?:^|\s)--jobserver-fds=(\d+)/) { + if (!open(my $in, "<&$1")) { + return 1; # unavailable + } + else { + close $in; + return 0; # available + } + } + + return; # no jobserver specified +} + +# Cleans out jobserver options from MAKEFLAGS. +sub clean_jobserver_makeflags { + if (exists $ENV{MAKEFLAGS}) { + if ($ENV{MAKEFLAGS} =~ /(?:^|\s)--jobserver-fds=(\d+)/) { + $ENV{MAKEFLAGS} =~ s/(?:^|\s)--jobserver-fds=\S+//g; + $ENV{MAKEFLAGS} =~ s/(?:^|\s)-j\b//g; + } + delete $ENV{MAKEFLAGS} if $ENV{MAKEFLAGS} =~ /^\s*$/; + } +} + +# If cross-compiling, returns appropriate cross version of command. +sub cross_command { + my $command=shift; + if (dpkg_architecture_value("DEB_BUILD_GNU_TYPE") + ne dpkg_architecture_value("DEB_HOST_GNU_TYPE")) { + return dpkg_architecture_value("DEB_HOST_GNU_TYPE")."-$command"; + } + else { + return $command; + } +} + +# Sets environment variables from dpkg-buildflags. Avoids changing +# any existing environment variables. +sub set_buildflags { + return if $ENV{DH_INTERNAL_BUILDFLAGS} || compat(8); + $ENV{DH_INTERNAL_BUILDFLAGS}=1; + + eval "use Dpkg::BuildFlags"; + if ($@) { + warning "unable to load build flags: $@"; + return; + } + + my $buildflags = Dpkg::BuildFlags->new(); + $buildflags->load_config(); + foreach my $flag ($buildflags->list()) { + next unless $flag =~ /^[A-Z]/; # Skip flags starting with lowercase + if (! exists $ENV{$flag}) { + $ENV{$flag} = $buildflags->get($flag); + } + } +} + +# Gets a DEB_BUILD_OPTIONS option, if set. +sub get_buildoption { + my $wanted=shift; + + return undef unless exists $ENV{DEB_BUILD_OPTIONS}; + + foreach my $opt (split(/\s+/, $ENV{DEB_BUILD_OPTIONS})) { + # currently parallel= is the only one with a parameter + if ($opt =~ /^parallel=(-?\d+)$/ && $wanted eq 'parallel') { + return $1; + } + elsif ($opt eq $wanted) { + return 1; + } + } +} + +1 diff --git a/Debian/Debhelper/Sequence/python_support.pm b/Debian/Debhelper/Sequence/python_support.pm new file mode 100644 index 00000000..c93d2126 --- /dev/null +++ b/Debian/Debhelper/Sequence/python_support.pm @@ -0,0 +1,15 @@ +#!/usr/bin/perl +# debhelper sequence file for python-support + +use warnings; +use strict; +use Debian::Debhelper::Dh_Lib; + +# Test if dh_pysupport is available before inserting it. +# (This would not be needed if this file was contained in the python-support +# package.) +if (-x "/usr/bin/dh_pysupport") { + insert_before("dh_installinit", "dh_pysupport"); +} + +1 diff --git a/GPL b/GPL new file mode 100644 index 00000000..d60c31a9 --- /dev/null +++ b/GPL @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..3d2d093a --- /dev/null +++ b/Makefile @@ -0,0 +1,106 @@ +# List of files of dh_* commands. Sorted for debhelper man page. +COMMANDS=$(shell find . -maxdepth 1 -type f -perm /100 -name "dh_*" -printf "%f\n" | sort) + +# Find deprecated commands by looking at their synopsis. +DEPRECATED=$(shell egrep -l '^dh_.* - .*deprecated' $(COMMANDS)) + +# This generates a list of synopses of debhelper commands, and substitutes +# it in to the #LIST# line on the man page fed to it on stdin. Must be passed +# parameters of all the executables or pod files to get the synopses from. +# For correct conversion of pod tags (like S< >) #LIST# must be substituted in +# the pod file and not in the troff file. +MAKEMANLIST=perl -e ' \ + undef $$/; \ + foreach (@ARGV) { \ + open (IN, $$_) or die "$$_: $$!"; \ + $$file=; \ + close IN; \ + if ($$file=~m/=head1 .*?\n\n(.*?) - (.*?)\n\n/s) { \ + my $$item="=item $$1(1)\n\n$$2\n\n"; \ + if (" $(DEPRECATED) " !~ / $$1 /) { \ + $$list.=$$item; \ + } \ + else { \ + $$list_deprecated.=$$item; \ + } \ + } \ + } \ + END { \ + while () { \ + s/\#LIST\#/$$list/; \ + s/\#LIST_DEPRECATED\#/$$list_deprecated/; \ + print; \ + }; \ + }' + +# Figure out the `current debhelper version. +VERSION=$(shell expr "`dpkg-parsechangelog |grep Version:`" : '.*Version: \(.*\)') + +PERLLIBDIR=$(shell perl -MConfig -e 'print $$Config{vendorlib}')/Debian/Debhelper + +PREFIX=/usr + +POD2MAN=pod2man --utf8 -c Debhelper -r "$(VERSION)" + +ifneq ($(USE_NLS),no) +# l10n to be built is determined from .po files +LANGS?=$(notdir $(basename $(wildcard man/po4a/po/*.po))) +else +LANGS= +endif + +build: version debhelper.7 + find . -maxdepth 1 -type f -perm /100 -name "dh*" \ + -exec $(POD2MAN) {} {}.1 \; +ifneq ($(USE_NLS),no) + po4a --previous -L UTF-8 man/po4a/po4a.cfg + set -e; \ + for lang in $(LANGS); do \ + dir=man/$$lang; \ + for file in $$dir/dh*.pod; do \ + prog=`basename $$file | sed 's/.pod//'`; \ + $(POD2MAN) $$file $$prog.$$lang.1; \ + done; \ + if [ -e $$dir/debhelper.pod ]; then \ + cat $$dir/debhelper.pod | \ + $(MAKEMANLIST) `find $$dir -type f -maxdepth 1 -name "dh_*.pod" | sort` | \ + $(POD2MAN) --name="debhelper" --section=7 > debhelper.$$lang.7; \ + fi; \ + done +endif + +version: + printf "package Debian::Debhelper::Dh_Version;\n\$$version='$(VERSION)';\n1" > \ + Debian/Debhelper/Dh_Version.pm + +debhelper.7: debhelper.pod + cat debhelper.pod | \ + $(MAKEMANLIST) $(COMMANDS) | \ + $(POD2MAN) --name="debhelper" --section=7 > debhelper.7 + +clean: + rm -f *.1 *.7 Debian/Debhelper/Dh_Version.pm +ifneq ($(USE_NLS),no) + po4a --previous --rm-translations --rm-backups man/po4a/po4a.cfg +endif + for lang in $(LANGS); do \ + if [ -e man/$$lang ]; then rmdir man/$$lang; fi; \ + done; + +install: + install -d $(DESTDIR)$(PREFIX)/bin \ + $(DESTDIR)$(PREFIX)/share/debhelper/autoscripts \ + $(DESTDIR)$(PERLLIBDIR)/Sequence \ + $(DESTDIR)$(PERLLIBDIR)/Buildsystem + install dh $(COMMANDS) $(DESTDIR)$(PREFIX)/bin + install -m 0644 autoscripts/* $(DESTDIR)$(PREFIX)/share/debhelper/autoscripts + install -m 0644 Debian/Debhelper/*.pm $(DESTDIR)$(PERLLIBDIR) + [ "$(PREFIX)" = /usr ] || \ + sed -i '/$$prefix=/s@/usr@$(PREFIX)@g' $(DESTDIR)$(PERLLIBDIR)/Dh_Lib.pm + install -m 0644 Debian/Debhelper/Sequence/*.pm $(DESTDIR)$(PERLLIBDIR)/Sequence + install -m 0644 Debian/Debhelper/Buildsystem/*.pm $(DESTDIR)$(PERLLIBDIR)/Buildsystem + +test: version + ./run perl -MTest::Harness -e 'runtests grep { ! /CVS/ && ! /\.svn/ && -f && -x } @ARGV' t/* t/buildsystems/* + # clean up log etc + ./run dh_clean diff --git a/autoscripts/maintscript-helper b/autoscripts/maintscript-helper new file mode 100644 index 00000000..c7e06c46 --- /dev/null +++ b/autoscripts/maintscript-helper @@ -0,0 +1 @@ +dpkg-maintscript-helper #PARAMS# -- "$@" diff --git a/autoscripts/postinst-emacsen b/autoscripts/postinst-emacsen new file mode 100644 index 00000000..f80e1dbd --- /dev/null +++ b/autoscripts/postinst-emacsen @@ -0,0 +1,4 @@ +if [ "$1" = "configure" ] && [ -x /usr/lib/emacsen-common/emacs-package-install ] +then + /usr/lib/emacsen-common/emacs-package-install #PACKAGE# +fi diff --git a/autoscripts/postinst-icons b/autoscripts/postinst-icons new file mode 100644 index 00000000..9e00f039 --- /dev/null +++ b/autoscripts/postinst-icons @@ -0,0 +1,3 @@ +if which update-icon-caches >/dev/null 2>&1 ; then + update-icon-caches #DIRLIST# +fi diff --git a/autoscripts/postinst-init b/autoscripts/postinst-init new file mode 100644 index 00000000..2430b2c0 --- /dev/null +++ b/autoscripts/postinst-init @@ -0,0 +1,4 @@ +if [ -x "/etc/init.d/#SCRIPT#" ]; then + update-rc.d #SCRIPT# #INITPARMS# >/dev/null + invoke-rc.d #SCRIPT# start || #ERROR_HANDLER# +fi diff --git a/autoscripts/postinst-init-nostart b/autoscripts/postinst-init-nostart new file mode 100644 index 00000000..7a1bd5e8 --- /dev/null +++ b/autoscripts/postinst-init-nostart @@ -0,0 +1,3 @@ +if [ -x "/etc/init.d/#SCRIPT#" ]; then + update-rc.d #SCRIPT# #INITPARMS# >/dev/null || #ERROR_HANDLER# +fi diff --git a/autoscripts/postinst-init-restart b/autoscripts/postinst-init-restart new file mode 100644 index 00000000..35bba207 --- /dev/null +++ b/autoscripts/postinst-init-restart @@ -0,0 +1,9 @@ +if [ -x "/etc/init.d/#SCRIPT#" ]; then + update-rc.d #SCRIPT# #INITPARMS# >/dev/null + if [ -n "$2" ]; then + _dh_action=restart + else + _dh_action=start + fi + invoke-rc.d #SCRIPT# $_dh_action || #ERROR_HANDLER# +fi diff --git a/autoscripts/postinst-init-tmpfiles b/autoscripts/postinst-init-tmpfiles new file mode 100644 index 00000000..fd613bcd --- /dev/null +++ b/autoscripts/postinst-init-tmpfiles @@ -0,0 +1,5 @@ +# In case this system is running systemd, we need to ensure that all +# necessary tmpfiles (if any) are created before starting. +if [ -d /run/systemd/system ] ; then + systemd-tmpfiles --create #TMPFILES# >/dev/null || true +fi diff --git a/autoscripts/postinst-makeshlibs b/autoscripts/postinst-makeshlibs new file mode 100644 index 00000000..8a25b9e9 --- /dev/null +++ b/autoscripts/postinst-makeshlibs @@ -0,0 +1,3 @@ +if [ "$1" = "configure" ]; then + ldconfig +fi diff --git a/autoscripts/postinst-menu b/autoscripts/postinst-menu new file mode 100644 index 00000000..b56a3462 --- /dev/null +++ b/autoscripts/postinst-menu @@ -0,0 +1,3 @@ +if [ "$1" = "configure" ] && [ -x "`which update-menus 2>/dev/null`" ]; then + update-menus +fi diff --git a/autoscripts/postinst-menu-method b/autoscripts/postinst-menu-method new file mode 100644 index 00000000..c56d6258 --- /dev/null +++ b/autoscripts/postinst-menu-method @@ -0,0 +1,7 @@ +inst=/etc/menu-methods/#PACKAGE# +if [ -f $inst ]; then + chmod a+x $inst + if [ -x "`which update-menus 2>/dev/null`" ]; then + update-menus + fi +fi diff --git a/autoscripts/postinst-modules b/autoscripts/postinst-modules new file mode 100644 index 00000000..f17dc2da --- /dev/null +++ b/autoscripts/postinst-modules @@ -0,0 +1,5 @@ +if [ "$1" = "configure" ]; then + if [ -e /boot/System.map-#KVERS# ]; then + depmod -a -F /boot/System.map-#KVERS# #KVERS# || true + fi +fi diff --git a/autoscripts/postinst-moveconffile b/autoscripts/postinst-moveconffile new file mode 100644 index 00000000..28f061e3 --- /dev/null +++ b/autoscripts/postinst-moveconffile @@ -0,0 +1,9 @@ +if [ "$1" = configure ]; then + if [ -e "#OLD#" ]; then + echo "Preserving user changes to #NEW# ..." + if [ -e "#NEW#" ]; then + mv -f "#NEW#" "#NEW#.dpkg-new" + fi + mv -f "#OLD#" "#NEW#" + fi +fi diff --git a/autoscripts/postinst-python b/autoscripts/postinst-python new file mode 100644 index 00000000..5a1943eb --- /dev/null +++ b/autoscripts/postinst-python @@ -0,0 +1,7 @@ +PYTHON=#PYVER# +if which $PYTHON >/dev/null 2>&1 && [ -e /usr/lib/$PYTHON/compileall.py ]; then + DIRLIST="#DIRLIST#" + for i in $DIRLIST ; do + $PYTHON /usr/lib/$PYTHON/compileall.py -q $i + done +fi diff --git a/autoscripts/postinst-suid b/autoscripts/postinst-suid new file mode 100644 index 00000000..db4bc6dd --- /dev/null +++ b/autoscripts/postinst-suid @@ -0,0 +1,8 @@ +if [ "$1" = "configure" ]; then + if which suidregister >/dev/null 2>&1 && [ -e /etc/suid.conf ]; then + suidregister -s #PACKAGE# /#FILE# #OWNER# #GROUP# #PERMS# + elif [ -e /#FILE# ]; then + chown #OWNER#:#GROUP# /#FILE# + chmod #PERMS# /#FILE# + fi +fi diff --git a/autoscripts/postinst-ucf b/autoscripts/postinst-ucf new file mode 100644 index 00000000..05468310 --- /dev/null +++ b/autoscripts/postinst-ucf @@ -0,0 +1,4 @@ +if [ "$1" = "configure" ]; then + ucf "#UCFSRC#" "#UCFDEST#" + ucfr #PACKAGE# "#UCFDEST#" +fi diff --git a/autoscripts/postinst-usrlocal b/autoscripts/postinst-usrlocal new file mode 100644 index 00000000..a2f004db --- /dev/null +++ b/autoscripts/postinst-usrlocal @@ -0,0 +1,16 @@ +if [ "$1" = configure ]; then +( + while read line; do + set -- $line + dir="$1"; mode="$2"; user="$3"; group="$4" + if [ ! -e "$dir" ]; then + if mkdir "$dir" 2>/dev/null; then + chown "$user":"$group" "$dir" + chmod "$mode" "$dir" + fi + fi + done +) << DATA +#DIRS# +DATA +fi diff --git a/autoscripts/postinst-wm b/autoscripts/postinst-wm new file mode 100644 index 00000000..ee636287 --- /dev/null +++ b/autoscripts/postinst-wm @@ -0,0 +1,6 @@ +if [ "$1" = "configure" ]; then + update-alternatives --install /usr/bin/x-window-manager \ + x-window-manager #WM# #PRIORITY# \ + --slave /usr/share/man/man1/x-window-manager.1.gz \ + x-window-manager.1.gz #WMMAN# +fi diff --git a/autoscripts/postinst-wm-noman b/autoscripts/postinst-wm-noman new file mode 100644 index 00000000..aef412a3 --- /dev/null +++ b/autoscripts/postinst-wm-noman @@ -0,0 +1,4 @@ +if [ "$1" = "configure" ]; then + update-alternatives --install /usr/bin/x-window-manager \ + x-window-manager #WM# #PRIORITY# +fi diff --git a/autoscripts/postinst-xfonts b/autoscripts/postinst-xfonts new file mode 100644 index 00000000..96390e4e --- /dev/null +++ b/autoscripts/postinst-xfonts @@ -0,0 +1,3 @@ +if which update-fonts-dir >/dev/null 2>&1; then + #CMDS# +fi diff --git a/autoscripts/postrm-debconf b/autoscripts/postrm-debconf new file mode 100644 index 00000000..5a61724d --- /dev/null +++ b/autoscripts/postrm-debconf @@ -0,0 +1,4 @@ +if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then + . /usr/share/debconf/confmodule + db_purge +fi diff --git a/autoscripts/postrm-icons b/autoscripts/postrm-icons new file mode 100644 index 00000000..9e00f039 --- /dev/null +++ b/autoscripts/postrm-icons @@ -0,0 +1,3 @@ +if which update-icon-caches >/dev/null 2>&1 ; then + update-icon-caches #DIRLIST# +fi diff --git a/autoscripts/postrm-init b/autoscripts/postrm-init new file mode 100644 index 00000000..6f5bb09a --- /dev/null +++ b/autoscripts/postrm-init @@ -0,0 +1,10 @@ +if [ "$1" = "purge" ] ; then + update-rc.d #SCRIPT# remove >/dev/null +fi + + +# In case this system is running systemd, we make systemd reload the unit files +# to pick up changes. +if [ -d /run/systemd/system ] ; then + systemctl --system daemon-reload >/dev/null || true +fi diff --git a/autoscripts/postrm-makeshlibs b/autoscripts/postrm-makeshlibs new file mode 100644 index 00000000..96bf24ed --- /dev/null +++ b/autoscripts/postrm-makeshlibs @@ -0,0 +1,3 @@ +if [ "$1" = "remove" ]; then + ldconfig +fi diff --git a/autoscripts/postrm-menu b/autoscripts/postrm-menu new file mode 100644 index 00000000..a180558d --- /dev/null +++ b/autoscripts/postrm-menu @@ -0,0 +1 @@ +if [ -x "`which update-menus 2>/dev/null`" ]; then update-menus ; fi diff --git a/autoscripts/postrm-menu-method b/autoscripts/postrm-menu-method new file mode 100644 index 00000000..ffa1e486 --- /dev/null +++ b/autoscripts/postrm-menu-method @@ -0,0 +1,3 @@ +inst=/etc/menu-methods/#PACKAGE# +if [ "$1" = "remove" ] && [ -f "$inst" ]; then chmod a-x $inst ; fi +if [ -x "`which update-menus 2>/dev/null`" ]; then update-menus ; fi diff --git a/autoscripts/postrm-modules b/autoscripts/postrm-modules new file mode 100644 index 00000000..c2577dd2 --- /dev/null +++ b/autoscripts/postrm-modules @@ -0,0 +1,3 @@ +if [ -e /boot/System.map-#KVERS# ]; then + depmod -a -F /boot/System.map-#KVERS# #KVERS# || true +fi diff --git a/autoscripts/postrm-sgmlcatalog b/autoscripts/postrm-sgmlcatalog new file mode 100644 index 00000000..f8278e68 --- /dev/null +++ b/autoscripts/postrm-sgmlcatalog @@ -0,0 +1,3 @@ +if [ "$1" = "purge" ]; then + rm -f #CENTRALCAT#.old +fi diff --git a/autoscripts/postrm-suid b/autoscripts/postrm-suid new file mode 100644 index 00000000..a4cfecf9 --- /dev/null +++ b/autoscripts/postrm-suid @@ -0,0 +1,4 @@ +if [ "$1" = remove ] && [ -e /etc/suid.conf ] && \ + which suidunregister >/dev/null 2>&1; then + suidunregister -s #PACKAGE# /#FILE# +fi diff --git a/autoscripts/postrm-ucf b/autoscripts/postrm-ucf new file mode 100644 index 00000000..da375726 --- /dev/null +++ b/autoscripts/postrm-ucf @@ -0,0 +1,12 @@ +if [ "$1" = "purge" ]; then + for ext in .ucf-new .ucf-old .ucf-dist ""; do + rm -f "#UCFDEST#$ext" + done + + if [ -x "`which ucf 2>/dev/null`" ]; then + ucf --purge "#UCFDEST#" + fi + if [ -x "`which ucfr 2>/dev/null`" ]; then + ucfr --purge #PACKAGE# "#UCFDEST#" + fi +fi diff --git a/autoscripts/postrm-xfonts b/autoscripts/postrm-xfonts new file mode 100644 index 00000000..cd476a3d --- /dev/null +++ b/autoscripts/postrm-xfonts @@ -0,0 +1,3 @@ +if [ -x "`which update-fonts-dir 2>/dev/null`" ]; then + #CMDS# +fi diff --git a/autoscripts/preinst-moveconffile b/autoscripts/preinst-moveconffile new file mode 100644 index 00000000..619b4cef --- /dev/null +++ b/autoscripts/preinst-moveconffile @@ -0,0 +1,9 @@ +if [ "$1" = install ] || [ "$1" = upgrade ]; then + if [ -e "#OLD#" ]; then + if [ "`md5sum \"#OLD#\" | sed -e \"s/ .*//\"`" = \ + "`dpkg-query -W -f='${Conffiles}' #PACKAGE# | sed -n -e \"\\\\' #OLD# '{s/ obsolete$//;s/.* //p}\"`" ] + then + rm -f "#OLD#" + fi + fi +fi diff --git a/autoscripts/preinst-sgmlcatalog b/autoscripts/preinst-sgmlcatalog new file mode 100644 index 00000000..96f06738 --- /dev/null +++ b/autoscripts/preinst-sgmlcatalog @@ -0,0 +1,8 @@ +if test -f #CENTRALCAT# -a "(" "$1" = "upgrade" -o "$1" = "install" -a -n "$2" ")" && + ! dpkg-query -S #CENTRALCAT# >/dev/null 2>&1; then + # If the dpkg-query command returns non-zero, the central catalog is + # not owned by any package. This is due to an old behaviour of + # debhelper. Now that file becomes a conffile. In order to avoid a + # question during installation, we remove the old non-conffile. + mv #CENTRALCAT# #CENTRALCAT#.old +fi diff --git a/autoscripts/prerm-emacsen b/autoscripts/prerm-emacsen new file mode 100644 index 00000000..8c3ca64c --- /dev/null +++ b/autoscripts/prerm-emacsen @@ -0,0 +1,3 @@ +if [ -x /usr/lib/emacsen-common/emacs-package-remove ] ; then + /usr/lib/emacsen-common/emacs-package-remove #PACKAGE# +fi diff --git a/autoscripts/prerm-init b/autoscripts/prerm-init new file mode 100644 index 00000000..2a8aa4c6 --- /dev/null +++ b/autoscripts/prerm-init @@ -0,0 +1,3 @@ +if [ -x "/etc/init.d/#SCRIPT#" ]; then + invoke-rc.d #SCRIPT# stop || #ERROR_HANDLER# +fi diff --git a/autoscripts/prerm-init-norestart b/autoscripts/prerm-init-norestart new file mode 100644 index 00000000..cacde6e3 --- /dev/null +++ b/autoscripts/prerm-init-norestart @@ -0,0 +1,3 @@ +if [ -x "/etc/init.d/#SCRIPT#" ] && [ "$1" = remove ]; then + invoke-rc.d #SCRIPT# stop || #ERROR_HANDLER# +fi diff --git a/autoscripts/prerm-python b/autoscripts/prerm-python new file mode 100644 index 00000000..e6e779f8 --- /dev/null +++ b/autoscripts/prerm-python @@ -0,0 +1,3 @@ +dpkg -L #PACKAGE# | + awk '$0~/\.py$/ {print $0"c\n" $0"o"}' | + xargs rm -f >&2 diff --git a/autoscripts/prerm-usrlocal b/autoscripts/prerm-usrlocal new file mode 100644 index 00000000..baafc23e --- /dev/null +++ b/autoscripts/prerm-usrlocal @@ -0,0 +1,7 @@ +( + while read dir; do + rmdir "$dir" 2>/dev/null || true + done +) << DATA +#JUSTDIRS# +DATA diff --git a/autoscripts/prerm-wm b/autoscripts/prerm-wm new file mode 100644 index 00000000..b97d627f --- /dev/null +++ b/autoscripts/prerm-wm @@ -0,0 +1,3 @@ +if [ "$1" = "remove" ]; then + update-alternatives --remove x-window-manager #WM# +fi diff --git a/debhelper.pod b/debhelper.pod new file mode 100644 index 00000000..216360b2 --- /dev/null +++ b/debhelper.pod @@ -0,0 +1,701 @@ +=head1 NAME + +debhelper - the debhelper tool suite + +=head1 SYNOPSIS + +BI<*> [B<-v>] [B<-a>] [B<-i>] [B<-s>] [B<--no-act>] [B<-p>I] [B<-N>I] [B<-P>I] + +=head1 DESCRIPTION + +Debhelper is used to help you build a Debian package. The philosophy behind +debhelper is to provide a collection of small, simple, and easily +understood tools that are used in F to automate various common +aspects of building a package. This means less work for you, the packager. +It also, to some degree means that these tools can be changed if Debian +policy changes, and packages that use them will require only a rebuild to +comply with the new policy. + +A typical F file that uses debhelper will call several debhelper +commands in sequence, or use L to automate this process. Examples of +rules files that use debhelper are in F + +To create a new Debian package using debhelper, you can just copy one of +the sample rules files and edit it by hand. Or you can try the B +package, which contains a L command that partially +automates the process. For a more gentle introduction, the B Debian +package contains a tutorial about making your first package using debhelper. + +=head1 DEBHELPER COMMANDS + +Here is the list of debhelper commands you can use. See their man +pages for additional documentation. + +=over 4 + +#LIST# + +=back + +=head2 Deprecated Commands + +A few debhelper commands are deprecated and should not be used. + +=over 4 + +#LIST_DEPRECATED# + +=back + +=head2 Other Commands + +If a program's name starts with B, and the program is not on the above +lists, then it is not part of the debhelper package, but it should still +work like the other programs described on this page. + +=head1 DEBHELPER CONFIG FILES + +Many debhelper commands make use of files in F to control what they +do. Besides the common F and F, which are +in all packages, not just those using debhelper, some additional files can +be used to configure the behavior of specific debhelper commands. These +files are typically named debian/I.foo (where I of course, +is replaced with the package that is being acted on). + +For example, B uses files named F to list +the documentation files it will install. See the man pages of individual +commands for details about the names and formats of the files they use. +Generally, these files will list files to act on, one file per line. Some +programs in debhelper use pairs of files and destinations or slightly more +complicated formats. + +Note for the first (or only) binary package listed in +F, debhelper will use F when there's no +F file. + +In some rare cases, you may want to have different versions of these files +for different architectures or OSes. If files named debian/I.foo.I +or debian/I.foo.I exist, where I and I are the same as the +output of "B" / +"B", +then they will be used in preference to other, more general files. + +Mostly, these config files are used to specify lists of various types of +files. Documentation or example files to install, files to move, and so on. +When appropriate, in cases like these, you can use standard shell wildcard +characters (B and B<*> and B<[>I<..>B<]> character classes) in the files. +You can also put comments in these files; lines beginning with B<#> are +ignored. + +The syntax of these files is intentionally kept very simple to make them +easy to read, understand, and modify. If you prefer power and complexity, +you can make the file executable, and write a program that outputs +whatever content is appropriate for a given situation. When you do so, +the output is not further processed to expand wildcards or strip comments. + +=head1 SHARED DEBHELPER OPTIONS + +The following command line options are supported by all debhelper programs. + +=over 4 + +=item B<-v>, B<--verbose> + +Verbose mode: show all commands that modify the package build directory. + +=item B<--no-act> + +Do not really do anything. If used with -v, the result is that the command +will output what it would have done. + +=item B<-a>, B<--arch> + +Act on architecture dependent packages that should be built for the +build architecture. + +=item B<-i>, B<--indep> + +Act on all architecture independent packages. + +=item B<-p>I, B<--package=>I + +Act on the package named I. This option may be specified multiple +times to make debhelper operate on a given set of packages. + +=item B<-s>, B<--same-arch> + +This used to be a smarter version of the B<-a> flag, but the B<-a> flag is now +equally smart. + +=item B<-N>I, B<--no-package=>I + +Do not act on the specified package even if an B<-a>, B<-i>, or B<-p> option lists +the package as one that should be acted on. + +=item B<--remaining-packages> + +Do not act on the packages which have already been acted on by this debhelper +command earlier (i.e. if the command is present in the package debhelper log). +For example, if you need to call the command with special options only for a +couple of binary packages, pass this option to the last call of the command to +process the rest of packages with default settings. + +=item B<--ignore=>I + +Ignore the specified file. This can be used if F contains a debhelper +config file that a debhelper command should not act on. Note that +F, F, and F can't be ignored, but +then, there should never be a reason to ignore those files. + +For example, if upstream ships a F that you don't want +B to install, use B<--ignore=debian/init> + +=item B<-P>I, B<--tmpdir=>I + +Use I for package build directory. The default is debian/I + +=item B<--mainpackage=>I + +This little-used option changes the package which debhelper considers the +"main package", that is, the first one listed in F, and the +one for which F files can be used instead of the usual +F files. + +=item B<-O=>I