#!/usr/share/ucs-test/runner bash
# shellcheck shell=bash
## desc: |
##  Update localhost repository using no_proxy
##  1. Setup http_proxy to not-existing proxy, here: port=discard
##  2. Disable localhost via no_proxy
## bugs: [16020]
## versions:
##  2.4-2: fixed
## roles-not: [basesystem]
## tags: [basic]
## packages:
##  - apache2 | apache2-mpm-prefork
## exposure: dangerous

RETVAL=110 # Test fehlgeschlagen
. pool.sh || exit 137
FIXED_12571=false

setup_apache "${repoprefix}"

# shellcheck disable=SC2046
mkpdir $(allpatchlevels "${_version_version}-${_version_patchlevel:?}") maintained "${ARCH}"
mkdeb "${pkgname}" 1 "${ARCH}" "${DIR_POOL}"
mkpkg "${DIR}" "${DIR_POOL}"

proxy_port=9 # discard
config_repo proxy/http="http://localhost:${proxy_port}" proxy/no_proxy=localhost

(
	set -e
	"${FIXED_12571}" || ucr commit /etc/apt/sources.list.d/15_ucs-online-version.list >&3
	checkapt "http://localhost\\(:80\\)\\?/${repoprefix}/" "${DIR}"
	# no_proxy can not be directly specified via /etc/apt/apt.conf.d/80proxy, only in environment.
	# univention-updater will export no_proxy for its forked children as well, simulate that here.
	eval "$(grep "^export no_proxy=" /etc/profile)"
	apt-get -qq update
	apt-get -qq install "${pkgname}"
	dpkg-query -W "${pkgname}" | grep -Fqx "${pkgname}	1"
	checkdeb "${pkgname}" 1
)
# shellcheck disable=SC2181
[ $? -eq 0 ] && RETVAL=100 # Test bestanden (Keine Fehler)
dpkg -P --force-all "${pkgname}" >&3 2>&3

exit ${RETVAL}
# vim:set ft=sh:
