4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
19 LIBDIR="$(dirname $(readlink -f ${BASH_SOURCE[0]}))"
21 GOLDEN_BASE_IMAGE_FETCH_USER=${GOLDEN_BASE_IMAGE_FETCH_USER:-}
22 GOLDEN_BASE_IMAGE_FETCH_PASSWORD=${GOLDEN_BASE_IMAGE_FETCH_PASSWORD:-}
24 WORK=$(readlink -f ${WORK:-$(dirname $(dirname $LIBDIR))})
28 WORKLOGS=$WORKTMP/logs
29 DURATION_LOG=$WORKLOGS/durations.log
30 MANIFEST_PATH=$(readlink -f ${MANIFEST_PATH:-$WORK/.repo/manifests})
31 BUILD_CONFIG_INI=${BUILD_CONFIG_INI:-$MANIFEST_PATH/build_config.ini}
32 GOLDEN_IMAGE_NAME=guest-image.img
33 TMP_GOLDEN_IMAGE=$WORKTMP/$GOLDEN_IMAGE_NAME
35 WORKRESULTS=$WORK/results
36 REPO_FILES=$WORKRESULTS/repo_files
37 REPO_DIR=$WORKRESULTS/repo
38 SRC_REPO_DIR=$WORKRESULTS/src_repo
39 RPMLISTS=$WORKRESULTS/rpmlists
40 CHECKSUM_DIR=$WORKRESULTS/bin_checksum
41 RESULT_IMAGES_DIR=$WORKRESULTS/images
43 function _read_build_config()
45 local config_ini=$BUILD_CONFIG_INI
46 if [[ -f "$1" ]] && [[ $1 == *.ini ]]; then
50 PYTHONPATH=$LIBDIR $LIBDIR/tools/script/read_build_config.py $config_ini $@
53 function _read_manifest_vars()
55 PRODUCT_RELEASE_BUILD_ID="${BUILD_NUMBER:-0}"
56 PRODUCT_RELEASE_LABEL="$(_read_build_config DEFAULT product_release_label)"
59 function _initialize_work_dirs()
63 mkdir -p $WORKRESULTS $REPO_FILES $REPO_DIR $SRC_REPO_DIR $RPMLISTS $CHECKSUM_DIR
64 # dont clear tmp, can be used for caching
82 _info "##################################################################"
84 _info "##################################################################"
90 _info "------------------------------------------------------------------"
96 _header "STEP START: $@"
109 _header "STEP OK: $@"
112 function _add_rpms_to_localrepo()
116 mkdir -p $SRC_REPO_DIR
118 if grep ".src.rpm" <<< "$rpm"; then
119 cp -f $rpm $SRC_REPO_DIR
127 function _create_localrepo()
130 createrepo --workers=8 --update .
133 createrepo --workers=8 --update .
137 function _publish_results()
141 mkdir -p $(dirname $to)
145 function _publish_image()
147 _publish_results $1 $2
151 function _create_checksum()
153 _create_md5_checksum $1
154 _create_sha256_checksum $1
157 function _create_sha256_checksum()
160 time sha256sum $(basename $1) > $(basename $1).sha256
164 function _create_md5_checksum()
167 time md5sum $(basename $1) > $(basename $1).md5
173 # e.g. for Jenkins boolean parameters
177 function _join_array()
184 function _get_package_list()
186 PYTHONPATH=$LIBDIR $LIBDIR/tools/script/read_package_config.py $@
189 function _load_docker_image()
191 local docker_image=$1
192 if docker inspect ${docker_image} &> /dev/null; then
193 echo "Using already built ${docker_image} image"
195 echo "Loading ${docker_image} image"
196 local docker_image_url="$(_read_build_config DEFAULT docker_images)/${docker_image}.tar"
197 curl -L $docker_image_url | docker load