From: Saku Chydenius Date: Sat, 11 May 2019 13:53:13 +0000 (+0300) Subject: Add a script to build REC images X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=ta%2Fbuild-tools.git;a=commitdiff_plain;h=900738828f48bade06f69c1e3a8f6fb988b97950 Add a script to build REC images This can be executed locally as well as in Jenkins to create REC images. To create REC image also manifest RPM must be built to get build information included to the REC runtime environment. This information can be then used within the REC to indentify which build has been installed. The "rpmbuilder" tool (that uses "mock") is way too heavy for manifest RPM creation thus Alpine based build environment was chosen. Manifest RPM has no dependencies thus this should be ok although experimental. Change-Id: Ic2ca3115bbfbbac89bf3139c47f8467a76ebd0b6 Signed-off-by: Saku Chydenius --- diff --git a/README b/README index 4efc9eb..879250b 100644 --- a/README +++ b/README @@ -6,3 +6,9 @@ Execute with: Execute only subset with verbose diff on assertion errors: $ tox -e py27 -- -vv tools/script/process_rpmdata_test.py::test_components +# Building REC + + $ git clone + $ git clone + $ build-tools/build_images.sh -m manifest -w work + diff --git a/build_images.sh b/build_images.sh new file mode 100755 index 0000000..9d94f59 --- /dev/null +++ b/build_images.sh @@ -0,0 +1,59 @@ +#!/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 -x +set -eu + +usage() { + echo "Usage: $0 -m -w " + exit 1 +} + +[ "$#" -ne 4 ] && usage +while getopts "m:w:" OPT; do + case $OPT in + m) + export MANIFEST_PATH=$(readlink -f $OPTARG) + ;; + w) + export WORK=$OPTARG + ;; + *) + usage + ;; + esac +done + +scriptdir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))" +source $scriptdir/lib.sh + +_initialize_work_dirs + +# Create manifest RPM +$LIBDIR/create_manifest_rpm.sh + +# Create repo config +$LIBDIR/build_step_create_yum_repo_files.sh + +# QCOW +$LIBDIR/build_step_golden_image.sh +sha1short=$(grep -v product-manifest $RPMLISTS/rpmlist | sha1sum | cut -c-8) + +# ISO images +$LIBDIR/build_step_create_install_cd.sh + +echo "=== SUCCESS ===" +echo "Build results are in $WORKRESULTS" +echo "Installed RPMS checksum: ${sha1short} (this will change if list of installed RPMs changes)" diff --git a/build_step_create_install_cd.sh b/build_step_create_install_cd.sh index 40de1cc..f2f7dab 100755 --- a/build_step_create_install_cd.sh +++ b/build_step_create_install_cd.sh @@ -23,11 +23,9 @@ _read_manifest_vars tmp=$WORKTMP/install_cd iso_build_dir=$tmp/build -input_image="$WORKTMP/goldenimage/${GOLDEN_IMAGE_NAME}" -output_image_path="$1" -[[ $output_image_path =~ ^/ ]] || output_image_path=$(pwd)/$output_image_path -output_bootcd_path="$2" -[[ $output_bootcd_path =~ ^/ ]] || output_bootcd_path=$(pwd)/$output_bootcd_path +input_image=$(readlink -f ${1:-$WORKTMP/goldenimage/$GOLDEN_IMAGE_NAME}) +output_image_path=${2:-$RESULT_IMAGES_DIR/rec.iso} +output_bootcd_path=${3:-$RESULT_IMAGES_DIR/bootcd.iso} mkdir -p $tmp rm -rf $iso_build_dir mkdir -p $iso_build_dir diff --git a/build_step_golden_image.sh b/build_step_golden_image.sh index 2dc1a37..dad25b4 100755 --- a/build_step_golden_image.sh +++ b/build_step_golden_image.sh @@ -19,10 +19,7 @@ set -e scriptdir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))" source $scriptdir/lib.sh -output_image_path="$1" -[[ $output_image_path =~ ^/ ]] || output_image_path=$(pwd)/$output_image_path -rpm_info_output_dir=$2 -[[ $rpm_info_output_dir =~ ^/ ]] || rpm_info_output_dir=$(pwd)/$rpm_info_output_dir +output_image_path=${1:-$WORKTMP/goldenimage/$GOLDEN_IMAGE_NAME} docker_dib_image=dib:2.0 _load_docker_image $docker_dib_image @@ -32,10 +29,15 @@ docker run \ --privileged \ -v /dev:/dev \ -v $WORK:/work \ + -e WORK=/work \ + -v $MANIFEST_PATH:/manifest \ + -e MANIFEST_PATH=/manifest \ + -v $scriptdir:/tools \ $docker_dib_image \ - $(realpath --relative-to $WORK $scriptdir)/create_golden_image.sh + /tools/create_golden_image.sh -_publish_image ${TMP_GOLDEN_IMAGE}.qcow2 $output_image_path/${GOLDEN_IMAGE_NAME} +mkdir -p $(dirname $output_image_path) +mv -f ${TMP_GOLDEN_IMAGE}.qcow2 $output_image_path input_dir=$WORKTMP/rpmdata mkdir $input_dir diff --git a/prepare_manifest.sh b/create_manifest_rpm.sh similarity index 50% rename from prepare_manifest.sh rename to create_manifest_rpm.sh index e34536d..b7ac213 100755 --- a/prepare_manifest.sh +++ b/create_manifest_rpm.sh @@ -14,15 +14,29 @@ # limitations under the License. set -x +set -eu scriptdir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))" source $scriptdir/lib.sh -_read_manifest_vars -pushd $MANIFEST_PATH -sed -i -e "s/^Version: .*/Version: $PRODUCT_RELEASE_BUILD_ID/" rpmbuild.spec -cat > product-release <