summaryrefslogtreecommitdiff
path: root/toru-path
blob: 9bfc3ff2513609493bbea9b47f396fe5d77dc7a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash

source $(dirname $(command -v $0))/toru-utils

if [ ! -w "$TORUPATH" ]; then
 error "Toru's path isn't writable. Please check $TORUPATH"
 exit 1
fi

LASTSYNCFILE=${TORUPATH}/lastsync.paths

# TODO pass other paths via flags
pkgbuilds=($(get_pkgbuilds ${ABSROOT}))
paths=()

msg "Updating path cache"
msg2 "${#pkgbuilds[@]} PKGBUILDs to update"
for _pkgbuild in ${pkgbuilds[@]}; do
  $DEBUG && plain "$_pkgbuild"
  source ${_pkgbuild} || {
    error "${_pkgbuild} contains errors, skipping"
    continue
  }

  fullpath=$(dirname ${_pkgbuild})

  for _pkg in ${pkgbase} ${pkgname[@]} ${provides[@]}; do
    paths+=(${_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}