summaryrefslogtreecommitdiff
path: root/toru-path
diff options
context:
space:
mode:
Diffstat (limited to 'toru-path')
-rwxr-xr-xtoru-path34
1 files changed, 24 insertions, 10 deletions
diff --git a/toru-path b/toru-path
index 5065a30..957f49b 100755
--- a/toru-path
+++ b/toru-path
@@ -2,17 +2,35 @@
source $(dirname $(command -v $0))/toru-utils
+TORUPATH=${T:-${TORUPATH}}
+VERBOSE=${V:-false}
+
+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 (( i = ${#REPOS[@]}-1 ; i >= 0 ; i-- )); do
+ ${VERBOSE} && msg "Processing [%s]" ${REPOS[$i]}
+ fullrepos+=("${ABSROOT}${REPOS[$i]}")
+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
}
@@ -20,15 +38,11 @@ for _pkgbuild in ${pkgbuilds[@]}; do
fullpath=$(dirname ${_pkgbuild})
for _pkg in ${pkgbase} ${pkgname[@]} ${provides[@]}; do
- paths+=(${_pkg/[<>=]*}:${fullpath})
+ $VERBOSE && msg2 "${_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}