Explorar o código

Dpkg::Arch: Make the host gnu type retrieval more compiler agnostic

Rename get_gcc_host_gnu_type() to get_host_gnu_type(), and use a hash to
store the values per compiler name, so that we can keep track of different
output depending on the compiler selected.

Update the warning messages to not assume that CC is pointing to gcc.
Guillem Jover %!s(int64=10) %!d(string=hai) anos
pai
achega
db5de20692
Modificáronse 3 ficheiros con 28 adicións e 23 borrados
  1. 2 0
      debian/changelog
  2. 21 18
      scripts/Dpkg/Arch.pm
  3. 5 5
      scripts/dpkg-architecture.pl

+ 2 - 0
debian/changelog

@@ -13,6 +13,8 @@ dpkg (1.18.4) UNRELEASED; urgency=low
     block, to unify the code an allow a future switch into a shared library.
   * Perform any necessary cleanups on normal exit from dpkg-divert --add and
     --remove commands.
+  * Make dpkg-architecture warning on non-matching GNU system type compiler
+    agnostic.
   * Build system:
     - Set PERL5LIB globally for the test suite to the local modules directory,
       to avoid using the system modules. Regression introduced in dpkg 1.17.8.

+ 21 - 18
scripts/Dpkg/Arch.pm

@@ -38,7 +38,7 @@ our @EXPORT_OK = qw(
     get_raw_host_arch
     get_build_arch
     get_host_arch
-    get_gcc_host_gnu_type
+    get_host_gnu_type
     get_valid_arches
     debarch_eq
     debarch_is
@@ -115,27 +115,30 @@ sub get_build_arch()
 }
 
 {
-    my $gcc_host_gnu_type;
+    my %cc_host_gnu_type;
 
-    sub get_gcc_host_gnu_type()
+    sub get_host_gnu_type()
     {
-	return $gcc_host_gnu_type if defined $gcc_host_gnu_type;
+        my $CC = $ENV{CC} || 'gcc';
 
-	$gcc_host_gnu_type = qx(\${CC:-gcc} -dumpmachine);
+        return $cc_host_gnu_type{$CC} if defined $cc_host_gnu_type{$CC};
+
+        $cc_host_gnu_type{$CC} = qx($CC -dumpmachine);
 	if ($? >> 8) {
-	    $gcc_host_gnu_type = '';
+            $cc_host_gnu_type{$CC} = '';
 	} else {
-	    chomp $gcc_host_gnu_type;
+            chomp $cc_host_gnu_type{$CC};
 	}
 
-	return $gcc_host_gnu_type;
+        return $cc_host_gnu_type{$CC};
     }
 
     sub set_host_gnu_type
     {
         my ($host_gnu_type) = @_;
+        my $CC = $ENV{CC} || 'gcc';
 
-        $gcc_host_gnu_type = $host_gnu_type;
+        $cc_host_gnu_type{$CC} = $host_gnu_type;
     }
 }
 
@@ -152,23 +155,23 @@ sub get_raw_host_arch()
 
     return $host_arch if defined $host_arch;
 
-    $gcc_host_gnu_type = get_gcc_host_gnu_type();
+    my $host_gnu_type = get_host_gnu_type();
 
-    if ($gcc_host_gnu_type eq '') {
-        warning(g_("couldn't determine gcc system type, falling back to " .
+    if ($host_gnu_type eq '') {
+        warning(g_('cannot determine CC system type, falling back to ' .
                    'default (native compilation)'));
     } else {
-        my (@host_archtriplet) = gnutriplet_to_debtriplet($gcc_host_gnu_type);
+        my (@host_archtriplet) = gnutriplet_to_debtriplet($host_gnu_type);
         $host_arch = debtriplet_to_debarch(@host_archtriplet);
 
         if (defined $host_arch) {
-            $gcc_host_gnu_type = debtriplet_to_gnutriplet(@host_archtriplet);
+            $host_gnu_type = debtriplet_to_gnutriplet(@host_archtriplet);
         } else {
-            warning(g_('unknown gcc system type %s, falling back to ' .
-                       'default (native compilation)'), $gcc_host_gnu_type);
-            $gcc_host_gnu_type = '';
+            warning(g_('unknown CC system type %s, falling back to ' .
+                       'default (native compilation)'), $host_gnu_type);
+            $host_gnu_type = '';
         }
-        set_host_gnu_type($gcc_host_gnu_type);
+        set_host_gnu_type($host_gnu_type);
     }
 
     if (!defined($host_arch)) {

+ 5 - 5
scripts/dpkg-architecture.pl

@@ -26,7 +26,7 @@ use Dpkg ();
 use Dpkg::Gettext;
 use Dpkg::Getopt;
 use Dpkg::ErrorHandling;
-use Dpkg::Arch qw(get_raw_build_arch get_raw_host_arch get_gcc_host_gnu_type
+use Dpkg::Arch qw(get_raw_build_arch get_raw_host_arch get_host_gnu_type
                   debarch_to_cpuattrs
                   get_valid_arches debarch_eq debarch_is debarch_to_debtriplet
                   debarch_to_gnutriplet gnutriplet_to_debarch
@@ -280,12 +280,12 @@ if (action_needs(DEB_HOST | DEB_GNU_INFO)) {
     }
     ($v{DEB_HOST_GNU_CPU}, $v{DEB_HOST_GNU_SYSTEM}) = split(/-/, $v{DEB_HOST_GNU_TYPE}, 2);
 
-    my $gcc = get_gcc_host_gnu_type();
+    my $host_gnu_type = get_host_gnu_type();
 
-    warning(g_('specified GNU system type %s does not match gcc system ' .
+    warning(g_('specified GNU system type %s does not match CC system ' .
                'type %s, try setting a correct CC environment variable'),
-            $v{DEB_HOST_GNU_TYPE}, $gcc)
-        if ($gcc ne '') && ($gcc ne $v{DEB_HOST_GNU_TYPE});
+            $v{DEB_HOST_GNU_TYPE}, $host_gnu_type)
+        if ($host_gnu_type ne '') && ($host_gnu_type ne $v{DEB_HOST_GNU_TYPE});
 }
 
 #