projects/aports·blob v2.19.2 · refs

133 lines · 2.7 KiB

1#!/bin/sh
2
3# abump - bump pkgver in APKBUILDs
4# Copyright (c) 2012 Natanael Copa <[email protected]>
5#
6# Distributed under GPL-2
7#
8
9program_version=@VERSION@
10datadir=@datadir@
11
12if ! [ -f "$datadir/functions.sh" ]; then
13 echo "$datadir/functions.sh: not found" >&2
14 exit 1
15fi
16. "$datadir/functions.sh"
17
18
19# version bump packages
20do_bump() {
21 local p rc=0 notbumped="" name ver section message
22 local upgrade="${cvelist:+security }upgrade"
23 local a
24 for p; do
25 if [ $rc -gt 0 ]; then
26 notbumped="$notbumped $p"
27 continue
28 fi
29 name=${p%-[0-9]*}
30 ver=${p#${name}-}
31
32 (
33 set -e
34
35 # calculate APKBUILD's path #vim syntax higlight '
36 if [ "${name#*/}" != "$name" ] && ! [ -d "$APORTSDIR/${name%/*}" ]; then
37 die "'$p' should be of form 'foo-1.2.3' or 'main/foo-1.2.3'"
38 fi
39 a=$(aports_buildscript "$name" ) \
40 || die "can't find APKBUILD for $name"
41
42 # verify APKBUILD
43 . "$a" || exit 1
44 [ "$pkgname" = "$name" ] \
45 || die "APKBUILD has different \$pkgname for $name"
46 type package | grep -q function \
47 || die "missing package() for $name"
48
49 cd "${a%/*}"
50 section=${PWD%/*}
51 section=${section##*/}
52
53 message="$section/$name: $upgrade to ${ver}${cvelist}"
54 if [ -n "$fixes" ]; then
55 message="$message
56
57fixes #${fixes#\#}
58"
59 fi
60 msg "$message"
61
62 sed -i -e "s/^pkgver=.*/pkgver=$ver/" \
63 -e "s/^pkgrel=.*/pkgrel=0/" \
64 APKBUILD
65
66 abuild $abuild_opts checksum all
67
68 git add APKBUILD
69 git commit -m"$message"
70 )
71 rc=$?
72 if [ $rc -gt 0 ]; then
73 error "Failed to build $p"
74 fi
75 done
76 if [ -n "$notbumped" ]; then
77 error "Not bumped: $notbumped"
78 fi
79 return $rc
80}
81
82usage() {
83 cat >&2 <<__EOF__
84$program $program_version - bump pkgver in APKBUILDs
85Usage: $program [-s CVE-1,CVE-2,...] [-f ISSUE] [-R|--recursive] [-k|--keep] PKGNAME-1.2.3 ...
86Options:
87 -s, --security CVE1,CVE-2,... Security update
88 -f, --fixes ISSUE Fixes ISSUE
89 -R, --recursive Run abuild with -R for recursive building
90 -k, --keep Run abuild with -k to keep existing packages
91 -q, --quiet
92 -h, --help Show this help
93
94__EOF__
95}
96
97keep=
98recursive="-r"
99cvelist=
100fixes=
101
102[ -n "$APORTSDIR" ] || error "can't locate \$APORTSDIR"
103git rev-parse 2>/dev/null || die "not in a git tree"
104
105args=`getopt -o f:s:Rkqh --long fixes:,security:,recursive,keep,quiet,help \
106 -n "$program" -- "$@"`
107if [ $? -ne 0 ]; then
108 usage
109 exit 2
110fi
111eval set -- "$args"
112while true; do
113 case $1 in
114 -s|--security) cvelist=" ($2)"; shift;;
115 -f|--fixes) fixes="$2"; shift;;
116 -R|--recursive) recursive="-R";;
117 -k|--keep) keep="-k";;
118 -q|--quiet) quiet=1;; # suppresses msg
119 -h|--help) usage; exit;;
120 --) shift; break;;
121 *) exit 1;; # getopt error
122 esac
123 shift
124done
125if [ $# -eq 0 ]; then
126 usage
127 exit 2
128fi
129
130abuild_opts="$recursive $keep"
131
132do_bump "$@"
133