summarylogtreecommitdiffstats
path: root/send.sh
blob: 01293fee1851a360be047c565cd221526a2c5300 (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
#!/usr/bin/env bash

cp PKGBUILD.in PKGBUILD

search() {
   grep "^\\s*$1=" PKGBUILD | sed "s/^\\s*$1=\\([^$]*\\)/\\1/"
}

# Read basic information about the package
pkgname="$(search pkgname)"
pkgver="$(search pkgver)"

# Download the current release
wget "https://github.com/Benni3D/${pkgname}/archive/v${pkgver}.tar.gz" || exit 1

# Change the md5sums
sed -i "s/^md5sums=.*/md5sums=\\('$(md5sum "v${pkgver}.tar.gz" | awk '{print $1}')'\\)/" PKGBUILD

# Clean up
rm "v${pkgver}.tar.gz"

# Generate .SRCINFO

arch=$(. PKGBUILD; echo "${arch[@]}")
license=$(. PKGBUILD; echo "${license[@]}")
get_from_PKGBUILD() {
   grep "^$1=" PKGBUILD | sed "s/$1=/\t$1 = /;s/\${pkgver}/${pkgver}/" | tr -d "\"'()" >> .SRCINFO
}

echo "pkgbase = ${pkgname}" > .SRCINFO
get_from_PKGBUILD pkgdesc
get_from_PKGBUILD pkgver
get_from_PKGBUILD pkgrel
get_from_PKGBUILD url
for a in ${arch}; do
   printf "\tarch = ${a}\n" >> .SRCINFO
done
for a in ${license}; do
   printf "\tlicense = ${a}\n" >> .SRCINFO
done
get_from_PKGBUILD depends
get_from_PKGBUILD optdepends
get_from_PKGBUILD source
get_from_PKGBUILD md5sums
printf "\npkgname = ${pkgname}\n\n" >> .SRCINFO

printf "Send [Yn]: "
read -r confirmation

echo "${confirmation}" | grep -q '[nN]' && exit 1

# Push to AUR repository
git add .
git commit -m "Updated to v${pkgver}"
git push origin master