From fcf41fb57bc387e7ec399ed4f6c4f9bf495e315a Mon Sep 17 00:00:00 2001 From: Scott Little Date: Mon, 2 Nov 2020 14:15:07 -0500 Subject: [PATCH] Support different mock.cfg.proto files for CentOS-7 vs CentOS-8 We'll be supporting CentOS-7 vs CentOS-8 based build environments concurrently for a time. The two distros require slightly different content in the mock.cfg. Modify generate-centos-repo.sh to determine which distribution we are building under, and select the correct mock.cfg prototype(s). It will look for files names mock.cfg.$DISTRO.$LAYER.proto and if found, substitute them for mock.cfg.$LAYER.proto. There will be a matching change in the 'root' git to introduce separate CentOS-7 and CentOS-8 mock prototypes. Story: 2006729 Change-Id: Ibf610bcd82b447b8ffeecd86595b19280106e458 Signed-off-by: Scott Little --- toCOPY/generate-centos-repo.sh | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/toCOPY/generate-centos-repo.sh b/toCOPY/generate-centos-repo.sh index a45503a5..deedaa75 100755 --- a/toCOPY/generate-centos-repo.sh +++ b/toCOPY/generate-centos-repo.sh @@ -125,7 +125,12 @@ echo dest_dir=$MY_REPO/centos-repo timestamp="$(date +%F_%H%M)" -mock_cfg_proto_default=mock.cfg.proto +mock_cfg_prefix="mock.cfg" +mock_cfg_default_suffix="proto" +mock_cfg_suffix="${mock_cfg_default_suffix}" +if [ -f /etc/os-release ]; then + mock_cfg_distro="$(source /etc/os-release; echo ${ID}${VERSION_ID}.proto)" +fi mock_cfg_dir=$MY_REPO/build-tools/repo_files mock_cfg_dest_dir=$MY_REPO/centos-repo comps_xml_file=$MY_REPO/build-tools/repo_files/comps.xml @@ -384,6 +389,17 @@ process_lst_file () { done } +# +# copy_with_backup: Copy a file to a directory or file. +# If the file already exists at the destination, +# a timestamped backup is created of the +# prior file content by adding a +# -backup- suffic to the file name. +# +# Usage: +# copy_with_backup +# copy_with_backup +# copy_with_backup () { local src_file="$1" local dest_dir="$2" @@ -395,8 +411,12 @@ copy_with_backup () { fi if [ ! -d ${dest_dir} ]; then - echo "destination directory '${dest_dir}' does not exist!" - exit 1 + dest_file="$2" + dest_dir=$(dir_name ${dest_file}) + if [ ! -d ${dest_dir} ]; then + echo "destination directory '${dest_dir}' does not exist!" + exit 1 + fi fi if [ -f "${dest_file}" ]; then @@ -448,14 +468,14 @@ done echo "Copying mock.cfg.proto file." # First look for layer specific file to copy. -mock_cfg_file="${mock_cfg_dir}/mock.cfg.${layer}.proto" +mock_cfg_file="${mock_cfg_dir}/${mock_cfg_prefix}.${layer}.${mock_cfg_suffix}" if [ -f "$mock_cfg_file" ]; then - copy_with_backup ${mock_cfg_file} ${mock_cfg_dest_dir} + copy_with_backup ${mock_cfg_file} ${mock_cfg_dest_dir}/${mock_cfg_prefix}.${layer}.${mock_cfg_default_suffix} fi # Always copy the default -mock_cfg_file=${mock_cfg_dir}/${mock_cfg_proto_default} -copy_with_backup ${mock_cfg_file} ${mock_cfg_dest_dir} +mock_cfg_file=${mock_cfg_dir}/${mock_cfg_prefix}.${mock_cfg_suffix} +copy_with_backup ${mock_cfg_file} ${mock_cfg_dest_dir}/${mock_cfg_prefix}.${mock_cfg_default_suffix} echo "Copying contents from other list files."