View | Details | Raw Unified | Return to bug 915037
Collapse All | Expand All

(-)dist/osc.complete (-22 / +63 lines)
Lines 43-49 fi Link Here
43
IFS="${IFS}="
43
IFS="${IFS}="
44
cmdline=($COMMAND_LINE)
44
cmdline=($COMMAND_LINE)
45
IFS="$OIFS"
45
IFS="$OIFS"
46
test "${cmdline[0]}" != "osc" && exit 1
46
case "${cmdline[0]}" in
47
iosc|isc|osc) ;;
48
*) exit 1
49
esac
47
50
48
let last=${#COMMAND_LINE}
51
let last=${#COMMAND_LINE}
49
let last--
52
let last--
Lines 80-103 oscprj="" Link Here
80
oscpkg=""
83
oscpkg=""
81
lnkprj=""
84
lnkprj=""
82
lnkpkg=""
85
lnkpkg=""
86
apiurl=""
87
alias=""
83
test -s ${PWD}/.osc/_project && read -t 1 oscprj < ${PWD}/.osc/_project
88
test -s ${PWD}/.osc/_project && read -t 1 oscprj < ${PWD}/.osc/_project
84
test -s ${PWD}/.osc/_package && read -t 1 oscpkg < ${PWD}/.osc/_package
89
test -s ${PWD}/.osc/_package && read -t 1 oscpkg < ${PWD}/.osc/_package
85
if test -s ${PWD}/.osc/_files ; then
90
if test -s ${PWD}/.osc/_files ; then
86
    lnkprj=$(command sed -rn '/<linkinfo/{s@.*[[:blank:]]project="([^"]+)".*@\1@p;}' < ${PWD}/.osc/_files)
91
    lnkprj=$(command sed -rn '/<linkinfo/{s@.*[[:blank:]]project="([^"]+)".*@\1@p;}' < ${PWD}/.osc/_files)
87
    lnkpkg=$(command sed -rn '/<linkinfo/{s@.*[[:blank:]]package="([^"]+)".*@\1@p;}' < ${PWD}/.osc/_files)
92
    lnkpkg=$(command sed -rn '/<linkinfo/{s@.*[[:blank:]]package="([^"]+)".*@\1@p;}' < ${PWD}/.osc/_files)
88
fi
93
fi
94
if test -s ${PWD}/.osc/_apiurl ; then
95
    read apiurl < ${PWD}/.osc/_apiurl
96
    alias=$(sed -rn '\@^\['${apiurl}'@,\@=@{\@^aliases=@{s@[^=]+=([^,]+),.*@\1@p};}' < ~/.oscrc 2> /dev/null)
97
fi
98
if test "${cmdline[0]}" = isc ; then
99
    alias=internal
100
fi
101
102
projects=~/.osc.projects
103
command=osc
104
105
case "${cmdline[1]}" in
106
-A|--apiurl)
107
    if test -n "${cmdline[2]}" -a -s ~/.oscrc ; then
108
	hints=($(sed -rn '/^(aliases=|\[http)/{s/,/ /g;s/(aliases=|\[|\])//gp}' < ~/.oscrc 2> /dev/null))
109
	for h in ${hints[@]} ; do
110
	    case "$h" in
111
	    http*)
112
		tmp=$(sed -rn '\@^\['${h}'@,\@=@{\@^aliases=@{s@[^=]+=([^,]+),.*@\1@p};}' < ~/.oscrc 2> /dev/null)
113
		if test "${cmdline[2]}" = "$h" ; then
114
		    alias=$tmp
115
		    break
116
		fi
117
		;;
118
	    *)
119
		if test "${cmdline[2]}" = "$h" ; then
120
		    alias=$h
121
		    break
122
		fi
123
	    esac
124
	done
125
    fi
126
esac
127
128
if test -n "$alias" ; then
129
    projects="${projects}.${alias}"
130
    command="$command -A $alias"
131
fi
89
132
90
if test -s ~/.osc.projects ; then
133
if test -s "${projects}" ; then
91
    typeset -i ctime=$(command date -d "$(command stat -c '%z' ~/.osc.projects)" +'%s')
134
    typeset -i ctime=$(command date -d "$(command stat -c '%z' ${projects})" +'%s')
92
    typeset -i   now=$(command date -d now +'%s')
135
    typeset -i   now=$(command date -d now +'%s')
93
    if ((now - ctime > 86400)) ; then
136
    if ((now - ctime > 86400)) ; then
94
	if tmp=$(mktemp ~/.osc.projects.XXXXXX) ; then
137
	if tmp=$(mktemp ${projects}.XXXXXX) ; then
95
	    command osc ls / >| $tmp
138
	    command ${command} ls / >| $tmp
96
	    mv -uf $tmp ~/.osc.projects
139
	    mv -uf $tmp ${projects}
97
	fi
140
	fi
98
    fi
141
    fi
99
else
142
else
100
    command osc ls / >| ~/.osc.projects
143
    command ${command} ls / >| "${projects}"
101
fi
144
fi
102
145
103
projects ()
146
projects ()
Lines 116-124 projects () Link Here
116
    shift $argc
159
    shift $argc
117
    cur="$1"
160
    cur="$1"
118
    if test -n "${cur}" ; then
161
    if test -n "${cur}" ; then
119
	list=($(command grep -E "^${cur}" ~/.osc.projects))
162
	list=($(command grep -E "^${cur}" ${projects}))
120
    else
163
    else
121
	list=($(command cat ~/.osc.projects))
164
	list=($(command cat ${projects}))
122
    fi
165
    fi
123
    if ((colon)) ; then
166
    if ((colon)) ; then
124
	local colon_word
167
	local colon_word
Lines 145-153 packages () Link Here
145
    shift $argc
188
    shift $argc
146
    cur="$1"
189
    cur="$1"
147
    if test -n "${cur}" ; then
190
    if test -n "${cur}" ; then
148
	list=($(command osc ls ${argv[@]}|command grep -E "^${cur}"))
191
	list=($(command ${command} ls ${argv[@]}|command grep -E "^${cur}"))
149
    else
192
    else
150
	list=($(command osc ls ${argv[@]}))
193
	list=($(command ${command} ls ${argv[@]}))
151
    fi
194
    fi
152
    builtin compgen -W "${list[*]}" -- "${cur}"
195
    builtin compgen -W "${list[*]}" -- "${cur}"
153
}
196
}
Lines 167-177 repositories () Link Here
167
    done
210
    done
168
    shift $argc
211
    shift $argc
169
    if test -n "$1" ; then
212
    if test -n "$1" ; then
170
	list=($(command osc meta prj ${argv[@]}|\
213
	list=($(command ${command} meta prj ${argv[@]}|\
171
	        command sed -rn '/<repository/{s@^\s*<.*name="([^"]*)".*@\1@p}'|\
214
	        command sed -rn '/<repository/{s@^\s*<.*name="([^"]*)".*@\1@p}'|\
172
		command sort -u|command grep -E "^$1"))
215
		command sort -u|command grep -E "^$1"))
173
    else
216
    else
174
	list=($(command osc meta prj ${argv[@]}|\
217
	list=($(command ${command} meta prj ${argv[@]}|\
175
	        command sed -rn '/<repository/{s@^\s*<.*name="([^"]*)".*@\1@p}'|\
218
	        command sed -rn '/<repository/{s@^\s*<.*name="([^"]*)".*@\1@p}'|\
176
		command sort -u))
219
		command sort -u))
177
    fi
220
    fi
Lines 193-203 architectures () Link Here
193
    done
236
    done
194
    shift $argc
237
    shift $argc
195
    if test -n "$1" ; then
238
    if test -n "$1" ; then
196
	list=($(command osc meta prj ${argv[@]}|\
239
	list=($(command ${command} meta prj ${argv[@]}|\
197
		command sed -rn '/<arch>/{s@^\s*<arch>(.*)</arch>@\1@p}'|\
240
		command sed -rn '/<arch>/{s@^\s*<arch>(.*)</arch>@\1@p}'|\
198
		command sort -u|command grep -E "^$1"))
241
		command sort -u|command grep -E "^$1"))
199
    else
242
    else
200
	list=($(command osc meta prj ${argv[@]}|\
243
	list=($(command ${command} meta prj ${argv[@]}|\
201
		command sed -rn '/<arch>/{s@^\s*<arch>(.*)</arch>@\1@p}'|\
244
		command sed -rn '/<arch>/{s@^\s*<arch>(.*)</arch>@\1@p}'|\
202
		command sort -u))
245
		command sort -u))
203
    fi
246
    fi
Lines 228-235 targets () Link Here
228
271
229
users ()
272
users ()
230
{
273
{
231
    if test -s ~/.osc.projects ; then
274
    if test -s ${projects} ; then
232
	command sed -rn "/^home:$1/{ s/^home:([^:]*):.*/\1/p}" ~/.osc.projects|command sort -u
275
	command sed -rn "/^home:$1/{ s/^home:([^:]*):.*/\1/p}" ${projects}|command sort -u
233
    elif test -s ~/.oscrc; then
276
    elif test -s ~/.oscrc; then
234
	command sed -rn '/^(user=)/{s/(user=)//p}' ~/.oscrc|command sort -u
277
	command sed -rn '/^(user=)/{s/(user=)//p}' ~/.oscrc|command sort -u
235
    else
278
    else
Lines 355-361 add|addremove|ar) Link Here
355
    fi
398
    fi
356
    ;;
399
    ;;
357
build)
400
build)
358
    opts=(--help --oldpackages --disable-cpio-bulk-download --download-api-only --release --baselibs 
401
    opts=(--help --oldpackages --disable-cpio-bulk-download --release --baselibs 
359
	  --disable-debuginfo --debuginfo --alternative-project --vm-type --linksources 
402
	  --disable-debuginfo --debuginfo --alternative-project --vm-type --linksources 
360
	  --local-package --build-uid --userootforbuild --define --without --with 
403
	  --local-package --build-uid --userootforbuild --define --without --with 
361
	  --ccache --icecream --jobs --root --extra-pkgs --keep-pkgs --prefer-pkgs 
404
	  --ccache --icecream --jobs --root --extra-pkgs --keep-pkgs --prefer-pkgs 
Lines 442-450 build) Link Here
442
	done
485
	done
443
    fi 
486
    fi 
444
    if ((count == 2)) ; then
487
    if ((count == 2)) ; then
445
	specs=($(command ls *.spec 2>/dev/null))
488
	specs=($(command ls *.spec))
446
	images=($(command ls *.kiwi 2>/dev/null))
489
	builtin compgen -W "${opts[*]} ${specs[*]}" -- "${cmdline[count]}"
447
	builtin compgen -W "${opts[*]} ${specs[*]} ${images[*]}" -- "${cmdline[count]}"
448
    fi
490
    fi
449
    ;;
491
    ;;
450
branch|getpac|bco|branchco)
492
branch|getpac|bco|branchco)
451
- 

Return to bug 915037