[buildd-tools-devel] re buildd's resolver and package's build deps

Roger Leigh rleigh at codelibre.net
Wed Feb 23 11:30:05 UTC 2011


On Wed, Feb 23, 2011 at 10:45:06AM +0100, Philipp Kern wrote:
> On Tue, Feb 22, 2011 at 10:40:52PM +0000, Roger Leigh wrote:
> > From discussion on IRC earlier this evening, it looks like the most
> > pragmatic approach will be to get the apt and aptitude sbuild
> > resolvers to strip the alternatives (after arch reduction), which
> > will make them behave pretty much exactly like the old internal
> > resolver, but without its bugs.  This will leave maintainers free to
> > use alternative dependencies, but like now they will be ignored.
> > What we can do though, is make the use of alternatives configurable
> > in sbuild, so you will be able to make use of them when building for
> > other suites e.g. backports.  This will disable the stripping.
> 
> I find this acceptable[0].  Thanks for driving this.

I've now implemented this with the attached patch.  If you are happy
with this behaviour, I'll commit it.  Those six lines are equivalent
to about 300 in the internal resolver!  With this change made, would
you be OK to consider moving over to the apt resolver on the buildds?
At this point it's pretty much identical in every way that matters,
certainly from empirical testing.

Example build log, using php5 since that's where this thread started:

Merged Build-Depends: base-files, base-passwd, bash, coreutils, dash,
debianutils, diffutils, dpkg, e2fsprogs, findutils, grep, gzip, hostname,
ncurses-base, ncurses-bin, perl-base, sed, login, sysvinit-utils, sysvinit,
tar, bsdutils, mount, util-linux, libc6-dev | libc-dev, gcc (>= 4:4.4.3), g++
(>= 4:4.4.3), make, dpkg-dev (>= 1.13.5), apache2-prefork-dev, autoconf (>=
2.63), automake (>= 1.11) | automake1.11, bison, chrpath, debhelper (>= 5),
firebird2.1-dev | firebird2.0-dev, flex, freetds-dev, hardening-wrapper,
libapr1-dev (>= 1.2.7-8), libbz2-dev, libc-client-dev, libcurl4-openssl-dev |
libcurl-dev, libdb-dev (>= 4.7) | libdb4.8-dev | libdb4.6-dev, libenchant-dev,
libevent-dev (>= 1.4.11), libexpat1-dev (>= 1.95.2-2.1), libfreetype6-dev,
libgcrypt11-dev, libgd2-xpm-dev, libglib2.0-dev, libgmp3-dev, libicu-dev,
libjpeg-dev | libjpeg62-dev, libkrb5-dev, libldap2-dev, libmcrypt-dev,
libmhash-dev (>= 0.8.8), libmysqlclient-dev | libmysqlclient15-dev,
libonig-dev, libpam0g-dev, libpcre3-dev (>= 6.6), libpng12-dev, libpq-dev,
libpspell-dev, libqdbm-dev, librecode-dev, libsasl2-dev, libsnmp-dev,
libsqlite0-dev, libsqlite3-dev, libssl-dev, libt1-dev, libtidy-dev, libtool (>=
2.2), libwrap0-dev, libxmltok1-dev, libxml2-dev, libxslt1-dev (>= 1.0.18),
locales-all, mysql-server, netbase, netcat-traditional, quilt, re2c,
unixodbc-dev, zlib1g-dev, tzdata
Merged Build-Conflicts: bind-dev
Filtered Build-Depends: base-files, base-passwd, bash, coreutils, dash,
debianutils, diffutils, dpkg, e2fsprogs, findutils, grep, gzip, hostname,
ncurses-base, ncurses-bin, perl-base, sed, login, sysvinit-utils, sysvinit,
tar, bsdutils, mount, util-linux, libc6-dev, gcc (>= 4:4.4.3), g++ (>=
4:4.4.3), make, dpkg-dev (>= 1.13.5), apache2-prefork-dev, autoconf (>= 2.63),
automake (>= 1.11), bison, chrpath, debhelper (>= 5), firebird2.1-dev, flex,
freetds-dev, hardening-wrapper, libapr1-dev (>= 1.2.7-8), libbz2-dev,
libc-client-dev, libcurl4-openssl-dev, libdb-dev (>= 4.7), libenchant-dev,
libevent-dev (>= 1.4.11), libexpat1-dev (>= 1.95.2-2.1), libfreetype6-dev,
libgcrypt11-dev, libgd2-xpm-dev, libglib2.0-dev, libgmp3-dev, libicu-dev,
libjpeg-dev, libkrb5-dev, libldap2-dev, libmcrypt-dev, libmhash-dev (>= 0.8.8),
libmysqlclient-dev, libonig-dev, libpam0g-dev, libpcre3-dev (>= 6.6),
libpng12-dev, libpq-dev, libpspell-dev, libqdbm-dev, librecode-dev,
libsasl2-dev, libsnmp-dev, libsqlite0-dev, libsqlite3-dev, libssl-dev,
libt1-dev, libtidy-dev, libtool (>= 2.2), libwrap0-dev, libxmltok1-dev,
libxml2-dev, libxslt1-dev (>= 1.0.18), locales-all, mysql-server, netbase,
netcat-traditional, quilt, re2c, unixodbc-dev, zlib1g-dev, tzdata
Filtered Build-Conflicts: bind-dev


diff --git a/etc/sbuild.conf b/etc/sbuild.conf
index fb244fe..4cccb32 100644
--- a/etc/sbuild.conf
+++ b/etc/sbuild.conf
@@ -150,6 +150,15 @@
 # build dependencies, respectively.
 #$build_dep_resolver = "aptitude";
 
+# Should the dependency resolve use alternatives in Build-Depends and
+# Build-Depends-Indep?  By default, only the first alternative will be
+# used; all other alternatives will be removed.  Note that this does
+# not include architecture-specific alternatives, which are reduced to
+# the build architecture prior to alternatives removal.  This should
+# be left disabled when building for unstable; it may be useful when
+# building backports.
+#$build_dep_resolver = 0;
+
 # APT policy.  1 to enable additional checking of package versions
 # available in the APT cache, or 0 to disable.  0 is the traditional
 # sbuild behaviour; 1 is needed to build from additional repositories
diff --git a/lib/Sbuild/Conf.pm b/lib/Sbuild/Conf.pm
index 44c8797..711b09a 100644
--- a/lib/Sbuild/Conf.pm
+++ b/lib/Sbuild/Conf.pm
@@ -545,6 +545,9 @@ sub setup ($) {
 	'RESOLVE_VIRTUAL'				=> {
 	    DEFAULT => 0
 	},
+	'RESOLVE_ALTERNATIVES'				=> {
+	    DEFAULT => 0
+	},
 	'SBUILD_BUILD_DEPENDS_SECRET_KEY'		=> {
 	    DEFAULT => '/var/lib/sbuild/apt-keys/sbuild-key.sec'
 	},
@@ -648,6 +651,7 @@ sub read ($) {
     my $log_external_command_output = undef;
     my $log_external_command_error = undef;
     my $resolve_virtual = undef;
+    my $resolve_alternatives = undef;
     my $core_depends = undef;
 
     foreach ($Sbuild::Sysconfig::paths{'SBUILD_CONF'}, "$HOME/.sbuildrc") {
@@ -665,6 +669,7 @@ sub read ($) {
     # Set before APT_GET or APTITUDE to allow correct validation.
     $conf->set('BUILD_DEP_RESOLVER', $build_dep_resolver);
     $conf->set('RESOLVE_VIRTUAL', $resolve_virtual);
+    $conf->set('RESOLVE_ALTERNATIVES', $resolve_alternatives);
     $conf->set('CORE_DEPENDS', $core_depends);
     $conf->set('ARCH', $arch);
     $conf->set('DISTRIBUTION', $distribution);
diff --git a/lib/Sbuild/ResolverBase.pm b/lib/Sbuild/ResolverBase.pm
index 5973c41..80c536e 100644
--- a/lib/Sbuild/ResolverBase.pm
+++ b/lib/Sbuild/ResolverBase.pm
@@ -536,6 +536,19 @@ EOF
 			      host_arch => $self->get('Arch'));
     }
 
+    $self->log("Merged Build-Depends: $positive\n") if $positive;
+    $self->log("Merged Build-Conflicts: $negative\n") if $negative;
+
+    # Filter out all but the first alternative.
+    if (!$self->get_conf('RESOLVE_ALTERNATIVES')) {
+	my $positive_filtered = Dpkg::Deps::AND->new();
+	foreach my $item ($positive->get_deps()) {
+	    my ($first) = $item->get_deps();
+	    $positive_filtered->add($first) if defined $first;
+	}
+	$positive = $positive_filtered;
+    }
+
     if ($positive ne "") {
 	print DUMMY_CONTROL 'Depends: ' . $positive . "\n";
     }
@@ -543,8 +556,8 @@ EOF
 	print DUMMY_CONTROL 'Conflicts: ' . $negative . "\n";
     }
 
-    debug("DUMMY Depends: $positive \n");
-    debug("DUMMY Conflicts: $negative \n");
+    $self->log("Filtered Build-Depends: $positive\n") if $positive;
+    $self->log("Filtered Build-Conflicts: $negative\n") if $negative;
 
     print DUMMY_CONTROL <<"EOF";
 Maintainer: Debian buildd-tools Developers <buildd-tools-devel\@lists.alioth.debian.org>

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux             http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?       http://gutenprint.sourceforge.net/
   `-    GPG Public Key: 0x25BFB848   Please GPG sign your mail.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/buildd-tools-devel/attachments/20110223/367dc81b/attachment-0001.pgp>


More information about the Buildd-tools-devel mailing list