]> git.saurik.com Git - apt.git/blobdiff - test/integration/framework
zh_TW.po: remove several fuzzy tags after review
[apt.git] / test / integration / framework
index 2b7f3f9679641ff5046f8106d5cb6b497b158f41..a68209326ab5f623f32f513ccafafe599f3f81f5 100644 (file)
@@ -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,9 +396,6 @@ 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
-       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
 
        configcompression '.' 'gz' #'bz2' 'lzma' 'xz'
        confighashes 'SHA256' # these are tests, not security best-practices
@@ -411,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"
 }
 
@@ -562,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() {
@@ -586,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 <joe@example.org>  $(date -R)" > debian/changelog
+ -- Joe Sixpack <joe@example.org>  $(date -u -R)" > debian/changelog
        test -e debian/control || echo "Source: $NAME
 Section: $SECTION
 Priority: optional
@@ -649,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 <joe@example.org>  $(date -R)" > "${BUILDDIR}/debian/changelog"
+ -- Joe Sixpack <joe@example.org>  $(date -u -R)" > "${BUILDDIR}/debian/changelog"
        {
                echo "Source: $NAME
 Priority: $PRIORITY
@@ -1005,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"
 }
@@ -1070,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 --digest-algo SHA512"
+       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"
@@ -1110,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"
@@ -1152,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
 }
 
@@ -1227,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}/"
 }
@@ -1496,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"
@@ -1505,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
@@ -1520,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
                }
@@ -1534,12 +1557,12 @@ msgfailoutput() {
                echo >&2
                while [ -n "$2" ]; do
                        echo "#### Complete file: $2 ####"
-                       cat >&2 "$2" || true
+                       catfile "$2"
                        shift
                done
                echo '#### cmp output ####'
        fi
-       cat >&2 "$OUTPUT"
+       catfile "$OUTPUT"
        msgfail "$MSG"
 }
 
@@ -1839,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"