diff --git a/obs-packaging/build_all.sh b/obs-packaging/build_all.sh index 1dd05b5bea..5c0789236c 100755 --- a/obs-packaging/build_all.sh +++ b/obs-packaging/build_all.sh @@ -10,19 +10,18 @@ set -o errexit set -o nounset set -o pipefail - script_dir=$(dirname "$0") #Note:Lets update qemu and the kernel first, they take longer to build. #Note: runtime is build at the end to get the version from all its dependencies. projects=( -qemu-lite -qemu-vanilla -kernel -kata-containers-image -proxy -shim -ksm-throttler -runtime + qemu-lite + qemu-vanilla + kernel + kata-containers-image + proxy + shim + ksm-throttler + runtime ) OSCRC="${HOME}/.oscrc" @@ -36,32 +35,48 @@ export BUILD_DISTROS=${BUILD_DISTROS:-xUbuntu_16.04} export AUTHOR="${AUTHOR:-user}" export AUTHOR_EMAIL="${AUTHOR_EMAIL:-user@example.com}" -cd "$script_dir" - OBS_API="https://api.opensuse.org" -if [ -n "${OBS_USER:-}" ] && [ -n "${OBS_PASS:-}" ] && [ ! -e "${OSCRC:-}" ]; then - echo "Creating ${OSCRC} with user $OBS_USER" - cat << eom > "${OSCRC}" +usage() { + msg="${1:-}" + exit_code=$"${2:-0}" + cat < +EOT + exit "${exit_code}" +} + +main() { + local branch="${1:-}" + [ -n "${branch}" ] || usage "missing branch" "1" + if [ -n "${OBS_USER:-}" ] && [ -n "${OBS_PASS:-}" ] && [ ! -e "${OSCRC:-}" ]; then + echo "Creating ${OSCRC} with user $OBS_USER" + cat <"${OSCRC}" [general] apiurl = ${OBS_API} [${OBS_API}] user = ${OBS_USER} pass = ${OBS_PASS} eom -fi + fi -if [ -n "${PUSH}" ]; then - # push to obs - PUSH_TO_OBS="-p" -elif [ -n "${LOCAL}" ]; then - # local build - PUSH_TO_OBS="-l" -fi + for p in "${projects[@]}"; do + pushd "$p" >>/dev/null + update_cmd="./update.sh" + if [ -n "${PUSH}" ]; then + # push to obs + update_cmd+=" -p" + elif [ -n "${LOCAL}" ]; then + # local build + update_cmd+=" -l" + fi -for p in "${projects[@]}"; do - pushd "$p" >> /dev/null - echo "update ${p}" - bash ./update.sh "${PUSH_TO_OBS}" -v - popd >> /dev/null -done + echo "update ${p}" + bash -c "${update_cmd} ${branch}" + popd >>/dev/null + done +} + +main $@