blob: 0a2b203a1fb0c19c9be09e7c63d36a86523f1f4f (
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
|
#!/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!
# Requires: pkgtools.
# I place this script in the public domain.
MYVERSION=0.1
PROGNAME="upgpkg"
if [ -r /usr/share/pkgtools/functions ]; then
source /usr/share/pkgtools/functions
else
printf "$(gettext "upgpkg: Unable to source function file!\n")" >&2
exit 1
fi
die() {
local message="$1"
shift
printf "$message" "$@"
exit 1
}
if [ -r /etc/pkgtools/newpkg.conf ]; then
source /etc/pkgtools/newpkg.conf
fi
if [ -r "${HOME}/.pkgtools/newpkg.conf" ]; then
source "${HOME}/.pkgtools/newpkg.conf"
fi
if [ -z "$BASEDIR" ]; then die "$(gettext "upgpkg: unable to locate BASEDIR in configuration.")"; fi
if [ -z "$1" ]; then printf "upgpkg %s\n" "$MYVERSION"; printf "$(gettext "usage: upgpkg package-name newver\n")"; exit; fi
if [ ! -d "$BASEDIR/$1" ]; then die "$(gettext "upgpkg: package %s not in %s.\n")" "$1" "$BASEDIR"; fi
if [ -z "$2" ]; then die "$(gettext "upgpkg: no new version specified for %s\n")" "$1"; fi
# Main code follows
cd "$BASEDIR/$1"
sed -ri '/md5sums[ ]?\=/{:a; /\)/d; N; ba;}' PKGBUILD || die "upgpkg: could not bump pkgver of $1\n"
source PKGBUILD
if [ $(vercmp $2 $pkgver) -gt 0 ]; then
sed -i "s/pkgver=.*$/pkgver=$2/g" PKGBUILD
sed -i "s/pkgrel=.*$/pkgrel=1/g" PKGBUILD
makepkg -g >> PKGBUILD
else
die "$(gettext "upgpkg: %s - new version (%s) older or equal to current %s\n")" "$1" "$2" "$pkgver"
fi
makepkg -m
if [ $? -gt 0 ]; then
sed -i "s/pkgver=.*$/pkgver=$pkgver/g" PKGBUILD
sed -i "s/pkgrel=.*$/pkgrel=$pkgrel/g" PKGBUILD
die "$(gettext "upgpkg: %s - build failed for %s, reverting to %s\n")" "$1" "$2" "$pkgver"
fi
|