#!/bin/bash usage() { >&2 echo 'usage: bumpPkgrel [-a] [-n] [-p /tmp/provided] $pkg1 $pkg2 $pkg3 ...' >&2 echo ' -a: auto-detect packages' >&2 echo ' -n: do not commit' >&2 echo ' -p: use this temporary file' exit 1 } export LC_ALL=C eval set -- "$( getopt -o anp: \ -n "$(basename "$0")" \ -- "$@" \ || echo "usage" )" auto_detect=false commit=true commit_flag='' provided=() while true; do case "$1" in '-a') auto_detect=true ;; '-n') commit=false commit_flag='-n' ;; '-p') shift provided=("${provided[@]}" "$1") ;; '--') shift break ;; *) >&2 printf 'FEHLER: Verstehe Option "%s" doch nicht! Ich beende.\n' "$1" exit 1 esac shift done if [ $# -eq 0 ] && ! ${auto_detect}; then usage fi if [ ${#provided[@]} -eq 0 ]; then provided=( $( printf 'arch\n%s\n' 'i486' 'i686' 'pentium4' 'x86_64' \ | parallel -l2 "${0%/*}/liste-verfuegbare-Versionen" ) ) trap 'rm -f "${provided[@]}"' EXIT fi pin_dependency() { prov=$( printf '%s\n' "${provided[@]}" \ | grep -m1 '\.\(arch\.'"$2"'\|'"$2"'\.x86_64\)$' ) || prov=$( printf '%s\n' "${provided[@]}" \ | grep -m1 '\.arch\.x86_64$' ) || prov=$( printf '%s\n' "${provided[@]}" \ | head -n1 ) >&2 echo "'$2' '$prov'" sed ' s/^\(\S\+\)>\?=\(\S\+\)$/\1 \2/ t s/^\S\+$/\0 BOGUS/ t d ' \ | sort -k1,1 \ | join -1 1 -2 2 -a 1 -e EMPTY -o 1.1,1.2,2.1 - "${prov}" \ | sed ' s/ \(\S\+\) EMPTY$/ \1 \1/ ' \ | sed ' s/^\(\S\+\) \S\+ \(\S\+\)$/'"${1}'"'\1=\2'"'"'/ s/^\(\s*'"'"'glibc\)=/\1>=/ t d ' } if [ $# -ne 1 ] || ${auto_detect}; then { printf '%s\n' "$@" if ${auto_detect}; then "${0%/*}/checkPinnedDependencies" -m "${provided[@]}" fi } \ | sort -u \ | xargs -rn1 "$0" ${commit_flag} $(printf ' -p %s' "${provided[@]}") if ${auto_detect} \ && prov=$( printf '%s\n' "${provided[@]}" \ | grep -m1 '\.arch\.x86_64$' ); then python_version=$( sed ' s/^\(3\.[0-9]\+\)\(\.[0-9.]\+\)\? python$/\1/ t d ' "${prov}" ) if cat "${0%/*}"/*/PKGBUILD \ | sed ' s/^\(.* \)\?\(["'"'"']\)\?\(python>=[0-9.]\+\)\2\( .*\)\?$/\3/ t d ' \ | grep -qvxF "python>=${python_version}"; then "${0%/*}/bumpPython" "${python_version}" "${provided[@]}" fi fi else cd "$(dirname "$0")" pkg="${1%/}" cd "${pkg}" while IFS=$(printf '\n') read -r line; do if printf '%s\n' "${line}" \ | grep -q '^\s*pkgrel='; then eval "${line}" printf '%s=%s\n' "${line%%=*}" "$((pkgrel+1))" continue fi if printf '%s\n' "${line}" \ | grep -q '^\s*_pinned_dependencies\([^=[:space:]]*\)=('; then suffix="${line%%=*}" suffix="${suffix##*_}" if [ "${suffix}" = 'dependencies' ]; then unset suffix fi space="${line%%_pinned_dependencies*=(*}" printf '%s=(\n' "${line%%=(*}" line="${line#*_pinned_dependencies*=(}" { while ! printf '%s\n' "${line}" \ | grep -qF ')'; do printf '%s\n' ${line%%#*} IFS=$(printf '\n') read -r line done printf '%s\n' ${line%%)*} } \ | sed ' /^$/d s/^\(["'"'"']\)\(\S\+\)\1$/\2/ ' \ | pin_dependency "${space} " "${suffix}" printf '%s)%s\n' "${space}" "${line#*)}" continue fi printf '%s\n' "${line}" done \ < 'PKGBUILD' \ | sponge 'PKGBUILD' if ${commit}; then ../commit-package "${pkg}: rebuild" fi fi