| author | Raphael Hertzog <hertzog@debian.org> | |
| Thu, 9 Apr 2009 16:07:09 +0000 (18:07 +0200) | ||
| committer | Raphael Hertzog <hertzog@debian.org> | |
| Sun, 10 May 2009 14:45:19 +0000 (16:45 +0200) |
This tool is meant to be used in debian/rules files to have common source
packages across multiple distributions and yet still have slightly
different binary packages.
To automatically conserve customizations across derivatives of a given
distribution, one can use “dpkg-vendor --derives-from vendor” so that all
derivatives keep the same customizations when they rebuild the source
package even if the current vendor is no more the same.
packages across multiple distributions and yet still have slightly
different binary packages.
To automatically conserve customizations across derivatives of a given
distribution, one can use “dpkg-vendor --derives-from vendor” so that all
derivatives keep the same customizations when they rebuild the source
package even if the current vendor is no more the same.
| debian/changelog | patch | blob | history | |
| debian/dpkg-dev.install | patch | blob | history | |
| man/Makefile.am | patch | blob | history | |
| man/dpkg-vendor.1 | [new file with mode: 0644] | patch | blob |
| man/po/po4a.cfg | patch | blob | history | |
| scripts/Makefile.am | patch | blob | history | |
| scripts/dpkg-vendor.pl | [new file with mode: 0755] | patch | blob |
diff --git a/debian/changelog b/debian/changelog
--- a/debian/changelog
+++ b/debian/changelog
* Fix update-alternatives to not remove real files installed in place of
an alternative link when the corresponding alternative is fully removed.
Closes: #526538
+ * Add a new dpkg-vendor tool to query vendor information stored in
+ /etc/dpkg/origins. It can be used in debian/rules to enable different
+ behaviour depending on the current vendor at the time of the build.
+ Closes: #498380
[ Guillem Jover ]
* Fix typo in dpkg output (‘unexecpted’ → ‘unexpected’). Closes: #519082
--- a/debian/dpkg-dev.install
+++ b/debian/dpkg-dev.install
usr/bin/dpkg-scansources
usr/bin/dpkg-shlibdeps
usr/bin/dpkg-source
+usr/bin/dpkg-vendor
usr/lib/dpkg/parsechangelog
usr/share/locale/*/LC_MESSAGES/dpkg-dev.mo
usr/share/man/{*/*,*}/822-date.1
usr/share/man/{*/*,*}/dpkg-scansources.1
usr/share/man/{*/*,*}/dpkg-shlibdeps.1
usr/share/man/{*/*,*}/dpkg-source.1
+usr/share/man/{*/*,*}/dpkg-vendor.1
usr/share/perl5/Dpkg
diff --git a/man/Makefile.am b/man/Makefile.am
--- a/man/Makefile.am
+++ b/man/Makefile.am
dpkg-split.1 \
dpkg-statoverride.8 \
dpkg-trigger.1 \
+ dpkg-vendor.1 \
dpkg.1 \
dpkg.cfg.5 \
install-info.8 \
diff --git a/man/dpkg-vendor.1 b/man/dpkg-vendor.1
--- /dev/null
+++ b/man/dpkg-vendor.1
@@ -0,0 +1,53 @@
+.TH dpkg\-vendor 1 "2009-05-10" "Debian Project" "dpkg suite"
+.SH NAME
+dpkg\-vendor \- queries information about distribution vendors
+.
+.SH SYNOPSIS
+.B dpkg\-vendor
+.RI [ option "...] " command
+.
+.SH DESCRIPTION
+\fBdpkg\-vendor\fP is a tool to query information about vendors listed in
+\fB/etc/dpkg/origins\fP. \fB/etc/dpkg/origins/default\fP contains
+information about the current vendor.
+.
+.SH COMMANDS
+.TP
+.BI \-\-is " vendor"
+Exits with 0 if the current vendor is \fIvendor\fP. Otherwise exits
+with non-zero.
+.TP
+.BI \-\-derives\-from " vendor"
+Exits with 0 if the current vendor distribution is a derivative of
+\fIvendor\fP, otherwise exits with non-zero. It uses the "Parent" field
+to browse all ancestors of the current vendor.
+.TP
+.BI \-\-query " field"
+Print on standard output the value of the vendor-specific \fIfield\fP for
+the current vendor.
+.TP
+.B \-\-help
+Show the usage message and exit.
+.TP
+.B \-\-version
+Show the version and exit.
+.
+.SH OPTIONS
+.TP
+.BI \-\-vendor " vendor"
+Assumes the current vendor is \fIvendor\fP instead of discovering it
+with the DEB_VENDOR environment variable or
+\fB/etc/dpkg/origins/default\fP.
+.
+.SH ENVIRONMENT
+.TP
+\fBDEB_VENDOR\fP
+This setting defines the current vendor. If not set, il will discover the
+current vendor by reading \fB/etc/dpkg/origins/default\fP.
+.
+.SH AUTHOR
+Copyright \(co 2009 Rapha\[:e]l Hertzog
+.sp
+This is free software; see the GNU General Public Licence version 2 or
+later for copying conditions. There is NO WARRANTY.
+
diff --git a/man/po/po4a.cfg b/man/po/po4a.cfg
--- a/man/po/po4a.cfg
+++ b/man/po/po4a.cfg
add_$lang:$(srcdir)/po/$lang.add
+[type:man] $(srcdir)/dpkg-vendor.1 \
+ $lang:$lang/dpkg-vendor.1 \
+ add_$lang:$(srcdir)/po/$lang.add
+
+
[type:man] $(srcdir)/dselect.1 \
$lang:$lang/dselect.1 \
add_$lang:$(srcdir)/po/$lang.add
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
dpkg-shlibdeps \
dpkg-statoverride \
dpkg-source \
+ dpkg-vendor \
update-alternatives
changelogdir = $(pkglibdir)/parsechangelog
dpkg-source.pl \
dpkg-divert.pl \
dpkg-statoverride.pl \
+ dpkg-vendor.pl \
install-info.pl \
update-alternatives.pl \
changelog/debian.pl \
diff --git a/scripts/dpkg-vendor.pl b/scripts/dpkg-vendor.pl
--- /dev/null
+++ b/scripts/dpkg-vendor.pl
@@ -0,0 +1,113 @@
+#!/usr/bin/perl
+#
+# dpkg-vendor
+#
+# Copyright © 2009 Raphaël Hertzog <hertzog@debian.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+use strict;
+use warnings;
+
+use Dpkg;
+use Dpkg::Gettext;
+use Dpkg::ErrorHandling;
+use Dpkg::Vendor qw(get_vendor_info get_current_vendor);
+
+textdomain("dpkg-dev");
+
+sub version {
+ printf _g("Debian %s version %s.\n"), $progname, $version;
+
+ printf _g("
+Copyright (C) 2009 Raphael Hertzog <hertzog\@debian.org>.");
+
+ printf _g("
+This is free software; see the GNU General Public Licence version 2 or
+later for copying conditions. There is NO warranty.
+");
+}
+
+sub usage {
+ printf _g(
+"Usage: %s [<option> ...] [<action>]
+
+Options:
+ --vendor <vendor> assume <vendor> is the current vendor
+
+Actions:
+ --is <vendor> returns true if current vendor is <vendor>.
+ --derives-from <vendor> returns true if current vendor derives from <vendor>.
+ --query <field> print the content of the vendor-specific field.
+ --help show this help message.
+ --version show the version.
+"), $progname;
+}
+
+my ($vendor, $param, $action);
+
+while (@ARGV) {
+ $_ = shift(@ARGV);
+ if (m/^--vendor$/) {
+ $vendor = shift(@ARGV);
+ } elsif (m/^--(is|derives-from|query)$/) {
+ badusage(_g("two commands specified: --%s and --%s"), $1, $action)
+ if defined($action);
+ $action = $1;
+ $param = shift(@ARGV);
+ } elsif (m/^-(h|-help)$/) {
+ usage();
+ exit 0;
+ } elsif (m/^--version$/) {
+ version();
+ exit 0;
+ } else {
+ usageerr(_g("unknown option \`%s'"), $_);
+ }
+}
+
+# Uses $ENV{DEB_VENDOR} if set
+$vendor = get_current_vendor() unless defined($vendor);
+
+my $info = get_vendor_info($vendor);
+unless (defined($info)) {
+ error(_g("vendor %s doesn't exist in /etc/dpkg/origins/"),
+ $vendor || "default");
+}
+
+if ($action eq 'is') {
+
+ exit(0) if lc($param) eq lc($info->{'Vendor'});
+ exit(1);
+
+} elsif ($action eq 'derives-from') {
+
+ exit(0) if lc($param) eq lc($info->{'Vendor'});
+ while (defined($info) && exists $info->{'Parent'}) {
+ $info = get_vendor_info($info->{'Parent'});
+ exit(0) if lc($param) eq lc($info->{'Vendor'});
+ }
+ exit(1);
+
+} elsif ($action eq 'query') {
+
+ if (exists $info->{$param}) {
+ print $info->{$param} . "\n";
+ exit(0);
+ } else {
+ exit(1);
+ }
+
+}
