summaryrefslogtreecommitdiff
path: root/get-repos
diff options
context:
space:
mode:
authorNicolás Reynolds <fauno@kiwwwi.com.ar>2012-01-09 15:34:13 -0300
committerNicolás Reynolds <fauno@kiwwwi.com.ar>2012-01-09 15:34:13 -0300
commit47b0e5207b933e5563324c92c8a1841322cde6e9 (patch)
treeca481632f00c43df99e4be3a7c4e74a142df2c3c /get-repos
parenta3e0b61d4d14f01442b98deaa18f66ceb3c4b3b9 (diff)
Use config ARCHES and REPOS to get-repos
Diffstat (limited to 'get-repos')
-rwxr-xr-xget-repos71
1 files changed, 52 insertions, 19 deletions
diff --git a/get-repos b/get-repos
index 824ab15..9ff701c 100755
--- a/get-repos
+++ b/get-repos
@@ -1,33 +1,66 @@
#!/bin/bash
-# TODO needs refactoring
+# Gets repo databases and updates parabolaweb
+# Note: It works remotely because our parabolaweb server and repo server are
+# two different hosts
-PDIR="/srv/http/web"
-DIR="/srv/http/web/repos"
+trap_exit() {
+ echo
+ error "$@"
+ exit 1
+}
-for arch in i686 x86_64 mips64el; do
- for repo in community extra core testing libre libre-testing social; do
- [[ ! -d $DIR/$arch ]] && mkdir -p $DIR/$arch
+source $(dirname $0)/config
+source $(dirname $0)/local_config
+source $(dirname $0)/libremessages
- cd $DIR/$arch
+# From makepkg
+set -E
- rm -f *.db.tar.gz
+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
- wget http://repo.parabolagnulinux.org/$repo/os/$arch/$repo.db.tar.gz && \
- $PDIR/manage.py reporead $arch $DIR/$arch/$repo.db.tar.gz
+TMPDIR="$(mktemp -d /tmp/$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
-for repo in connos connos-extra; do
- arch=i586
- [[ ! -d $DIR/$arch ]] && mkdir -p $DIR/$arch
+# 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
- cd $DIR/$arch
+# 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
- rm -f *.db.tar.gz
+# Create the arches regexp arch1|arch2
+arch_re="$(echo "(${ARCHES[@]} i586)" | tr ' ' '|')"
- wget http://www.connochaetos.org/os/$arch/$repo/$repo.db.tar.gz && \
- $PDIR/manage.py reporead $arch $DIR/$arch/$repo.db.tar.gz
-done
+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}"
+done
-exit 0
+exit $?