#!/bin/bash ## pre_checkin.sh script is expected to be called from ## a local copy of the build service image after running ## the _services file, e.g. `osc service disabledrun` log() { echo ">>> $@" ; } abort() { log "FATAL: $@" ; exit 1 ; } usage() { cat < /dev/null changes_log=$(git log --pretty=format:"${git_log_format}" \ ${previous_commit} -- pre_checkin.sh \ "${image}" | sed "1 s/- \(.*$\)/\1/") popd 1> /dev/null [ -z "${changes_log}" ] && abort "Missing new changelog entries" osc vc ${changes_file} -m "${changes_log}" } if [ "${namespace}" == "kubic" ]; then product='kubic' baseimage="opensuse/tumbleweed#current" distro="openSUSE Kubic" elif [[ "${namespace}" =~ ^caasp/.* ]]; then product='caasp' baseimage="suse/sle15#latest" distro="SLES15" else usage abort "Unknown product. Product needs to match 'kubic|caasp/.*'" fi set -e for file in *kiwi.ini; do image="${file%%.kiwi.ini}" changes_file="${product}-${image}.changes" kiwi_file="${product}-${image}.kiwi" extra_packages="" extra_packages_file="${product}-extra-packages" # Create a list of extra packages if [ -f "${extra_packages_file}" ]; then while read -r package; do extra_packages+=" \n" done < "${extra_packages_file}" fi # update the changes file, mostly used for automation in Concourse CI [ -n "${mkchanges}" ] && make_changes_file # create *.kiwi file from *kiwi.ini template cp "${file}" "${kiwi_file}" sed -i -e "s@_BASEIMAGE_@${baseimage}@g" \ -e "s@_DISTRO_@${distro}@g" \ -e "s@_NAMESPACE_@${namespace}@g" \ -e "s@_PRODUCT_@${product}@g" \ -e "/^\n" \ -e "s@_EXTRA_PACKAGES_@${extra_packages}@g" "${kiwi_file}" # Remove blank lines sed -i "/^ *$/d" "${kiwi_file}" log "${kiwi_file} has been created" done