summaryrefslogtreecommitdiff
path: root/toru
diff options
context:
space:
mode:
authorNicolas Reynolds <fauno@kiwwwi.com.ar>2011-08-17 12:13:58 -0300
committerNicolas Reynolds <fauno@kiwwwi.com.ar>2011-08-17 12:13:58 -0300
commitd220266566780795b2cad867253ac75b99c59604 (patch)
tree6d8904c714d75761637b0f958e12d6b6e6477594 /toru
parent7dfa60c89fe293ca4004bac15be0e1ffffc9dc7d (diff)
Toru stores PKGBUILD paths. Fullpkg consults toru path cache to know where to
find them. Removed package path guessing altogether Usage: (on abs root) toru -u [repo] Do that for every repo, then you can use fullpkg safely
Diffstat (limited to 'toru')
-rwxr-xr-xtoru56
1 files changed, 33 insertions, 23 deletions
diff --git a/toru b/toru
index a9f0be7..d622510 100755
--- a/toru
+++ b/toru
@@ -21,15 +21,18 @@ if [ ! -w "$TORUPATH" ]; then
fi
# TODO move to common functions
-function in_array { # usage : in_array( $needle, $haystack )
-
- [[ $2 ]] || return 1 # Not found
- local needle=$1; shift
- local item
- for item in "$@"; do
- [[ ${item#@} = $needle ]] && return 0 # Found
- done
- return 1 # Not Found
+# usage : in_array( $needle, $haystack )
+function in_array {
+ [[ $2 ]] || return 1 # Not found
+
+ local needle=$1; shift
+ local item
+
+ for item in "$@"; do
+ [[ ${item#@} = $needle ]] && return 0 # Found
+ done
+
+ return 1 # Not Found
}
# Stores the lastsync date
@@ -146,21 +149,32 @@ update() {
# Check if the repo is set as such, otherwise skip
is_repo ${_repo} || continue
+# Fullpath of the repo
+ _repopath=$(readlink -f ${_repo})
+
# This is the syncfile, stores the last date as content and mtime
local lastsyncfile=${TORUPATH}/${_repo}.lastsync
# Find all the PKGBUILDs newer than the last update
# Update newer, otherwise everything
if [[ $force = true || ! -e ${lastsyncfile} ]]; then
+
$quiet || warning "Forcing upgrade"
- pkgbuilds=($(find ${_repo} -maxdepth 2 -type f -name 'PKGBUILD'))
+# Get all PKGBUILDs
+ pkgbuilds=($(find ${_repopath} -maxdepth 2 -type f -name 'PKGBUILD'))
+
else
- pkgbuilds=($(find ${_repo} -maxdepth 2 -type f -name 'PKGBUILD' -newer ${lastsyncfile}))
+
+# Only find newer than lastsyncfile and read everything else from cache
+ pkgbuilds=($(find ${_repopath} -maxdepth 2 -type f -name 'PKGBUILD' -newer ${lastsyncfile}))
packages_in_abs=($(read_cache ${_repo}))
- package_paths=($(read_cache paths))
+
$quiet || msg2 "Getting ${#packages_in_abs[@]} packages from cache"
+
fi
+ package_paths=($(read_cache ${_repo}.paths))
+
# Inform how many PKGBUILDS were found and quit immediately if none
$quiet || msg "Found $((${#pkgbuilds[*]}-1)) PKGBUILDs to update"
@@ -169,13 +183,13 @@ update() {
# Update the sync file because there are pkgbuilds to update
update_sync_file=true
-# Guess pkgbase from PKGBUILD's basedir
- _pkgpath=$(dirname "${_pkgbuild}")
- _pkgbase=$(basename "${_pkgpath}")
-
# Load PKGBUILD's metadata
source ${_pkgbuild}
+# Guess pkgbase from PKGBUILD's basedir
+ _pkgpath=$(dirname "${_pkgbuild}")
+ _pkgbase=${pkgbase:-${pkgname[0]}}
+
# We won't need this (all unsets are for memory efficiency)
unset build package url md5sums install pkgdesc backup options
# TODO fill a license list
@@ -199,9 +213,9 @@ update() {
# Sync! (Only if there was an actual sync)
${update_sync_file} && lastsync ${lastsyncfile}
- if [ "${lastsyncfile}" -nt "${TORUPATH}/paths.cache" ]; then
+ if [ "${lastsyncfile}" -nt "${TORUPATH}/${_repo}.paths.cache" ]; then
print_package_array "${package_paths[@]}" > $TMPDIR/paths
- store_cache paths $TMPDIR/paths
+ store_cache ${_repo}.paths $TMPDIR/paths
fi
# If there isn't an update cache or it's older than the last update, we check
@@ -256,7 +270,7 @@ update() {
store_cache ${_repo}.updates ${TMPDIR}/updates
else
- msg "Reading updates from cache..."
+ $quiet || msg "Reading updates from cache..."
read_cache ${_repo}.updates
fi
@@ -292,10 +306,6 @@ TMPDIR=$(mktemp -d)
[[ -z ${TMPDIR} ]] && exit 1
-# TODO this is all for debugging
-msg2 "force: $force quiet: $quiet repos: $@ commands: ${commands[@]}"
-msg2 "read lastsync: $([ -e $lastsyncfile ])"
-
${commands[0]} ${@}
#rm -rf ${TMPDIR}