summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2024-04-23 16:13:46 +0000
committerDavid Kalnischkies <david@kalnischkies.de>2024-04-24 13:16:21 +0000
commit9c06578c37ff77b70b9d978d48528df13e13530f (patch)
treeb95b208a7e00045b2d498b6e293526b01e4aae15
parentd030a1041b243c45dcd41e34d3c2b21cf1a533ba (diff)
Drop sudo-related envvars in testing framework
Our autoremoval-advertisment is modified by SUDO_USER as if the current apt call was made with sudo it seems a good idea to show the ad with sudo as well. That is annoying for our tests through as normally the tests are run locally or by autopkgtest without sudo, but in Gitlab CI we use it (to run our tests as user… as we are already root) and so individual tests had to deal with this. That is annoying and really not needed as we can have our autoremove test check that this ad gets displayed the right way and ignore it the rest of the time.
-rw-r--r--test/integration/framework1
-rwxr-xr-xtest/integration/test-apt-get-autoremove26
-rwxr-xr-xtest/integration/test-bug-604222-new-and-autoremove13
-rwxr-xr-xtest/integration/test-bug-611729-mark-as-manual8
-rwxr-xr-xtest/integration/test-bug-613420-new-garbage-dependency8
-rwxr-xr-xtest/integration/test-disappearing-packages13
-rwxr-xr-xtest/integration/test-external-dependency-solver-protocol6
-rwxr-xr-xtest/integration/test-kernel-helper-autoremove10
8 files changed, 29 insertions, 56 deletions
diff --git a/test/integration/framework b/test/integration/framework
index 147de9808..de280cb8d 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -324,6 +324,7 @@ setupenvironment() {
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 SUDO_USER SUDO_UID SUDO_GID SUDO_COMMAND
unset http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy
export GCOV_ERROR_FILE=/dev/null
diff --git a/test/integration/test-apt-get-autoremove b/test/integration/test-apt-get-autoremove
index 66257f442..9454df5c8 100755
--- a/test/integration/test-apt-get-autoremove
+++ b/test/integration/test-apt-get-autoremove
@@ -27,10 +27,6 @@ testdpkginstalled 'po-debconf' 'unrelated'
echo 'unrelated purge' | dpkg --set-selections
testdpkgstatus 'pi' '1' 'unrelated'
-AUTOREMOVE='apt autoremove'
-if [ -n "$SUDO_USER" ]; then
- AUTOREMOVE="sudo $AUTOREMOVE"
-fi
echo 'APT::NeverAutoRemove { "^debc.*nf$"; };' > rootdir/etc/apt/apt.conf.d/00autoremove
testsuccessequal 'Reading package lists...
Building dependency tree...
@@ -39,20 +35,28 @@ The following packages will be REMOVED:
po-debconf
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
Remv po-debconf [1.0.16]' aptget autoremove -s
-testequal "Reading package lists...
+for sudouser in '_apt' ''; do
+ if [ -n "$sudouser" ]; then
+ export SUDO_USER="$sudouser"
+ AUTOREMOVE='sudo apt autoremove'
+ else
+ unset SUDO_USER
+ AUTOREMOVE='apt autoremove'
+ fi
+ testequal "Reading package lists...
Building dependency tree...
Reading state information...
The following package was automatically installed and is no longer required:
po-debconf
Use '$AUTOREMOVE' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s
-testequal "Reading package lists...
+ testequal "Reading package lists...
Building dependency tree...
Reading state information...
1 package was automatically installed and is no longer required.
Use '$AUTOREMOVE' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s -o APT::Get::HideAutoRemove=small
-testequal "Reading package lists...
+ testequal "Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
@@ -60,6 +64,8 @@ The following package was automatically installed and is no longer required:
po-debconf
Use '$AUTOREMOVE' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget upgrade -s
+done
+
testsuccessequal 'Reading package lists...
Building dependency tree...
Reading state information...
@@ -111,7 +117,7 @@ Reading state information...
Calculating upgrade...
The following package was automatically installed and is no longer required:
po-debconf
-Use '$AUTOREMOVE' to remove it.
+Use 'apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget upgrade -s
rm -f rootdir/etc/apt/apt.conf.d/autoremoval
@@ -163,13 +169,13 @@ Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
debhelper po-debconf
-Use '$AUTOREMOVE' to remove them.
+Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s
testequal "Reading package lists...
Building dependency tree...
Reading state information...
2 packages were automatically installed and are no longer required.
-Use '$AUTOREMOVE' to remove them.
+Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s -o APT::Get::HideAutoRemove=small
testsuccess aptmark hold debhelper
diff --git a/test/integration/test-bug-604222-new-and-autoremove b/test/integration/test-bug-604222-new-and-autoremove
index adb2c26d3..78a288214 100755
--- a/test/integration/test-bug-604222-new-and-autoremove
+++ b/test/integration/test-bug-604222-new-and-autoremove
@@ -36,17 +36,12 @@ insertinstalledpackage 'libvtk5.4' 'i386' '5.4.2-7'
testsuccess aptmark markauto 'libvtk5.4'
testmarkedauto 'libvtk5.4'
-AUTOREMOVE='apt autoremove'
-if [ -n "$SUDO_USER" ]; then
- AUTOREMOVE="sudo $AUTOREMOVE"
-fi
-
testsuccessequal "Reading package lists...
Building dependency tree...
Reading state information...
The following package was automatically installed and is no longer required:
libvtk5.4
-Use '$AUTOREMOVE' to remove it.
+Use 'apt autoremove' to remove it.
The following NEW packages will be installed:
libavcodec52
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
@@ -57,7 +52,7 @@ testsuccessequal "Reading package lists...
Building dependency tree...
Reading state information...
1 package was automatically installed and is no longer required.
-Use '$AUTOREMOVE' to remove it.
+Use 'apt autoremove' to remove it.
The following NEW packages will be installed:
libavcodec52
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
@@ -69,7 +64,7 @@ Building dependency tree...
Reading state information...
The following package was automatically installed and is no longer required:
libvtk5.4
-Use '$AUTOREMOVE' to remove it.
+Use 'apt autoremove' to remove it.
The following additional packages will be installed:
libavcodec52 libopenal-dev
The following NEW packages will be installed:
@@ -82,7 +77,7 @@ testequal "Reading package lists...
Building dependency tree...
Reading state information...
1 package was automatically installed and is no longer required.
-Use '$AUTOREMOVE' to remove it.
+Use 'apt autoremove' to remove it.
The following additional packages will be installed:
libavcodec52 libopenal-dev
The following NEW packages will be installed:
diff --git a/test/integration/test-bug-611729-mark-as-manual b/test/integration/test-bug-611729-mark-as-manual
index 63f8245a7..bd9af32b6 100755
--- a/test/integration/test-bug-611729-mark-as-manual
+++ b/test/integration/test-bug-611729-mark-as-manual
@@ -56,14 +56,8 @@ testdpkginstalled b c
testmarkedauto 'b'
sed -i rootdir/var/log/apt/history.log -e '/^Commandline: / d' -e '/^Start-Date: / d' -e '/^End-Date: / d'
-if [ -n "$SUDO_USER" ] && [ "$(id -u "$SUDO_USER")" -gt 0 ]; then
- testfileequal 'rootdir/var/log/apt/history.log' "
-Requested-By: $SUDO_USER ($(id -u "$SUDO_USER"))
-Reinstall: b:i386 (1.0)"
-else
- testfileequal 'rootdir/var/log/apt/history.log' '
+testfileequal 'rootdir/var/log/apt/history.log' '
Reinstall: b:i386 (1.0)'
-fi
testsuccessequal 'Reading package lists...
Building dependency tree...
diff --git a/test/integration/test-bug-613420-new-garbage-dependency b/test/integration/test-bug-613420-new-garbage-dependency
index 46c3d94c9..75a653c7e 100755
--- a/test/integration/test-bug-613420-new-garbage-dependency
+++ b/test/integration/test-bug-613420-new-garbage-dependency
@@ -16,17 +16,13 @@ setupaptarchive
touch rootdir/var/lib/apt/extended_states
testsuccess aptmark markauto openoffice.org-officebean
testmarkedauto openoffice.org-officebean
-AUTOREMOVE='apt autoremove'
-if [ -n "$SUDO_USER" ]; then
- AUTOREMOVE="sudo $AUTOREMOVE"
-fi
testfailureequal "Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
libreoffice-officebean openoffice.org-officebean
-Use '$AUTOREMOVE' to remove them.
+Use 'apt autoremove' to remove them.
The following additional packages will be installed:
libreoffice-core libreoffice-officebean openoffice.org-officebean
The following packages will be REMOVED:
@@ -43,7 +39,7 @@ testequal "Reading package lists...
Building dependency tree...
Reading state information...
2 packages were automatically installed and are no longer required.
-Use '$AUTOREMOVE' to remove them.
+Use 'apt autoremove' to remove them.
The following additional packages will be installed:
libreoffice-core libreoffice-officebean openoffice.org-officebean
The following packages will be REMOVED:
diff --git a/test/integration/test-disappearing-packages b/test/integration/test-disappearing-packages
index f3fed04f3..f93e10e74 100755
--- a/test/integration/test-disappearing-packages
+++ b/test/integration/test-disappearing-packages
@@ -60,23 +60,12 @@ all files have been overwritten by other packages:
Note: This is done automatically and on purpose by dpkg.' tail -n 4 disappear.output
sed -i rootdir/var/log/apt/history.log -e '/^Commandline: / d' -e '/^Start-Date: / d' -e '/^End-Date: / d' -e "s#:$(getarchitecture 'native') #:native #"
-if [ -n "$SUDO_USER" ] && [ "$(id -u "$SUDO_USER")" -gt 0 ]; then
- testfileequal 'rootdir/var/log/apt/history.log' "
-Requested-By: $SUDO_USER ($(id -u "$SUDO_USER"))
-Install: old-pkg:native (1)
-
-Requested-By: $SUDO_USER ($(id -u "$SUDO_USER"))
-Install: new-pkg:native (2, automatic)
-Upgrade: old-pkg:native (1, 2)
-Disappeared: old-pkg (1)"
-else
- testfileequal 'rootdir/var/log/apt/history.log' '
+testfileequal 'rootdir/var/log/apt/history.log' '
Install: old-pkg:native (1)
Install: new-pkg:native (2, automatic)
Upgrade: old-pkg:native (1, 2)
Disappeared: old-pkg (1)'
-fi
testmarkedauto # new-pkg should have get the manual flag from old-pkg
diff --git a/test/integration/test-external-dependency-solver-protocol b/test/integration/test-external-dependency-solver-protocol
index 485a77068..ca6a5ae8b 100755
--- a/test/integration/test-external-dependency-solver-protocol
+++ b/test/integration/test-external-dependency-solver-protocol
@@ -113,17 +113,13 @@ Remv somestuff [1]
Remv cool [1]
Remv stuff [1]' aptget autoremove --solver apt somestuff -s
-AUTOREMOVE='apt autoremove'
-if [ -n "$SUDO_USER" ]; then
- AUTOREMOVE="sudo $AUTOREMOVE"
-fi
testsuccessequal "Reading package lists...
Building dependency tree...
Reading state information...
Execute external solver...
The following package was automatically installed and is no longer required:
stuff
-Use '$AUTOREMOVE' to remove it.
+Use 'apt autoremove' to remove it.
The following packages will be REMOVED:
cool* somestuff*
0 upgraded, 0 newly installed, 2 to remove and 1 not upgraded.
diff --git a/test/integration/test-kernel-helper-autoremove b/test/integration/test-kernel-helper-autoremove
index 208bd1425..20a09685a 100755
--- a/test/integration/test-kernel-helper-autoremove
+++ b/test/integration/test-kernel-helper-autoremove
@@ -45,10 +45,6 @@ testprotected() {
testfailure --nomsg grep -e '^\^linux-image-amd64\$$' -e '^\^linux-image-686-pae\$$' -e ':i386' protected.list
}
-AUTOREMOVE='apt autoremove'
-if [ -n "$SUDO_USER" ]; then
- AUTOREMOVE="sudo $AUTOREMOVE"
-fi
testsuccessequal "Reading package lists...
Building dependency tree...
Reading state information...
@@ -60,7 +56,7 @@ The following packages were automatically installed and are no longer required:
${CURRENTKERNEL}+variant (5-1)
${CURRENTKERNEL}-686-pae:i386 (5-1)
${CURRENTKERNEL}-dbg (5-1)
-Use '$AUTOREMOVE' to remove them.
+Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -sV -o APT::Protect-Kernels=0
testsuccessequal "Reading package lists...
Building dependency tree...
@@ -74,13 +70,13 @@ The following packages were automatically installed and are no longer required:
${CURRENTKERNEL}-686-pae:i386 (5-1)
${CURRENTKERNEL}-dbg (5-1)
${CURRENTKERNEL}-rt (5-1)
-Use '$AUTOREMOVE' to remove them.
+Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -sV --ignore-hold -o APT::Protect-Kernels=0
testequal "Reading package lists...
Building dependency tree...
Reading state information...
7 packages were automatically installed and are no longer required.
-Use '$AUTOREMOVE' to remove them.
+Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s -o APT::Get::HideAutoRemove=small -o APT::Protect-Kernels=0
testequal "Reading package lists...
Building dependency tree...