#!/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 "$(readlink -e "$0")")/config" source "$(dirname "$(readlink -e "$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 -dt "${0##*/}.XXXX")" DBLIST=() # Repos for _repo in "${PKGREPOS[@]}"; do for _arch in "${ARCHES[@]}"; do DBLIST+=("http://repo.parabolagnulinux.org/${_repo}/os/${_arch}/${_repo}${FILESEXT}") done 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 "*${FILESEXT}" | 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 $?