diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-06-15 23:00:32 -0400 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-06-15 23:00:32 -0400 |
commit | fbfcdfb31cd1a14d2356c1e0a42191c35ad33055 (patch) | |
tree | d7cb8f797b31ce5d516f9a9c7a01a3d42eaf0a9b /db-sync | |
parent | c76ecd8ae9425f0717f30cdac8e47485c887bcb6 (diff) | |
parent | d902025a8a000c1383c7612e9f442c6734290169 (diff) |
Merge branch 'master' into lukeshu/archlinux+xbs+merge-parabola
Conflicts:
config
libremessages
Diffstat (limited to 'db-sync')
-rwxr-xr-x | db-sync | 42 |
1 files changed, 30 insertions, 12 deletions
@@ -62,6 +62,8 @@ init() { msg "%d packages in blacklist" ${#blacklist[@]} + test ${#blacklist[@]} -eq 0 && fatal_error "Empty blacklist" + # Sync the repos databases get_repos @@ -86,10 +88,10 @@ init() { # TODO capture all removed packages for printing on debug mode msg2 "Removing blacklisted packages from %s database..." .db LC_ALL=C repo-remove "${db_file}" "${blacklist[@]}" \ - |& sed -n 's/-> Removing/ &/p' + |& sed -n 's/-> Removing/ &/p' msg2 "Removing blacklisted packages from %s database..." .files LC_ALL=C repo-remove "${files_file}" "${blacklist[@]}" \ - |& sed -n 's/-> Removing/ &/p' + |& sed -n 's/-> Removing/ &/p' # Get db contents db=($(get_repo_content ${db_file})) @@ -98,7 +100,10 @@ init() { # Create a whitelist, add * wildcard to end # TODO due to lack of -arch suffix, the pool sync retrieves every arch even if # we aren't syncing them - printf '%s\n' "${db[@]}" | sed "s|$|*|g" > /tmp/${_repo}-${_arch}.whitelist + # IMPORTANT: the . in the sed command is needed because an empty + # whitelist would consist of a single * allowing any package to + # pass through + printf '%s\n' "${db[@]}" | sed "s|.$|&*|g" > /tmp/${_repo}-${_arch}.whitelist msg2 "$(wc -l /tmp/${_repo}-${_arch}.whitelist | cut -d' ' -f1) packages in whitelist" @@ -130,22 +135,23 @@ init() { msg "Syncing package pool" - # Concatenate all whitelists - cat ${whitelists[@]} | sort -u > /tmp/any.whitelist + # Concatenate all whitelists, check for single *s just in case + cat ${whitelists[@]} | grep -v "^\*$" | sort -u > /tmp/any.whitelist msg2 "Retrieving $(wc -l /tmp/any.whitelist | cut -d' ' -f1) packages from pool" # Sync # *Don't delete-after*, this is the job of cleanup scripts. It will remove our # packages too - for PKGPOOL in ${PKGPOOLS[@]}; do + local pkgpool + for pkgpool in ${ARCHPKGPOOLS[@]}; do rsync ${extra} --no-motd -rtlH \ --delay-updates \ --safe-links \ --include-from=/tmp/any.whitelist \ --exclude="*" \ - rsync://${mirror}/${mirrorpath}/${PKGPOOL}/ \ - ${FTP_BASE}/${PKGPOOL}/ + rsync://${mirror}/${mirrorpath}/${pkgpool}/ \ + ${FTP_BASE}/${pkgpool}/ done # Sync sources @@ -156,20 +162,27 @@ init() { # Sync # *Don't delete-after*, this is the job of cleanup scripts. It will remove our # packages too - for SRCPOOL in ${SRCPOOLS[@]}; do + local srcpool + for srcpool in ${ARCHSRCPOOLS[@]}; do rsync ${extra} --no-motd -rtlH \ --delay-updates \ --safe-links \ --include-from=/tmp/any.whitelist \ --exclude="*" \ - rsync://${mirror}/${mirrorpath}/${SRCPOOL}/ \ - ${FTP_BASE}/${SRCPOOL}/ + rsync://${mirror}/${mirrorpath}/${srcpool}/ \ + ${FTP_BASE}/${srcpool}/ done # Cleanup unset blacklist whitelists _arch _repo repo_file } +fatal_error() { + local mesg=$1; shift + error "$mesg" "$@" + exit 1 +} + trap_exit() { local signal=$1; shift echo @@ -182,10 +195,15 @@ source "$(dirname "$(readlink -e "$0")")/config" source "$(dirname "$(readlink -e "$0")")/local_config" source "$(dirname "$(readlink -e "$0")")/libremessages" +# Check variables presence +for var in DBEXT FILESEXT mirror mirrorpath WORKDIR BLACKLIST_FILE FTP_BASE ARCHSRCPOOLS ARCHPKGPOOLS; do + test -z "${!var}" && fatal_error "Empty ${var}" +done + # From makepkg set -E for signal in TERM HUP QUIT; do - trap "trap_exit $signal '%s signal caught. Exiting...' $signal" $signal + trap "trap_exit $signal '%s signal caught. Exiting...' $signal" $signal done trap 'trap_exit INT "Aborted by user! Exiting..."' INT trap 'trap_exit USR1 "An unknown error has occurred. Exiting..."' ERR |