summaryrefslogtreecommitdiff
path: root/toru
diff options
context:
space:
mode:
authorJoshua Ismael Haase Hernández <hahj87@gmail.com>2011-12-25 22:17:46 -0600
committerJoshua Ismael Haase Hernández <hahj87@gmail.com>2011-12-25 22:17:46 -0600
commit69acc962f6277cf591125ba111716a7c5723e70e (patch)
tree7411eee79826b88d2e0dc181278bcea3fece6723 /toru
parentcc746eb378b3d24a38e6f6b58890061fd2a995dd (diff)
toru: -p flag for showing the path of some pkgname
Diffstat (limited to 'toru')
-rwxr-xr-xtoru72
1 files changed, 40 insertions, 32 deletions
diff --git a/toru b/toru
index b71fb8c..a054ddf 100755
--- a/toru
+++ b/toru
@@ -15,34 +15,11 @@
source /etc/abs.conf
source /etc/libretools.conf
-# TODO: clean usage instructions
-function usage {
- echo "$0 [options] repo1 ... repon"
- echo
- echo "-h : this message"
- exit 1
-}
-
if [ ! -w "$TORUPATH" ]; then
error "Toru's path isn't writable. Please check $TORUPATH"
exit 1
fi
-# TODO move to common functions
-# 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
lastsync() {
local lastsyncfile
@@ -290,23 +267,56 @@ 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
+ echo ${_path}
+}
+
+# TODO: clean usage instructions
+function usage {
+ 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"
+ 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 ;;
+# a) update_all_repos ;;
+ q) quiet=true ;;
+ f) force=true ;;
+ u) commands+=(update);;
+ p) shift $(( OPTIND - 1 ))
+ where_is "$1"
+ exit 0;;
+ m) commands+=(missing);;
esac
- shift $((OPTIND-1))
+ shift $(( OPTIND - 1 ))
done
@@ -316,6 +326,4 @@ TMPDIR=$(mktemp -d)
${commands[0]} ${@}
-#rm -rf ${TMPDIR}
-
exit $?