From e94864ec44a6ba9288a493bb7b649924a29d5295 Mon Sep 17 00:00:00 2001 From: Saku Chydenius Date: Mon, 20 May 2019 14:03:31 +0300 Subject: [PATCH] Align build scripts to LF - In LF we shall build docker containers on every build. Improvement to this process would be to separate these two docker environments from the build-tools repo. They could publish images to LF Nexus3 from where build-tools could directly utilize then. - There is not need to download ISO image dependencies from the Nexus3 thus this code is removed. Now they will be downloaded directly from the internet with wget. Change-Id: I8cbc89a1c25a5dedc0ce0556d00e80c09995c976 Signed-off-by: Saku Chydenius --- build_images.sh | 3 +++ build_step_create_install_cd.sh | 29 ++++++----------------- build_step_golden_image.sh | 2 +- create_rpmdata_in_docker.sh | 2 +- docker-context/Dockerfile-dib | 5 ++-- lib.sh | 2 +- nexus3_dl.sh | 52 ----------------------------------------- 7 files changed, 16 insertions(+), 79 deletions(-) delete mode 100755 nexus3_dl.sh diff --git a/build_images.sh b/build_images.sh index 4b1581c..bbaaf00 100755 --- a/build_images.sh +++ b/build_images.sh @@ -54,6 +54,9 @@ source $scriptdir/lib.sh _initialize_work_dirs +docker build -f $scriptdir/docker-context/Dockerfile-dib -t dib $scriptdir/docker-context +docker build -f $scriptdir/docker-context/Dockerfile-buildtools -t buildtools $scriptdir/docker-context + # Create manifest RPM $LIBDIR/create_manifest_rpm.sh diff --git a/build_step_create_install_cd.sh b/build_step_create_install_cd.sh index ee66b90..82a5cbf 100755 --- a/build_step_create_install_cd.sh +++ b/build_step_create_install_cd.sh @@ -24,13 +24,13 @@ tmp=$WORKTMP/install_cd iso_build_dir=$tmp/build input_image=$(readlink -f ${1:-$WORKTMP/goldenimage/$GOLDEN_IMAGE_NAME}) -output_image_path=${2:-$RESULT_IMAGES_DIR/rec.iso} +output_image_path=${2:-$RESULT_IMAGES_DIR/install.iso} output_bootcd_path=${3:-$RESULT_IMAGES_DIR/bootcd.iso} mkdir -p $tmp rm -rf $iso_build_dir mkdir -p $iso_build_dir -reposnap_base=$(_read_build_config DEFAULT centos_reposnap_base) +reposnap_base=$(_read_build_config DEFAULT centos_reposnap) release_version=$PRODUCT_RELEASE_LABEL reposnap_base_dir="${reposnap_base}/os/x86_64/" iso_image_label=$(_read_build_config DEFAULT iso_image_label) @@ -42,13 +42,6 @@ remove_extra_slashes_from_url() { echo $1 | sed -re 's#([^:])//+#\1/#g' } -get_nexus() { - $scriptdir/nexus3_dl.sh \ - $nexus_url \ - $(basename $nexus_reposnaps) \ - ${reposnap_base#$nexus_reposnaps/}/os/x86_64 $@ -} - wget_dir() { local url=$1 echo $url | grep -q /$ || _abort "wget path '$url' must end with slash for recursive wget" @@ -62,19 +55,11 @@ wget_dir() { pushd $iso_build_dir # Get files needed for generating CD image. -if echo $reposnap_base_dir | grep -E "https?://nexus3"; then - nexus_url=$(_read_build_config DEFAULT nexus_url) - nexus_reposnaps=$(_read_build_config DEFAULT nexus_reposnaps) - get_nexus "EFI/BOOT" "EFI/BOOT/fonts" - get_nexus "images:*efiboot.img" "images/pxeboot" - get_nexus "isolinux" -else - wget_dir ${cd_efi_dir}/ - wget_dir ${cd_images_dir}/ - rm -rf images/boot.iso - sync - wget_dir ${cd_isolinux_dir}/ -fi +wget_dir ${cd_efi_dir}/ +wget_dir ${cd_images_dir}/ +rm -rf images/boot.iso +sync +wget_dir ${cd_isolinux_dir}/ chmod +w -R isolinux/ EFI/ images/ if [ -e $scriptdir/isolinux/isolinux.cfg ]; then diff --git a/build_step_golden_image.sh b/build_step_golden_image.sh index dad25b4..ceb9a90 100755 --- a/build_step_golden_image.sh +++ b/build_step_golden_image.sh @@ -21,7 +21,7 @@ source $scriptdir/lib.sh output_image_path=${1:-$WORKTMP/goldenimage/$GOLDEN_IMAGE_NAME} -docker_dib_image=dib:2.0 +docker_dib_image=dib _load_docker_image $docker_dib_image docker run \ diff --git a/create_rpmdata_in_docker.sh b/create_rpmdata_in_docker.sh index 3e0885d..26b6159 100755 --- a/create_rpmdata_in_docker.sh +++ b/create_rpmdata_in_docker.sh @@ -18,7 +18,7 @@ set -ex scriptdir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))" source $scriptdir/lib.sh -docker_image=buildtools:2.0 +docker_image=buildtools _load_docker_image $docker_image function _resolve_abs_path() { diff --git a/docker-context/Dockerfile-dib b/docker-context/Dockerfile-dib index fa1359f..ffaa975 100644 --- a/docker-context/Dockerfile-dib +++ b/docker-context/Dockerfile-dib @@ -12,10 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. + +# Use newer than the CentOS stock diskimage-builder via "cloud" repo FROM centos:7.5.1804 RUN \ - yum-config-manager --add-repo http://mirror.centos.org/centos/7/cloud/x86_64/openstack-pike/ && \ - yum-config-manager --add-repo https://trunk.rdoproject.org/centos7-pike/57/c7/57c7be250c919c04b51361d4d42e95818cfec5a5_15fc9723 && \ + yum-config-manager --add-repo http://mirror.centos.org/centos/7/cloud/x86_64/openstack-queens/ && \ yum install --nogpgcheck -y diskimage-builder \ git \ python \ diff --git a/lib.sh b/lib.sh index ecd1121..50cf9b8 100644 --- a/lib.sh +++ b/lib.sh @@ -189,11 +189,11 @@ function _get_package_list() function _load_docker_image() { local docker_image=$1 - local docker_image_url="$(_read_build_config DEFAULT docker_images)/${docker_image}.tar" if docker inspect ${docker_image} &> /dev/null; then echo "Using already built ${docker_image} image" else echo "Loading ${docker_image} image" + local docker_image_url="$(_read_build_config DEFAULT docker_images)/${docker_image}.tar" curl -L $docker_image_url | docker load fi } diff --git a/nexus3_dl.sh b/nexus3_dl.sh deleted file mode 100755 index 03dd7ed..0000000 --- a/nexus3_dl.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -# Copyright 2019 Nokia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eu - -NEXUS_URL=$1 -NEXUS_REPOSITORY=$2 -NEXUS_REPOSITORY_BASE_PATH=$3 -shift;shift;shift -NEXUS_REPOSITORY_SEARCH_PATTERNS=$@ - -_abort() { - echo "ERROR: $@" - exit 1 -} - -_search_group() { - local params="" - [ -n "$1" ] && params+="&group=$1" - [ -n "${2:-}" ] && params+="&name=$2" - curl "${NEXUS_URL}/service/rest/v1/search?repository=${NEXUS_REPOSITORY}${params}" -} - -for pat in $NEXUS_REPOSITORY_SEARCH_PATTERNS; do - search_group="/$NEXUS_REPOSITORY_BASE_PATH/$(echo $pat | cut -d':' -f1)" - search_name="" - if echo $pat | grep ':'; then - search_name="$(echo $pat | cut -d':' -f2)" - fi - resp=$(_search_group $search_group $search_name) - if [ "$(echo $resp | jq -r '.continuationToken')" != "null" ]; then - _abort "Pagination not implemented" - fi - for url in $(echo $resp | jq -r '.items[].assets[].downloadUrl'); do - to=${url#$NEXUS_URL/repository/$NEXUS_REPOSITORY/$NEXUS_REPOSITORY_BASE_PATH/} - mkdir -p $(dirname $to) - echo "Fetch $url" - curl $url > $to - done -done -- 2.16.6