From 69acc962f6277cf591125ba111716a7c5723e70e Mon Sep 17 00:00:00 2001 From: Joshua Ismael Haase Hernández Date: Sun, 25 Dec 2011 22:17:46 -0600 Subject: toru: -p flag for showing the path of some pkgname --- toru | 72 ++++++++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 40 insertions(+), 32 deletions(-) (limited to 'toru') 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 +# 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 : 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 $? -- cgit v1.2.3-54-g00ecf