#!/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 # # 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 "$@"