]> git.donarmstrong.com Git - debhelper.git/blobdiff - Debian/Debhelper/Dh_Lib.pm
If neither -a or -i are specified, debhelper commands used to default to acting on...
[debhelper.git] / Debian / Debhelper / Dh_Lib.pm
index ac0d8ab4a05f7ea6f7aa317b8202b7471ab60bec..b96ea3443091b77465c0a093dba9d7172ce8d7a2 100644 (file)
@@ -16,7 +16,8 @@ use vars qw(@ISA @EXPORT %dh);
            &compat &addsubstvar &delsubstvar &excludefile &package_arch
            &is_udeb &udeb_filename &debhelper_script_subst &escape_shell
            &inhibit_log &load_log &write_log &dpkg_architecture_value
-           &sourcepackage &is_make_jobserver_unavailable &clean_makeflags);
+           &sourcepackage
+           &is_make_jobserver_unavailable &clean_jobserver_makeflags);
 
 my $max_compat=7;
 
@@ -32,7 +33,7 @@ sub init {
            grep /^-/, @ARGV) {
                eval "use Debian::Debhelper::Dh_Getopt";
                error($@) if $@;
-               Debian::Debhelper::Dh_Getopt::parseopts($params{options});
+               Debian::Debhelper::Dh_Getopt::parseopts(%params);
        }
 
        # Another way to set excludes.
@@ -75,7 +76,7 @@ sub init {
        # Check if packages to build have been specified, if not, fall back to
        # the default, doing them all.
        if (! defined $dh{DOPACKAGES} || ! @{$dh{DOPACKAGES}}) {
-               push @{$dh{DOPACKAGES}},@allpackages;
+               push @{$dh{DOPACKAGES}}, getpackages('both');
        }
 
        # Check to see if -P was specified. If so, we can only act on a single
@@ -250,12 +251,11 @@ sub verbose_print {
        }
 }
 
-# Output an error message and exit.
+# Output an error message and die (can be caught).
 sub error {
        my $message=shift;
 
-       warning($message);
-       exit 1;
+       die basename($0).": $message\n";
 }
 
 # Output a warning.
@@ -312,7 +312,7 @@ sub dirname {
                        }
                }
 
-               if ($c < 4 && ! $warned_compat) {
+               if ($c <= 4 && ! $warned_compat) {
                        warning("Compatibility levels before 5 are deprecated.");
                        $warned_compat=1;
                }
@@ -576,7 +576,7 @@ sub filedoublearray {
                # as if we were in the specified directory, so the
                # filenames that come out are relative to it.
                if (defined $globdir && ! compat(2)) {
-                       for (map { glob "$globdir/$_" } split) {
+                       foreach (map { glob "$globdir/$_" } split) {
                                s#^$globdir/##;
                                push @line, $_;
                        }
@@ -667,8 +667,10 @@ sub sourcepackage {
 }
 
 # Returns a list of packages in the control file.
-# Pass "arch" or "indep" to specify arch-dependant or
-# independant. If nothing is specified, returns all packages.
+# 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);
@@ -715,8 +717,8 @@ sub getpackages {
                        }
 
                        if ($package &&
-                           (($type eq 'indep' && $arch eq 'all') ||
-                            ($type eq 'arch' && ($arch eq 'any' ||
+                           ((($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)) {
@@ -811,16 +813,13 @@ sub is_make_jobserver_unavailable {
        return; # no jobserver specified
 }
 
-# Cleans out job control options from MAKEFLAGS.
-sub clean_makeflags {
+# 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;
                }
-               else {
-                       $ENV{MAKEFLAGS} =~ s/(?:^|\s)(?:(?:-j\s*|--jobs(?:=|\s+))(\d+)?|--jobs)\b//g;
-               }
                delete $ENV{MAKEFLAGS} if $ENV{MAKEFLAGS} =~ /^\s*$/;
        }
 }