EXIT_CODE=0
# we all like colorful messages
-if [ "$MSGCOLOR" != 'NO' ]; then
+if [ "$MSGCOLOR" != 'NO' ] && [ "$MSGCOLOR" != 'ALWAYS' ]; then
if [ ! -t 1 ]; then # but check that we output to a terminal
export MSGCOLOR='NO'
fi
echo "Dir::Bin::apt-key \"${BUILDDIRECTORY}/apt-key\";" >> aptconfig.conf
fi
- cat > "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg" <<EOF
+ cat << EOF > "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg"
#!/bin/sh
set -e
if [ -r "${TMPWORKINGDIRECTORY}/noopchroot.so" ]; then
--log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log \\
--force-not-root --force-bad-path "\$@"
EOF
- cat "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg"
chmod +x "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg"
echo "Dir::Bin::dpkg \"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg\";" > rootdir/etc/apt/apt.conf.d/99dpkg
[ -e ftparchive.conf ] || createaptftparchiveconfig
[ -e dists ] || buildaptftparchivedirectorystructure
msgninfo "\tGenerate Packages, Sources and Contents files… "
- aptftparchive -qq generate ftparchive.conf
+ testsuccess aptftparchive generate ftparchive.conf
cd - > /dev/null
msgdone "info"
generatereleasefiles "$@"
downloadfile() {
local PROTO="${1%%:*}"
- apthelper -o Debug::Acquire::${PROTO}=1 -o Debug::pkgAcquire::Worker=1 \
- download-file "$1" "$2" 2>&1 || true
+ if ! apthelper -o Debug::Acquire::${PROTO}=1 -o Debug::pkgAcquire::Worker=1 \
+ download-file "$1" "$2" 2>&1 ; then
+ return 1
+ fi
# only if the file exists the download was successful
if [ -r "$2" ]; then
return 0
else
msgtest 'Test for successful execution with warnings of' "$*"
fi
- local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output"
+ local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testwarning.output"
if "$@" >${OUTPUT} 2>&1; then
if expr match "$1" '^apt.*' >/dev/null; then
if grep -q -E ' runtime error: ' "$OUTPUT"; then
aptautotest 'testfailure' "$@"
}
+testsuccessequal() {
+ local CMP="$1"
+ shift
+ testsuccess "$@"
+ testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output" "$CMP"
+}
+testwarningequal() {
+ local CMP="$1"
+ shift
+ testwarning "$@"
+ testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/testwarning.output" "$CMP"
+}
+testfailureequal() {
+ local CMP="$1"
+ shift
+ testfailure "$@"
+ testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" "$CMP"
+}
+
+testfailuremsg() {
+ local CMP="$1"
+ shift
+ testfailure "$@"
+ msgtest 'Check that the output of the previous failed command has expected' 'failures and warnings'
+ grep '^\(W\|E\):' "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" > "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailureequal.output" 2>&1 || true
+ if echo "$CMP" | checkdiff - "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailureequal.output"; then
+ msgpass
+ else
+ echo '### Complete output ###'
+ cat "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output"
+ msgfail
+ fi
+}
+
testfilestats() {
msgtest "Test that file $1 has $2 $3" "$4"
if [ "$4" "$3" "$(stat --format "$2" "$1")" ]; then
testaptautotestnodpkgwarning() {
local TESTCALL="$1"
while [ -n "$2" ]; do
- if [ "$2" = '-s' ]; then return; fi
+ if expr match "$2" '^-[a-z]*s' >/dev/null 2>&1; then return; fi
shift
done
testfailure grep '^dpkg: warning:.*ignor.*' "${TMPWORKINGDIRECTORY}/rootdir/tmp-before/${TESTCALL}.output"