Compare commits

9 Commits
main ... wip

Author SHA1 Message Date
Ludwig Nussel
d84b19c908 Update README 2023-03-02 15:43:42 +01:00
Ludwig Nussel
f15ebf021e pulls 2023-03-02 15:41:42 +01:00
Ludwig Nussel
a3ff31cd06 fixes 2023-03-02 13:43:35 +01:00
Ludwig Nussel
bc02fc7b38 fix pusher 2023-02-23 18:12:04 +01:00
Ludwig Nussel
f17106dbf4 readme 2023-02-23 18:11:51 +01:00
Ludwig Nussel
360c63e446 update pusher 2023-02-23 17:05:40 +01:00
Ludwig Nussel
721114aa3f update 2023-02-23 17:05:34 +01:00
Ludwig Nussel
e0aac8ec9e Add new and remove old 2023-02-23 13:57:17 +01:00
Ludwig Nussel
ecfcb53fd3 Split
- move pusher to separate script
- add getopt
2023-02-20 14:27:54 +01:00
5 changed files with 21 additions and 122 deletions

View File

@@ -27,8 +27,8 @@ REMOTE="origin"
BASE_BRANCH="main" BASE_BRANCH="main"
# optional: fixed date or a filename prefixed with @ to get a stable date for testing # optional: fixed date or a filename prefixed with @ to get a stable date for testing
DATE="@token" DATE="@token"
# optional: OBS projects with a list of packages # optional: an OBS project with a list of packages
OBS_PROJECTS="openSUSE:Factory:Rings:0-Bootstrap" OBSPKGLIST="https://api.opensuse.org/public/source/openSUSE:Factory:Rings:0-Bootstrap"
``` ```
Scripts: Scripts:
@@ -36,16 +36,13 @@ Scripts:
All scripts use getopt, --help may not always be up to date though All scripts use getopt, --help may not always be up to date though
:-) :-)
- obspkglist: given obs projects, prints all packages in those projects that
are also in gitea
- updatemodules: checks all submodules for updates. For packages - updatemodules: checks all submodules for updates. For packages
that need to be updated creates `refs/pq/$packagename`. The that need to be updated creates `refs/pq/$packagename`. The
updated refence there updates the submodule commit reference for updated refence there updates the submodule commit reference for
updates. It also adds or removes entries from/to `.gitmodules` if updates. It also adds or removes entries from/to `.gitmodules` if
needed. There's also a `--single` option which produces a single needed. There's also a `--single` option which produces a single
reference for all updates. The `--status` option show the current reference for all updates. The `--status` option show the current
state. Use --packages-from to read a package list produced by `obspkglist`. state.
With the list the script can also add or drop packages.
- pusher: compares the references created by the `updatemodules` - pusher: compares the references created by the `updatemodules`
script with the specified remote. Pushed pending refs to an script with the specified remote. Pushed pending refs to an
`update_$packagename` ref. Gitea doesn't seem to support refs in `update_$packagename` ref. Gitea doesn't seem to support refs in

View File

@@ -130,21 +130,21 @@ while true; do
action="$result" action="$result"
case "$action" in case "$action" in
raw) raw)
jq ".[]|select(.number==$prno)" < "$requestfile" > "$tmpfile" jq ".[]|select(.number==$prno)" < "$requestfile" > "$tmpfile"
d --textbox "$tmpfile" 0 0 d --textbox "$tmpfile" 0 0
;; ;;
diff) diff)
request "/pulls/$prno.diff" > "$tmpfile" request "/pulls/$prno.diff" > "$tmpfile"
d --textbox "$tmpfile" 0 0 d --textbox "$tmpfile" 0 0
;; ;;
merge) merge)
request "/pulls/$prno/merge" -d '{ "do": "merge", "delete_branch_after_merge": true}' | jq > "$tmpfile" request "/pulls/$prno/merge" -d '{ "do": "merge", "delete_branch_after_merge": true}' | jq > "$tmpfile"
d --textbox "$tmpfile" 0 0 d --textbox "$tmpfile" 0 0
fetch_requests fetch_requests
break break
;; ;;
close) close)
request "/pulls/$prno" -d '{ "state": "closed"}' -X PATCH | jq > "$tmpfile" request "/pulls/$prno" -d '{ "state": "closed"}' -X PATCH | jq > "$tmpfile"
d --textbox "$tmpfile" 0 0 d --textbox "$tmpfile" 0 0
fetch_requests fetch_requests

View File

@@ -1,73 +0,0 @@
#!/bin/bash
set -e
# https://api.opensuse.org/public/source/openSUSE:Factory:Rings:0-Bootstrap
APIURL="https://api.opensuse.org"
GITEA_PACKAGES="https://gitea.opensuse.org/api/v1/repos/rpm"
OBS_PROJECTS=()
# command line only
packages_from=
single=
verbose=0
cfg_file=
###################
declare -A packages
helpandquit()
{
cat <<-EOF
Usage: $0 [OPTIONS] [<projects> ...]
OPTIONS:
--apiurl=URL OBS api url
--single create single commit for all changes
-h help screen
EOF
exit 0
}
log_info()
{
[ "$verbose" -gt 0 ] || return 0
echo "$@"
}
getopttmp=$(getopt -o hc:v --long help,config:,verbose,apiurl: -n "${0##*/}" -- "$@")
eval set -- "$getopttmp"
while true ; do
case "$1" in
-h|--help) helpandquit; shift ;;
-v|--verbose) verbose=$((++verbose)); shift ;;
-c|--config) cfg_file="$2"; shift 2 ;;
--apiurl) APIURL="$2"; shift 2 ;;
--) shift ; break ;;
*) echo "Internal error!" ; exit 1 ;;
esac
done
[ $# ] && OBS_PROJECTS=("$@")
# shellcheck disable=SC1090
. "${cfg_file:-.settings}" 2>/dev/null || :
for prj in "${OBS_PROJECTS[@]}"; do
while read -r p l; do
if [ -n "$l" ]; then
echo "Warning: link $p -> $l ignored" >&2
continue
fi
packages["$p"]=1
done < <(curl -s -f "$APIURL/public/source/$prj"|sed -ne 's/.*entry name="\([^"]*\)"\( \+originpackage="\([^"]*\)"\)\?.*\/>/\1 \3/p'|sort -u)
done
for p in "${!packages[@]}"; do
# XXX: unfortuantely plain git would ask for auth
if ! curl -s -f "$GITEA_PACKAGES/$p" >/dev/null; then
log_info "Warning: $p not found in $GITEA_PACKAGES" >&2
continue
fi
echo "$p"
done

13
pusher
View File

@@ -168,19 +168,6 @@ for m in "${!pq[@]}"; do
fi fi
done done
for m in "${!rq[@]}"; do
[ "${#modules[@]}" -eq 0 -o -n "${modules[$m]}" ] || continue
if [ -z "${pq[$m]}" ]; then
log_info "delete remote request $m"
if ! git send-pack --force "$push_url" ":refs/heads/update_$m"; then
echo "failed to push $m update" >&2
ret=1
continue
fi
did_push=1
fi
done
if [ -n "$did_push" ]; then if [ -n "$did_push" ]; then
log_info "Updating remote $PUSH_REMOTE" log_info "Updating remote $PUSH_REMOTE"
git remote update -p "$PUSH_REMOTE" > /dev/null git remote update -p "$PUSH_REMOTE" > /dev/null

View File

@@ -7,11 +7,12 @@ REMOTE="origin"
BASE_BRANCH="main" BASE_BRANCH="main"
PACKAGE_BASE_URL= PACKAGE_BASE_URL=
PACKAGE_RELATIVE_URL="../../rpm" PACKAGE_RELATIVE_URL="../../rpm"
# https://api.opensuse.org/public/source/openSUSE:Factory:Rings:0-Bootstrap
OBSPKGLIST=
DATE="$(date "+%s %z")" DATE="$(date "+%s %z")"
PACKAGES_KEEP= keep["dummy-release"]=1
# command line only # command line only
packages_from=
single= single=
verbose=0 verbose=0
cfg_file= cfg_file=
@@ -21,7 +22,7 @@ cfg_file=
# constant needed to aid quoting # constant needed to aid quoting
nl=$'\n' nl=$'\n'
declare -A packages declare -A obs
declare -A new declare -A new
declare -A drop declare -A drop
declare -A revs declare -A revs
@@ -32,7 +33,6 @@ helpandquit()
cat <<-EOF cat <<-EOF
Usage: $0 [OPTIONS] [<module> ...] Usage: $0 [OPTIONS] [<module> ...]
OPTIONS: OPTIONS:
--packages-from=FILE read list of packges to sync from FILE
--single create single commit for all changes --single create single commit for all changes
-h help screen -h help screen
EOF EOF
@@ -81,7 +81,7 @@ makedict()
done done
} }
getopttmp=$(getopt -o hc:v --long help,single,branch:,config:,date:,remote:,status,verbose,clear,packages-from: -n "${0##*/}" -- "$@") getopttmp=$(getopt -o hc:v --long help,single,branch:,config:,date:,remote:,status,verbose,clear -n "${0##*/}" -- "$@")
eval set -- "$getopttmp" eval set -- "$getopttmp"
while true ; do while true ; do
@@ -90,7 +90,6 @@ while true ; do
-v|--verbose) verbose=$((++verbose)); shift ;; -v|--verbose) verbose=$((++verbose)); shift ;;
-c|--config) cfg_file="$2"; shift 2 ;; -c|--config) cfg_file="$2"; shift 2 ;;
--single) single=1; shift ;; --single) single=1; shift ;;
--packages-from) packages_from="$2"; shift 2 ;;
--remote) REMOTE="$2"; shift 2 ;; --remote) REMOTE="$2"; shift 2 ;;
--branch) BASE_BRANCH="$2"; shift 2 ;; --branch) BASE_BRANCH="$2"; shift 2 ;;
--status) show_status; exit 0 ;; --status) show_status; exit 0 ;;
@@ -108,10 +107,6 @@ PACKAGE_BASE_URL="$(git config --get remote."$REMOTE".url)"
# shellcheck disable=SC1090 # shellcheck disable=SC1090
. "${cfg_file:-.settings}" . "${cfg_file:-.settings}"
for p in $PACKAGES_KEEP; do
keep["$p"]=1
done
if [ "${DATE:0:1}" = '@' ]; then if [ "${DATE:0:1}" = '@' ]; then
DATE="$(stat -c %Y "${DATE:1}") +0100" DATE="$(stat -c %Y "${DATE:1}") +0100"
fi fi
@@ -140,13 +135,14 @@ while read -r m t cid p; do
revs["$p"]="$cid" revs["$p"]="$cid"
done < <(git cat-file -p "$REMOTE/$BASE_BRANCH^{tree}") done < <(git cat-file -p "$REMOTE/$BASE_BRANCH^{tree}")
if [ -n "$packages_from" ]; then if [ -n "$OBSPKGLIST" ]; then
while read -r p; do while read -r p; do
packages["$p"]=1 obs["$p"]=1
[ -n "${revs[$p]}" ] || new["$p"]=1 [ -n "${revs[$p]}" ] || new["$p"]=1
done < "$packages_from" done < <(curl -s -f "$OBSPKGLIST"|sed -ne 's/.*entry name="\([^":]*\).*\/>/\1/p'|sort -u | grep -v AGGR)
for m in "${!revs[@]}"; do for m in "${!revs[@]}"; do
[ -n "${packages[$m]}" -o -n "${keep[$m]}" ] || drop["$m"]=1 [ -n "${obs[$m]}" -o -n "${keep[$m]}" ] || drop["$m"]=1
done done
fi fi
@@ -161,14 +157,6 @@ fi
declare -A pq declare -A pq
makedict pq git for-each-ref 'refs/pq/*' --format '%(refname)' makedict pq git for-each-ref 'refs/pq/*' --format '%(refname)'
for r in "${!pq[@]}"; do
m="${r##*/}"
if [ -z "${revs[$m]}" ] && ! isnew "$m" && ! todrop "$m"; then
log_info "remove stale update entry for $m"
git update-ref -d "$r"
fi
done
# check remotes for updates # check remotes for updates
declare -A commits declare -A commits
treetext=$(git cat-file -p "$REMOTE/$BASE_BRANCH^{tree}") treetext=$(git cat-file -p "$REMOTE/$BASE_BRANCH^{tree}")
@@ -196,9 +184,9 @@ for m in "${modules[@]}"; do
cid= cid=
if ! todrop "$m"; then if ! todrop "$m"; then
read -r cid _d < <(GIT_ASKPASS=/bin/true git ls-remote "$url" "${smbranch:-HEAD}" 2>/dev/null) || true read -r cid _d < <(git ls-remote "$url" "${smbranch:-HEAD}")
if [ -z "$cid" ]; then if [ -z "$cid" ]; then
echo "Warning: $path not in pool, ignored" >&2 echo "$path not in pool" >&2
continue continue
fi fi
fi fi