&pkgfile &pkgext &pkgfilename &isnative &autoscript &filearray
&filedoublearray &getpackages &basename &dirname &xargs %dh
&compat &addsubstvar &delsubstvar &excludefile &package_arch
- &is_udeb &udeb_filename);
+ &is_udeb &udeb_filename &debhelper_script_subst &escape_shell);
-my $max_compat=4;
+my $max_compat=5;
sub init {
# If DH_OPTIONS is set, prepend it @ARGV.
my $x=$_;
$x=escape_shell($x);
$x=~s/\./\\./g;
- $dh{EXCLUDE_FIND}.="-regex .*$x.* -or ";
+ $dh{EXCLUDE_FIND}.="-regex .\\*$x.\\* -or ";
}
$dh{EXCLUDE_FIND}=~s/ -or $//;
}
# Pass in a number, will return true iff the current compatibility level
# is less than or equal to that number.
-sub compat {
- my $num=shift;
+{
+ my $warned_compat=0;
+ my $c;
+
+ sub compat {
+ my $num=shift;
- my $c=1;
- if (defined $ENV{DH_COMPAT}) {
- $c=$ENV{DH_COMPAT};
- }
- elsif (-e 'debian/compat') {
- # Try the file..
- open (COMPAT_IN, "debian/compat") || error "debian/compat: $!";
- my $l=<COMPAT_IN>;
- if (! defined $l || ! length $l) {
- warning("debian/compat is empty, assuming level $c");
+ if (! defined $c) {
+ $c=1;
+ if (defined $ENV{DH_COMPAT}) {
+ $c=$ENV{DH_COMPAT};
+ }
+ elsif (-e 'debian/compat') {
+ # Try the file..
+ open (COMPAT_IN, "debian/compat") || error "debian/compat: $!";
+ my $l=<COMPAT_IN>;
+ if (! defined $l || ! length $l) {
+ warning("debian/compat is empty, assuming level $c");
+ }
+ else {
+ chomp $l;
+ $c=$l;
+ }
+ }
}
- else {
- chomp $l;
- $c=$l
+
+ if ($c < 4 && ! $warned_compat) {
+ warning("Compatibility levels before 4 are deprecated.");
+ $warned_compat=1;
+ }
+
+ if ($c > $max_compat) {
+ error("Sorry, but $max_compat is the highest compatibility level supported by this debhelper.");
}
- }
- if ($c > $max_compat) {
- error("Sorry, but $max_compat is the highest compatibility level of debhelper currently supported.");
+ return ($c <= $num);
}
-
- return ($c <= $num);
}
# Pass it a name of a binary package, it returns the name of the tmp dir to
my @ret;
open (DH_FARRAY_IN, $file) || error("cannot read $file: $1");
while (<DH_FARRAY_IN>) {
+ chomp;
+ # Only ignore comments and empty lines in v5 mode.
+ if (! compat(4)) {
+ next if /^#/ || /^$/;
+ }
my @line;
# Only do glob expansion in v3 mode.
#
return @list;
}
+# Returns the arch a package will build for.
sub package_arch {
my $package=shift;
return $package_arches{$package} eq 'all' ? "all" : buildarch();
}
+# Return true if a given package is really a udeb.
sub is_udeb {
my $package=shift;
return $package_types{$package} eq 'udeb';
}
+# Generates the filename that is used for a udeb package.
sub udeb_filename {
my $package=shift;
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");
+ }
+}
+
1