Fixes DIB_DISTRIBUTION_MIRROR_UBUNTU_IGNORE matching when empty

- 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>
This commit is contained in:
Manuel Torrinha 2019-08-08 12:12:19 +01:00
parent 37909a0e81
commit a38ac762f1

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 1 ]; then
if [[ ${DIB_DEBUG_TRACE:-0} -gt 1 ]]; then
set -x
fi
set -eu
@ -8,11 +8,11 @@ set -o pipefail
DIB_DISTRIBUTION_MIRROR=${DIB_DISTRIBUTION_MIRROR:-}
[ -n "$DIB_DISTRIBUTION_MIRROR" ] || exit 0
[[ -n "$DIB_DISTRIBUTION_MIRROR" ]] || exit 0
while IFS= read line
do
if [[ "$line" =~ ${DIB_DISTRIBUTION_MIRROR_UBUNTU_IGNORE:-} ]]; then
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