From 69acc962f6277cf591125ba111716a7c5723e70e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Sun, 25 Dec 2011 22:17:46 -0600 Subject: toru: -p flag for showing the path of some pkgname --- fullpkg | 21 ++----------------- toru | 72 ++++++++++++++++++++++++++++++++++++----------------------------- 2 files changed, 42 insertions(+), 51 deletions(-) diff --git a/fullpkg b/fullpkg index eddf3d5..bd2e8ae 100755 --- a/fullpkg +++ b/fullpkg @@ -40,23 +40,6 @@ usage() { } -# Finds a PKGBUILD on toru's path cache -# Look in all caches but pick the first one -# TODO move to a toru flag (-p?) -where_is() { - local _repo - local _path - for _repo in ${REPOS[@]}; do - _path=$(grep "^${1}:" "${TORUPATH}/${_repo}.paths.cache" 2>/dev/null| \ - cut -d: -f2 2>/dev/null) - - [ -n "${_path}" ] && break - done - - echo ${_path} - -} - # Removes a package from the buildorder # $1 package name # $2 buildorder file @@ -148,9 +131,9 @@ find_deps() { for _dep in ${deps[@]}; do local found=false - local pkgdir=$(where_is ${_dep}) + local pkgdir=$(toru -p ${_dep}) - if [ -d "${pkgdir}" ]; then + if [ -n "$pkgdir" -a -d "${pkgdir}" ]; then found=true pushd "${pkgdir}" > /dev/null 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.1-4-g5e80