forked from h4tr3d/qtcreator-opt
-
Notifications
You must be signed in to change notification settings - Fork 2
/
pkgbuild.sh
49 lines (39 loc) · 1.25 KB
/
pkgbuild.sh
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
#!/bin/bash
set -ex
# Environment variables.
makepkg_conf="/home/pkguser/.makepkg.conf"
if [ ! -f ${makepkg_conf} ] || ! $(grep -Fxq "PACKAGER" ${makepkg_conf}) ; then
# echo "No makepkg.conf or no PACKAGER variable found: exporting it..."
export PACKAGER="${1/\// } <${2}@travis.build.id>"
fi
export AURDEST="$(pwd)/src"
# Variables declaration.
declare -r pkgrepo="${1#*/}"
declare -a pkglist=()
declare -a pkgkeys=()
declare -a pkgdeps=()
# Remove comments or blank lines.
for pkgfile in "pkglist" "pkgkeys"; do
sed -i -e "/\s*#.*/s/\s*#.*//" -e "/^\s*$/d" $pkgfile
done
# Load files.
mapfile pkglist < "pkglist"
mapfile pkgkeys < "pkgkeys"
# Create package list with dependencies.
mapfile pkgdeps < <(echo ${pkglist[@]} | aur depends -n)
pkgdeps+=("${pkglist[@]}")
# Remove packages from repository.
cd "bin"
while read pkgpackage; do
repo-remove "${pkgrepo}.db.tar.gz" $pkgpackage
done < <(comm -23 <(pacman -Slq $pkgrepo | sort) <(printf "%s" "${pkgdeps[@]}" | sort))
cd ".."
# Get package gpg keys.
for pkgkey in ${pkgkeys[@]}; do
gpg --recv-keys --keyserver "hkp://ipv4.pool.sks-keyservers.net" $pkgkey
done
# Build outdated packages.
if (( ${#pkglist[@]} )); then
aur sync -d $pkgrepo --root "${HOME}/bin" -n ${pkglist[@]}
fi
{ set +ex; } 2>/dev/null