From e30e2e8a0114f8f9dcd33e1c6874a158e5907ab0 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Thu, 27 Sep 2018 18:35:39 +0800 Subject: [PATCH] osc: test alternative oscrc locations On ubuntu, it exists at ~/.config/osc/oscrc instead. Signed-off-by: Peng Tao --- obs-packaging/build_from_docker.sh | 18 ------------------ obs-packaging/scripts/obs-docker.sh | 28 +++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/obs-packaging/build_from_docker.sh b/obs-packaging/build_from_docker.sh index ed96822d50..ad42f17694 100755 --- a/obs-packaging/build_from_docker.sh +++ b/obs-packaging/build_from_docker.sh @@ -26,9 +26,6 @@ source "${script_dir}/scripts/obs-docker.sh" GO_ARCH=$(go env GOARCH) export GO_ARCH -OSCRC="${HOME}/.oscrc" -OBS_API="https://api.opensuse.org" - usage() { msg="${1:-}" exit_code=$"${2:-0}" @@ -52,21 +49,6 @@ main() { popd >>/dev/null #Build all kata packages make -f "${script_dir}/Makefile" clean - 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 - - if [ ! -e "${OSCRC}" ]; then - echo "${OSCRC}, please do 'export OBS_USER=your_user ; export OBS_PASS=your_pass' to configure osc for first time." - exit 1 - fi docker_run "${packaging_repo_dir}/obs-packaging/build_all.sh ${branch}" } diff --git a/obs-packaging/scripts/obs-docker.sh b/obs-packaging/scripts/obs-docker.sh index 678b861f01..43956399cc 100755 --- a/obs-packaging/scripts/obs-docker.sh +++ b/obs-packaging/scripts/obs-docker.sh @@ -7,12 +7,38 @@ _obs_docker_packaging_repo_dir=$(cd $(dirname "${BASH_SOURCE[0]}") && cd ../.. && pwd) GO_ARCH=$(go env GOARCH) +setup_oscrc() { + # oscrc exists at different places on different distros + [ -f "${HOME}/.config/osc/oscrc" ] && OSCRC="${HOME}/.config/osc/oscrc" + OSCRC=${OSCRC:-"${HOME}/.oscrc"} + OBS_API="https://api.opensuse.org" + + if [ -n "${OBS_USER:-}" ] && [ -n "${OBS_PASS:-}" ] && [ ! -e "${OSCRC}" ]; then + echo "Creating ${OSCRC} with user $OBS_USER" + mkdir -p $(dirname $OSCRC) + cat <"${OSCRC}" +[general] +apiurl = ${OBS_API} +[${OBS_API}] +user = ${OBS_USER} +pass = ${OBS_PASS} +eom + fi + + if [ ! -e "${OSCRC}" ]; then + echo "${OSCRC}, please do 'export OBS_USER=your_user ; export OBS_PASS=your_pass' to configure osc for first time." + exit 1 + fi +} + docker_run() { local cmd="$*" local obs_image="obs-kata" #where results will be stored local host_datadir="${PWD}/pkgs" local cache_dir=${PWD}/obs-cache + setup_oscrc + sudo docker build \ --quiet \ --build-arg http_proxy="${http_proxy:-}" \ @@ -32,7 +58,7 @@ docker_run() { -v "${cache_dir}":/var/tmp/osbuild-packagecache/ \ -v "${_obs_docker_packaging_repo_dir}":"${_obs_docker_packaging_repo_dir}" \ -v "${host_datadir}":/var/packaging \ - -v "${HOME}/.oscrc":/root/.oscrc \ + -v "${OSCRC}":/root/.oscrc \ -v "${PWD}":"${PWD}" \ -w "${PWD}" \ -ti "${obs_image}" bash -c "${cmd}"