Created
October 9, 2023 14:51
-
-
Save mohd-akram/92912470caec3c6bc99dea748eab3779 to your computer and use it in GitHub Desktop.
Utility to bump revision of a list of ports (MacPorts)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -euo pipefail | |
root= | |
while getopts D: opt; do | |
case $opt in | |
D) root=$OPTARG ;; | |
?) exit 2 | |
esac | |
done | |
shift $((OPTIND-1)) | |
port info --line --portdir "$@" | sort | uniq | while read dir; do | |
if [ "$root" ]; then | |
dir=$root/$dir | |
fi | |
f=$dir/Portfile | |
n=$(awk '/^ *revision *[0-9]+/ {++i} END {print i+0}' "$f") | |
if [ "$n" -gt 1 ]; then | |
echo >&2 "skipping $f (more than one revision line)" | |
continue | |
fi | |
if [ "$n" -eq 0 ]; then | |
echo >&2 "skipping $f (revision not found)" | |
continue | |
fi | |
newrev=$(awk '/^ *revision *[0-9]+/ {print $2+1}' "$f") | |
ed -s "$f" <<-EOF | |
/^ *revision/s/[0-9][0-9]*/$newrev/ | |
w | |
q | |
EOF | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment