summaryrefslogtreecommitdiff
path: root/test/integration/framework
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2021-10-18 13:36:00 +0000
committerJulian Andres Klode <jak@debian.org>2021-10-18 13:36:00 +0000
commitedf4b2169405e7ca6e21f408229e5fc4bbd4f4ed (patch)
tree864a13dbda22e3b4de7b69600521fb7e7d8b39a2 /test/integration/framework
parent883a12310a4130370965eab0a710a2c8fae6cc09 (diff)
parent70c669e2566d119559d2986635bb6c1d0d368073 (diff)
Merge branch 'feature/barbarianarchs' into 'main'
Streamline access to barbarian architecture functionality See merge request apt-team/apt!184
Diffstat (limited to 'test/integration/framework')
-rw-r--r--test/integration/framework77
1 files changed, 43 insertions, 34 deletions
diff --git a/test/integration/framework b/test/integration/framework
index 1f942d162..d8fd6ba95 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -204,6 +204,9 @@ aptinternalplanner() { runapt "${APTINTERNALPLANNER}" "$@"; }
dpkg() {
"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg" "$@"
}
+dpkgquery() {
+ command dpkg-query --admindir="${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg" "$@"
+}
dpkg_version() {
command perl -MDpkg -E 'say $Dpkg::PROGVERSION'
}
@@ -290,7 +293,6 @@ escape_shell() {
}
find_project_binary_dir() {
- local TESTDIRECTORY="$(readlink -f "$(dirname $0)")"
if [ -z "$PROJECT_BINARY_DIR" ]; then
PROJECT_BINARY_DIR=
for dir in ${TESTDIRECTORY}/../../ ${TESTDIRECTORY}/../../*; do
@@ -315,6 +317,16 @@ _removetmpworkingdirectory() {
TMPWORKINGDIRECTORY=''
}
setupenvironment() {
+ # cleanup the environment a bit
+ export LC_ALL=C
+ unset LANGUAGE COLUMNS NLSPATH
+ unset APT_CONFIG DPKG_ADMINDIR DPKG_COLORS
+ unset DEB_CHECK_COMMAND DEB_SIGN_KEYID DEB_BUILD_OPTIONS DEB_BUILD_PROFILES
+ unset DH_VERBOSE DH_QUIET DH_COMPAT DH_NO_ACT DH_OPTIONS DH_EXTRA_ADDONS
+ unset GREP_OPTIONS POSIXLY_CORRECT
+ unset http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy
+ export GCOV_ERROR_FILE=/dev/null
+
# Next check needs a gnu stat, let's figure that out early.
stat=stat
if command -v gnustat >/dev/null 2>&1; then
@@ -347,18 +359,40 @@ setupenvironment() {
done
export PATH="${TMPWORKINGDIRECTORY}/bin/:$PATH"
+ if [ -z "$TESTDIRECTORY" ]; then
+ TESTDIRECTORY="$(readlink -f "$(dirname $0)")"
+ fi
+ cd "$TMPWORKINGDIRECTORY"
- mkdir -m 700 "${TMPWORKINGDIRECTORY}/downloaded"
+ mkdir -m 700 'downloaded'
if [ "$(id -u)" = '0' ]; then
# relax permissions so that running as root with user switching works
umask 022
chmod 711 "$TMPWORKINGDIRECTORY"
chown _apt:$(id -gn) "${TMPWORKINGDIRECTORY}/downloaded"
fi
+ mkdir -p 'rootdir/usr/bin' 'rootdir/var/cache' 'rootdir/var/lib' 'rootdir/var/log' 'rootdir/var/crash' 'rootdir/tmp'
- TESTDIRECTORY="$(readlink -f "$(dirname $0)")"
# Find the newest build directory (sets PROJECT_BINARY_DIR)
find_project_binary_dir
+
+ _setupprojectenvironment
+
+ # create some files in /tmp and look at user/group to get what this means
+ TEST_DEFAULT_USER="$(id -un)"
+ touch "${TMPWORKINGDIRECTORY}/test-file"
+ TEST_DEFAULT_GROUP=$(stat --format '%G' "${TMPWORKINGDIRECTORY}/test-file")
+
+ # prefer our apt binaries over the system apt binaries
+ export PATH="${BUILDDIRECTORY}:${PATH}:/usr/local/sbin:/usr/sbin:/sbin"
+
+ if [ -r "${TESTDIRECTORY}/extra-environment" ]; then
+ . "${TESTDIRECTORY}/extra-environment"
+ fi
+
+ msgdone "info"
+}
+_setupprojectenvironment() {
# allow overriding the default BUILDDIR location
SOURCEDIRECTORY="${APT_INTEGRATION_TESTS_SOURCE_DIR:-"${TESTDIRECTORY}/../../"}"
BUILDDIRECTORY="${APT_INTEGRATION_TESTS_BUILD_DIR:-"${PROJECT_BINARY_DIR}/cmdline"}"
@@ -372,17 +406,15 @@ setupenvironment() {
APTINTERNALPLANNER="${APT_INTEGRATION_TESTS_INTERNAL_PLANNER:-"${BUILDDIRECTORY}/planners/apt"}"
ARTIFACTSDIR="${APT_INTEGRATION_TESTS_ARTIFACTS_DIR:-"${BUILDDIRECTORY}/artifacts"}"
test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first"
- # -----
- cd "$TMPWORKINGDIRECTORY"
echo "#x-apt-configure-index \"${SOURCEDIRECTORY}/doc/examples/configure-index\";" > aptconfig.conf
- mkdir rootdir aptarchive keys
+ mkdir aptarchive keys
cd rootdir
mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d
- mkdir -p usr/bin var/cache var/lib var/log var/crash tmp
mkdir -p var/lib/dpkg/info var/lib/dpkg/updates var/lib/dpkg/triggers
mkdir -p usr/lib/apt/solvers usr/lib/apt/planners
- touch var/lib/dpkg/available
+ touch var/lib/dpkg/available var/lib/dpkg/lock
+ echo '1' > var/lib/dpkg/info/format
ln -s "${METHODSDIR}" usr/lib/apt/methods
ln -s "${APTDUMPSOLVER}" usr/lib/apt/solvers/dump
ln -s "${APTDUMPSOLVER}" usr/lib/apt/planners/dump
@@ -499,29 +531,10 @@ EOF
configcompression '.' 'gz' #'bz2' 'lzma' 'xz'
confighashes 'SHA256' # these are tests, not security best-practices
- # create some files in /tmp and look at user/group to get what this means
- TEST_DEFAULT_USER="$(id -un)"
- touch "${TMPWORKINGDIRECTORY}/test-file"
- TEST_DEFAULT_GROUP=$(stat --format '%G' "${TMPWORKINGDIRECTORY}/test-file")
-
- # cleanup the environment a bit
- # prefer our apt binaries over the system apt binaries
- export PATH="${BUILDDIRECTORY}:${PATH}:/usr/local/sbin:/usr/sbin:/sbin"
- export LC_ALL=C
- unset LANGUAGE COLUMNS NLSPATH
- unset APT_CONFIG DPKG_ADMINDIR DPKG_COLORS
- unset DEB_CHECK_COMMAND DEB_SIGN_KEYID DEB_BUILD_OPTIONS DEB_BUILD_PROFILES
- unset DH_VERBOSE DH_QUIET DH_COMPAT DH_NO_ACT DH_OPTIONS DH_EXTRA_ADDONS
- unset GREP_OPTIONS POSIXLY_CORRECT
- unset http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy
-
# Make dpkg inherit testing path
echo 'DPkg::Path "";' >> aptconfig.conf
echo 'Dir::Bin::ischroot "/bin/false";' >> aptconfig.conf
- # Make gcov shut up
- export GCOV_ERROR_FILE=/dev/null
-
# If gpgv supports --weak-digest, pass it to make sure we can disable SHA1
if aptkey verify --weak-digest SHA1 --help 2>/dev/null >/dev/null; then
echo 'Acquire::gpgv::Options { "--weak-digest"; "sha1"; };' > rootdir/etc/apt/apt.conf.d/no-sha1
@@ -529,12 +542,6 @@ EOF
# most tests just need one signed Release file, not both
export APT_DONT_SIGN='Release.gpg'
-
- if [ -r "${TESTDIRECTORY}/extra-environment" ]; then
- . "${TESTDIRECTORY}/extra-environment"
- fi
-
- msgdone "info"
}
getarchitecture() {
@@ -1059,10 +1066,12 @@ Version: $VERSION" >> "$FILE"
test -z "$DEPENDENCIES" || printf "%b\n" "$DEPENDENCIES" >> "$FILE"
printf "%b\n" "Description: $DESCRIPTION" >> "$FILE"
echo >> "$FILE"
- if [ "$(dpkg-query -W --showformat='${Multi-Arch}')" = 'same' ]; then
+ if [ "$(dpkgquery -W --showformat='${Multi-Arch}' "${NAME}:${arch}" 2>/dev/null)" = 'same' ]; then
echo -n > "${INFO}/${NAME}:${arch}.list"
+ echo -n > "${INFO}/${NAME}:${arch}.md5sums"
else
echo -n > "${INFO}/${NAME}.list"
+ echo -n > "${INFO}/${NAME}.md5sums"
fi
done
}