summaryrefslogtreecommitdiffstats
path: root/pkgup
blob: 4ae31cec645227f7086234f1b74f1411f93a11d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh

vendor="Remi Collet <remi@remirepo.net>"
rpmdate=$(LC_ALL="C" date +"%a %b %d %Y")
rpmdate=${rpmdate/ 0/  }
name=$(basename $PWD)

if [ $# -lt 2 ]; then
	echo "usage $0 version commit [ date [ spec ]]"
    exit 1
fi
if [ x$3 = x ]; then
   date=$(date +%Y-%m-%d)
else
   date=$3
fi
if [ x$4 = x ]; then
   name=$(basename $PWD)
else
   name=$(basename $4 .spec)
fi

sed --regexp-extended \
	--expression "/^Version:/s/[0-9.]+$/$1/" \
    --expression "/github_version/s/[0-9.]+$/$1/" \
    --expression "/upstream_version/s/[0-9.]+$/$1/" \
    --expression "/(github|gh)_commit/s/[0-9a-f]{40}$/$2/" \
    --expression "/(github|gh)_date/s/[0-9\-]{10}$/$date/" \
    --expression '/^Release:/s/[0-9.]+/1/' \
    --expression "s/%changelog/%changelog\n* $rpmdate $vendor - $1-1\n- update to $1\n/" \
    --in-place $name.spec