X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/07aca07ae73016aa7823e708dda746eec8346989..29636cc759c6fbb92c6c462c90611eefb67cbbd4:/test/integration/framework diff --git a/test/integration/framework b/test/integration/framework index b0be3eaf1..a68209326 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -175,6 +175,7 @@ runapt() { esac MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG="$(getaptconfig)" LD_LIBRARY_PATH="${LIBRARYPATH}:${LD_LIBRARY_PATH}" "$CMD" "$@" } +runpython3() { runapt command python3 "$@"; } aptconfig() { runapt apt-config "$@"; } aptcache() { runapt apt-cache "$@"; } aptcdrom() { runapt apt-cdrom "$@"; } @@ -216,6 +217,12 @@ gdb() { fi runapt command gdb --quiet -ex run "$CMD" --args "$CMD" "$@" } +lastmodification() { + date -u -d "@$(stat -c '%Y' "${TMPWORKINGDIRECTORY}/$1")" '+%a, %d %b %Y %H:%M:%S GMT' +} +releasefiledate() { + grep "^${2:-Date}:" "$1" | cut -d' ' -f 2- | sed -e 's#UTC#GMT#' +} exitwithstatus() { # error if we about to overflow, but ... @@ -389,8 +396,9 @@ EOF echo "Acquire::https::CaInfo \"${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem\";" > rootdir/etc/apt/apt.conf.d/99https echo "Apt::Cmd::Disable-Script-Warning \"1\";" > rootdir/etc/apt/apt.conf.d/apt-binary echo 'Acquire::Connect::AddrConfig "false";' > rootdir/etc/apt/apt.conf.d/connect-addrconfig + configcompression '.' 'gz' #'bz2' 'lzma' 'xz' - confighashes 'SHA1' # these are tests, not security best-practices + 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)" @@ -407,6 +415,12 @@ EOF unset LANGUAGE APT_CONFIG unset GREP_OPTIONS DEB_BUILD_PROFILES unset http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy + + # 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 + fi + msgdone "info" } @@ -517,7 +531,7 @@ int execvp(const char *file, char *const argv[]) { return func_execvp(newfile, argv); } EOF - testsuccess --nomsg gcc -Wall -fPIC -shared -o noopchroot.so noopchroot.c -ldl + testempty --nomsg gcc -Wall -Wextra -fPIC -shared -o noopchroot.so noopchroot.c -ldl } configcompression() { local CMD='apthelper cat-file -C' @@ -558,6 +572,11 @@ forcecompressor() { local CONFFILE="${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/00force-compressor" echo "Acquire::CompressionTypes::Order { \"${COMPRESS}\"; }; Dir::Bin::uncompressed \"/does/not/exist\";" > "$CONFFILE" + for COMP in $(aptconfig dump 'APT::Compressor' --format '%f%n' | cut -d':' -f 5 | uniq); do + if [ -z "$COMP" -o "$COMP" = '.' -o "$COMP" = "$COMPRESSOR" ]; then continue; fi + echo "Dir::Bin::${COMP} \"/does/not/exist\";" >> "$CONFFILE" + echo "APT::Compressor::${COMP}::Name \"${COMP}-disabled\";" >> "$CONFFILE" + done } setupsimplenativepackage() { @@ -582,12 +601,12 @@ setupsimplenativepackage() { mkdir -p ${BUILDDIR}/debian/source cd ${BUILDDIR} echo "* most suckless software product ever" > FEATURES - test -e debian/copyright || echo "Copyleft by Joe Sixpack $(date +%Y)" > debian/copyright + test -e debian/copyright || echo "Copyleft by Joe Sixpack $(date -u +%Y)" > debian/copyright test -e debian/changelog || echo "$NAME ($VERSION) $RELEASE; urgency=low * Initial release - -- Joe Sixpack $(date -R)" > debian/changelog + -- Joe Sixpack $(date -u -R)" > debian/changelog test -e debian/control || echo "Source: $NAME Section: $SECTION Priority: optional @@ -645,12 +664,12 @@ buildsimplenativepackage() { echo "#!/bin/sh echo '$NAME says \"Hello!\"'" > "${BUILDDIR}/${NAME}" - echo "Copyleft by Joe Sixpack $(date +%Y)" > "${BUILDDIR}/debian/copyright" + echo "Copyleft by Joe Sixpack $(date -u +%Y)" > "${BUILDDIR}/debian/copyright" echo "$NAME ($VERSION) $RELEASE; urgency=low * Initial release - -- Joe Sixpack $(date -R)" > "${BUILDDIR}/debian/changelog" + -- Joe Sixpack $(date -u -R)" > "${BUILDDIR}/debian/changelog" { echo "Source: $NAME Priority: $PRIORITY @@ -1001,13 +1020,13 @@ NotAutomatic: yes' "$dir/Release" fi if [ -n "$DATE" -a "$DATE" != "now" ]; then for release in $(find ./aptarchive -name 'Release'); do - sed -i "s/^Date: .*$/Date: $(date -d "$DATE" '+%a, %d %b %Y %H:%M:%S %Z')/" "$release" + sed -i "s/^Date: .*$/Date: $(date -u -d "$DATE" '+%a, %d %b %Y %H:%M:%S %Z')/" "$release" touch -d "$DATE" "$release" done fi if [ -n "$VALIDUNTIL" ]; then sed -i "/^Date: / a\ -Valid-Until: $(date -d "$VALIDUNTIL" '+%a, %d %b %Y %H:%M:%S %Z')" $(find ./aptarchive -name 'Release') +Valid-Until: $(date -u -d "$VALIDUNTIL" '+%a, %d %b %Y %H:%M:%S %Z')" $(find ./aptarchive -name 'Release') fi msgdone "info" } @@ -1066,7 +1085,7 @@ signreleasefiles() { local SIGNER="${1:-Joe Sixpack}" local REPODIR="${2:-aptarchive}" local KEY="keys/$(echo "$SIGNER" | tr 'A-Z' 'a-z' | sed 's# ##g')" - local GPG="aptkey --quiet --keyring ${KEY}.pub --secret-keyring ${KEY}.sec --readonly adv --batch --yes" + local GPG="aptkey --quiet --keyring ${KEY}.pub --secret-keyring ${KEY}.sec --readonly adv --batch --yes --digest-algo ${APT_TESTS_DIGEST_ALGO:-SHA512}" msgninfo "\tSign archive with $SIGNER key $KEY… " local REXKEY='keys/rexexpired' local SECEXPIREBAK="${REXKEY}.sec.bak" @@ -1106,7 +1125,7 @@ signreleasefiles() { } redatereleasefiles() { - local DATE="$(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')" + local DATE="$(date -u -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')" for release in $(find aptarchive/ -name 'Release'); do sed -i "s/^Date: .*$/Date: ${DATE}/" "$release" touch -d "$DATE" "$release" @@ -1148,8 +1167,8 @@ rewritesourceslist() { local APTARCHIVE2="copy://$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive" | sed 's# #%20#g')" for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do sed -i $LIST -e "s#$APTARCHIVE#${1}#" -e "s#$APTARCHIVE2#${1}#" \ - -e "s#http://localhost:${APTHTTPPORT}/#${1}#" \ - -e "s#https://localhost:${APTHTTPSPORT}/#${1}#" + -e "s#http://[^@]*@\?localhost:${APTHTTPPORT}/\?#${1}#" \ + -e "s#https://[^@]*@\?localhost:${APTHTTPSPORT}/\?#${1}#" done } @@ -1223,7 +1242,7 @@ connect = $APTHTTPPORT msgdie 'Could not fork stunnel4 successfully' fi addtrap 'prefix' "kill ${PID};" - APTHTTPSPORT="$(lsof -i | awk "/^stunnel4 / && \$2 == \"${PID}\" {print \$9; exit; }" | cut -d':' -f 2)" + APTHTTPSPORT="$(lsof -i -n | awk "/^stunnel4 / && \$2 == \"${PID}\" {print \$9; exit; }" | cut -d':' -f 2)" webserverconfig 'aptwebserver::port::https' "$APTHTTPSPORT" "https://localhost:${APTHTTPSPORT}" rewritesourceslist "https://localhost:${APTHTTPSPORT}/" } @@ -1313,9 +1332,13 @@ testfileequal() { testempty() { msggroup 'testempty' - msgtest "Test for no output of" "$*" + if [ "$1" = '--nomsg' ]; then + shift + else + msgtest "Test for no output of" "$*" + fi local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testempty.comparefile" - if ("$@" >"$COMPAREFILE" 2>&1 || true) && test ! -s "$COMPAREFILE"; then + if "$@" >"$COMPAREFILE" 2>&1 && test ! -s "$COMPAREFILE"; then msgpass else msgfailoutput '' "$COMPAREFILE" "$@" @@ -1488,6 +1511,14 @@ testmarkedmanual() { msggroup } +catfile() { + if [ "${1##*.}" = 'deb' ]; then + stat >&2 "$1" || true + file >&2 "$1" || true + else + cat >&2 "$1" || true + fi +} msgfailoutput() { msgreportheader 'msgfailoutput' local MSG="$1" @@ -1497,7 +1528,7 @@ msgfailoutput() { echo >&2 while [ -n "$2" ]; do shift; done echo "#### Complete file: $1 ####" - cat >&2 "$1" || true + catfile "$1" echo '#### grep output ####' elif [ "$1" = 'test' ]; then echo >&2 @@ -1512,7 +1543,7 @@ msgfailoutput() { ls >&2 "$2" || true elif test -e "$2"; then echo "#### Complete file: $2 ####" - cat >&2 "$2" || true + catfile "$2" fi fi } @@ -1522,8 +1553,16 @@ msgfailoutput() { msgfailoutputstatfile "$2" "$3" done echo '#### test output ####' + elif [ "$1" = 'cmp' ]; then + echo >&2 + while [ -n "$2" ]; do + echo "#### Complete file: $2 ####" + catfile "$2" + shift + done + echo '#### cmp output ####' fi - cat >&2 "$OUTPUT" + catfile "$OUTPUT" msgfail "$MSG" } @@ -1765,8 +1804,18 @@ createlistofkeys() { local OUTPUT="$1" shift while [ -n "$1" ]; do + # gpg 2.1.something starts printing [SC] at some point + if grep -q ' rsa2048/' "$OUTPUT" && grep -qF '[SC]' "$OUTPUT"; then + case "$1" in + *Joe*|*Sixpack*) echo 'pub rsa2048/DBAC8DAE 2010-08-18 [SC]';; + *Rex*|*Expired*) echo 'pub rsa2048/27CE74F9 2013-07-12 [SC] [expired: 2013-07-13]';; + *Marvin*|*Paranoid*) echo 'pub rsa2048/528144E2 2011-01-16 [SC]';; + oldarchive) echo 'pub rsa1024/F68C85A3 2013-12-19 [SC]';; + newarchive) echo 'pub rsa2048/DBAC8DAE 2010-08-18 [SC]';; + *) echo 'UNKNOWN KEY';; + esac # gpg 2.1 has a slightly different output format - if grep -q ' rsa2048/' "$OUTPUT"; then + elif grep -q ' rsa2048/' "$OUTPUT"; then case "$1" in *Joe*|*Sixpack*) echo 'pub rsa2048/DBAC8DAE 2010-08-18';; *Rex*|*Expired*) echo 'pub rsa2048/27CE74F9 2013-07-12 [expired: 2013-07-13]';; @@ -1813,6 +1862,7 @@ listcurrentlistsdirectory() { } | sort } forallsupportedcompressors() { + rm -f "${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/00force-compressor" for COMP in $(aptconfig dump 'APT::Compressor' --format '%f%n' | cut -d':' -f 5 | uniq); do if [ -z "$COMP" -o "$COMP" = '.' ]; then continue; fi "$@" "$COMP"