blob: 2ddc282dac5aea941c6f3472f5d90b9010259608 (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
#!/bin/bash
# upgpkg: Upgrades package versions in PKGBUILD and starts build.
# Author: Abhishek Dasgupta <abhidg@gmail.com>
# Thanks to cactus, profjim and daenyth for all the sed help!
# Edited: Florian Pritz <flo@xinu.at>
# I place this script in the public domain.
VERSION=0.6
# from makepkg
unset ALL_OFF BOLD BLUE GREEN RED YELLOW
if [[ -t 2 ]]; then
# prefer terminal safe colored and bold text when tput is supported
if tput setaf 0 &>/dev/null; then
ALL_OFF="$(tput sgr0)"
BOLD="$(tput bold)"
BLUE="${BOLD}$(tput setaf 4)"
GREEN="${BOLD}$(tput setaf 2)"
RED="${BOLD}$(tput setaf 1)"
YELLOW="${BOLD}$(tput setaf 3)"
else
ALL_OFF="\033[1;0m"
BOLD="\033[1;1m"
BLUE="${BOLD}\033[1;34m"
GREEN="${BOLD}\033[1;32m"
RED="${BOLD}\033[1;31m"
YELLOW="${BOLD}\033[1;33m"
fi
fi
readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
die() {
local message="$1"
shift
printf "$RED==> $(gettext "Error"):$ALL_OFF $(gettext "$message")\n" "$@"
exit 1
}
warn() {
local message="$1"
shift
printf "$YELLOW==> $(gettext "Warning"):$ALL_OFF $(gettext "$message")\n" "$@"
}
scriptlet() {
if [ -f "upgpkg" ]; then
if [[ $(type -t upgpkg_$1) = "function" ]]; then
upgpkg_$1 || die "\"%s\" scriptlet failed" $1
fi
fi
}
help() {
echo "upgpkg $VERSION"
printf "$(gettext "usage: upgpkg [options] newver")\n"
printf "$(gettext " -h this help")\n"
printf "$(gettext " -g generate a template ./upgpkg file")\n"
exit 2
}
if [ -z "$1" ]; then
help
fi
_newpkgver=$1
while getopts "gh" OPTION; do
case $OPTION in
g)
cat > upgpkg <<EOF
upgpkg_pre_upgrade() {
# You might want to remove old sources here
# The new pkgver can be accessed using \$_newpkgver
true
}
upgpkg_build() {
makepkg
}
EOF
exit;
;;
h) help;
esac
done
[ ! -f PKGBUILD ] && die "No \"%s\" in %s" "PKGBUILD" "$PWD"
if [ -f "upgpkg" ]; then
source ./upgpkg
fi
source PKGBUILD
scriptlet pre_upgrade
if [[ $(vercmp $1 $pkgver) -le 0 ]]; then
warn "New version (%s) older or equal to current %s" "$1" "$pkgver"
fi
setconf PKGBUILD pkgver="$_newpkgver"
setconf PKGBUILD pkgrel=1
sed -i "s/pkgver=.*$/pkgver=$_newpkgver/g" PKGBUILD
sed -i "s/pkgrel=.*$/pkgrel=1/g" PKGBUILD
updpkgsums
makepkg --verifysource -d
source PKGBUILD
if [ -f "upgpkg" ]; then
source ./upgpkg
fi
scriptlet build
|