-
Notifications
You must be signed in to change notification settings - Fork 1
/
aurpush
executable file
·98 lines (81 loc) · 2.95 KB
/
aurpush
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
#!/bin/bash
######################################################################
# aurpush - AUR4 package uploader
version="0.1"
# Copyright OS Hazard <oshazard+aur@gmail.com>
######################################################################
# VARS
pkgname="$1"
aurver="aur4"
# FUNCTIONS
err() { echo "ERROR: $@"; exit 1; }
deptest() { type -p $1 &>/dev/null; }
create_pkg() {
maintainer_name=$(git config -l | grep ^user.name | awk -F = '{print $2}')
maintainer_email=$(git config -l | grep ^user.email | awk -F = '{print $2}')
[ -z "$maintainer_name" -o -z "$maintainer_email" ] && err "Run git config first"
git clone ssh://aur@${aurver}.archlinux.org/${pkgname}.git || err "Must copy public key to AUR first"
cd "$pkgname"
echo "# Maintainer: ${maintainer_name} <${maintainer_email}>" > PKGBUILD
echo "pkgname=${pkgname}" >> PKGBUILD
echo "pkgver=0.1" >> PKGBUILD
echo "pkgrel=1" >> PKGBUILD
echo "pkgdesc=""\"Description"\""" >> PKGBUILD
echo "url=""\"http://github.com/<USERNAME>/${pkgname}"\""" >> PKGBUILD
echo "license=(\"None\")" >> PKGBUILD
echo "arch=('any')" >> PKGBUILD
echo "makedepends=('')" >> PKGBUILD
echo "depends=('')" >> PKGBUILD
echo "provides=('')" >> PKGBUILD
echo "source=(""\"https://github.com/<USERNAME>/${pkgname}/archive/master.tar.gz"\"")" >> PKGBUILD
echo "md5sums=('')" >> PKGBUILD
echo "" >> PKGBUILD
echo "package() {" >> PKGBUILD
echo " cd ""\"\${srcdir}/${pkgname}-master"\""" >> PKGBUILD
echo "" >> PKGBUILD
echo " # Install script" >> PKGBUILD
echo " mkdir -p ""\"\$pkgdir/usr/bin"\""" >> PKGBUILD
echo " install -m755 ${pkgname} ""\"\$pkgdir/usr/bin/${pkgname}"\""" >> PKGBUILD
echo "" >> PKGBUILD
echo " # Install license" >> PKGBUILD
echo " #mkdir -p ""\"\${pkgdir}/usr/share/licenses/${pkgname}"\""" >> PKGBUILD
echo " #install -m644 LICENSE "\${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"" >> PKGBUILD
echo "}" >> PKGBUILD
echo "*.tar.*" > .gitignore
echo "==> cd $pkgname"
echo "==> Edit PKGBUILD"
}
update_pkg() {
mksrcinfo || err "Unable to create .SRCINFO"
git add -A || err "Unable to add files to git repo"
git commit -m "Package $pkgname submitted by aurpush" || err "Unable to create git commit"
git log
read -p "Confirm push (Y/n)? " input
if [[ "$input" = [Yy] ]]; then
git push origin master || err "Unable to push update to AUR"
echo "Uploaded $pkgname to AUR [SUCCESS]"
fi
}
# SANITY CHECKS
[ ! -z "$pkgname" -o -f "PKGBUILD" ] || err "USAGE: $0 {[NONE]|[pkgname]}"
deps="git makepkg mksrcinfo updpkgsums"
for i in $deps; do
deptest $i || err "Missing dependency $i"
done
# PARSE
if [ ! -z "$pkgname" ]; then
if [ ! -d "$pkgname" ]; then
create_pkg
else
err "Directory $pkgname already exists"
fi
else
pkgname=$(basename $PWD)
updpkgsums || err "Unable to fetch source"
makepkg -c || err "Package failed to build"
read -p "==> Update package (Y/n)? " input
if [[ "$input" = [Yy] ]]; then
update_pkg
fi
fi
# END