diff options
Diffstat (limited to 'db-sync')
-rwxr-xr-x | db-sync | 42 |
1 files changed, 22 insertions, 20 deletions
@@ -13,7 +13,6 @@ # TODO # * make a tarball of files used for forensics -# * get files db # Run as `V=true db-sync` to get verbose output VERBOSE=${V} @@ -25,7 +24,7 @@ trap "rm -rf -- $(printf '%q' "${WORKDIR}")" EXIT # Returns contents of a repo get_repos() { # Exclude everything but db files - rsync ${extra} -mrtlH --no-p --include="*/" \ + rsync ${extra} --no-motd -mrtlH --no-p --include="*/" \ --include="*.db" \ --include="*${DBEXT}" \ --include="*.files" \ @@ -61,7 +60,7 @@ init() { # Store all the whitelist files whitelists=() - msg "${#blacklist[@]} packages in blacklist" + msg "%d packages in blacklist" ${#blacklist[@]} # Sync the repos databases get_repos @@ -85,11 +84,12 @@ init() { # Remove blacklisted packages and count them # TODO capture all removed packages for printing on debug mode - msg2 "Removing blacklisted packages from .db database..." - LC_ALL=C repo-remove "${db_file}" "${blacklist[@]}" - msg2 "Removing blacklisted packages from .files database..." - LC_ALL=C repo-remove "${files_file}" "${blacklist[@]}" - + msg2 "Removing blacklisted packages from %s database..." .db + LC_ALL=C repo-remove "${db_file}" "${blacklist[@]}" \ + |& 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' # Get db contents db=($(get_repo_content ${db_file})) @@ -98,13 +98,13 @@ 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 - echo ${db[@]} | tr ' ' "\n" | sed "s|$|*|g" > /tmp/${_repo}-${_arch}.whitelist + printf '%s\n' "${db[@]}" | sed "s|$|*|g" > /tmp/${_repo}-${_arch}.whitelist msg2 "$(wc -l /tmp/${_repo}-${_arch}.whitelist | cut -d' ' -f1) packages in whitelist" # Sync excluding everything but whitelist # We delete here for cleanup - rsync ${extra} -rtlH \ + rsync ${extra} --no-motd -rtlH \ --delete-after \ --delete-excluded \ --delay-updates \ @@ -117,7 +117,7 @@ init() { whitelists+=(/tmp/${_repo}-${_arch}.whitelist) msg "Putting databases back in place" - rsync ${extra} -rtlH \ + rsync ${extra} --no-motd -rtlH \ --delay-updates \ --safe-links \ "${WORKDIR}/${_repo}/os/${_arch}/" \ @@ -139,7 +139,7 @@ init() { # *Don't delete-after*, this is the job of cleanup scripts. It will remove our # packages too for PKGPOOL in ${PKGPOOLS[@]}; do - rsync ${extra} -rtlH \ + rsync ${extra} --no-motd -rtlH \ --delay-updates \ --safe-links \ --include-from=/tmp/any.whitelist \ @@ -151,13 +151,13 @@ init() { # Sync sources msg "Syncing source pool" #sed "s|\.pkg\.tar\.|.src.tar.|" /tmp/any.whitelist > /tmp/any-src.whitelist + #msg2 "Retrieving %d sources from pool" $(wc -l < /tmp/any-src.whitelist) - #msg2 "Retrieving $(wc -l /tmp/any-src.whitelist | cut -d' ' -f1) sources from pool" # Sync # *Don't delete-after*, this is the job of cleanup scripts. It will remove our # packages too for SRCPOOL in ${SRCPOOLS[@]}; do - rsync ${extra} -rtlH \ + rsync ${extra} --no-motd -rtlH \ --delay-updates \ --safe-links \ --include-from=/tmp/any.whitelist \ @@ -171,21 +171,23 @@ init() { } trap_exit() { + local signal=$1; shift echo error "$@" - exit 1 + trap -- "$signal" + kill "-$signal" "$$" } - source "$(dirname "$(readlink -e "$0")")/config" source "$(dirname "$(readlink -e "$0")")/local_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 +for signal in TERM HUP QUIT; do + 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 init |