summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-02-25 14:26:18 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2014-03-13 13:58:44 +0100
commitce7f128c020e1347f91c6074238fc5da58c5df71 (patch)
treed7ee2d69fd674597f61c170e415ffc4d1b7d6570
parent565ded7b65240b25ad8551789ac388c8ce72b1f4 (diff)
support DEB_BUILD_PROFILES and -P for build profiles
Inspired by the rest of the patch in 661537, but abstract the parsing of various ways of setting the build profiles more so it can potentially be reused and all apt parts have the same behaviour. Especially config options, cmdline options and environment will not be combined as proposed as this isn't APTs usual behaviour and dpkg doesn't do it either, so one overrides the other as it normally does.
-rw-r--r--apt-pkg/aptconfiguration.cc26
-rw-r--r--apt-pkg/aptconfiguration.h5
-rw-r--r--apt-pkg/deb/deblistparser.cc2
-rw-r--r--apt-private/private-cmndline.cc2
-rw-r--r--cmdline/apt-config.cc5
-rw-r--r--cmdline/apt-get.cc6
-rw-r--r--debian/control2
-rw-r--r--doc/apt-get.8.xml13
-rw-r--r--doc/apt.conf.5.xml9
-rw-r--r--test/integration/framework6
-rwxr-xr-xtest/integration/test-bug-661537-build-profiles-support147
11 files changed, 219 insertions, 4 deletions
diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc
index f5c758e14..3948854c6 100644
--- a/apt-pkg/aptconfiguration.cc
+++ b/apt-pkg/aptconfiguration.cc
@@ -426,7 +426,7 @@ void Configuration::setDefaultConfigurationForCompressors() {
}
}
/*}}}*/
-// getCompressors - Return Vector of usbale compressors /*{{{*/
+// getCompressors - Return Vector of usealbe compressors /*{{{*/
// ---------------------------------------------------------------------
/* return a vector of compressors used by apt-ftparchive in the
multicompress functionality or to detect data.tar files */
@@ -508,4 +508,28 @@ Configuration::Compressor::Compressor(char const *name, char const *extension,
UncompressArgs.push_back(uncompressArg);
}
/*}}}*/
+// getBuildProfiles - return a vector of enabled build profiles /*{{{*/
+std::vector<std::string> const Configuration::getBuildProfiles() {
+ // order is: override value (~= commandline), environment variable, list (~= config file)
+ std::string profiles_env = getenv("DEB_BUILD_PROFILES") == 0 ? "" : getenv("DEB_BUILD_PROFILES");
+ if (profiles_env.empty() == false) {
+ profiles_env = SubstVar(profiles_env, " ", ",");
+ std::string const bp = _config->Find("APT::Build-Profiles");
+ _config->Clear("APT::Build-Profiles");
+ if (bp.empty() == false)
+ _config->Set("APT::Build-Profiles", bp);
+ }
+ return _config->FindVector("APT::Build-Profiles", profiles_env);
+}
+std::string const Configuration::getBuildProfilesString() {
+ std::vector<std::string> profiles = getBuildProfiles();
+ if (profiles.empty() == true)
+ return "";
+ std::vector<std::string>::const_iterator p = profiles.begin();
+ std::string list = *p;
+ for (; p != profiles.end(); ++p)
+ list.append(",").append(*p);
+ return list;
+}
+ /*}}}*/
}
diff --git a/apt-pkg/aptconfiguration.h b/apt-pkg/aptconfiguration.h
index bf7deae85..026493c6d 100644
--- a/apt-pkg/aptconfiguration.h
+++ b/apt-pkg/aptconfiguration.h
@@ -117,6 +117,11 @@ public: /*{{{*/
/** \brief Return a vector of extensions supported for data.tar's */
std::vector<std::string> static const getCompressorExtensions();
+
+ /** \return Return a vector of enabled build profile specifications */
+ std::vector<std::string> static const getBuildProfiles();
+ /** \return Return a comma-separated list of enabled build profile specifications */
+ std::string static const getBuildProfilesString();
/*}}}*/
private: /*{{{*/
void static setDefaultConfigurationForCompressors();
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index a4795f15d..89f3514c9 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -625,7 +625,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
if (unlikely(I == Stop))
return 0;
- std::vector<string> const profiles = _config->FindVector("APT::Build-Profiles");
+ std::vector<string> const profiles = APT::Configuration::getBuildProfiles();
const char *End = I;
bool Found = false;
diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc
index ef7d65f3c..b99443210 100644
--- a/apt-private/private-cmndline.cc
+++ b/apt-private/private-cmndline.cc
@@ -141,6 +141,7 @@ bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const * const
{
addArg('b', "compile", "APT::Get::Compile", 0);
addArg('b', "build", "APT::Get::Compile", 0);
+ addArg('P', "build-profiles", "APT::Build-Profiles", CommandLine::HasArg);
addArg(0, "diff-only", "APT::Get::Diff-Only", 0);
addArg(0, "debian-only", "APT::Get::Diff-Only", 0);
addArg(0, "tar-only", "APT::Get::Tar-Only", 0);
@@ -149,6 +150,7 @@ bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const * const
else if (CmdMatches("build-dep"))
{
addArg('a', "host-architecture", "APT::Get::Host-Architecture", CommandLine::HasArg);
+ addArg('P', "build-profiles", "APT::Build-Profiles", CommandLine::HasArg);
addArg(0, "purge", "APT::Get::Purge", 0);
addArg(0, "solver", "APT::Solver", CommandLine::HasArg);
// this has no effect *but* sbuild is using it (see LP: #1255806)
diff --git a/cmdline/apt-config.cc b/cmdline/apt-config.cc
index 30c2a22d5..9f20b3c1b 100644
--- a/cmdline/apt-config.cc
+++ b/cmdline/apt-config.cc
@@ -155,6 +155,11 @@ int main(int argc,const char *argv[]) /*{{{*/
_config->Set(comp + "UncompressArg::", *a);
}
+ std::vector<std::string> const profiles = APT::Configuration::getBuildProfiles();
+ _config->Clear("APT::Build-Profiles");
+ for (std::vector<std::string>::const_iterator p = profiles.begin(); p != profiles.end(); ++p)
+ _config->Set("APT::Build-Profiles::", *p);
+
// Match the operation
CmdL.DispatchArg(Cmds);
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 12e385b69..f8de80a91 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -970,6 +970,12 @@ bool DoSource(CommandLine &CmdL)
string buildopts = _config->Find("APT::Get::Host-Architecture");
if (buildopts.empty() == false)
buildopts = "-a" + buildopts + " ";
+
+ // get all active build profiles
+ std::string const profiles = APT::Configuration::getBuildProfilesString();
+ if (profiles.empty() == false)
+ buildopts.append(" -P").append(profiles).append(" ");
+
buildopts.append(_config->Find("DPkg::Build-Options","-b -uc"));
// Call dpkg-buildpackage
diff --git a/debian/control b/debian/control
index 2d58d0711..5ce68414e 100644
--- a/debian/control
+++ b/debian/control
@@ -21,7 +21,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ${apt:keyring}, gnupg
Replaces: manpages-pl (<< 20060617-3~), manpages-it (<< 2.80-4~)
Breaks: manpages-pl (<< 20060617-3~), manpages-it (<< 2.80-4~)
Conflicts: python-apt (<< 0.7.93.2~)
-Suggests: aptitude | synaptic | wajig, dpkg-dev, apt-doc, python-apt
+Suggests: aptitude | synaptic | wajig, dpkg-dev (>= 1.17.2), apt-doc, python-apt
Description: commandline package manager
This package provides commandline tools for searching and
managing as well as querying information about packages
diff --git a/doc/apt-get.8.xml b/doc/apt-get.8.xml
index 595ea875d..1ed08904e 100644
--- a/doc/apt-get.8.xml
+++ b/doc/apt-get.8.xml
@@ -371,7 +371,18 @@
by <command>apt-get source --compile</command> and how cross-builddependencies
are satisfied. By default is it not set which means that the host architecture
is the same as the build architecture (which is defined by <literal>APT::Architecture</literal>).
- Configuration Item: <literal>APT::Get::Host-Architecture</literal>
+ Configuration Item: <literal>APT::Get::Host-Architecture</literal>.
+ </para></listitem>
+ </varlistentry>
+
+ <varlistentry><term><option>-P</option></term>
+ <term><option>--build-profiles</option></term>
+ <listitem><para>This option controls the activated build profiles for which
+ a source package is built by <command>apt-get source --compile</command> and
+ how build dependencies are satisfied. By default no build profile is active.
+ More than one build profile can be activated at a time by concatenating them
+ with a comma.
+ Configuration Item: <literal>APT::Build-Profiles</literal>.
</para></listitem>
</varlistentry>
diff --git a/doc/apt.conf.5.xml b/doc/apt.conf.5.xml
index bfc43ba29..78f6a27a2 100644
--- a/doc/apt.conf.5.xml
+++ b/doc/apt.conf.5.xml
@@ -177,6 +177,15 @@ DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";};
</para></listitem>
</varlistentry>
+ <varlistentry><term><option>Build-Profiles</option></term>
+ <listitem><para>
+ List of all build profiles enabled for build-dependency resolution,
+ without the "<literal>profile.</literal>" namespace prefix.
+ By default this list is empty. The <envar>DEB_BUILD_PROFILES</envar>
+ as used by &dpkg-buildpackage; overrides the list notation.
+ </para></listitem>
+ </varlistentry>
+
<varlistentry><term><option>Default-Release</option></term>
<listitem><para>Default release to install packages from if more than one
version is available. Contains release name, codename or release version. Examples: 'stable', 'testing',
diff --git a/test/integration/framework b/test/integration/framework
index 911a4d742..9c4ac87d3 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -120,6 +120,9 @@ aptwebserver() {
dpkg() {
command dpkg --root=${TMPWORKINGDIRECTORY}/rootdir --force-not-root --force-bad-path --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log "$@"
}
+dpkgcheckbuilddeps() {
+ command dpkg-checkbuilddeps --admindir=${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg "$@"
+}
aptitude() {
if [ -f ./aptconfig.conf ]; then
APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} command aptitude "$@"
@@ -240,6 +243,9 @@ setupenvironment() {
# newer gpg versions are fine without it, but play it safe for now
gpg --quiet --check-trustdb --secret-keyring $SECRETKEYRING --keyring $SECRETKEYRING >/dev/null 2>&1
+ # cleanup the environment a bit
+ unset GREP_OPTIONS DEB_BUILD_PROFILES
+
msgdone "info"
}
diff --git a/test/integration/test-bug-661537-build-profiles-support b/test/integration/test-bug-661537-build-profiles-support
new file mode 100755
index 000000000..ae1403f71
--- /dev/null
+++ b/test/integration/test-bug-661537-build-profiles-support
@@ -0,0 +1,147 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64' 'i386' 'armel'
+
+insertinstalledpackage 'build-essential' 'all' '0' 'Multi-Arch: foreign'
+
+insertpackage 'unstable' 'foo' 'all' '1.0'
+insertpackage 'unstable' 'bar' 'all' '1.0'
+
+insertsource 'unstable' 'buildprofiles' 'any' '1' 'Build-Depends: foo (>= 1.0) [i386 arm] <!profile.stage1 !profile.cross>, bar'
+
+# table from https://wiki.debian.org/BuildProfileSpec
+insertsource 'unstable' 'spec-1' 'any' '1' 'Build-Depends: foo <!profile.stage1>'
+insertsource 'unstable' 'spec-2' 'any' '1' 'Build-Depends: foo <profile.stage1>'
+insertsource 'unstable' 'spec-3' 'any' '1' 'Build-Depends: foo <!profile.stage1 !profile.notest>'
+insertsource 'unstable' 'spec-4' 'any' '1' 'Build-Depends: foo <profile.stage1 profile.notest>'
+insertsource 'unstable' 'spec-5' 'any' '1' 'Build-Depends: foo <!profile.stage1 profile.notest>'
+insertsource 'unstable' 'spec-6' 'any' '1' 'Build-Depends: foo <profile.stage1 !profile.notest>'
+# multiple stanzas not supported: error out
+insertsource 'unstable' 'spec-7' 'any' '1' 'Build-Depends: foo <profile.stage1><!profile.notest>'
+insertsource 'unstable' 'spec-8' 'any' '1' 'Build-Depends: foo <profile.stage1> <!profile.notest>'
+
+setupaptarchive
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ bar
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst bar (1.0 unstable [all])
+Conf bar (1.0 unstable [all])' aptget build-dep buildprofiles -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ bar foo
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst bar (1.0 unstable [all])
+Inst foo (1.0 unstable [all])
+Conf bar (1.0 unstable [all])
+Conf foo (1.0 unstable [all])' aptget build-dep buildprofiles -s -o APT::Architecture=i386
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ bar
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst bar (1.0 unstable [all])
+Conf bar (1.0 unstable [all])' aptget build-dep buildprofiles -s -o APT::Architecture=armel
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ bar
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst bar (1.0 unstable [all])
+Conf bar (1.0 unstable [all])' aptget build-dep buildprofiles -s -o APT::Architecture=i386 -P stage1
+
+KEEP='Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ foo
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst foo (1.0 unstable [all])
+Conf foo (1.0 unstable [all])'
+DROP='Reading package lists...
+Building dependency tree...
+0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.'
+
+msgtest 'Check if version of installed dpkg is high enough for' 'build profiles support'
+if dpkg --compare-versions "$(command dpkg-query --showformat='${Version}' --show dpkg)" 'ge' '1.17.2'; then
+ msgpass
+ testwithdpkg() {
+ msgtest "Test with" "dpkg-checkbuilddeps -d '$1' -P '$2'"
+ local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testwithdpkg.output"
+ if dpkgcheckbuilddeps -d "$1" -P "$2" /dev/null >$OUTPUT 2>&1; then
+ if [ "$3" = "$DROP" ]; then
+ msgpass
+ else
+ cat $OUTPUT
+ msgfail
+ fi
+ else
+ if [ "$3" = "$KEEP" ]; then
+ msgpass
+ else
+ cat $OUTPUT
+ msgfail
+ fi
+ fi
+ }
+else
+ msgskip
+ testwithdpkg() {
+ msgtest "Test with" "dpkg-checkbuilddeps -d '$1' -P '$2'"
+ msgskip
+ }
+fi
+
+testprofile() {
+ if [ -n "$3" ]; then
+ testequal "$4" aptget build-dep "$1" -s -P "$3"
+ export DEB_BUILD_PROFILES="$(echo "$3" | tr ',' ' ')"
+ testequal "$4" aptget build-dep "$1" -s -o with::environment=1
+ unset DEB_BUILD_PROFILES
+ else
+ testequal "$4" aptget build-dep "$1" -s
+ fi
+ testwithdpkg "$2" "$3" "$4"
+}
+
+testprofile 'spec-1' 'foo <!profile.stage1>' '' "$KEEP"
+testprofile 'spec-1' 'foo <!profile.stage1>' 'stage1' "$DROP"
+testprofile 'spec-1' 'foo <!profile.stage1>' 'notest' "$KEEP"
+testprofile 'spec-1' 'foo <!profile.stage1>' 'stage1,notest' "$DROP"
+
+testprofile 'spec-2' 'foo <profile.stage1>' '' "$DROP"
+testprofile 'spec-2' 'foo <profile.stage1>' 'stage1' "$KEEP"
+testprofile 'spec-2' 'foo <profile.stage1>' 'notest' "$DROP"
+testprofile 'spec-2' 'foo <profile.stage1>' 'stage1,notest' "$KEEP"
+
+testprofile 'spec-3' 'foo <!profile.stage1 !profile.notest>' '' "$KEEP"
+testprofile 'spec-3' 'foo <!profile.stage1 !profile.notest>' 'stage1' "$DROP"
+testprofile 'spec-3' 'foo <!profile.stage1 !profile.notest>' 'notest' "$DROP"
+testprofile 'spec-3' 'foo <!profile.stage1 !profile.notest>' 'stage1,notest' "$DROP"
+
+testprofile 'spec-4' 'foo <profile.stage1 profile.notest>' '' "$DROP"
+testprofile 'spec-4' 'foo <profile.stage1 profile.notest>' 'stage1' "$KEEP"
+testprofile 'spec-4' 'foo <profile.stage1 profile.notest>' 'notest' "$KEEP"
+testprofile 'spec-4' 'foo <profile.stage1 profile.notest>' 'stage1,notest' "$KEEP"
+
+testprofile 'spec-5' 'foo <!profile.stage1 profile.notest>' '' "$KEEP"
+testprofile 'spec-5' 'foo <!profile.stage1 profile.notest>' 'stage1' "$DROP"
+testprofile 'spec-5' 'foo <!profile.stage1 profile.notest>' 'notest' "$KEEP"
+testprofile 'spec-5' 'foo <!profile.stage1 profile.notest>' 'stage1,notest' "$DROP"
+
+testprofile 'spec-6' 'foo <profile.stage1 !profile.notest>' '' "$KEEP"
+testprofile 'spec-6' 'foo <profile.stage1 !profile.notest>' 'stage1' "$KEEP"
+testprofile 'spec-6' 'foo <profile.stage1 !profile.notest>' 'notest' "$DROP"
+testprofile 'spec-6' 'foo <profile.stage1 !profile.notest>' 'stage1,notest' "$KEEP"
+
+testfailure aptget build-dep spec-7 -s
+testfailure aptget build-dep spec-8 -s