]> git.donarmstrong.com Git - debhelper.git/commitdiff
Add dpkg_architecture_value and sourcepackage to Dh_Lib
authorModestas Vainius <modestas@vainius.eu>
Mon, 23 Mar 2009 19:32:43 +0000 (21:32 +0200)
committerJoey Hess <joey@gnu.kitenet.net>
Fri, 10 Apr 2009 20:03:34 +0000 (16:03 -0400)
Both these function are taken from dh_auto_configure. I believe they
are useful enough to be in Dh_Lib (esp. dpkg_architecture_value()).

The patch removes these funtions from dh_auto_configure too.

Signed-off-by: Modestas Vainius <modestas@vainius.eu>
Debian/Debhelper/Dh_Lib.pm
dh_auto_configure

index b57c4d97d15c66faf1fb166ed82ca0c1480c7010..f0ad505b1a1fd4a9a19fca6ec002e5f9fcba2962 100644 (file)
@@ -15,7 +15,8 @@ use vars qw(@ISA @EXPORT %dh);
            &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);
+           &inhibit_log &load_log &write_log &dpkg_architecture_value
+           &sourcepackage);
 
 my $max_compat=7;
 
@@ -600,15 +601,21 @@ sub excludefile {
         return 0;
 }
 
+sub dpkg_architecture_value {
+       my $var = shift;
+       my $value=`dpkg-architecture -q$var 2>/dev/null` || error("dpkg-architecture failed");
+       chomp $value;
+       return $value;
+}
+
 # Returns the build architecture. (Memoized)
 {
        my $arch;
        
        sub buildarch {
-               return $arch if defined $arch;
-
-               $arch=`dpkg-architecture -qDEB_HOST_ARCH 2>/dev/null` || error("dpkg-architecture failed");
-               chomp $arch;
+               if (!defined $arch) {
+                   $arch=dpkg_architecture_value('DEB_HOST_ARCH');
+               }
                return $arch;
        }
 }
@@ -625,6 +632,23 @@ sub samearch {
        return 0;
 }
 
+# Returns source package name
+sub sourcepackage {
+       open (CONTROL, 'debian/control') ||
+           error("cannot read debian/control: $!\n");
+       while (<CONTROL>) {
+               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.
 # Must pass "arch" or "indep" or "same" to specify arch-dependant or
 # -independant or same arch packages. If nothing is specified, returns all
index 41f6210fb29cce210fa902cf7ef969e5bcc4060a..0445c34395231791287ea747655dcdda37fcc780 100755 (executable)
@@ -40,29 +40,6 @@ or override the standard parameters that dh_auto_configure passes.
 
 init();
 
-sub dpkg_architecture_value {
-       my $var=shift;
-       my $value=`dpkg-architecture -q$var 2>/dev/null` || error("dpkg-architecture failed");
-       chomp $value;
-       return $value;
-}
-
-sub sourcepackage {
-       open (CONTROL, 'debian/control') ||
-               error("cannot read debian/control: $!\n");
-       while (<CONTROL>) {
-               chomp;
-               s/\s+$//;
-               if (/^Source:\s*(.*)/) {
-                       close CONTROL;
-                       return $1;
-               }
-       }
-
-       close CONTROL;
-       error("could not find Source: line in control file.");
-}
-
 if (-x "configure") {
        # Standard set of options for configure.
        my @opts;