mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-24 22:06:14 +01:00
Allow osc to be called as isc and iosc
Signed-off-by: Werner Fink <werner@suse.de>
This commit is contained in:
parent
9f76dc0777
commit
e2699d9fc3
84
dist/osc.complete
vendored
Normal file → Executable file
84
dist/osc.complete
vendored
Normal file → Executable file
@ -43,7 +43,10 @@ fi
|
||||
IFS="${IFS}="
|
||||
cmdline=($COMMAND_LINE)
|
||||
IFS="$OIFS"
|
||||
test "${cmdline[0]}" != "osc" && exit 1
|
||||
case "${cmdline[0]}" in
|
||||
iosc|isc|osc) ;;
|
||||
*) exit 1
|
||||
esac
|
||||
|
||||
let last=${#COMMAND_LINE}
|
||||
let last--
|
||||
@ -80,24 +83,64 @@ oscprj=""
|
||||
oscpkg=""
|
||||
lnkprj=""
|
||||
lnkpkg=""
|
||||
apiurl=""
|
||||
alias=""
|
||||
test -s ${PWD}/.osc/_project && read -t 1 oscprj < ${PWD}/.osc/_project
|
||||
test -s ${PWD}/.osc/_package && read -t 1 oscpkg < ${PWD}/.osc/_package
|
||||
if test -s ${PWD}/.osc/_files ; then
|
||||
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)
|
||||
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
|
||||
typeset -i ctime=$(command date -d "$(command stat -c '%z' ~/.osc.projects)" +'%s')
|
||||
projects=~/.osc.projects
|
||||
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')
|
||||
if ((now - ctime > 86400)) ; then
|
||||
if tmp=$(mktemp ~/.osc.projects.XXXXXX) ; then
|
||||
command osc ls / >| $tmp
|
||||
mv -uf $tmp ~/.osc.projects
|
||||
if tmp=$(mktemp ${projects}.XXXXXX) ; then
|
||||
command ${command} ls / >| $tmp
|
||||
mv -uf $tmp ${projects}
|
||||
fi
|
||||
fi
|
||||
else
|
||||
command osc ls / >| ~/.osc.projects
|
||||
command ${command} ls / >| "${projects}"
|
||||
fi
|
||||
|
||||
projects ()
|
||||
@ -116,9 +159,9 @@ projects ()
|
||||
shift $argc
|
||||
cur="$1"
|
||||
if test -n "${cur}" ; then
|
||||
list=($(command grep -E "^${cur}" ~/.osc.projects))
|
||||
list=($(command grep -E "^${cur}" ${projects}))
|
||||
else
|
||||
list=($(command cat ~/.osc.projects))
|
||||
list=($(command cat ${projects}))
|
||||
fi
|
||||
if ((colon)) ; then
|
||||
local colon_word
|
||||
@ -145,9 +188,9 @@ packages ()
|
||||
shift $argc
|
||||
cur="$1"
|
||||
if test -n "${cur}" ; then
|
||||
list=($(command osc ls ${argv[@]}|command grep -E "^${cur}"))
|
||||
list=($(command ${command} ls ${argv[@]}|command grep -E "^${cur}"))
|
||||
else
|
||||
list=($(command osc ls ${argv[@]}))
|
||||
list=($(command ${command} ls ${argv[@]}))
|
||||
fi
|
||||
builtin compgen -W "${list[*]}" -- "${cur}"
|
||||
}
|
||||
@ -167,11 +210,11 @@ repositories ()
|
||||
done
|
||||
shift $argc
|
||||
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 sort -u|command grep -E "^$1"))
|
||||
else
|
||||
list=($(command osc meta prj ${argv[@]}|\
|
||||
list=($(command ${command} meta prj ${argv[@]}|\
|
||||
command sed -rn '/<repository/{s@^\s*<.*name="([^"]*)".*@\1@p}'|\
|
||||
command sort -u))
|
||||
fi
|
||||
@ -193,11 +236,11 @@ architectures ()
|
||||
done
|
||||
shift $argc
|
||||
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 sort -u|command grep -E "^$1"))
|
||||
else
|
||||
list=($(command osc meta prj ${argv[@]}|\
|
||||
list=($(command ${command} meta prj ${argv[@]}|\
|
||||
command sed -rn '/<arch>/{s@^\s*<arch>(.*)</arch>@\1@p}'|\
|
||||
command sort -u))
|
||||
fi
|
||||
@ -228,8 +271,8 @@ targets ()
|
||||
|
||||
users ()
|
||||
{
|
||||
if test -s ~/.osc.projects ; then
|
||||
command sed -rn "/^home:$1/{ s/^home:([^:]*):.*/\1/p}" ~/.osc.projects|command sort -u
|
||||
if test -s ${projects} ; then
|
||||
command sed -rn "/^home:$1/{ s/^home:([^:]*):.*/\1/p}" ${projects}|command sort -u
|
||||
elif test -s ~/.oscrc; then
|
||||
command sed -rn '/^(user=)/{s/(user=)//p}' ~/.oscrc|command sort -u
|
||||
else
|
||||
@ -355,7 +398,7 @@ add|addremove|ar)
|
||||
fi
|
||||
;;
|
||||
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
|
||||
--local-package --build-uid --userootforbuild --define --without --with
|
||||
--ccache --icecream --jobs --root --extra-pkgs --keep-pkgs --prefer-pkgs
|
||||
@ -442,9 +485,8 @@ build)
|
||||
done
|
||||
fi
|
||||
if ((count == 2)) ; then
|
||||
specs=($(command ls *.spec 2>/dev/null))
|
||||
images=($(command ls *.kiwi 2>/dev/null))
|
||||
builtin compgen -W "${opts[*]} ${specs[*]} ${images[*]}" -- "${cmdline[count]}"
|
||||
specs=($(command ls *.spec))
|
||||
builtin compgen -W "${opts[*]} ${specs[*]}" -- "${cmdline[count]}"
|
||||
fi
|
||||
;;
|
||||
branch|getpac|bco|branchco)
|
||||
|
Loading…
Reference in New Issue
Block a user