#!/bin/bash set -e -u -o pipefail ARCH="amd64" BUILD="/var/univention/buildsystem2" APT="${BUILD}/apt" PBUILDER="${BUILD}/pbuilder" main () { header "$@" setup_tmp parse_yaml "$@" mount_build find_debs run_tests } header () { echo "INFO: $0 $*" echo "INFO: ${SSH_ORIGINAL_COMMAND:-}" } setup_tmp () { tmp=$(mktemp -d) trap "rm -rf '$tmp'" EXIT } parse_yaml () { yaml="$tmp/yaml" cat ${1+"$1"} >"$yaml" exec "$debs" } gen_apt () { { cat <<__TEXT__ #!/bin/bash cat <<__APT__ >/etc/apt/apt.conf.d/20secureapt APT::Get::AllowUnauthenticated "true"; APT::Get::Force-Yes "true"; __APT__ cat <<'__APT__' >/etc/apt/sources.list __TEXT__ for ((minor=0;minor"$tmp/post_setup_apt" chmod +x "$tmp/post_setup_apt" cat <<__TEXT__ >"$tmp/pre_upgrade_apt" #!/bin/bash cat <<'__APT__' >>/etc/apt/sources.list deb http://omar.knut.univention.de/build2 ucs_${major}.${minor}-0-errata${major}.${minor}-${max_patch}/all/ deb http://omar.knut.univention.de/build2 ucs_${major}.${minor}-0-errata${major}.${minor}-${max_patch}/\$(ARCH)/ __APT__ apt-get update __TEXT__ chmod +x "$tmp/pre_upgrade_apt" ln -f "$tmp/pre_upgrade_apt" "$tmp/pre_install_apt" } _gen_apt () { local base="deb http://univention-repository.knut.univention.de" echo "${base}/${1}.${2}/maintained/${4:+component/} ${1}.${2}-${3}${4:-}/all/" echo "${base}/${1}.${2}/maintained/${4:+component/} ${1}.${2}-${3}${4:-}/\$(ARCH)/" echo "${base}/${1}.${2}/unmaintained/${4:+component/} ${1}.${2}-${3}${4:-}/all/" echo "${base}/${1}.${2}/unmaintained/${4:+component/} ${1}.${2}-${3}${4:-}/\$(ARCH)/" } run_tests () { local rc=0 patch for patch in $versions do echo "INFO: $major.$max_minor-$patch" max_patch=$patch gen_apt while read deb do run_test "$deb" echo done <"$debs" done exit $rc } run_test () { local lrc deb="$1" echo "INFO: $deb" if piuparts \ --defaults=debian --distribution=sid \ --basetgz="${PBUILDER}/${scope}_${ARCH}.tgz" --keep-sources-list \ --scriptsdir="$tmp" \ --no-symlinks \ --warn-on-others \ --ignore=/etc/apt/sources.list \ --ignore=/usr/lib/libncurses.so.5 \ --ignore-regex='var/log/.*' \ --ignore-regex='var/lib/apt/lists/.*' \ "$deb" then lrc=$? echo "SUCCESS: $lrc (rc=$rc)" else lrc=$? rc=$? echo "ERROR: $lrc (rc=$rc)" sleep 5 fi } colorize () { : ${red:=$(tput setaf 1)} ${green:=$(tput setaf 2)} ${yellow:=$(tput setaf 3)} ${blue:=$(tput setaf 4)} ${reset:=$(tput op)} sed -r \ -e "s/^([0-9]+m[0-9.]+s )?ERROR: /$red&/;t" \ -e "s/^([0-9]+m[0-9.]+s )?SUCCESS: /$green&/;t" \ -e "s/^([0-9]+m[0-9.]+s )?INFO: /$yellow&/;t" \ -e "s/^([0-9]+m[0-9.]+s )?DEBUG: /$blue&/;t" \ -e "s/^([0-9]+m[0-9.]+s )?DUMP: /$reset&/;t" \ -e "s/^[0-9]+m[0-9.]+s /$reset&/;t" } if [ -t 2 ] then main "$@" | colorize else main "$@" fi