Jimmy Berry 88add9aefa dist/ci/obs-deploy: limit request list by user to avoid source requests.
Otherwise, requests from Factory to Leap will prevent request to Factory
from being generated.
2018-01-19 15:24:26 -06:00

33 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
osc-init
osc checkout "$OBS_PACKAGE"
cd "$OBS_PACKAGE"
rm *.obscpio
osc service disabledrun
# ensure _servicedata ends with a newline
tail -n1 _servicedata | read -r _ || echo >> _servicedata
osc addremove
if [ "$(osc status | wc -l)" -gt 0 ] ; then
osc commit -m "$(grep -oP 'version: \K.*' *.obsinfo)"
fi
# Create submit request if none currently exists.
OBS_TARGET_PROJECT="$(osc info | grep -oP "Link info:.*?project \K[^\s,]+")"
OBS_TARGET_PACKAGE="$(osc info | grep -oP "Link info:.*?, package \K[^\s,]+")"
echo "checking for existing requests to $OBS_TARGET_PROJECT/$OBS_TARGET_PACKAGE..."
# Limit by user in an attempt to avoid requests sourced from target project.
# Unfortunately the command line provides no mechanism to do so and a full API
# query is rather ungainly compared to this workaround.
if osc request list -U "$OBS_USER" "$OBS_TARGET_PROJECT" "$OBS_TARGET_PACKAGE" |
grep 'No results for package' ; then
osc service wait
osc sr --diff | cat
osc sr --yes -m "automatic update"
fi