diskimage-builder/elements/apt-sources/extra-data.d/99-override-default-apt-sources
Martin André 2cd6f3fc3b Fix unbound variables in apt-{preferences,sources}
Also make the apt-sources element exit with a non-error status code
when the DIB_APT_SOURCES is not set.

This allows including the apt-preferences and apt-sources elements
even if DIB_DPKG_MANIFEST and DIB_APT_SOURCES are not exported.

Change-Id: I8507dd9c69d1371eab38f720dcfdd89aa5345e8b
2015-02-24 12:27:50 +00:00

23 lines
688 B
Bash
Executable File

#!/bin/bash
# Override the default /etc/apt/sources.list with $DIB_APT_SOURCES
set -eu
set -o pipefail
# exit directly if DIB_APT_SOURCES is not defined properly
if [ -z "${DIB_APT_SOURCES:-}" ] ; then
echo "DIB_APT_SOURCES must be set to the location of a sources.list file you wish to use"
exit 0
elif [ ! -f "$DIB_APT_SOURCES" -o ! -s "$DIB_APT_SOURCES" ] ; then
echo "$DIB_APT_SOURCES is not a valid sources.list file."
echo "You should assign proper sources.list file in DIB_APT_SOURCES"
exit 1
fi
DIB_APT_SOURCES=`readlink -f $DIB_APT_SOURCES`
# copy the sources.list to cloudimg
pushd $TMP_MOUNT_PATH/etc/apt/
sudo cp -f $DIB_APT_SOURCES sources.list
popd