summaryrefslogtreecommitdiff
path: root/get
blob: c8cdd77931c227e6f584a940c19c20ca71c9d214 (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
#!/bin/bash

pkg=$1

pkgbuild="$(mktemp --tmpdir libreboot.XXXXXXXXXX)"
makepkg_conf="$(mktemp --tmpdir libreboot.XXXXXXXXXX)"
trap "rm -f -- $(printf -- '%q ' "$pkgbuild" "$makepkg_conf")" EXIT

get() {
	pkg="$1"
	{
		# Bogus stuff to keep makepkg happy
		printf 'pkgname=%q\n' "$pkg"
		printf 'pkgver=libreboot\n'
		printf 'pkgrel=1\n'
		printf 'arch=(any)\n'
		printf 'package() { :; }\n'
		printf 'md5sums=(SKIP)\n'
		# Actual stuff we care about
		printf 'source=("${%s_source}")\n' "$pkg"
		printf 'if type %s_mksource &>/dev/null; then\n' "$pkg"
		printf 'prepare() { resources=%q; %s_mksource; }\n' "$PWD/resources" "$pkg"
		printf 'fi\n'
	} | cat source-locations.sh - > "$pkgbuild"

	makepkg -o -p "$pkgbuild" --config "$makepkg_conf"
}

main() {
	{
		printf -- '%s\n' \
		       "DLAGENTS=('ftp::/usr/bin/curl -fC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'" \
		       "          'http::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u'" \
		       "          'https::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u'" \
		       "          'rsync::/usr/bin/rsync --no-motd -z %u %o'" \
		       "          'scp::/usr/bin/scp -C %u %o')"
		printf 'BUILDENV=(fakeroot color)\n'
		printf 'SRCDEST=%q\n' "$PWD/src/downloads"
	} > "$makepkg_conf"
	mkdir -p -- "$PWD/src/downloads"
	for pkg in "$@"; do
		get "$pkg"
	done
}

main "$@"