diff --git a/elements/apt-sources/README.md b/elements/apt-sources/README.md new file mode 100644 index 00000000..27b11fd3 --- /dev/null +++ b/elements/apt-sources/README.md @@ -0,0 +1,15 @@ +Override the default sources.list + +For Ubuntu OS, if your network connection is slow for the default sources.list, +you can define DIB_APT_SOURCES with your favorite sources.list to override it, +before running devtest.sh. + +The new sources.list will take effect at build time and run time. + +If you want to use this element in tripleo project, set NODE_DIST or +EXTRA_ELEMENTS / UNDERCLOUD_DIB_EXTRA_ARGS / OVERCLOUD_DIB_EXTRA_ARGS +to make it take effect at build time and run time. + +e.g. before running devtest.sh: +export DIB_APT_SOURCES=/etc/apt/sources.list +export NODE_DIST="ubuntu apt-sources" diff --git a/elements/apt-sources/extra-data.d/99-override-default-apt-sources b/elements/apt-sources/extra-data.d/99-override-default-apt-sources new file mode 100755 index 00000000..fce7150b --- /dev/null +++ b/elements/apt-sources/extra-data.d/99-override-default-apt-sources @@ -0,0 +1,25 @@ +#!/bin/bash +# Override the default /etc/apt/sources.list with $DIB_APT_SOURCES + +set -e + +# get the cloudimg version +source $TMP_MOUNT_PATH/etc/lsb-release +echo "Current cloudimg codename is: $DISTRIB_DESCRIPTION $DISTRIB_CODENAME" + +# 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 1 +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