projects/aports·blob v2.15.0 · refs

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