Package: dpkg Version: 1.14.12 Severity: wishlist Tags: patch Hi,
the attached patch adds a new variable DEB_VARIANT to the build environment, which can be used to build different binary packages out of the same source package in different circumstances. The most obvious application would be derived distributions; there is currently no reliable way to communicate cross-derivatives building of a package that uses the same source tree in multiple distributions but should provide different binaries on each; the most notorious example is gcc which uses different compiler defaults on Ubuntu, and detects whether the build system is a Debian or Ubuntu system and configures the target compiler appropriately (so it is difficult to build a compiler that will create binaries targeted at a Debian system on an Ubuntu system, as the resulting compiler will assume that the target's libc contains SSP support). A different application will be embedded systems, where a variant string could be used to build a finer grained package split or leave out large optional bits of the package. The system is self-perpetuating; as soon as a deriver built dpkg with this patch once, telling it which DEB_VARIANT to use, this information will be passed on to all packages built from there on, including newer versions of dpkg. This will allow for branding changes to be merged back into Debian, and thus reduce merging work. Simon -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 2.6.22-3-amd64 (SMP w/1 CPU core) Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages dpkg depends on: ii coreutils 5.97-5.6 The GNU core utilities ii libc6 2.7-5 GNU C Library: Shared libraries dpkg recommends no packages. -- no debconf information
diff -Nru /tmp/CTGRa1SVPh/dpkg-1.14.12/configure.ac /tmp/Zg4BEoCa5A/dpkg-1.14.12/configure.ac --- /tmp/CTGRa1SVPh/dpkg-1.14.12/configure.ac 2007-11-29 05:58:22.000000000 +0100 +++ /tmp/Zg4BEoCa5A/dpkg-1.14.12/configure.ac 2007-12-21 23:46:29.000000000 +0100 @@ -49,6 +49,15 @@ esac]) AC_SUBST(admindir) +AC_ARG_WITH(variant, + AS_HELP_STRING([--with-variant=VARIANT], + [Debian system variant [[debian]]]), +[case "$with_variant" in + "") AC_MSG_ERROR([invalid variant specified]) ;; + *) variant="$with_variant" ;; +esac], +[variant=debian]) +AC_SUBST(variant) # Checks for programs. AC_PROG_CC diff -Nru /tmp/CTGRa1SVPh/dpkg-1.14.12/debian/rules /tmp/Zg4BEoCa5A/dpkg-1.14.12/debian/rules --- /tmp/CTGRa1SVPh/dpkg-1.14.12/debian/rules 2007-10-18 00:30:14.000000000 +0200 +++ /tmp/Zg4BEoCa5A/dpkg-1.14.12/debian/rules 2007-12-22 00:04:27.000000000 +0100 @@ -32,6 +32,9 @@ confflags += --with-selinux=static endif +DEB_VARIANT ?= debian + +confflags += --with-variant=$(DEB_VARIANT) # Create configure script if necessary, automake handles rebuilding it. configure: diff -Nru /tmp/CTGRa1SVPh/dpkg-1.14.12/scripts/dpkg-buildpackage.pl /tmp/Zg4BEoCa5A/dpkg-1.14.12/scripts/dpkg-buildpackage.pl --- /tmp/CTGRa1SVPh/dpkg-1.14.12/scripts/dpkg-buildpackage.pl 2007-10-18 00:41:02.000000000 +0200 +++ /tmp/Zg4BEoCa5A/dpkg-1.14.12/scripts/dpkg-buildpackage.pl 2007-12-22 00:09:07.000000000 +0100 @@ -48,6 +48,7 @@ -us unsigned source. -uc unsigned changes. -a<arch> Debian architecture we build for (implies -d). + -V<variant> Distribution variant we build for -b binary-only, do not build source. } also passed to -B binary-only, no arch-indep files. } dpkg-genchanges -S source only, no binary files. } @@ -106,6 +107,11 @@ my $diffignore = ''; my $binarytarget = 'binary'; my $targetarch = my $targetgnusystem = ''; +my $variant = "debian"; + +if (defined($ENV{'DEB_VARIANT'})) { + $variant = $ENV{'DEB_VARIANT'}; +} while (@ARGV) { $_ = shift @ARGV; @@ -139,6 +145,8 @@ } elsif (/^-a(.*)$/) { $targetarch = $1; $checkbuilddep = 0; + } elsif (/^-V(.*)$/) { + $variant = $1; } elsif (/^-s[iad]$/) { $sourcestyle = $_; } elsif (/^-s[nsAkurKUR]$/) { @@ -299,6 +307,8 @@ } close $arch_env or subprocerr('dpkg-architecture'); +$ENV{'DEB_VARIANT'} = $variant; + my $arch; unless ($sourceonly) { $arch = mustsetvar($ENV{'DEB_HOST_ARCH'}, _g('host architecture')); diff -Nru /tmp/CTGRa1SVPh/dpkg-1.14.12/scripts/Makefile.am /tmp/Zg4BEoCa5A/dpkg-1.14.12/scripts/Makefile.am --- /tmp/CTGRa1SVPh/dpkg-1.14.12/scripts/Makefile.am 2007-11-24 06:14:44.000000000 +0100 +++ /tmp/Zg4BEoCa5A/dpkg-1.14.12/scripts/Makefile.am 2007-12-21 23:35:20.000000000 +0100 @@ -90,8 +90,10 @@ dist_pkglib_SCRIPTS = \ controllib.pl +variant = @variant@ do_perl_subst = sed -e "s:^\#![:space:]*/usr/bin/perl:\#!$(PERL):" \ + -e "s:\$$variant[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$variant=\"$(variant)\":" \ -e "s:\$$dpkglibdir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$dpkglibdir=\"$(pkglibdir)\":" \ -e "s:\$$pkgdatadir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$pkgdatadir=\"$(pkgdatadir)\":" \ -e "s:\$$admindir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$admindir=\"$(admindir)\":" \