1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 06:46:15 +01:00

Allow osc to be called as isc and iosc

Signed-off-by: Werner Fink <werner@suse.de>
This commit is contained in:
Werner Fink 2015-05-05 13:47:08 +02:00 committed by Bernhard M. Wiedemann
parent 9f76dc0777
commit e2699d9fc3

84
dist/osc.complete vendored Normal file → Executable file
View File

@ -43,7 +43,10 @@ fi
IFS="${IFS}=" IFS="${IFS}="
cmdline=($COMMAND_LINE) cmdline=($COMMAND_LINE)
IFS="$OIFS" IFS="$OIFS"
test "${cmdline[0]}" != "osc" && exit 1 case "${cmdline[0]}" in
iosc|isc|osc) ;;
*) exit 1
esac
let last=${#COMMAND_LINE} let last=${#COMMAND_LINE}
let last-- let last--
@ -80,24 +83,64 @@ oscprj=""
oscpkg="" oscpkg=""
lnkprj="" lnkprj=""
lnkpkg="" lnkpkg=""
apiurl=""
alias=""
test -s ${PWD}/.osc/_project && read -t 1 oscprj < ${PWD}/.osc/_project test -s ${PWD}/.osc/_project && read -t 1 oscprj < ${PWD}/.osc/_project
test -s ${PWD}/.osc/_package && read -t 1 oscpkg < ${PWD}/.osc/_package test -s ${PWD}/.osc/_package && read -t 1 oscpkg < ${PWD}/.osc/_package
if test -s ${PWD}/.osc/_files ; then if test -s ${PWD}/.osc/_files ; then
lnkprj=$(command sed -rn '/<linkinfo/{s@.*[[:blank:]]project="([^"]+)".*@\1@p;}' < ${PWD}/.osc/_files) lnkprj=$(command sed -rn '/<linkinfo/{s@.*[[:blank:]]project="([^"]+)".*@\1@p;}' < ${PWD}/.osc/_files)
lnkpkg=$(command sed -rn '/<linkinfo/{s@.*[[:blank:]]package="([^"]+)".*@\1@p;}' < ${PWD}/.osc/_files) lnkpkg=$(command sed -rn '/<linkinfo/{s@.*[[:blank:]]package="([^"]+)".*@\1@p;}' < ${PWD}/.osc/_files)
fi fi
if test -s ${PWD}/.osc/_apiurl ; then
read apiurl < ${PWD}/.osc/_apiurl
alias=$(sed -rn '\@^\['${apiurl}'@,\@=@{\@^aliases=@{s@[^=]+=([^,]+),.*@\1@p};}' < ~/.oscrc 2> /dev/null)
fi
if test "${cmdline[0]}" = isc ; then
alias=internal
fi
if test -s ~/.osc.projects ; then projects=~/.osc.projects
typeset -i ctime=$(command date -d "$(command stat -c '%z' ~/.osc.projects)" +'%s') command=osc
case "${cmdline[1]}" in
-A|--apiurl)
if test -n "${cmdline[2]}" -a -s ~/.oscrc ; then
hints=($(sed -rn '/^(aliases=|\[http)/{s/,/ /g;s/(aliases=|\[|\])//gp}' < ~/.oscrc 2> /dev/null))
for h in ${hints[@]} ; do
case "$h" in
http*)
tmp=$(sed -rn '\@^\['${h}'@,\@=@{\@^aliases=@{s@[^=]+=([^,]+),.*@\1@p};}' < ~/.oscrc 2> /dev/null)
if test "${cmdline[2]}" = "$h" ; then
alias=$tmp
break
fi
;;
*)
if test "${cmdline[2]}" = "$h" ; then
alias=$h
break
fi
esac
done
fi
esac
if test -n "$alias" ; then
projects="${projects}.${alias}"
command="$command -A $alias"
fi
if test -s "${projects}" ; then
typeset -i ctime=$(command date -d "$(command stat -c '%z' ${projects})" +'%s')
typeset -i now=$(command date -d now +'%s') typeset -i now=$(command date -d now +'%s')
if ((now - ctime > 86400)) ; then if ((now - ctime > 86400)) ; then
if tmp=$(mktemp ~/.osc.projects.XXXXXX) ; then if tmp=$(mktemp ${projects}.XXXXXX) ; then
command osc ls / >| $tmp command ${command} ls / >| $tmp
mv -uf $tmp ~/.osc.projects mv -uf $tmp ${projects}
fi fi
fi fi
else else
command osc ls / >| ~/.osc.projects command ${command} ls / >| "${projects}"
fi fi
projects () projects ()
@ -116,9 +159,9 @@ projects ()
shift $argc shift $argc
cur="$1" cur="$1"
if test -n "${cur}" ; then if test -n "${cur}" ; then
list=($(command grep -E "^${cur}" ~/.osc.projects)) list=($(command grep -E "^${cur}" ${projects}))
else else
list=($(command cat ~/.osc.projects)) list=($(command cat ${projects}))
fi fi
if ((colon)) ; then if ((colon)) ; then
local colon_word local colon_word
@ -145,9 +188,9 @@ packages ()
shift $argc shift $argc
cur="$1" cur="$1"
if test -n "${cur}" ; then if test -n "${cur}" ; then
list=($(command osc ls ${argv[@]}|command grep -E "^${cur}")) list=($(command ${command} ls ${argv[@]}|command grep -E "^${cur}"))
else else
list=($(command osc ls ${argv[@]})) list=($(command ${command} ls ${argv[@]}))
fi fi
builtin compgen -W "${list[*]}" -- "${cur}" builtin compgen -W "${list[*]}" -- "${cur}"
} }
@ -167,11 +210,11 @@ repositories ()
done done
shift $argc shift $argc
if test -n "$1" ; then if test -n "$1" ; then
list=($(command osc meta prj ${argv[@]}|\ list=($(command ${command} meta prj ${argv[@]}|\
command sed -rn '/<repository/{s@^\s*<.*name="([^"]*)".*@\1@p}'|\ command sed -rn '/<repository/{s@^\s*<.*name="([^"]*)".*@\1@p}'|\
command sort -u|command grep -E "^$1")) command sort -u|command grep -E "^$1"))
else else
list=($(command osc meta prj ${argv[@]}|\ list=($(command ${command} meta prj ${argv[@]}|\
command sed -rn '/<repository/{s@^\s*<.*name="([^"]*)".*@\1@p}'|\ command sed -rn '/<repository/{s@^\s*<.*name="([^"]*)".*@\1@p}'|\
command sort -u)) command sort -u))
fi fi
@ -193,11 +236,11 @@ architectures ()
done done
shift $argc shift $argc
if test -n "$1" ; then if test -n "$1" ; then
list=($(command osc meta prj ${argv[@]}|\ list=($(command ${command} meta prj ${argv[@]}|\
command sed -rn '/<arch>/{s@^\s*<arch>(.*)</arch>@\1@p}'|\ command sed -rn '/<arch>/{s@^\s*<arch>(.*)</arch>@\1@p}'|\
command sort -u|command grep -E "^$1")) command sort -u|command grep -E "^$1"))
else else
list=($(command osc meta prj ${argv[@]}|\ list=($(command ${command} meta prj ${argv[@]}|\
command sed -rn '/<arch>/{s@^\s*<arch>(.*)</arch>@\1@p}'|\ command sed -rn '/<arch>/{s@^\s*<arch>(.*)</arch>@\1@p}'|\
command sort -u)) command sort -u))
fi fi
@ -228,8 +271,8 @@ targets ()
users () users ()
{ {
if test -s ~/.osc.projects ; then if test -s ${projects} ; then
command sed -rn "/^home:$1/{ s/^home:([^:]*):.*/\1/p}" ~/.osc.projects|command sort -u command sed -rn "/^home:$1/{ s/^home:([^:]*):.*/\1/p}" ${projects}|command sort -u
elif test -s ~/.oscrc; then elif test -s ~/.oscrc; then
command sed -rn '/^(user=)/{s/(user=)//p}' ~/.oscrc|command sort -u command sed -rn '/^(user=)/{s/(user=)//p}' ~/.oscrc|command sort -u
else else
@ -355,7 +398,7 @@ add|addremove|ar)
fi fi
;; ;;
build) build)
opts=(--help --oldpackages --disable-cpio-bulk-download --download-api-only --release --baselibs opts=(--help --oldpackages --disable-cpio-bulk-download --release --baselibs
--disable-debuginfo --debuginfo --alternative-project --vm-type --linksources --disable-debuginfo --debuginfo --alternative-project --vm-type --linksources
--local-package --build-uid --userootforbuild --define --without --with --local-package --build-uid --userootforbuild --define --without --with
--ccache --icecream --jobs --root --extra-pkgs --keep-pkgs --prefer-pkgs --ccache --icecream --jobs --root --extra-pkgs --keep-pkgs --prefer-pkgs
@ -442,9 +485,8 @@ build)
done done
fi fi
if ((count == 2)) ; then if ((count == 2)) ; then
specs=($(command ls *.spec 2>/dev/null)) specs=($(command ls *.spec))
images=($(command ls *.kiwi 2>/dev/null)) builtin compgen -W "${opts[*]} ${specs[*]}" -- "${cmdline[count]}"
builtin compgen -W "${opts[*]} ${specs[*]} ${images[*]}" -- "${cmdline[count]}"
fi fi
;; ;;
branch|getpac|bco|branchco) branch|getpac|bco|branchco)