From 5daa989fb88be872500ff4d6eac719b75806febc Mon Sep 17 00:00:00 2001 From: Kui Shi Date: Tue, 17 Dec 2013 02:19:21 -0800 Subject: [PATCH] Add element to modify /etc/apt/sources.list in dib Add apt-sources element for Ubuntu OS to override the default /etc/apt/sources.list in cloudimg. Set DIB_APT_SOURCES with a proper sources.list file to replace the default one. 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" Change-Id: I9ce0d03b506c2948b96382e4d6e85f0aff906450 --- elements/apt-sources/README.md | 15 +++++++++++ .../99-override-default-apt-sources | 25 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 elements/apt-sources/README.md create mode 100755 elements/apt-sources/extra-data.d/99-override-default-apt-sources diff --git a/elements/apt-sources/README.md b/elements/apt-sources/README.md new file mode 100644 index 000000000..27b11fd3b --- /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 000000000..fce7150bc --- /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