-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-repo
executable file
·74 lines (60 loc) · 1.57 KB
/
build-repo
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
#!/bin/sh -ex
export PKGDEST="$(pwd)/build/packages"
export SRCDEST="$(pwd)/build/sources"
main() {
while read -r package; do
build_package "${package}"
done < packages.txt
build_repo "$1"
}
build_package() {
local package="$1"
if [ -d "build/snapshots/${package}" ]; then
echo "Already built package ${package}, skipping..."
return
fi
mkdir -p "build/snapshots"
curl "https://aur.archlinux.org/cgit/aur.git/snapshot/${package}.tar.gz" \
| tar --extract --gzip --verbose --directory='build/snapshots'
for pgp_key in $(get_pgp_keys "${package}"); do
gpg --recv-keys "${pgp_key}"
done
for dependency in $(get_dependencies "${package}"); do
if ! package_in_official_repo "$dependency"; then
build_package "${dependency}"
fi
done
mkdir -p \
"${PKGDEST}" \
"${SRCDEST}"
(cd "build/snapshots/${package}" &&
makepkg \
--clean \
--force \
--noconfirm \
--syncdeps)
}
# TODO: Remove versions (e.g. X>=Y)
get_dependencies() {
local package="$1"
(cd "build/snapshots/${package}" &&
bash -c 'source PKGBUILD && echo ${depends[@]} ${makedepends[@]}') \
| sed --regexp-extended 's/>[^ ]+//g'
}
package_in_official_repo() {
local package="$1"
pacman --sync --search "^${package}$" > /dev/null
}
get_pgp_keys() {
local package="$1"
(cd "build/snapshots/${package}" &&
bash -c 'source PKGBUILD && echo ${validpgpkeys[@]}')
}
build_repo() {
local repository=$1
mkdir -p build/repo
repo-add --new --remove \
"build/repo/${repository}.db.tar.xz" \
build/packages/*
}
main "$@"