a38ac762f1
- DIB_DISTRIBUTION_MIRROR_UBUNTU_IGNORE matches when it is empty or not set and DIB_DISTRIBUTION_MIRROR is being used. Checking for it being set and not empty solves this. - Normalizing bash conditionals for readability Closes-Bug: #1808359 Change-Id: I87853fcda4c8b29a3f1720a2778debeb3acc3a53 Signed-off-by: Manuel Torrinha <manuel.torrinha@tecnico.ulisboa.pt>
30 lines
992 B
Bash
Executable file
30 lines
992 B
Bash
Executable file
#!/bin/bash
|
|
|
|
if [[ ${DIB_DEBUG_TRACE:-0} -gt 1 ]]; then
|
|
set -x
|
|
fi
|
|
set -eu
|
|
set -o pipefail
|
|
|
|
DIB_DISTRIBUTION_MIRROR=${DIB_DISTRIBUTION_MIRROR:-}
|
|
|
|
[[ -n "$DIB_DISTRIBUTION_MIRROR" ]] || exit 0
|
|
|
|
while IFS= read line
|
|
do
|
|
if [[ -n "${DIB_DISTRIBUTION_MIRROR_UBUNTU_IGNORE:-}" && "$line" =~ ${DIB_DISTRIBUTION_MIRROR_UBUNTU_IGNORE:-} ]]; then
|
|
# append line unmodified
|
|
echo "$line" | tee --append /etc/apt/sources.list.new
|
|
else
|
|
echo "$line" | \
|
|
sed -e "s&http://\(archive\|security\).ubuntu.com/ubuntu&$DIB_DISTRIBUTION_MIRROR&" | \
|
|
tee --append /etc/apt/sources.list.new
|
|
fi
|
|
done < /etc/apt/sources.list
|
|
|
|
if [[ -n "${DIB_DISTRIBUTION_MIRROR_UBUNTU_INSECURE:-}" ]]; then
|
|
echo "APT::Get::AllowUnauthenticated \"true\";" | tee /etc/apt/apt.conf.d/95allow-unauthenticated
|
|
echo "Acquire::AllowInsecureRepositories \"true\";" | tee -a /etc/apt/apt.conf.d/95allow-unauthenticated
|
|
fi
|
|
|
|
mv /etc/apt/sources.list.new /etc/apt/sources.list
|