diff options
Diffstat (limited to 'src/toru')
-rwxr-xr-x | src/toru/toru-path | 71 |
1 files changed, 27 insertions, 44 deletions
diff --git a/src/toru/toru-path b/src/toru/toru-path index 888a5e4..4600a5c 100755 --- a/src/toru/toru-path +++ b/src/toru/toru-path @@ -3,6 +3,7 @@ # Copyright (C) 2011-2012 Nicolás Reynolds <fauno@parabola.nu> # Copyright (C) 2012 Michał Masłowski <mtjm@mtjm.eu> # Copyright (C) 2012 Joshua Ismael Haase Hernández (xihh) <hahj87@gmail.com> +# Copyright (C) 2014 Luke Shumaker <lukeshu@sbcglobal.net> # # License: GNU GPLv3+ # @@ -20,48 +21,18 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. . libremessages -. "$(librelib conf.sh)" -load_files libretools -check_vars libretools TORUPATH REPOS || exit 1 -load_files abs -check_vars abs ABSROOT || exit 1 - setup_traps +# TODO: better option parsing TORUPATH=${T:-${TORUPATH}} VERBOSE=${V:-false} -FORCE=false - -# Stores the lastsync date -lastsync() { - local lastsyncfile="$1" - - if [[ -e "${lastsyncfile}" -a ! -w "${lastsyncfile}" ]]; then - error "The sync date can't be saved: file not writable: %q" "${lastsyncfile}" - return 1 - fi - - date +%s > "${lastsyncfile}" - touch "${lastsyncfile}" -} - -# repo paths -get_pkgbuilds() { - local lastsyncfile="$1"; shift - # Only find newer than lastsyncfile and read - # everything else from cache - local extra=(-newer "${lastsyncfile}") +FORCE=${F:-false} - if [[ $FORCE = true || ! -e ${lastsyncfile} ]]; then - - ${VERBOSE} && warning "Forcing upgrade" - # Get all PKGBUILDs - extra=() - fi - - # Return all PKGBUILDs found - find "$@" -mindepth 2 -maxdepth 3 -type f -name 'PKGBUILD' "${extra[@]}" -} +. "$(librelib conf.sh)" +load_files libretools +check_vars libretools TORUPATH REPOS || exit 1 +load_files abs +check_vars abs ABSROOT || exit 1 if [ ! -w "$TORUPATH" ]; then error "Toru's path isn't writable. Please check $TORUPATH" @@ -75,23 +46,35 @@ if [ ! -e "${pathfile}" ]; then tcamgr create "${pathfile}" fi -# TODO pass other paths via flags -# ABSROOT has trailing slash +# TODO: ability to use flags to pass in other directories to fullrepos + +# This loops over ${REPOS[@]} backward. This is because early entries +# in REPOS have higher precidence, but the way this is implemented, +# the later entries have precedence, so we need to flip the order. fullrepos=() -# This loop is complicated because it goes over REPOS backward for (( i = ${#REPOS[@]}-1 ; i >= 0 ; i-- )); do - ${VERBOSE} && msg "Processing [%s]" "${REPOS[$i]}" + $VERBOSE && msg "Processing [%s]" "${REPOS[$i]}" + # ABSROOT has trailing slash if [ -d "${ABSROOT}${REPOS[$i]}" ]; then fullrepos+=("${ABSROOT}${REPOS[$i]}") fi done + +# Find PKGBUILDs in ${fullrepos[@]} +find_args=("${fullrepos[@]}" -mindepth 2 -maxdepth 3 -type f -name PKGBUILD) +if ! $FORCE && [[ -e $lastsyncfile ]]; then + # if lastfilesync exists, only look at things that have + # changed since then (unless $FORCE is on) + find_args+=(-newer "${lastsyncfile}") +fi IFS=$'\n' -pkgbuilds=($(get_pkgbuilds "${lastsyncfile}" "${fullrepos[@]}")) +pkgbuilds=($(find "${find_args[@]}")) +# Add information from each of the PKGBUILDs to the toru cache. msg "Updating path cache" msg2 "%d PKGBUILDs to update" ${#pkgbuilds[@]} -for _pkgbuild in "${pkgbuilds[@]}"; do +for pkgbuild in "${pkgbuilds[@]}"; do # plain "$_pkgbuild" if ! load_PKGBUILD "${_pkgbuild}" >/dev/null 2>&1; then error "%q contains errors, skipping" "${_pkgbuild}" @@ -106,4 +89,4 @@ for _pkgbuild in "${pkgbuilds[@]}"; do done done -lastsync "${lastsyncfile}" +date +%s > "${lastsyncfile}" |