summaryrefslogtreecommitdiff
path: root/toru-path
diff options
context:
space:
mode:
authorNicolás Reynolds <fauno@kiwwwi.com.ar>2012-10-20 16:04:17 -0300
committerNicolás Reynolds <fauno@kiwwwi.com.ar>2012-10-20 16:04:17 -0300
commit12377d79078170ec47c1fa5fb56b12ecb13367e8 (patch)
treec09c6db12782575b31c15c7df883ecf34add9a67 /toru-path
parentb4c8f17a6d97b63589b624d726e10d64cbd743ec (diff)
Use TokyoCabinet to store the PKGBUILD path cache
Diffstat (limited to 'toru-path')
-rwxr-xr-xtoru-path23
1 files changed, 13 insertions, 10 deletions
diff --git a/toru-path b/toru-path
index 9bfc3ff..7f1d599 100755
--- a/toru-path
+++ b/toru-path
@@ -2,22 +2,30 @@
source $(dirname $(command -v $0))/toru-utils
+TORUPATH=${T:-${TORUPATH}}
+
if [ ! -w "$TORUPATH" ]; then
error "Toru's path isn't writable. Please check $TORUPATH"
exit 1
fi
LASTSYNCFILE=${TORUPATH}/lastsync.paths
+PATHFILE=${TORUPATH}/paths.tch
+
+if [ ! -e "${PATHFILE}" ]; then
+ tcamgr create "${PATHFILE}"
+fi
# TODO pass other paths via flags
-pkgbuilds=($(get_pkgbuilds ${ABSROOT}))
-paths=()
+# ABSROOT has trailing slash
+fullrepos=($(for _repo in ${REPOS[@]}; do echo "${ABSROOT}${_repo}"; done))
+pkgbuilds=($(get_pkgbuilds ${fullrepos[@]}))
msg "Updating path cache"
msg2 "${#pkgbuilds[@]} PKGBUILDs to update"
for _pkgbuild in ${pkgbuilds[@]}; do
- $DEBUG && plain "$_pkgbuild"
- source ${_pkgbuild} || {
+# plain "$_pkgbuild"
+ source ${_pkgbuild} >/dev/null 2>&1 || {
error "${_pkgbuild} contains errors, skipping"
continue
}
@@ -25,15 +33,10 @@ for _pkgbuild in ${pkgbuilds[@]}; do
fullpath=$(dirname ${_pkgbuild})
for _pkg in ${pkgbase} ${pkgname[@]} ${provides[@]}; do
- paths+=(${_pkg/[<>=]*}:${fullpath})
+ tcamgr put ${PATHFILE} ${_pkg/[<>=]*} ${fullpath}
done
unset pkgbase pkgname provides
done
-
-# TODO remove old paths
-# by joining new paths to old paths and exclude the joining points from the
-# cache (sort of a sql join)
-echo ${paths[@]} | tr ' ' "\n" | sort >> ${TORUPATH}/paths
lastsync ${LASTSYNCFILE}