blob: 699a48b0df6245ee2763774f8f5dfc632bb3c1f1 (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#!/bin/bash
# Releases 'any' packages from Arch arches to our arches
set -eu -o pipefail
source "$(dirname "$(readlink -e "$0")")/config"
source "$(dirname "$(readlink -e "$0")")/db-import-any.conf"
source "$(librelib messages)"
setup_traps
# usage: expac_file <file.db> <expac_args>
#
# Uses the ${WORKDIR} global
expac_file() {
local dbfile=$1
local args=("${@:2}")
local reponame=${dbfile##*/}
reponame=${reponame%%.*}
mkdir -p -- "${WORKDIR}/expac/root"
cat >"${WORKDIR}/expac/pacman.conf" <<-EOT
[options]
RootDir = ${WORKDIR}/expac/root
DBPath = ${WORKDIR}/expac/root
[${reponame}]
Server = file://$(realpath --no-symlinks -- "${dbfile%/*}")
EOT
fakeroot pacman --config="${WORKDIR}/expac/pacman.conf" -Syy >/dev/null
# expac exits with non-zero on emtpy databases, so ignore errors
expac --config="${WORKDIR}/expac/pacman.conf" --sync "${args[@]}" || true
}
db_list_any_pkgfiles() {
local dbfile="$1"
expac_file "$dbfile" '%a %f' | awk '$1 == "any" { print $2 }'
}
main() {
WORKDIR=$(mktemp -dt "${0##*/}.XXXXXXXXXX")
readonly WORKDIR
trap "rm -rf -- ${WORKDIR@Q}" EXIT
local repo arch
for repo in "${PKGREPOS[@]}"; do
msg "Processing %s..." "${repo}"
mkdir -p -- "${WORKDIR}/staging/${repo}"
# Look for arch=(any) packages that exist in
# ${BASEARCH} for this repo but is missing from one or
# more of ${ARCHES[@]}.
db_list_any_pkgfiles "${FTP_BASE}/${repo}/os/${BASEARCH}/${repo}.db" | sort -u > "${WORKDIR}/base.txt"
for arch in "${ARCHES[@]}"; do
[[ $arch != "$BASEARCH" ]] || continue
db_list_any_pkgfiles "${FTP_BASE}/${repo}/os/${arch}/${repo}.db" | sort -u > "${WORKDIR}/arch.txt"
comm -23 "${WORKDIR}/base.txt" "${WORKDIR}/arch.txt"
done \
| sort -u \
| xargs -d '\n' -r -n1 -- printf '%s/%s\n' "${FTP_BASE}/${repo}/os/${BASEARCH}" \
| sed 's/.*/&\n&.sig/' \
| xargs -d '\n' -r -- ln -srv -t "${WORKDIR}/staging/${repo}" --
done
msg "Running db-update..."
STAGING=${WORKDIR}/staging db-update
}
main "$@"
|