summaryrefslogtreecommitdiff
path: root/any-to-ours
blob: 8c37622ee5ae7112fa853ef83c67426a5a382cf2 (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
#!/bin/bash
# Releases 'any' packages from Arch arches to ours

trap_exit() {
    echo
    error "$@"
    exit 1
}

source $(dirname $0)/config
source $(dirname $0)/local_config
source $(dirname $0)/libremessages

# From makepkg
set -E

trap 'trap_exit "$(gettext "TERM signal caught. Exiting...")"' TERM HUP QUIT
trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT
trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR

# The architecture to compare with
BASEARCH='x86_64'

# Traverse all Arch repos
for _repo in ${ARCHREPOS[@]}; do
    msg "Processing ${_repo}..."

# Find 'any' packages
# This is hardcoded but it could release other arches...
    PKGS=($(find "${FTP_BASE}/${_repo}/os/${BASEARCH}/" \
                 -iname '*-any.pkg.tar.?z' \
                 -printf "%f "))

    if [ ${#PKGS[@]} -eq 0 ]; then
        msg2 "No 'any' packages here"
        continue
    fi

    for _arch in ${OURARCHES[@]}; do
        msg2 "Syncing ${_arch}..."

# Sync 'any' only and extract the synced packages
        SYNCED=($(
        rsync -av \
              --include='*-any.pkg.tar.?z' \
              --exclude='*' \
              ${FTP_BASE}/${_repo}/os/${BASEARCH}/ \
              ${FTP_BASE}/${_repo}/os/${_arch}/ 2>&1 | \
            grep 'any.pkg.tar' | \
            cut -d ' ' -f 1 ))

        msg2 "Synced ${#SYNCED[@]} packages"

        msg2 "Adding to db..."

        pushd ${FTP_BASE}/${_repo}/os/${_arch}/ >/dev/null 

# Add the packages to the db
        $(dirname $0)/repo-add ${_repo}${DBEXT} \
                               ${SYNCED[@]}

        popd >/dev/null 

# Avoid mixups
        unset SYNCED PKGS
    done
done