summaryrefslogtreecommitdiff
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
parenta3e0b61d4d14f01442b98deaa18f66ceb3c4b3b9 (diff)
Use config ARCHES and REPOS to get-repos
-rw-r--r--config5
-rwxr-xr-xget-repos71
-rwxr-xr-xget_repos33
3 files changed, 57 insertions, 52 deletions
diff --git a/config b/config
index 949d171..1304e01 100644
--- a/config
+++ b/config
@@ -11,6 +11,8 @@ OURREPOS=('libre' 'libre-testing')
USERREPOS=('~fauno' '~smv' '~xihh' '~mtjm' '~brendan' '~lukeshu')
# Community project repos
PROJREPOS=('social' 'elementary' 'kernels' 'radio' 'security' 'sugar' 'gnu')
+# Remote repos
+RMTREPOS=('connos' 'connos-extra')
PKGREPOS=(${ARCHREPOS[@]} ${OURREPOS[@]} ${USERREPOS[@]} ${PROJREPOS[@]})
PKGPOOL='pool/packages'
SRCPOOL='sources/packages'
@@ -48,3 +50,6 @@ SRCEXT=".src.tar.gz"
MAKEPKGCONF="~/.makepkg.conf"
BLACKLIST_FILE="$HOME/blacklist/blacklist.txt"
+
+# parabolaweb root
+WEB_DIR=/srv/http/web
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 $?
diff --git a/get_repos b/get_repos
deleted file mode 100755
index 824ab15..0000000
--- a/get_repos
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-# TODO needs refactoring
-
-PDIR="/srv/http/web"
-DIR="/srv/http/web/repos"
-
-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
-
- cd $DIR/$arch
-
- rm -f *.db.tar.gz
-
- wget http://repo.parabolagnulinux.org/$repo/os/$arch/$repo.db.tar.gz && \
- $PDIR/manage.py reporead $arch $DIR/$arch/$repo.db.tar.gz
- done
-done
-
-for repo in connos connos-extra; do
- arch=i586
- [[ ! -d $DIR/$arch ]] && mkdir -p $DIR/$arch
-
- cd $DIR/$arch
-
- rm -f *.db.tar.gz
-
- wget http://www.connochaetos.org/os/$arch/$repo/$repo.db.tar.gz && \
- $PDIR/manage.py reporead $arch $DIR/$arch/$repo.db.tar.gz
-done
-
-
-exit 0