summaryrefslogtreecommitdiff
path: root/get-repos
blob: 4397d542a3392cf7f165505d3684cd4e726d3e8e (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
# Gets repo databases and updates parabolaweb
# Note: It works remotely because our parabolaweb server and repo server are
# two different hosts

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

TMPDIR="$(mktemp -d /tmp/$(basename $0).XXXX)"
DBLIST=()

# Repos
for _repo in ${PKGREPOS[@]}; do
    for _arch in ${ARCHES[@]}; do
        DBLIST+=("http://repo.parabolagnulinux.org/${_repo}/os/${_arch}/${_repo}${DBEXT}")
    done
done

# Remote repos
# TODO don't hardcode the remote architecture
# TODO don't hardcode the remote url
# MAYBE run scripts on get-repos.d/ which should return db urls
for _repo in ${RMTREPOS}; do
    _arch=i586
    DBLIST+=("http://www.connochaetos.org/os/${_arch}/${_repo}/${_repo}${DBEXT}")
done

# Get them all
msg "Retrieving ${#DBLIST[@]} databases"
wget --directory-prefix=${TMPDIR} \
     --no-verbose \
     --force-directories \
     --no-host-directories \
     ${DBLIST[@]} || true 
# Always return true, some databases are expect to be missing

# Create the arches regexp arch1|arch2
arch_re="$(echo "(${ARCHES[@]} i586)" | tr ' ' '|')"

msg "Adding to parabolaweb"
find "${TMPDIR}" -iname "*${DBEXT}" | while read _db; do
    _arch=$(echo "${_db}" | egrep -o "${arch_re}")

    if [ -z "${_arch}" ]; then
        error "Can't find database architecture: ${_db}"
        continue
    fi

    "${WEB_DIR}"/manage.py reporead "${_arch}" "${_db}" || true
done

rm -r ${TMPDIR}

exit $?