summaryrefslogtreecommitdiff
path: root/toru
diff options
context:
space:
mode:
Diffstat (limited to 'toru')
-rwxr-xr-xtoru56
1 files changed, 46 insertions, 10 deletions
diff --git a/toru b/toru
index 55e4119..9616119 100755
--- a/toru
+++ b/toru
@@ -79,7 +79,7 @@ split_pkgname_from_pkgver() {
sed "s/^\(.\+\)-\([^-]\+-[^-]\+\)$/\1 \2/" $1
}
-# Get the fullpkgver
+# Get the fullpkgver
# pkgname from pkgver separator can be either '-' or ' '
extract_fullpkgver() {
echo "$@" | tr " " "\n" | sed "s/^.\+[ -]\([^-]\+-[^-]\+\)$/\1/"
@@ -248,23 +248,61 @@ missing() {
true
}
+## Finds a PKGBUILD on toru's path cache
+## usage: where_is <pkgname>
+# Look in all caches but pick the first one
+where_is() {
+ local _repo
+ local _path
+ for _repo in ${REPOS[@]}; do
+ _path=$(grep "^${1}:" "${TORUPATH}/${_repo}.paths.cache" 2>/dev/null |
+ cut -d: -f2)
+ [ -n "${_path}" ] && break
+ done
+
+ [ -z "$_path" ] && return 1
+
+ echo ${_path}
+}
+
+# TODO: clean usage instructions
+function usage {
+ echo ""
+ echo "$0 [options] repo1 ... repon"
+ echo ""
+ echo "Make a db containing PKGBUILD metadata."
+ echo ""
+ echo "-h : this message"
+# echo "-a : update all repos at once"
+ echo "-u : update repo information"
+ echo "-q : quiet"
+ echo "-f : rebuild the db even if it is updated"
+ echo "-p <pkgname>: return the path for pkgname"
+ echo ""
+ exit 1
+}
## MAIN
commands=()
repos=()
quiet=false
force=false
-while getopts 'hqfum' arg; do
+while getopts 'haqfpum' arg; do
case $arg in
- h) usage; exit 0 ;;
- q) quiet=true ;;
- f) force=true ;;
- u) commands+=(update);;
- m) commands+=(missing);;
+ h) usage; exit 0 ;;
+# TODO: Update all repos on $REPOS array
+# a) update_all_repos ;;
+ q) quiet=true ;;
+ f) force=true ;;
+ u) commands+=(update);;
+ p) shift $(( OPTIND - 1 ))
+ where_is "$1"
+ exit $?;;
+ m) commands+=(missing);;
esac
- shift $((OPTIND-1))
+ shift $(( OPTIND - 1 ))
done
@@ -274,6 +312,4 @@ TMPDIR=$(mktemp -d)
${commands[0]} ${@}
-#rm -rf ${TMPDIR}
-
exit $?