Ticket #23260: bump-rev.sh

File bump-rev.sh, 769 bytes (added by nox@…, 15 years ago)
Line 
1#!/bin/sh
2
3treedir=$1
4shift
5
6function portfile {
7    echo ${treedir}/$(port file "$1" | grep -o "\\([^/]*/\\)\\{2\\}[^/]*\$")
8}
9
10for port in $(port echo $@); do
11    file=$(portfile ${port})
12    echo Bumping ${port} in ${file}
13    echo Checking for an existing revision...
14    revision=$(grep ^revision "${file}" | awk '{print $2}')
15    if test -n "${revision}"; then
16        echo Revision found: ${revision}
17        new=$(expr ${revision} + 1)
18        echo Incrementing to ${new}...
19        sed -i .before-bump /^revision/s/${revision}/${new}/ "${file}"
20    else
21        echo Revision not found
22        echo Inserting revision 1
23        sed -i .before-bump "/^version/a\\
24revision        1
25" "${file}"
26    fi
27    diff -u ${file}.before-bump ${file}
28    echo Done.
29done