From 3fe90cc439e5fdccaf1354c41f532de5eec25116 Mon Sep 17 00:00:00 2001 From: Marco Vedovati Date: Mon, 19 Nov 2018 19:35:27 +0100 Subject: [PATCH 1/2] build_all.sh: specify a list of projects as extra args Add the ability to specify a list of projects to process, instead of processing all projects (default behaviour). Fixes: #244 Signed-off-by: Marco Vedovati --- obs-packaging/build_all.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/obs-packaging/build_all.sh b/obs-packaging/build_all.sh index bb10a3c167..887b8fd15c 100755 --- a/obs-packaging/build_all.sh +++ b/obs-packaging/build_all.sh @@ -41,9 +41,13 @@ main() { local branch="${1:-}" [ -n "${branch}" ] || usage "missing branch" "1" - pushd "${script_dir}" - for p in "${OBS_PKGS_PROJECTS[@]}"; do - pushd "$p" >>/dev/null + shift + local projectsList=("$@") + [ "${#projectsList[@]}" = "0" ] && projectsList=("${OBS_PKGS_PROJECTS[@]}") + + pushd "${script_dir}" >>/dev/null + for p in "${projectsList[@]}"; do + [ -d "$p" ] || usage "$p is not a valid project directory" "1" update_cmd="./update.sh" if [ -n "${PUSH}" ]; then # push to obs @@ -53,11 +57,13 @@ main() { update_cmd+=" -l" fi - echo "update ${p}" + echo "======= Updating ${p} =======" + pushd "$p" >>/dev/null bash -c "${update_cmd} ${branch}" popd >>/dev/null + echo "" done - popd + popd >> /dev/null } main $@ From bc7959349cba72b18cda77c3637667fc0eea2af4 Mon Sep 17 00:00:00 2001 From: Marco Vedovati Date: Mon, 19 Nov 2018 19:34:42 +0100 Subject: [PATCH 2/2] build_all.sh: improve usage and error handling Usage: - add more information about what the script does - support for -h / --help flags - tagging of error messages with `ERROR: ` prefix Fixes: #244 Signed-off-by: Marco Vedovati --- obs-packaging/build_all.sh | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/obs-packaging/build_all.sh b/obs-packaging/build_all.sh index 887b8fd15c..78f890dcde 100755 --- a/obs-packaging/build_all.sh +++ b/obs-packaging/build_all.sh @@ -18,7 +18,6 @@ source "${script_dir}/scripts/obs-pkgs.sh" PUSH=${PUSH:-""} LOCAL=${LOCAL:-""} -PUSH_TO_OBS="" export BUILD_DISTROS=${BUILD_DISTROS:-xUbuntu_16.04} # Packaging use this variable instead of use git user value @@ -29,17 +28,46 @@ export AUTHOR_EMAIL="${AUTHOR_EMAIL:-user@example.com}" usage() { msg="${1:-}" exit_code=$"${2:-0}" + if [ -n "${msg}" ]; then + local logPrefix="" + [ ${exit_code} != "0" ] && logPrefix="ERROR: " + echo -e "${logPrefix}${msg}\n" + fi + cat < +${script_name} [-h | --help] [PROJ1 PROJ2 ... ] + +Generate OBS packages sources for the kata projects, based on branch +kata-branch. +${script_name} processes all the kata projects by default; alternatively you can +specify a subset of the projects as additional arguments. + +Environment variables: +PUSH When set, push the packages sources to the openSUSE build + service. + +LOCAL When set, build the packages locally. + EOT exit "${exit_code}" } main() { - local branch="${1:-}" - [ -n "${branch}" ] || usage "missing branch" "1" + case "${1:-}" in + "-h"|"--help") + usage "" "0" + ;; + -*) + usage "Invalid option: ${1:-}" "1" + ;; + "") + usage "missing branch" "1" + ;; + *) + branch="${1:-}" + ;; + esac shift local projectsList=("$@")