File update-PKGBUILD-pkgrel-number.sh of Package linphoneqt

#!/usr/bin/bash

DRYRUN=true # true false
VERBOSE=true # true false
SOURCE=${BASH_SOURCE[0]}
while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
    DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
    SOURCE=$(readlink "$SOURCE")
    [[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )

# declare an array variable with directories that could contain a PKGBUILD file
declare -a searchdirs=('bcg729' 'bcmatroska2' 'bctoolbox' 'bcunit' 'belcard' 'belle-sip' 'belr' 'broadvoice16' 'bzrtp' 'liboqs' 'soci-4.0.3-archlinux' 'lime' 'linphone' 'linphoneqt' 'mediastreamer2' 'ortp' 'postquantumcryptoengine')

cd "$DIR/.."; echo "Current directory: $(pwd)"
for i in "${searchdirs[@]}"
do
    if [ -d "$i" ]; then
	if $VERBOSE; then echo "Looking into directory: $i" ; fi
	if [ -f "$i/PKGBUILD" ] ; then
	    if $VERBOSE; then
		echo "    found file: $i/PKGGBUILD"
		echo -n "    "; grep -e "pkgrel=" "$i/PKGBUILD"
	    fi
	    if ! $DRYRUN; then
		awk -v FS='=' -v OFS='=' '$1=="pkgrel"{$2++} {print}'  "$i/PKGBUILD" \
		    > "$i/tmpPKGBUILD" && mv -f "$i/tmpPKGBUILD" "$i/PKGBUILD"
		echo -n "Updated $i/PKGBUILD with "
		grep -e "pkgrel=" "$i/PKGBUILD"
	    else
		if $VERBOSE; then
		    echo -n "    Dry-run: "
		fi
		echo -n "    Proposing change $i/PKGBUILD "
		echo -n "$(grep -e "pkgrel=" "$i/PKGBUILD") to "
		awk -v FS='=' -v OFS='=' '$1=="pkgrel"{$2++} {print}'  "$i/PKGBUILD" \
		    | grep "pkgrel="
		echo  "    No changes have been saved!"
	    fi
	fi
    else
	if $VERBOSE; then
	    echo "Directory $i not found. Consider checking out entire repository."
	fi
    fi	    
done
exit 0
openSUSE Build Service is sponsored by