Преглед изворни кода

Merge branch 'master' of git+ssh://kreutzm-guest@git.debian.org/git/dpkg/dpkg

Helge Kreutzmann пре 19 година
родитељ
комит
ab1db83b37

+ 31 - 0
ChangeLog

@@ -1,3 +1,34 @@
+2007-10-12  Guillem Jover  <guillem@debian.org>
+
+	* scripts/controllib.pl ($host_arch, get_host_arch, get_valid_arches)
+	(@cpu, @os, %cputable, %ostable, %cputable_re, %ostable_re)
+	(%debtriplet_to_debarch, %debarch_to_debtriplet, read_cputable)
+	(read_ostable, read_triplettable, debtriplet_to_gnutriplet)
+	(gnutriplet_to_debtriplet, debtriplet_to_debarch)
+	(debarch_to_debtriplet, debwildcard_to_debtriplet)
+	(debarch_eq, debarch_is): Move to ...
+	* scripts/Dpkg/Arch.pm: ... here. New file.
+	* scripts/Makefile.am (nobase_dist_perllib_DATA): Add 'Dpkg/Arch.pm'.
+	* scripts/po/POTFILES.in: Add 'scripts/Dpkg/Arch.pm'.
+
+	* scripts/controllib.pl: Use new Dpkg::Arch module.
+	* scripts/dpkg-architecture.pl: Likewise.
+	* scripts/dpkg-checkbuilddeps.pl: Likewise.
+	* scripts/dpkg-genchanges.pl: Likewise.
+	* scripts/dpkg-gencontrol.pl: Likewise.
+	* scripts/dpkg-source.pl: Likewise.
+
+	* scripts/dpkg-architecture.pl: Do not require controllib.pl anymore.
+
+2007-10-12  Frank Lichtenheld  <djpig@debian.org>
+
+	* scripts/t/300_Dpkg_BuildOptions.t: New file.
+	Leads to the following fixes:
+	* scripts/Dpkg/BuildOptions.pm (parse): Add
+	support for nocheck and make it actually work.
+	(set): Really set DEB_BUILD_OPTIONS. Discovered
+	by Daniel Shepler.
+
 2007-10-11  Guillem Jover  <guillem@debian.org>
 
 	* scripts/controllib.pl ($warnable_error, $quiet_warnings): Remove

+ 4 - 0
debian/changelog

@@ -37,13 +37,17 @@ dpkg (1.14.8) UNRELEASED; urgency=low
     Closes: #382673
   * Various small fixes to the manpages suggested by Helge Kreutzmann.
     Closes: #445858
+  * Fix Dpkg::BuildOptions (and thereby dpkg-buildpackage) to really
+    set DEB_BUILD_OPTIONS. Found by Daniel Shepler. Closes: #446119
 
   [ Guillem Jover ]
   * Use shipped perl modules when calling perl programs at build time.
   * Switch perl programs to use the new Dpkg/ErrorHandling module.
+  * Switch perl programs to use the new Dpkg/Arch module.
 
   [ Updated dpkg translations ]
   * Polish (Robert Luberda).
+  * Russian (Yuri Kozlov). Closes: #446278
 
   [ Updated man pages translations ]
   * German (Helge Kreutzmann).

+ 1 - 0
debian/dpkg-dev.install

@@ -17,6 +17,7 @@ usr/bin/dpkg-shlibdeps
 usr/bin/dpkg-source
 usr/lib/dpkg/controllib.pl
 usr/lib/dpkg/parsechangelog
+usr/share/perl5/Dpkg/Arch.pm
 usr/share/perl5/Dpkg/Path.pm
 usr/share/perl5/Dpkg/Version.pm
 usr/share/perl5/Dpkg/ErrorHandling.pm

+ 8 - 0
man/ChangeLog

@@ -1,3 +1,11 @@
+2007-10-12  Frank Lichtenheld  <djpig@debian.org>
+
+	* dpkg.1 (AUTHORS): Remove some unneccessary markup.
+	Allows reuse of one more msgid.
+
+	* Makefile.am (update-po): New target to easily
+	update the .pot and .po files. Uses po4a --force.
+
 2007-10-11  Helge Kreutzmann  <debian@helgefjell.de>
 
 	* po/de.po: Updated to 1279t0f64u.

+ 6 - 0
man/Makefile.am

@@ -13,6 +13,11 @@ clean-local:
 		$(srcdir)/po/po4a.cfg
 	rm -f man.stamp
 
+update-po:
+	cd $(srcdir)/po && \
+		po4a --no-backups --force --variable srcdir=../../man \
+			./po4a.cfg 
+
 # Extract the list of languages from the po4a config file.
 LINGUAS = $(shell sed -ne 's/^.*\[po4a_langs\] \(.*\)$$/\1/p' $(srcdir)/po/po4a.cfg)
 
@@ -87,3 +92,4 @@ EXTRA_DIST = \
 	po/po4a.cfg \
 	po/dpkg-man.pot
 
+.PHONY: update-po

+ 0 - 2
man/dpkg.1

@@ -619,7 +619,5 @@ and
 \fB\-\-no\-act\fP usually gives less information than might be helpful.
 .
 .SH AUTHORS
-.nf
 See \fI/usr/share/doc/dpkg/THANKS\fP for the list of people who have
 contributed to \fBdpkg\fP.
-.fi

+ 4 - 0
po/ChangeLog

@@ -1,3 +1,7 @@
+2007-10-12  Yuri Kozlov  <kozlov.y@gmail.com>
+
+	* ru.po: Updated to 929t.
+
 2007-10-08  Robert Luberda  <robert@debian.org>
 
 	* pl.po: Updated to 929t.

+ 61 - 93
po/ru.po

@@ -6,10 +6,10 @@
 # Yuri Kozlov <kozlov.y@gmail.com>, 2004, 2005, 2006, 2007.
 msgid ""
 msgstr ""
-"Project-Id-Version: 1.14.5\n"
+"Project-Id-Version: 1.14.7\n"
 "Report-Msgid-Bugs-To: debian-dpkg@lists.debian.org\n"
 "POT-Creation-Date: 2007-08-18 03:58+0300\n"
-"PO-Revision-Date: 2007-08-05 22:24+0400\n"
+"PO-Revision-Date: 2007-10-11 21:01+0400\n"
 "Last-Translator: Yuri Kozlov <kozlov.y@gmail.com>\n"
 "Language-Team: Russian <debian-l10n-russian@lists.debian.org>\n"
 "MIME-Version: 1.0\n"
@@ -812,27 +812,27 @@ msgstr "не удалось закрыть файл %.255s после чтени
 #: lib/parse.c:332
 #, c-format
 msgid "no package information in `%.255s'"
-msgstr "в файле %.255s нет информации о пакете"
+msgstr "в файле `%.255s' нет информации о пакете"
 
 #: lib/parsehelp.c:38
 #, c-format
 msgid "failed to read `%s' at line %d"
-msgstr "ошибка чтения файла %s в строке %d"
+msgstr "ошибка чтения файла `%s' в строке %d"
 
 #: lib/parsehelp.c:41
-#, fuzzy, c-format
+#, c-format
 msgid "warning, in file `%.255s' near line %d"
-msgstr "%s в файле %.255s около строки %d"
+msgstr "предупреждение, файл `%.255s' около строки %d"
 
 #: lib/parsehelp.c:44
-#, fuzzy, c-format
+#, c-format
 msgid "parse error, in file `%.255s' near line %d"
-msgstr "%s в файле %.255s около строки %d"
+msgstr "ошибка разбора, файл `%.255s' около строки %d"
 
 #: lib/parsehelp.c:48
 #, c-format
 msgid " package `%.255s'"
-msgstr " пакет %.255s"
+msgstr " пакет `%.255s'"
 
 #: lib/parsehelp.c:59
 msgid "failed to write parsing warning"
@@ -924,9 +924,10 @@ msgid "error setting permissions of `%.255s'"
 msgstr "ошибка при установке прав доступа к %.255s"
 
 #: src/archives.c:339
-#, fuzzy, c-format
+#, c-format
 msgid "failed to stat (dereference) existing symlink `%.250s'"
-msgstr "не удалось сделать файл %.250s исполняемым"
+msgstr ""
+"не удалось выполнить stat для существующей символической ссылки `%.250s'"
 
 #: src/archives.c:360
 #, c-format
@@ -934,22 +935,22 @@ msgid ""
 "failed to stat (dereference) proposed new symlink target `%.250s' for "
 "symlink `%.250s'"
 msgstr ""
+"не удалось выполнить stat для предполагаемой новой символической цели `"
+"%.250s' для символической ссылки `%.250s'"
 
 #: src/archives.c:411
-#, fuzzy, c-format
+#, c-format
 msgid ""
 "trying to overwrite `%.250s', which is the diverted version of `"
 "%.250s' (package: %.100s)"
 msgstr ""
-"попытка переписать файл `%.250s', являющийся файлом %.250s с изменённым\n"
-"размещением %.10s%.100s%.10s"
+"попытка переписать `%.250s', являющийся изменённой версией `%.250s' (пакет: "
+"%.100s)"
 
 #: src/archives.c:417
-#, fuzzy, c-format
+#, c-format
 msgid "trying to overwrite `%.250s', which is the diverted version of `%.250s'"
-msgstr ""
-"попытка переписать файл `%.250s', являющийся файлом %.250s с изменённым\n"
-"размещением %.10s%.100s%.10s"
+msgstr "попытка переписать `%.250s', являющийся изменённой версией `%.250s'"
 
 #: src/archives.c:440
 #, c-format
@@ -1080,62 +1081,62 @@ msgid "unable to install new version of `%.255s'"
 msgstr "не удалось установить новую версию %.255s"
 
 #: src/archives.c:853
-#, fuzzy, c-format
+#, c-format
 msgid ""
 "dpkg: warning - ignoring dependency problem with %s:\n"
 "%s"
 msgstr ""
-"dpkg: предупреждение -- %s удаляется, несмотря на проблемы зависимостей:\n"
+"dpkg: предупреждение -- игнорируются проблемы зависимостей с %s:\n"
 "%s"
 
 #: src/archives.c:860
-#, fuzzy, c-format
+#, c-format
 msgid ""
 "dpkg: warning - considering deconfiguration of essential\n"
 " package %s, to enable %s.\n"
 msgstr ""
-"dpkg: предупреждение -- для удаления пакета %2$s необходимо\n"
-"удаление пакета первой необходимости %1$s и файлов его конфигурации.\n"
+"dpkg: предупреждение -- рассматривается деконфигурация пакета первой\n"
+"необходимости %s для активации %s.\n"
 
 #: src/archives.c:864
-#, fuzzy, c-format
+#, c-format
 msgid ""
 "dpkg: no, %s is essential, will not deconfigure\n"
 " it in order to enable %s.\n"
 msgstr ""
-"dpkg: пакет %s является пакетом первой необходимости и не будет\n"
-"удалён, хотя это и нужно для удаления пакета %s.\n"
+"dpkg: нет, пакет %s является пакетом первой необходимости и не будет\n"
+"деконфигурирован для активации %s.\n"
 
 #: src/archives.c:878
-#, fuzzy, c-format
+#, c-format
 msgid ""
 "dpkg: no, cannot proceed with %s (--auto-deconfigure will help):\n"
 "%s"
 msgstr ""
-"dpkg: удалить %s невозможно (вам поможет --auto-deconfigure):\n"
+"dpkg: нет, невозможно продолжить с %s (вам поможет --auto-deconfigure):\n"
 "%s"
 
 #: src/archives.c:888
-#, fuzzy, c-format
+#, c-format
 msgid "removal of %.250s"
-msgstr "ошибка чтения файла %.250s"
+msgstr "удаление %.250s"
 
 #: src/archives.c:915
-#, fuzzy, c-format
+#, c-format
 msgid "installation of %.250s"
-msgstr "не удалось установить новую версию %.255s"
+msgstr "установка %.255s"
 
 #: src/archives.c:916
-#, fuzzy, c-format
+#, c-format
 msgid ""
 "dpkg: considering deconfiguration of %s, which would be broken by %s ...\n"
 msgstr ""
-"dpkg: чтобы можно было установить пакет %2$s, необходимо удалить %1$s...\n"
+"dpkg: рассматривается деконфигурация %s, который был бы сломан %s ...\n"
 
 #: src/archives.c:923
-#, fuzzy, c-format
+#, c-format
 msgid "dpkg: yes, will deconfigure %s (broken by %s).\n"
-msgstr "dpkg: %s будет удалён, чтобы можно было установить %s.\n"
+msgstr "dpkg: да, %s будет деконфигурирован (сломан из-за %s).\n"
 
 #: src/archives.c:927 src/archives.c:1048
 #, c-format
@@ -1143,13 +1144,13 @@ msgid ""
 "dpkg: regarding %s containing %s:\n"
 "%s"
 msgstr ""
-"dpkg: анализ файла %s, содержащего пакет %s:\n"
+"dpkg: относительно %s, содержащего %s:\n"
 "%s"
 
 #: src/archives.c:935
-#, fuzzy, c-format
+#, c-format
 msgid "dpkg: warning - ignoring breakage, may proceed anyway !\n"
-msgstr "dpkg: предупреждение -- конфликт игнорируется, можно продолжать!\n"
+msgstr "dpkg: предупреждение -- поломка игнорируется, можно продолжать!\n"
 
 #: src/archives.c:941
 #, c-format
@@ -1157,11 +1158,13 @@ msgid ""
 "installing %.250s would break %.250s, and\n"
 " deconfiguration is not permitted (--auto-deconfigure might help)"
 msgstr ""
+"установка %.250s сломает %.250s, и\n"
+" деконфигурация не разрешена (--auto-deconfigure может помочь)"
 
 #: src/archives.c:945
 #, c-format
 msgid "installing %.250s would break existing software"
-msgstr ""
+msgstr "установка %.250s сломает имеющееся ПО"
 
 #: src/archives.c:978
 #, c-format
@@ -2786,19 +2789,19 @@ msgid "  Package %s is not installed.\n"
 msgstr "  Пакет %s не установлен.\n"
 
 #: src/packages.c:362
-#, fuzzy, c-format
+#, c-format
 msgid " %s (%s) breaks %s and is %s.\n"
-msgstr "  пакет %.250s предоставляет %.250s и %s.\n"
+msgstr " %s (%s) ломает %s и %s.\n"
 
 #: src/packages.c:370
-#, fuzzy, c-format
+#, c-format
 msgid "  %s (%s) provides %s.\n"
-msgstr "%s (подпроцесс): %s\n"
+msgstr "  %s (%s) предоставляет %s.\n"
 
 #: src/packages.c:375
-#, fuzzy, c-format
+#, c-format
 msgid "  Version of %s to be configured is %s.\n"
-msgstr "  Версия %s в системе %s.\n"
+msgstr "  Версия %s, которая будет настроена: %s.\n"
 
 #: src/packages.c:467
 msgid " depends on "
@@ -2928,14 +2931,14 @@ msgid "error trying to open %.250s"
 msgstr "ошибка при попытке открыть файл %.250s"
 
 #: src/processarc.c:405
-#, fuzzy, c-format
+#, c-format
 msgid "De-configuring %s, to allow removal of %s ...\n"
-msgstr "Удаляются файлы настройки пакета %s, чтобы можно было удалить %s...\n"
+msgstr "Деконфигурация %s, чтобы можно было удалить %s ...\n"
 
 #: src/processarc.c:408
-#, fuzzy, c-format
+#, c-format
 msgid "De-configuring %s ...\n"
-msgstr "Удаляется пакет %s...\n"
+msgstr "Деконфигурация %s ...\n"
 
 #: src/processarc.c:479
 #, c-format
@@ -3101,24 +3104,24 @@ msgid "No packages found matching %s.\n"
 msgstr "Шаблону %s не соответствует ни один пакет.\n"
 
 #: src/query.c:254
-#, fuzzy, c-format
+#, c-format
 msgid "diversion by %s from: %s\n"
-msgstr "размещение файла изменено пакетом %s на %s\n"
+msgstr "размещение изменено %s из %s\n"
 
 #: src/query.c:256
-#, fuzzy, c-format
+#, c-format
 msgid "diversion by %s to: %s\n"
-msgstr "размещение файла изменено пакетом %s на %s\n"
+msgstr "размещение изменено %s на %s\n"
 
 #: src/query.c:259
-#, fuzzy, c-format
+#, c-format
 msgid "local diversion from: %s\n"
-msgstr "локальное изменение размещения файлов"
+msgstr "локальное изменение размещения из %s\n"
 
 #: src/query.c:260
-#, fuzzy, c-format
+#, c-format
 msgid "local diversion to: %s\n"
-msgstr "локальное изменение размещения файла на %s\n"
+msgstr "локальное изменение размещения на %s\n"
 
 #: src/query.c:285
 msgid "--search needs at least one file name pattern argument"
@@ -5704,38 +5707,3 @@ msgstr "пропущен символ новой строки после %s"
 #, perl-format
 msgid "Serious problem: %s"
 msgstr "Серьёзная проблема: %s"
-
-#~ msgid "warning"
-#~ msgstr "нештатная ситуация"
-
-#~ msgid "parse error"
-#~ msgstr "ошибка разбора"
-
-#~ msgid " (package: "
-#~ msgstr " (пакет: "
-
-#~ msgid ""
-#~ "dpkg: regarding %s containing %s:\n"
-#~ " package uses Breaks; not supported in this dpkg\n"
-#~ msgstr ""
-#~ "dpkg: пакет %s в файле %s:\n"
-#~ "используется Breaks; это не поддерживается в данной версии dpkg\n"
-
-#~ msgid "unsupported dependency problem - not installing %.250s"
-#~ msgstr ""
-#~ "проблема с неподдерживаемой зависимостью, пакет %.250s не будет установлен"
-
-#~ msgid "dpkg: warning - ignoring Breaks !\n"
-#~ msgstr "dpkg: предупреждение -- игнорируется Breaks !\n"
-
-#~ msgid "diversion by %s"
-#~ msgstr "размещение файла изменено пакетом %s"
-
-#~ msgid "to"
-#~ msgstr "на"
-
-#~ msgid "from"
-#~ msgstr "с"
-
-#~ msgid "error reading %s"
-#~ msgstr "ошибка чтения %s"

+ 242 - 0
scripts/Dpkg/Arch.pm

@@ -0,0 +1,242 @@
+package Dpkg::Arch;
+
+use strict;
+use warnings;
+
+use Exporter;
+our @ISA = qw(Exporter);
+our @EXPORT_OK = qw(get_host_arch get_valid_arches debarch_eq debarch_is
+                    debtriplet_to_gnutriplet gnutriplet_to_debtriplet
+                    debtriplet_to_debarch debarch_to_debtriplet);
+
+use Dpkg;
+use Dpkg::ErrorHandling qw(syserr subprocerr);
+
+my (@cpu, @os);
+my (%cputable, %ostable);
+my (%cputable_re, %ostable_re);
+
+my %debtriplet_to_debarch;
+my %debarch_to_debtriplet;
+
+{
+    my $host_arch;
+
+    sub get_host_arch()
+    {
+	return $host_arch if defined $host_arch;
+
+	$host_arch = `dpkg-architecture -qDEB_HOST_ARCH`;
+	$? && subprocerr("dpkg-architecture -qDEB_HOST_ARCH");
+	chomp $host_arch;
+	return $host_arch;
+    }
+}
+
+sub get_valid_arches()
+{
+    read_cputable() if (!@cpu);
+    read_ostable() if (!@os);
+
+    foreach my $os (@os) {
+	foreach my $cpu (@cpu) {
+	    my $arch = debtriplet_to_debarch(split(/-/, $os, 2), $cpu);
+	    print $arch."\n" if defined($arch);
+	}
+    }
+}
+
+sub read_cputable
+{
+    local $_;
+
+    open CPUTABLE, "$pkgdatadir/cputable"
+	or syserr(_g("unable to open cputable"));
+    while (<CPUTABLE>) {
+	if (m/^(?!\#)(\S+)\s+(\S+)\s+(\S+)/) {
+	    $cputable{$1} = $2;
+	    $cputable_re{$1} = $3;
+	    push @cpu, $1;
+	}
+    }
+    close CPUTABLE;
+}
+
+sub read_ostable
+{
+    local $_;
+
+    open OSTABLE, "$pkgdatadir/ostable"
+	or syserr(_g("unable to open ostable"));
+    while (<OSTABLE>) {
+	if (m/^(?!\#)(\S+)\s+(\S+)\s+(\S+)/) {
+	    $ostable{$1} = $2;
+	    $ostable_re{$1} = $3;
+	    push @os, $1;
+	}
+    }
+    close OSTABLE;
+}
+
+sub read_triplettable()
+{
+    read_cputable() if (!@cpu);
+
+    local $_;
+
+    open TRIPLETTABLE, "$pkgdatadir/triplettable"
+	or syserr(_g("unable to open triplettable"));
+    while (<TRIPLETTABLE>) {
+	if (m/^(?!\#)(\S+)\s+(\S+)/) {
+	    my $debtriplet = $1;
+	    my $debarch = $2;
+
+	    if ($debtriplet =~ /<cpu>/) {
+		foreach my $_cpu (@cpu) {
+		    (my $dt = $debtriplet) =~ s/<cpu>/$_cpu/;
+		    (my $da = $debarch) =~ s/<cpu>/$_cpu/;
+
+		    $debarch_to_debtriplet{$da} = $dt;
+		    $debtriplet_to_debarch{$dt} = $da;
+		}
+	    } else {
+		$debarch_to_debtriplet{$2} = $1;
+		$debtriplet_to_debarch{$1} = $2;
+	    }
+	}
+    }
+    close TRIPLETTABLE;
+}
+
+sub debtriplet_to_gnutriplet(@)
+{
+    read_cputable() if (!@cpu);
+    read_ostable() if (!@os);
+
+    my ($abi, $os, $cpu) = @_;
+
+    return undef unless defined($abi) && defined($os) && defined($cpu) &&
+        exists($cputable{$cpu}) && exists($ostable{"$abi-$os"});
+    return join("-", $cputable{$cpu}, $ostable{"$abi-$os"});
+}
+
+sub gnutriplet_to_debtriplet($)
+{
+    my ($gnu) = @_;
+    return undef unless defined($gnu);
+    my ($gnu_cpu, $gnu_os) = split(/-/, $gnu, 2);
+    return undef unless defined($gnu_cpu) && defined($gnu_os);
+
+    read_cputable() if (!@cpu);
+    read_ostable() if (!@os);
+
+    my ($os, $cpu);
+
+    foreach my $_cpu (@cpu) {
+	if ($gnu_cpu =~ /^$cputable_re{$_cpu}$/) {
+	    $cpu = $_cpu;
+	    last;
+	}
+    }
+
+    foreach my $_os (@os) {
+	if ($gnu_os =~ /^(.*-)?$ostable_re{$_os}$/) {
+	    $os = $_os;
+	    last;
+	}
+    }
+
+    return undef if !defined($cpu) || !defined($os);
+    return (split(/-/, $os, 2), $cpu);
+}
+
+sub debtriplet_to_debarch(@)
+{
+    read_triplettable() if (!%debtriplet_to_debarch);
+
+    my ($abi, $os, $cpu) = @_;
+
+    if (!defined($abi) || !defined($os) || !defined($cpu)) {
+	return undef;
+    } elsif (exists $debtriplet_to_debarch{"$abi-$os-$cpu"}) {
+	return $debtriplet_to_debarch{"$abi-$os-$cpu"};
+    } else {
+	return undef;
+    }
+}
+
+sub debarch_to_debtriplet($)
+{
+    read_triplettable() if (!%debarch_to_debtriplet);
+
+    local ($_) = @_;
+    my $arch;
+
+    if (/^linux-([^-]*)/) {
+	# XXX: Might disappear in the future, not sure yet.
+	$arch = $1;
+    } else {
+	$arch = $_;
+    }
+
+    my $triplet = $debarch_to_debtriplet{$arch};
+
+    if (defined($triplet)) {
+	return split('-', $triplet, 3);
+    } else {
+	return undef;
+    }
+}
+
+sub debwildcard_to_debtriplet($)
+{
+    local ($_) = @_;
+
+    if (/any/) {
+	if (/^([^-]*)-([^-]*)-(.*)/) {
+	    return ($1, $2, $3);
+	} elsif (/^([^-]*)-([^-]*)$/) {
+	    return ('any', $1, $2);
+	} else {
+	    return ($_, $_, $_);
+	}
+    } else {
+	return debarch_to_debtriplet($_);
+    }
+}
+
+sub debarch_eq($$)
+{
+    my ($a, $b) = @_;
+
+    return 1 if ($a eq $b);
+
+    my @a = debarch_to_debtriplet($a);
+    my @b = debarch_to_debtriplet($b);
+
+    return 0 if grep(!defined, (@a, @b));
+
+    return ($a[0] eq $b[0] && $a[1] eq $b[1] && $a[2] eq $b[2]);
+}
+
+sub debarch_is($$)
+{
+    my ($real, $alias) = @_;
+
+    return 1 if ($alias eq $real or $alias eq 'any');
+
+    my @real = debarch_to_debtriplet($real);
+    my @alias = debwildcard_to_debtriplet($alias);
+
+    return 0 if grep(!defined, (@real, @alias));
+
+    if (($alias[0] eq $real[0] || $alias[0] eq 'any') &&
+        ($alias[1] eq $real[1] || $alias[1] eq 'any') &&
+        ($alias[2] eq $real[2] || $alias[2] eq 'any')) {
+	return 1;
+    }
+
+    return 0;
+}
+
+1;

+ 6 - 2
scripts/Dpkg/BuildOptions.pm

@@ -11,9 +11,10 @@ sub parse {
     unless ($env) { return {}; }
 
     my %opts;
-    if ($env =~ s/(noopt|nostrip),?//ig) {
+    while ($env =~ s/(noopt|nostrip|nocheck),?//i) {
 	$opts{lc $1} = '';
-    } elsif ($env =~ s/(parallel)=(-?\d+),?//ig) {
+    }
+    while ($env =~ s/(parallel)=(-?\d+),?//i) {
 	$opts{lc $1} = $2;
     }
 
@@ -33,6 +34,9 @@ sub set {
 	    $env .= "$k,";
 	}
     }
+
+    $ENV{DEB_BUILD_OPTIONS} = $env if $env;
+    return $env;
 }
 
 1;

+ 1 - 0
scripts/Makefile.am

@@ -72,6 +72,7 @@ CLEANFILES = \
 
 perllibdir = $(PERL_LIBDIR)
 nobase_dist_perllib_DATA = \
+	Dpkg/Arch.pm \
 	Dpkg/Shlibs.pm \
 	Dpkg/Shlibs/Objdump.pm \
 	Dpkg/Shlibs/SymbolFile.pm \

+ 1 - 231
scripts/controllib.pl

@@ -8,6 +8,7 @@ use POSIX qw(:errno_h);
 use Dpkg;
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling qw(warning error failure internerr syserr subprocerr);
+use Dpkg::Arch qw(get_host_arch debarch_is);
 
 textdomain("dpkg-dev");
 
@@ -83,237 +84,6 @@ sub capit {
     return join '-', @pieces;
 }
 
-#
-# Architecture library
-#
-
-my (@cpu, @os);
-my (%cputable, %ostable);
-my (%cputable_re, %ostable_re);
-
-my %debtriplet_to_debarch;
-my %debarch_to_debtriplet;
-
-{
-    my $host_arch;
-
-    sub get_host_arch()
-    {
-	return $host_arch if defined $host_arch;
-
-	$host_arch = `dpkg-architecture -qDEB_HOST_ARCH`;
-	$? && subprocerr("dpkg-architecture -qDEB_HOST_ARCH");
-	chomp $host_arch;
-	return $host_arch;
-    }
-}
-
-sub get_valid_arches()
-{
-    read_cputable() if (!@cpu);
-    read_ostable() if (!@os);
-
-    foreach my $os (@os) {
-	foreach my $cpu (@cpu) {
-	    my $arch = debtriplet_to_debarch(split(/-/, $os, 2), $cpu);
-	    print $arch."\n" if defined($arch);
-	}
-    }
-}
-
-sub read_cputable
-{
-    local $_;
-
-    open CPUTABLE, "$pkgdatadir/cputable"
-	or syserr(_g("unable to open cputable"));
-    while (<CPUTABLE>) {
-	if (m/^(?!\#)(\S+)\s+(\S+)\s+(\S+)/) {
-	    $cputable{$1} = $2;
-	    $cputable_re{$1} = $3;
-	    push @cpu, $1;
-	}
-    }
-    close CPUTABLE;
-}
-
-sub read_ostable
-{
-    local $_;
-
-    open OSTABLE, "$pkgdatadir/ostable"
-	or syserr(_g("unable to open ostable"));
-    while (<OSTABLE>) {
-	if (m/^(?!\#)(\S+)\s+(\S+)\s+(\S+)/) {
-	    $ostable{$1} = $2;
-	    $ostable_re{$1} = $3;
-	    push @os, $1;
-	}
-    }
-    close OSTABLE;
-}
-
-sub read_triplettable()
-{
-    read_cputable() if (!@cpu);
-
-    local $_;
-
-    open TRIPLETTABLE, "$pkgdatadir/triplettable"
-	or syserr(_g("unable to open triplettable"));
-    while (<TRIPLETTABLE>) {
-	if (m/^(?!\#)(\S+)\s+(\S+)/) {
-	    my $debtriplet = $1;
-	    my $debarch = $2;
-
-	    if ($debtriplet =~ /<cpu>/) {
-		foreach my $_cpu (@cpu) {
-		    (my $dt = $debtriplet) =~ s/<cpu>/$_cpu/;
-		    (my $da = $debarch) =~ s/<cpu>/$_cpu/;
-
-		    $debarch_to_debtriplet{$da} = $dt;
-		    $debtriplet_to_debarch{$dt} = $da;
-		}
-	    } else {
-		$debarch_to_debtriplet{$2} = $1;
-		$debtriplet_to_debarch{$1} = $2;
-	    }
-	}
-    }
-    close TRIPLETTABLE;
-}
-
-sub debtriplet_to_gnutriplet(@)
-{
-    read_cputable() if (!@cpu);
-    read_ostable() if (!@os);
-
-    my ($abi, $os, $cpu) = @_;
-
-    return undef unless defined($abi) && defined($os) && defined($cpu) &&
-        exists($cputable{$cpu}) && exists($ostable{"$abi-$os"});
-    return join("-", $cputable{$cpu}, $ostable{"$abi-$os"});
-}
-
-sub gnutriplet_to_debtriplet($)
-{
-    my ($gnu) = @_;
-    return undef unless defined($gnu);
-    my ($gnu_cpu, $gnu_os) = split(/-/, $gnu, 2);
-    return undef unless defined($gnu_cpu) && defined($gnu_os);
-
-    read_cputable() if (!@cpu);
-    read_ostable() if (!@os);
-
-    my ($os, $cpu);
-
-    foreach my $_cpu (@cpu) {
-	if ($gnu_cpu =~ /^$cputable_re{$_cpu}$/) {
-	    $cpu = $_cpu;
-	    last;
-	}
-    }
-
-    foreach my $_os (@os) {
-	if ($gnu_os =~ /^(.*-)?$ostable_re{$_os}$/) {
-	    $os = $_os;
-	    last;
-	}
-    }
-
-    return undef if !defined($cpu) || !defined($os);
-    return (split(/-/, $os, 2), $cpu);
-}
-
-sub debtriplet_to_debarch(@)
-{
-    read_triplettable() if (!%debtriplet_to_debarch);
-
-    my ($abi, $os, $cpu) = @_;
-
-    if (!defined($abi) || !defined($os) || !defined($cpu)) {
-	return undef;
-    } elsif (exists $debtriplet_to_debarch{"$abi-$os-$cpu"}) {
-	return $debtriplet_to_debarch{"$abi-$os-$cpu"};
-    } else {
-	return undef;
-    }
-}
-
-sub debarch_to_debtriplet($)
-{
-    read_triplettable() if (!%debarch_to_debtriplet);
-
-    local ($_) = @_;
-    my $arch;
-
-    if (/^linux-([^-]*)/) {
-	# XXX: Might disappear in the future, not sure yet.
-	$arch = $1;
-    } else {
-	$arch = $_;
-    }
-
-    my $triplet = $debarch_to_debtriplet{$arch};
-
-    if (defined($triplet)) {
-	return split('-', $triplet, 3);
-    } else {
-	return undef;
-    }
-}
-
-sub debwildcard_to_debtriplet($)
-{
-    local ($_) = @_;
-
-    if (/any/) {
-	if (/^([^-]*)-([^-]*)-(.*)/) {
-	    return ($1, $2, $3);
-	} elsif (/^([^-]*)-([^-]*)$/) {
-	    return ('any', $1, $2);
-	} else {
-	    return ($_, $_, $_);
-	}
-    } else {
-	return debarch_to_debtriplet($_);
-    }
-}
-
-sub debarch_eq($$)
-{
-    my ($a, $b) = @_;
-
-    return 1 if ($a eq $b);
-
-    my @a = debarch_to_debtriplet($a);
-    my @b = debarch_to_debtriplet($b);
-
-    return 0 if grep(!defined, (@a, @b));
-
-    return ($a[0] eq $b[0] && $a[1] eq $b[1] && $a[2] eq $b[2]);
-}
-
-sub debarch_is($$)
-{
-    my ($real, $alias) = @_;
-
-    return 1 if ($alias eq $real or $alias eq 'any');
-
-    my @real = debarch_to_debtriplet($real);
-    my @alias = debwildcard_to_debtriplet($alias);
-
-    return 0 if grep(!defined, (@real, @alias));
-
-    if (($alias[0] eq $real[0] || $alias[0] eq 'any') &&
-        ($alias[1] eq $real[1] || $alias[1] eq 'any') &&
-        ($alias[2] eq $real[2] || $alias[2] eq 'any')) {
-	return 1;
-    }
-
-    return 0;
-}
-
 sub substvars {
     my ($v) = @_;
     my $lhs;

+ 3 - 3
scripts/dpkg-architecture.pl

@@ -25,9 +25,9 @@ use warnings;
 use Dpkg;
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling qw(warning syserr usageerr);
-
-push(@INC,$dpkglibdir);
-require 'controllib.pl';
+use Dpkg::Arch qw(get_valid_arches debarch_eq debarch_is
+                  debtriplet_to_gnutriplet gnutriplet_to_debtriplet
+                  debtriplet_to_debarch debarch_to_debtriplet);
 
 textdomain("dpkg-dev");
 

+ 1 - 0
scripts/dpkg-checkbuilddeps.pl

@@ -8,6 +8,7 @@ use Getopt::Long;
 use Dpkg;
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling qw(error);
+use Dpkg::Arch qw(get_host_arch);
 
 push(@INC,$dpkglibdir);
 require 'controllib.pl';

+ 1 - 0
scripts/dpkg-genchanges.pl

@@ -9,6 +9,7 @@ use Dpkg;
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling qw(warning error failure unknown internerr syserr
                            subprocerr usageerr);
+use Dpkg::Arch qw(get_host_arch debarch_eq debarch_is);
 
 push(@INC,$dpkglibdir);
 require 'controllib.pl';

+ 1 - 0
scripts/dpkg-gencontrol.pl

@@ -9,6 +9,7 @@ use Dpkg;
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling qw(warning error failure unknown internerr syserr
                            subprocerr usageerr);
+use Dpkg::Arch qw(get_host_arch debarch_eq debarch_is);
 
 push(@INC,$dpkglibdir);
 require 'controllib.pl';

+ 1 - 0
scripts/dpkg-source.pl

@@ -8,6 +8,7 @@ use Dpkg::Gettext;
 use Dpkg::ErrorHandling qw(warning warnerror error failure unknown
                            internerr syserr subprocerr usageerr
                            $warnable_error $quiet_warnings);
+use Dpkg::Arch qw(debarch_eq);
 
 my @filesinarchive;
 my %dirincluded;

+ 1 - 0
scripts/po/POTFILES.in

@@ -15,6 +15,7 @@ scripts/dpkg-scansources.pl
 scripts/dpkg-shlibdeps.pl
 scripts/dpkg-source.pl
 scripts/changelog/debian.pl
+scripts/Dpkg/Arch.pm
 scripts/Dpkg/Shlibs.pm
 scripts/Dpkg/Shlibs/Objdump.pm
 scripts/Dpkg/Shlibs/SymbolFile.pm

+ 41 - 0
scripts/t/300_Dpkg_BuildOptions.t

@@ -0,0 +1,41 @@
+# -*- mode: cperl;-*-
+
+use Test::More tests => 6;
+
+use strict;
+use warnings;
+
+use_ok('Dpkg::BuildOptions');
+
+$ENV{DEB_BUILD_OPTIONS} = 'foonostripbar,parallel=3,bazNOCHECK';
+
+my $dbo = Dpkg::BuildOptions::parse();
+
+my %dbo = (
+	   nostrip => '',
+	   nocheck => '',
+	   parallel => 3,
+	   );
+my %dbo2 = (
+	    nocheck => '',
+	   );
+
+
+is_deeply($dbo, \%dbo, 'parse');
+
+$dbo = Dpkg::BuildOptions::parse('no opt,no-strip,parallel = 5,nocheck');
+
+is_deeply($dbo, \%dbo2, 'parse (param)');
+
+$dbo->{parallel} = 5;
+$dbo->{noopt} = '';
+
+my $env = Dpkg::BuildOptions::set($dbo,1);
+
+is($ENV{DEB_BUILD_OPTIONS}, $env, 'set (return value)');
+is_deeply(Dpkg::BuildOptions::parse(), $dbo, 'set (env)');
+
+$ENV{DEB_BUILD_OPTIONS} = 'foobar';
+$dbo = { noopt => '' };
+$env = Dpkg::BuildOptions::set($dbo);
+is($env, "foobar,noopt,", 'set (append)');