From 8e29ff81ecfe0a1ab41b111ee95999d39c9fa4d5 Mon Sep 17 00:00:00 2001 From: Saku Chydenius Date: Tue, 14 May 2019 12:35:59 +0300 Subject: [PATCH] Support RPM create when ISO image is built Optionally before the ISO image is created, a list of local REC components can be packaged into RPMs. All RPMs built this way will have higher priority over the latest RPMs in Nexus when ISO image is created. Change-Id: I8f7fc38718e10a1858e50089991f7a92df1efe7d Signed-off-by: Saku Chydenius --- build_images.sh | 26 ++++++++++++--- build_rpms.sh | 80 +++++++++++++++++++++++++++++++++++++++++++++++ build_step_create_rpms.sh | 54 -------------------------------- 3 files changed, 102 insertions(+), 58 deletions(-) create mode 100755 build_rpms.sh delete mode 100755 build_step_create_rpms.sh diff --git a/build_images.sh b/build_images.sh index 9d94f59..4b1581c 100755 --- a/build_images.sh +++ b/build_images.sh @@ -14,15 +14,16 @@ # limitations under the License. set -x -set -eu +set -e +set -o pipefail usage() { - echo "Usage: $0 -m -w " + echo "Usage: $0 -m -w [-r -p ]" exit 1 } -[ "$#" -ne 4 ] && usage -while getopts "m:w:" OPT; do +rpm_search_paths="" +while getopts "m:w:p:r:" OPT; do case $OPT in m) export MANIFEST_PATH=$(readlink -f $OPTARG) @@ -30,12 +31,24 @@ while getopts "m:w:" OPT; do w) export WORK=$OPTARG ;; + r) + export RPMBUILDER_PATH=$(readlink -f $OPTARG) + ;; + p) + rpm_search_paths+=" $OPTARG" + ;; *) usage ;; esac done +[ -z "$MANIFEST_PATH" ] && usage +[ -z "$WORK" ] && usage +[ -n "$rpm_search_paths" -a -z "$RPMBUILDER_PATH" ] && usage +shift "$((OPTIND-1))" +[ "$#" -ne 0 ] && usage + scriptdir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))" source $scriptdir/lib.sh @@ -44,6 +57,11 @@ _initialize_work_dirs # Create manifest RPM $LIBDIR/create_manifest_rpm.sh +# Create RPMs +if [ -n "$rpm_search_paths" ]; then + $LIBDIR/build_rpms.sh $rpm_search_paths +fi + # Create repo config $LIBDIR/build_step_create_yum_repo_files.sh diff --git a/build_rpms.sh b/build_rpms.sh new file mode 100755 index 0000000..f935bff --- /dev/null +++ b/build_rpms.sh @@ -0,0 +1,80 @@ +#!/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 -e +set -o pipefail + +usage() { + echo "Builds all git repositories under give search dirs" + echo "Usage: $0 -m -w -r [..]" + exit 1 +} + +while getopts "m:w:r:" OPT; do + case $OPT in + m) + export MANIFEST_PATH=$(readlink -f $OPTARG) + ;; + w) + export WORK=$OPTARG + ;; + r) + export RPMBUILDER_PATH=$(readlink -f $OPTARG) + ;; + *) + usage + ;; + esac +done + +[ -z "$MANIFEST_PATH" ] && usage +[ -z "$RPMBUILDER_PATH" ] && usage +[ -z "$WORK" ] && usage + +shift "$((OPTIND-1))" +search_paths="$@" +[ "$#" -eq 0 ] && usage +for p in $search_paths; do + [ ! -d "$p" ] && usage +done + +scriptdir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))" +source $scriptdir/lib.sh + +projects_to_build=$(find $search_paths -name .git -printf "%h\n" | sort) + +work=$WORKTMP/rpms +rm -rf $work +mkdir -p $work + +$scriptdir/create_mock_config.sh $BUILD_CONFIG_INI $work/mock_config + +CENTOS_SOURCES="$(_read_build_config rpm centos_sources)" \ +$RPMBUILDER_PATH/makebuild.py \ + -m $work/mock_config/mock.cfg \ + -w $work \ + $projects_to_build #-v --nowipe + +echo "### Built RPMS #######################################" +find $work/projects/ -type f -name '*.rpm' | xargs ls -l +echo "### Built RPM details ##########################################" +for rpm in $(find $work/projects/ -type f -name '*.rpm'); do + echo "=== $rpm ========================" + rpm -qip $rpm +done + +_add_rpms_to_localrepo $(find $work/buildrepository/mock -name '*.rpm') + diff --git a/build_step_create_rpms.sh b/build_step_create_rpms.sh deleted file mode 100755 index 3d45388..0000000 --- a/build_step_create_rpms.sh +++ /dev/null @@ -1,54 +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 -x -set -e - -scriptdir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))" -source $scriptdir/lib.sh - -_get_projects_all() { repo list -g torpm -n | sort; } - -_get_project_dirs() { - for i in $@; do - repo info -l $i | grep "^Mount path: " | awk '{print $3}' | tr '\n' ' ' - done -} - -build_rpms() -{ - local work=$1 - shift - rm -rf $work - mkdir -p $work - - CENTOS_SOURCES="$(_read_build_config rpm centos_sources)" \ - $RPM_BUILDER/makebuild.py \ - -m $RPM_BUILDER_SETTINGS \ - -w $work \ - $@ #-v --nowipe -} - -# build one or all projects -if [ -n "$1" ]; then - projects_to_build=$@ -else - projects_to_build="$MANIFEST_PATH $(_get_project_dirs $(_get_projects_all))" - _run_cmd $LIBDIR/prepare_manifest.sh -fi - -rpmwork=$WORKTMP/rpms -build_rpms $rpmwork $projects_to_build -_add_rpms_to_repos_from_workdir $rpmwork -- 2.16.6