Use mirrors snapshots 27/7527/7
authorMichal Skalski <mskalski@mirantis.com>
Thu, 21 Jan 2016 01:17:11 +0000 (02:17 +0100)
committerMichal Skalski <mskalski@mirantis.com>
Thu, 21 Jan 2016 15:16:35 +0000 (16:16 +0100)
Add logic to fetch information about last suitable snapshot which can be
used to download ubuntu packages. This is for example use to build
community ISO [1]. This should help in case of snapshot switch [2].

[1]
https://github.com/fuel-infra/jenkins-jobs/blob/master/servers/fuel-ci/8.0/builders/community.all.sh#L36-L40
[2] https://bugs.launchpad.net/fuel/+bug/1493390/comments/9

Change-Id: Id5a8d41278561473ea4844631bfefa0049e64dbc
Signed-off-by: Michal Skalski <mskalski@mirantis.com>
build/Makefile
build/docker/Dockerfile
build/docker/runcontext
build/f_isoroot/f_repobuild/select_ubuntu_repo.sh
build/fuel_build_loop

index f690b7c..1d28db3 100644 (file)
@@ -43,6 +43,24 @@ export DOCKERIMG = opnfv.org/ubuntu-builder:14.04
 export TOPDIR := $(shell pwd)
 export REPOINFO  := $(BUILD_BASE)/repo_info.sh
 
+# Use snapshots
+# Use nearby repositories
+export MIRROR_UBUNTU_URL := $(shell ./f_isoroot/f_repobuild/select_ubuntu_repo.sh --url)
+export MIRROR_UBUNTU := $(shell echo "$(MIRROR_UBUNTU_URL)" | cut -d'/' -f3 )
+export MIRROR_UBUNTU_ROOT := $(shell echo -n '/' ; echo "$(MIRROR_UBUNTU_URL)" | cut -d'/' -f4-)
+
+export LATEST_MIRROR_ID_URL := http://mirror.seed-us1.fuel-infra.org
+
+export MIRROR_MOS_UBUNTU := $(shell echo "$(LATEST_MIRROR_ID_URL)" | cut -d'/' -f3)
+export LATEST_TARGET_UBUNTU := $(shell curl -sSf "$(MIRROR_MOS_UBUNTU)/mos-repos/ubuntu/8.0.target.txt" | head -1)
+export MIRROR_MOS_UBUNTU_ROOT := "/mos-repos/ubuntu/$(LATEST_TARGET_UBUNTU)"
+
+export LATEST_TARGET_CENTOS := $(shell curl -sSf "$(LATEST_MIRROR_ID_URL)/mos-repos/centos/mos8.0-centos7-fuel/os.target.txt" | head -1)
+export MIRROR_FUEL := "$(LATEST_MIRROR_ID_URL)/mos-repos/centos/mos8.0-centos7-fuel/$(LATEST_TARGET_CENTOS)/x86_64"
+
+# uncomment and use: make print-VARIABLE
+#print-%  : ; @echo $* = $($*)
+
 #Build subclasses
 
 SUBDIRS := f_isoroot
index 9d1881c..4ac5147 100644 (file)
@@ -24,9 +24,12 @@ RUN echo "ALL ALL=NOPASSWD: ALL" > /etc/sudoers.d/open-sudo
 RUN echo "Defaults env_keep += \"ftp_proxy http_proxy https_proxy no_proxy RSYNC_PROXY RSYNC_CONNECT_PROG npm_config_registry\"" > /etc/sudoers.d/keep-proxies
 # Keeping PWD is needed to build as root
 RUN echo "Defaults env_keep += \"PWD\"" > /etc/sudoers.d/keep-pwd
+# Keeping variables for ISO build
+RUN echo "Defaults env_keep += \"MIRROR_UBUNTU MIRROR_UBUNTU_ROOT MIRROR_MOS_UBUNTU MIRROR_MOS_UBUNTU_ROOT MIRROR_FUEL\"" > /etc/sudoers.d/keep-mos
 RUN chmod 0440 /etc/sudoers.d/open-sudo
 RUN chmod 0440 /etc/sudoers.d/keep-proxies
 RUN chmod 0440 /etc/sudoers.d/keep-pwd
+RUN chmod 0440 /etc/sudoers.d/keep-mos
 RUN chmod 4755 /bin/fusermount
 
 ADD ./setcontext /root/setcontext
index 4ddd754..2df7658 100755 (executable)
@@ -111,7 +111,7 @@ if [ -n "$CACHEBASE" ]; then
     fi
 fi
 
-RUN_CONTEXT_OPT="--cidfile $CID_FILE --privileged=true --rm -e HOME=$HOME -e CACHEDEBUG -e CACHETRANSPORT -e CACHEMAXAGE -e CACHEBASE -e BUILD_FUEL_PLUGINS -u $USER_ID:$GROUP_ID -w $PWD -v $GITROOT:$GITROOT -v /sys/fs/cgroup:/sys/fs/cgroup:ro $CACHEMOUNT"
+RUN_CONTEXT_OPT="--cidfile $CID_FILE --privileged=true --rm -e HOME=$HOME -e CACHEDEBUG -e CACHETRANSPORT -e CACHEMAXAGE -e CACHEBASE -e BUILD_FUEL_PLUGINS -e MIRROR_UBUNTU -e MIRROR_UBUNTU_ROOT -e MIRROR_MOS_UBUNTU -e MIRROR_MOS_UBUNTU_ROOT -e MIRROR_FUEL -u $USER_ID:$GROUP_ID -w $PWD -v $GITROOT:$GITROOT -v /sys/fs/cgroup:/sys/fs/cgroup:ro $CACHEMOUNT"
 
 # Passing "debug" puts up an interactive bash shell
 if [ "$1" == "debug" ]; then
index cb05fe1..992359a 100755 (executable)
@@ -11,6 +11,19 @@ RSYNC="rsync -4 --contimeout 5 --no-motd --list-only"
 # local mirror can be found after four attempts, the default archive
 # is returned instead.
 
+return_url=0
+
+while [ "$1" != "" ]; do
+    case $1 in
+        -u | --url )   shift
+                       return_url=1
+                       ;;
+    # Shift all the parameters down by one
+    esac
+    shift
+done
+
+
 cnt=0
 while [ $cnt -lt 4 ]
 do
@@ -21,13 +34,22 @@ do
         then
             if ! $RSYNC "${host}::ubuntu/Archive-Update-in-Progress*" &> /dev/null
             then
-                echo "$host"
-                exit 0
+                if [ "$return_url" = "1" ]; then
+                    echo "$url"
+                    exit 0
+                else
+                    echo "$host"
+                    exit 0
+                fi
             fi
         fi
     done
     cnt=$[cnt + 1]
     sleep 15
 done
-echo "archive.ubuntu.com"
 
+if [ "$return_url" = "1" ]; then
+    echo "http://archive.ubuntu.com/ubuntu/"
+else
+    echo "archive.ubuntu.com"
+fi
index 7c6cb60..7e26b98 100755 (executable)
@@ -9,14 +9,6 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 
-LATEST_MIRROR_ID_URL=http://mirror.seed-cz1.fuel-infra.org
-
-LATEST_TARGET_UBUNTU=$(curl -sSf "${LATEST_MIRROR_ID_URL}/mos-repos/ubuntu/8.0.target.txt" | head -1)
-export MIRROR_MOS_UBUNTU_ROOT="/mos-repos/ubuntu/${LATEST_TARGET_UBUNTU}"
-
-LATEST_TARGET_CENTOS=$(curl -sSf "${LATEST_MIRROR_ID_URL}/mos-repos/centos/mos8.0-centos7-fuel/os.target.txt" | head -1)
-export MIRROR_FUEL="${LATEST_MIRROR_ID_URL}/mos-repos/centos/mos8.0-centos7-fuel/${LATEST_TARGET_CENTOS}/x86_64"
-
 echo "MIRROR_MOS_UBUNTU_ROOT=${MIRROR_MOS_UBUNTU_ROOT}"
 echo "MIRROR_FUEL=${MIRROR_FUEL}"