From 12ca05299dea13c62952048e50a17d1ca354e328 Mon Sep 17 00:00:00 2001 From: Erich Cordoba Date: Tue, 19 Feb 2019 10:14:25 -0600 Subject: [PATCH 1/2] Move docker creation and deletion to tb.sh A makefile was used only for creation and clean up of the docker image for building. In this process, all the environment variables were sourced and included into the Makefile. However this can fail on systems that has functions and cause a failing makefile. Trying to fixing this issue I realize that this Makefile ain't needed, as all the logic for docker management is under `tb.sh`, therefore makes sense to remove this Makefile and use this script for the entire process. Story: 2002560 Change-Id: I2795593521a5d16dc2033861946fd09c2270424e Signed-off-by: Erich Cordoba --- Makefile | 44 -------------------------------------------- README.rst | 4 ++-- tb.sh | 26 ++++++++++++++++++++++++-- 3 files changed, 26 insertions(+), 48 deletions(-) delete mode 100644 Makefile diff --git a/Makefile b/Makefile deleted file mode 100644 index c4ebff49..00000000 --- a/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# TC Build container - -# Set defaults that may be overridden in the buidrc -MY_TC_RELEASE := tis-r5-pike - -UID := $(shell id -u) -USER := $(shell id -un) - -# Import the build config -NULL := $(shell bash -c "source buildrc; set | sed -E '/^[[:alnum:]_]+/s/=/:=/' | sed 's/^//' > .makeenv") -include .makeenv - -MYUNAME ?= $(USER) - -TC_CONTAINER_NAME := $(MYUNAME)-centos-builder -TC_CONTAINER_TAG := local/$(MYUNAME)-stx-builder:7.4 -TC_DOCKERFILE := Dockerfile - -all: - docker build \ - --build-arg MYUID=$(UID) \ - --build-arg MYUNAME=$(MYUNAME) \ - --ulimit core=0 \ - --network host \ - -t $(TC_CONTAINER_TAG) \ - -f $(TC_DOCKERFILE) \ - . - -clean: - docker rm $(TC_CONTAINER_NAME) || true - docker image rm $(TC_CONTAINER_TAG) - -env: - @echo "TC_DOCKERFILE=$(TC_DOCKERFILE)" - @echo "TC_CONTAINER_NAME=$(TC_CONTAINER_NAME)" - @echo "TC_CONTAINER_TAG=$(TC_CONTAINER_TAG)" - @echo "SOURCE_REMOTE_NAME=$(SOURCE_REMOTE_NAME)" - @echo "SOURCE_REMOTE_URI=$(SOURCE_REMOTE_URI)" - @echo "HOST_MIRROR_DIR=$(HOST_MIRROR_DIR)" - @echo "MY_TC_RELEASE=$(MY_TC_RELEASE)" - @echo "LOCALDISK=${LOCALDISK}" - @echo "GUEST_LOCALDISK=${GUEST_LOCALDISK}" - -.PHONY: all clean env diff --git a/README.rst b/README.rst index ea298fe0..f8651023 100644 --- a/README.rst +++ b/README.rst @@ -54,11 +54,11 @@ Build image ~~~~~~~~~~~ Once the configuration files have been customized, it is possible to build -the docker image. This process is automated by the Makefile. +the docker image. This process is automated by the ``tb.sh`` script. .. code-block:: bash - make + ./tb.sh create NOTE: ~~~~~ diff --git a/tb.sh b/tb.sh index e0508dd3..90ce3cae 100755 --- a/tb.sh +++ b/tb.sh @@ -25,6 +25,17 @@ TC_CONTAINER_NAME=${MYUNAME}-centos-builder TC_CONTAINER_TAG=local/${MYUNAME}-stx-builder:7.4 TC_DOCKERFILE=Dockerfile +function create_container { + docker build \ + --build-arg MYUID=$(id -u) \ + --build-arg MYUNAME=${USER} \ + --ulimit core=0 \ + --network host \ + -t ${TC_CONTAINER_TAG} \ + -f ${TC_DOCKERFILE} \ + . +} + function exec_container { docker cp ${WORK_DIR}/buildrc ${TC_CONTAINER_NAME}:/home/${MYUNAME} docker cp ${WORK_DIR}/localrc ${TC_CONTAINER_NAME}:/home/${MYUNAME} @@ -57,8 +68,13 @@ function kill_container { docker kill ${TC_CONTAINER_NAME} } +function clean_container { + docker rm ${TC_CONTAINER_NAME} || true + docker image rm ${TC_CONTAINER_TAG} +} + function usage { - echo "$0 [run|exec|env|stop|kill]" + echo "$0 [create|run|exec|env|stop|kill|clean]" } case $CMD in @@ -74,6 +90,9 @@ case $CMD in echo "MY_TC_RELEASE=${MY_TC_RELEASE}" echo "MY_REPO_ROOT_DIR=${MY_REPO_ROOT_DIR}" ;; + create) + create_container + ;; exec) exec_container ;; @@ -86,9 +105,12 @@ case $CMD in kill) kill_container ;; + clean) + clean_container + ;; *) echo "Unknown command: $CMD" - usage + usage exit 1 ;; esac From a044f794c4662760f1ca89d0f8d3bec20a49c4e5 Mon Sep 17 00:00:00 2001 From: Marcela Rosales Date: Mon, 18 Feb 2019 16:03:43 +0000 Subject: [PATCH 2/2] Revert "Change download mechanism for tss2 (git clone to wget)" This reverts commit 40a9622d7716e60a28807724ce5eece22f0e1c0c. The URL for tss2 is not always working and this causes an incomplete mirror in a clean environment. Closes-bug:1816813 Change-Id: I9c8fa64e1f0f9154dd45a67088fdc27f4b8f8313 Signed-off-by: Marcela Rosales --- centos-mirror-tools/dl_tarball.sh | 42 +++++++++++++++++++++++++----- centos-mirror-tools/tarball-dl.lst | 2 +- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/centos-mirror-tools/dl_tarball.sh b/centos-mirror-tools/dl_tarball.sh index 4846d9e2..753e877d 100755 --- a/centos-mirror-tools/dl_tarball.sh +++ b/centos-mirror-tools/dl_tarball.sh @@ -329,18 +329,48 @@ for line in $(cat $tarball_file); do rm -rf $directory_name rm e6aef069b6e97790cb127d5eeb86ae9ff0b7b0e3.tar.gz elif [ "$tarball_name" = "tss2-930.tar.gz" ]; then - download_package $tarball_url - if [ $? -ne 0 ]; then + dest_dir=ibmtpm20tss-tss + for dl_src in $dl_source; do + case $dl_src in + $dl_from_stx_mirror) + url="$(url_to_stx_mirror_url "$tarball_url" "$distro")" + ;; + $dl_from_upstream) + url="$tarball_url" + ;; + *) + echo "Error: Unknown dl_source '$dl_src'" + continue + ;; + esac + + git clone $url $dest_dir + if [ $? -eq 0 ]; then + # Success + break + else + echo "Warning: Failed to git clone from '$url'" + continue + fi + done + + if [ ! -d $dest_dir ]; then + echo "Error: Failed to git clone from '$tarball_url'" + echo "$tarball_url" > "$output_log" error_count=$((error_count + 1)) popd # pushd $output_tarball continue fi - unzip_file=ibmtpm20tss-tss-52539cb81c811c973b26ed23fafd28a700b7cc78 - zip_file="$unzip_file.zip" - unzip $zip_file - mv $unzip_file $directory_name + + pushd $dest_dir + branch=$util + git checkout $branch + rm -rf .git + popd + mv ibmtpm20tss-tss $directory_name tar czvf $tarball_name $directory_name rm -rf $directory_name + popd # pushd $dest_dir fi popd # pushd $output_tarball continue diff --git a/centos-mirror-tools/tarball-dl.lst b/centos-mirror-tools/tarball-dl.lst index 19a5e02d..762b6f7f 100644 --- a/centos-mirror-tools/tarball-dl.lst +++ b/centos-mirror-tools/tarball-dl.lst @@ -28,7 +28,7 @@ requests-toolbelt-0.5.1.tar.gz#requests-toolbelt-0.5.1#https://github.com/reques rpm-4.14.0.tar.bz2#rpm-4.14.0#https://ftp.osuosl.org/pub/rpm/releases/rpm-4.14.x/rpm-4.14.0.tar.bz2#http## swtpm-0.1.0-253eac5.tar.gz#swtpm-0.1.0#https://github.com/stefanberger/swtpm/tarball/1303be7d03294fb02204cb8242f366cbf0da076d#http## !tpm-kmod-e6aef069.tar.gz#tpm#http://git.infradead.org/users/jjs/linux-tpmdd.git/snapshot/e6aef069b6e97790cb127d5eeb86ae9ff0b7b0e3.tar.gz#http_script#post-dl-script/tpm-kmod.sh -!tss2-930.tar.gz#tss2-930#https://sourceforge.net/code-snapshots/git/i/ib/ibmtpm20tss/tss.git/ibmtpm20tss-tss-52539cb81c811c973b26ed23fafd28a700b7cc78.zip#http## +!tss2-930.tar.gz#tss2-930#https://git.code.sf.net/p/ibmtpm20tss/tss#git#v930# spectre-meltdown-checker-0.37+-5cc77741.tar.gz#spectre-meltdown-checker#https://github.com/speed47/spectre-meltdown-checker/tarball/5cc77741af1d2f52140aa9f89339f56b6c4b6783#http## puppet-boolean-22b726dd78b0a60a224cc7054aebbf28e9306f62.tar.gz#puppet-boolean#https://github.com/voxpupuli/puppet-boolean/tarball/22b726dd78b0a60a224cc7054aebbf28e9306f62#http## puppet-dnsmasq-cff07e90890662972c97684a2baee964f68ff3ed.tar.gz#packstack/puppet/modules/dnsmasq/#https://github.com/procore/puppet-dnsmasq/tarball/cff07e90890662972c97684a2baee964f68ff3ed#http##