#!/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] [ ...] 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