osc: test alternative oscrc locations

On ubuntu, it exists at ~/.config/osc/oscrc instead.

Signed-off-by: Peng Tao <bergwolf@gmail.com>
This commit is contained in:
Peng Tao 2018-09-27 18:35:39 +08:00
parent e074aa1099
commit e30e2e8a01
2 changed files with 27 additions and 19 deletions

View File

@ -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 <<eom >"${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}"
}

View File

@ -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 <<eom >"${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}"