mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-12 08:56:13 +01:00
code cleanup
This commit is contained in:
parent
ce0c2a5ad2
commit
661d927d38
332
dist/osc.complete
vendored
332
dist/osc.complete
vendored
@ -63,320 +63,320 @@ submit ()
|
|||||||
local target
|
local target
|
||||||
|
|
||||||
if ((pos == 1)) ; then
|
if ((pos == 1)) ; then
|
||||||
if test -z "${cmdline[$((2+off))]}" -a -n "${oscprj}" ; then
|
if test -z "${cmdline[$((2+off))]}" -a -n "${oscprj}" ; then
|
||||||
builtin compgen -W "${oscprj}"
|
builtin compgen -W "${oscprj}"
|
||||||
else
|
else
|
||||||
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[$((2+off))]}"
|
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[$((2+off))]}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if ((pos == 2)) ; then
|
if ((pos == 2)) ; then
|
||||||
if test -z "${cmdline[$((3+off))]}" -a -n "${oscpkg}" ; then
|
if test -z "${cmdline[$((3+off))]}" -a -n "${oscpkg}" ; then
|
||||||
builtin compgen -W "${oscpkg}"
|
builtin compgen -W "${oscpkg}"
|
||||||
else
|
else
|
||||||
builtin compgen -W "$(command osc ls "${cmdline[$((2+off))]}")" -- "${cmdline[$((3+off))]}"
|
builtin compgen -W "$(command osc ls "${cmdline[$((2+off))]}")" -- "${cmdline[$((3+off))]}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if ((pos == 3)) ; then
|
if ((pos == 3)) ; then
|
||||||
if test -z "${cmdline[$((4+off))]}" -a -n "${lnkprj}" ; then
|
if test -z "${cmdline[$((4+off))]}" -a -n "${lnkprj}" ; then
|
||||||
builtin compgen -W "${lnkprj}"
|
builtin compgen -W "${lnkprj}"
|
||||||
else
|
else
|
||||||
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[$((4+off))]}"
|
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[$((4+off))]}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if ((pos == 4)) ; then
|
if ((pos == 4)) ; then
|
||||||
target="${lnkpkg}"
|
target="${lnkpkg}"
|
||||||
target="${target:+$target }$oscpkg"
|
target="${target:+$target }$oscpkg"
|
||||||
if test -n "${target}" ; then
|
if test -n "${target}" ; then
|
||||||
builtin compgen -W "${target}" -- "${cmdline[$((5+off))]}"
|
builtin compgen -W "${target}" -- "${cmdline[$((5+off))]}"
|
||||||
else
|
else
|
||||||
builtin compgen -W "$(command osc ls "${cmdline[$((4+off))]}")" -- "${cmdline[$((5+off))]}"
|
builtin compgen -W "$(command osc ls "${cmdline[$((4+off))]}")" -- "${cmdline[$((5+off))]}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
case "${cmdline[1]}" in
|
case "${cmdline[1]}" in
|
||||||
add|addremove|ar)
|
add|addremove|ar)
|
||||||
if ((count == 1)) ; then
|
if ((count == 1)) ; then
|
||||||
builtin compgen -W 'add addremove ar' -- "${cmdline[1]}"
|
builtin compgen -W 'add addremove ar' -- "${cmdline[1]}"
|
||||||
else
|
else
|
||||||
for x in $(builtin compgen -f -X '.osc' -- "${cmdline[2]}"); do
|
for x in $(builtin compgen -f -X '.osc' -- "${cmdline[2]}"); do
|
||||||
test -d $x && builtin echo $x/ || builtin echo $x
|
test -d $x && builtin echo $x/ || builtin echo $x
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
branch)
|
branch)
|
||||||
if ((count == 1)) ; then
|
if ((count == 1)) ; then
|
||||||
builtin compgen -W 'branch' -- "${cmdline[1]}"
|
builtin compgen -W 'branch' -- "${cmdline[1]}"
|
||||||
fi
|
fi
|
||||||
case "${cmdline[2]}" in
|
case "${cmdline[2]}" in
|
||||||
--nodevelproject)
|
--nodevelproject)
|
||||||
if ((count == 3)) ; then
|
if ((count == 3)) ; then
|
||||||
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[3]}"
|
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[3]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 4)) ; then
|
if ((count == 4)) ; then
|
||||||
builtin compgen -W "$(command osc ls "${cmdline[3]}")" -- "${cmdline[4]}"
|
builtin compgen -W "$(command osc ls "${cmdline[3]}")" -- "${cmdline[4]}"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
-*) builtin compgen -W '--nodevelproject' -- "${cmdline[3]}" ;;
|
-*) builtin compgen -W '--nodevelproject' -- "${cmdline[3]}" ;;
|
||||||
*)
|
*)
|
||||||
if ((count == 2)) ; then
|
if ((count == 2)) ; then
|
||||||
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 3)) ; then
|
if ((count == 3)) ; then
|
||||||
builtin compgen -W "$(command osc ls "${cmdline[2]}")" -- "${cmdline[3]}"
|
builtin compgen -W "$(command osc ls "${cmdline[2]}")" -- "${cmdline[3]}"
|
||||||
fi
|
fi
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
list|ls)
|
list|ls)
|
||||||
if ((count == 1)) ; then
|
if ((count == 1)) ; then
|
||||||
builtin compgen -W 'list ls' -- "${cmdline[1]}"
|
builtin compgen -W 'list ls' -- "${cmdline[1]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 2)) ; then
|
if ((count == 2)) ; then
|
||||||
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 3)) ; then
|
if ((count == 3)) ; then
|
||||||
builtin compgen -W "$(command osc ls "${cmdline[2]}")" -- "${cmdline[3]}"
|
builtin compgen -W "$(command osc ls "${cmdline[2]}")" -- "${cmdline[3]}"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
sr|submitreq|submitrequest)
|
sr|submitreq|submitrequest)
|
||||||
if ((count == 1)) ; then
|
if ((count == 1)) ; then
|
||||||
builtin compgen -W 'sr submitreq submitrequest' -- "${cmdline[1]}"
|
builtin compgen -W 'sr submitreq submitrequest' -- "${cmdline[1]}"
|
||||||
fi
|
fi
|
||||||
case "${cmdline[2]}" in
|
case "${cmdline[2]}" in
|
||||||
--nodevelproject)
|
--nodevelproject)
|
||||||
submit $((count - 2)) 1 ;;
|
submit $((count - 2)) 1 ;;
|
||||||
-*) builtin compgen -W '--nodevelproject' -- "${cmdline[2]}" ;;
|
-*) builtin compgen -W '--nodevelproject' -- "${cmdline[2]}" ;;
|
||||||
*) submit $((count - 1)) 0 ;;
|
*) submit $((count - 1)) 0 ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
rq|request)
|
rq|request)
|
||||||
if ((count == 1)) ; then
|
if ((count == 1)) ; then
|
||||||
builtin compgen -W 'rq request' -- "${cmdline[1]}"
|
builtin compgen -W 'rq request' -- "${cmdline[1]}"
|
||||||
fi
|
fi
|
||||||
case "${cmdline[2]}" in
|
case "${cmdline[2]}" in
|
||||||
accept|decline|wipe|revoke|log)
|
accept|decline|wipe|revoke|log)
|
||||||
if ((count == 3)) ; then
|
if ((count == 3)) ; then
|
||||||
builtin echo -n 'ID'
|
builtin echo -n 'ID'
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
show)
|
show)
|
||||||
if ((count == 3)) ; then
|
if ((count == 3)) ; then
|
||||||
builtin compgen -W '--diff' -- "${cmdline[3]}"
|
builtin compgen -W '--diff' -- "${cmdline[3]}"
|
||||||
else
|
else
|
||||||
builtin echo -n 'ID'
|
builtin echo -n 'ID'
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
list)
|
list)
|
||||||
if ((count == 3)) ; then
|
if ((count == 3)) ; then
|
||||||
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[3]}"
|
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[3]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 4)) ; then
|
if ((count == 4)) ; then
|
||||||
builtin compgen -W "$(command osc ls "${cmdline[3]}")" -- "${cmdline[4]}"
|
builtin compgen -W "$(command osc ls "${cmdline[3]}")" -- "${cmdline[4]}"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
((count == 2)) && builtin compgen -W "$(builtin echo ${oscreq[@]})" -- "${cmdline[2]}"
|
((count == 2)) && builtin compgen -W "$(builtin echo ${oscreq[@]})" -- "${cmdline[2]}"
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
copypac|linkpac)
|
copypac|linkpac)
|
||||||
if ((count == 1)) ; then
|
if ((count == 1)) ; then
|
||||||
builtin compgen -W 'copypac linkpac' -- "${cmdline[1]}"
|
builtin compgen -W 'copypac linkpac' -- "${cmdline[1]}"
|
||||||
fi
|
fi
|
||||||
case "${cmdline[2]}" in
|
case "${cmdline[2]}" in
|
||||||
*)
|
*)
|
||||||
if ((count == 2)) ; then
|
if ((count == 2)) ; then
|
||||||
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 3)) ; then
|
if ((count == 3)) ; then
|
||||||
builtin compgen -W "$(osc ls "${cmdline[2]}")" -- "${cmdline[3]}"
|
builtin compgen -W "$(osc ls "${cmdline[2]}")" -- "${cmdline[3]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 4)) ; then
|
if ((count == 4)) ; then
|
||||||
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[4]}"
|
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[4]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 5)) ; then
|
if ((count == 5)) ; then
|
||||||
builtin compgen -W "$(command osc ls "${cmdline[4]}")" -- "${cmdline[5]}"
|
builtin compgen -W "$(command osc ls "${cmdline[4]}")" -- "${cmdline[5]}"
|
||||||
fi
|
fi
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
deleterequest|deletereq|dr)
|
deleterequest|deletereq|dr)
|
||||||
if ((count == 1)) ; then
|
if ((count == 1)) ; then
|
||||||
builtin compgen -W 'deleterequest deletereq dr' -- "${cmdline[1]}"
|
builtin compgen -W 'deleterequest deletereq dr' -- "${cmdline[1]}"
|
||||||
fi
|
fi
|
||||||
case "${cmdline[2]}" in
|
case "${cmdline[2]}" in
|
||||||
*)
|
*)
|
||||||
if ((count == 2)) ; then
|
if ((count == 2)) ; then
|
||||||
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 3)) ; then
|
if ((count == 3)) ; then
|
||||||
builtin compgen -W "$(osc ls "${cmdline[2]}")" -- "${cmdline[3]}"
|
builtin compgen -W "$(osc ls "${cmdline[2]}")" -- "${cmdline[3]}"
|
||||||
fi
|
fi
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
changedevelrequest|changedevelreq|cr)
|
changedevelrequest|changedevelreq|cr)
|
||||||
if ((count == 1)) ; then
|
if ((count == 1)) ; then
|
||||||
builtin compgen -W 'changedevelrequest changedevelreq cr' -- "${cmdline[1]}"
|
builtin compgen -W 'changedevelrequest changedevelreq cr' -- "${cmdline[1]}"
|
||||||
fi
|
fi
|
||||||
case "${cmdline[2]}" in
|
case "${cmdline[2]}" in
|
||||||
*)
|
*)
|
||||||
if ((count == 2)) ; then
|
if ((count == 2)) ; then
|
||||||
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 3)) ; then
|
if ((count == 3)) ; then
|
||||||
builtin compgen -W "$(osc ls "${cmdline[2]}")" -- "${cmdline[3]}"
|
builtin compgen -W "$(osc ls "${cmdline[2]}")" -- "${cmdline[3]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 4)) ; then
|
if ((count == 4)) ; then
|
||||||
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[4]}"
|
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[4]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 5)) ; then
|
if ((count == 5)) ; then
|
||||||
builtin compgen -W "$(command osc ls "${cmdline[4]}")" -- "${cmdline[5]}"
|
builtin compgen -W "$(command osc ls "${cmdline[4]}")" -- "${cmdline[5]}"
|
||||||
fi
|
fi
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
rdiff)
|
rdiff)
|
||||||
if ((count == 1)) ; then
|
if ((count == 1)) ; then
|
||||||
builtin compgen -W 'rdiff' -- "${cmdline[1]}"
|
builtin compgen -W 'rdiff' -- "${cmdline[1]}"
|
||||||
fi
|
fi
|
||||||
case "${cmdline[2]}" in
|
case "${cmdline[2]}" in
|
||||||
*)
|
*)
|
||||||
if ((count == 2)) ; then
|
if ((count == 2)) ; then
|
||||||
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 3)) ; then
|
if ((count == 3)) ; then
|
||||||
builtin compgen -W "$(osc ls "${cmdline[2]}")" -- "${cmdline[3]}"
|
builtin compgen -W "$(osc ls "${cmdline[2]}")" -- "${cmdline[3]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 4)) ; then
|
if ((count == 4)) ; then
|
||||||
builtin compgen -W "$(command cat ~/.osc.projects)" -P --oldprj= -- "${cmdline[4]#*=}"
|
builtin compgen -W "$(command cat ~/.osc.projects)" -P --oldprj= -- "${cmdline[4]#*=}"
|
||||||
fi
|
fi
|
||||||
if ((count == 5)) ; then
|
if ((count == 5)) ; then
|
||||||
builtin compgen -W "$(command osc ls "${cmdline[4]#*=}")" -P --oldpkg= -- "${cmdline[5]#*=}"
|
builtin compgen -W "$(command osc ls "${cmdline[4]#*=}")" -P --oldpkg= -- "${cmdline[5]#*=}"
|
||||||
fi
|
fi
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
ci|commit|checkin)
|
ci|commit|checkin)
|
||||||
if ((count == 1)) ; then
|
if ((count == 1)) ; then
|
||||||
builtin compgen -W 'ci commit checkin' -- "${cmdline[1]}"
|
builtin compgen -W 'ci commit checkin' -- "${cmdline[1]}"
|
||||||
else
|
else
|
||||||
for x in $(builtin compgen -f -X '.osc' -- "${cmdline[2]}"); do
|
for x in $(builtin compgen -f -X '.osc' -- "${cmdline[2]}"); do
|
||||||
test -d $x && builtin echo $x/ || builtin echo $x
|
test -d $x && builtin echo $x/ || builtin echo $x
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
co|checkout)
|
co|checkout)
|
||||||
if ((count == 1)) ; then
|
if ((count == 1)) ; then
|
||||||
builtin compgen -W 'co copypac checkout' -- "${cmdline[1]}"
|
builtin compgen -W 'co copypac checkout' -- "${cmdline[1]}"
|
||||||
else
|
else
|
||||||
if ((count == 2)) ; then
|
if ((count == 2)) ; then
|
||||||
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 3)) ; then
|
if ((count == 3)) ; then
|
||||||
builtin compgen -W "$(command osc ls "${cmdline[2]}")" -- "${cmdline[3]}"
|
builtin compgen -W "$(command osc ls "${cmdline[2]}")" -- "${cmdline[3]}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
maintainer)
|
maintainer)
|
||||||
if ((count == 1)) ; then
|
if ((count == 1)) ; then
|
||||||
builtin compgen -W 'maintainer' -- "${cmdline[1]}"
|
builtin compgen -W 'maintainer' -- "${cmdline[1]}"
|
||||||
else
|
else
|
||||||
if ((count == 2)) ; then
|
if ((count == 2)) ; then
|
||||||
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 3)) ; then
|
if ((count == 3)) ; then
|
||||||
builtin compgen -W "$(command osc ls "${cmdline[2]}")" -- "${cmdline[3]}"
|
builtin compgen -W "$(command osc ls "${cmdline[2]}")" -- "${cmdline[3]}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
up|update)
|
up|update)
|
||||||
if ((count == 1)) ; then
|
if ((count == 1)) ; then
|
||||||
builtin compgen -W 'up update' -- "${cmdline[1]}"
|
builtin compgen -W 'up update' -- "${cmdline[1]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 2)) ; then
|
if ((count == 2)) ; then
|
||||||
builtin compgen -W '--expand-link --unexpand-link' -- "${cmdline[2]}"
|
builtin compgen -W '--expand-link --unexpand-link' -- "${cmdline[2]}"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
meta)
|
meta)
|
||||||
if ((count == 1)) ; then
|
if ((count == 1)) ; then
|
||||||
builtin compgen -W 'meta metafromspec' -- "${cmdline[1]}"
|
builtin compgen -W 'meta metafromspec' -- "${cmdline[1]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 2)) ; then
|
if ((count == 2)) ; then
|
||||||
builtin compgen -W 'prj pkg' -- "${cmdline[2]}"
|
builtin compgen -W 'prj pkg' -- "${cmdline[2]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 3)) ; then
|
if ((count == 3)) ; then
|
||||||
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[3]}"
|
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[3]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 4)) && test "${cmdline[2]}" = pkg ; then
|
if ((count == 4)) && test "${cmdline[2]}" = pkg ; then
|
||||||
builtin compgen -W "$(command osc ls "${cmdline[3]}")" -- "${cmdline[4]}"
|
builtin compgen -W "$(command osc ls "${cmdline[3]}")" -- "${cmdline[4]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 5)) ; then
|
if ((count == 5)) ; then
|
||||||
builtin compgen -W '--edit -e' -- "${cmdline[5]}"
|
builtin compgen -W '--edit -e' -- "${cmdline[5]}"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
wipebinaries)
|
wipebinaries)
|
||||||
if ((count == 1)) ; then
|
if ((count == 1)) ; then
|
||||||
builtin compgen -W 'wipebinaries' -- "${cmdline[1]}"
|
builtin compgen -W 'wipebinaries' -- "${cmdline[1]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 2)) ; then
|
if ((count == 2)) ; then
|
||||||
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 3)) ; then
|
if ((count == 3)) ; then
|
||||||
builtin compgen -W "$(command osc ls "${cmdline[2]}")" -- "${cmdline[3]}"
|
builtin compgen -W "$(command osc ls "${cmdline[2]}")" -- "${cmdline[3]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 4)) ; then
|
if ((count == 4)) ; then
|
||||||
builtin compgen -W "--expansion --broken --build-failed --build-disabled" -- "${cmdline[4]}"
|
builtin compgen -W "--expansion --broken --build-failed --build-disabled" -- "${cmdline[4]}"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
help)
|
help)
|
||||||
if ((count == 1)) ; then
|
if ((count == 1)) ; then
|
||||||
builtin compgen -W 'help' -- "${cmdline[1]}"
|
builtin compgen -W 'help' -- "${cmdline[1]}"
|
||||||
fi
|
fi
|
||||||
((count == 2)) && builtin compgen -W "$(builtin echo ${osccmds[@]})" -- "${cmdline[2]}"
|
((count == 2)) && builtin compgen -W "$(builtin echo ${osccmds[@]})" -- "${cmdline[2]}"
|
||||||
;;
|
;;
|
||||||
search)
|
search)
|
||||||
if ((count == 1)) ; then
|
if ((count == 1)) ; then
|
||||||
builtin compgen -W 'search' -- "${cmdline[1]}"
|
builtin compgen -W 'search' -- "${cmdline[1]}"
|
||||||
else
|
else
|
||||||
oscsearch="--help --csv -i --involved -v --verbose --description --title \
|
oscsearch="--help --csv -i --involved -v --verbose --description --title \
|
||||||
--project --package -e --exact --repos-baseurl"
|
--project --package -e --exact --repos-baseurl"
|
||||||
builtin compgen -W "${oscsearch}" -- "${cmdline[$count]}"
|
builtin compgen -W "${oscsearch}" -- "${cmdline[$count]}"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
pr|prjresults)
|
pr|prjresults)
|
||||||
if ((count == 1)) ; then
|
if ((count == 1)) ; then
|
||||||
builtin compgen -W 'pr prjresults' -- "${cmdline[1]}"
|
builtin compgen -W 'pr prjresults' -- "${cmdline[1]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 2)) ; then
|
if ((count == 2)) ; then
|
||||||
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
||||||
fi
|
fi
|
||||||
if ((count > 2)) ; then
|
if ((count > 2)) ; then
|
||||||
case "${cmdline[$((count-1))]}" in
|
case "${cmdline[$((count-1))]}" in
|
||||||
-n|--name-filter*)
|
-n|--name-filter*)
|
||||||
builtin compgen -W "$(command osc ls "${cmdline[2]}")" -- "${cmdline[$count]}"
|
builtin compgen -W "$(command osc ls "${cmdline[2]}")" -- "${cmdline[$count]}"
|
||||||
;;
|
;;
|
||||||
-s|--status-filter*)
|
-s|--status-filter*)
|
||||||
OIFS="$IFS"; IFS=:
|
OIFS="$IFS"; IFS=:
|
||||||
builtin compgen -W 'disabled:failed:finished:building:succeeded:broken:scheduled:expansion error:blocked' -- "${cmdline[$count]}"
|
builtin compgen -W 'disabled:failed:finished:building:succeeded:broken:scheduled:expansion error:blocked' -- "${cmdline[$count]}"
|
||||||
IFS="$OIFS"
|
IFS="$OIFS"
|
||||||
;;
|
;;
|
||||||
-p|--project*)
|
-p|--project*)
|
||||||
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[$count]}"
|
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[$count]}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
builtin compgen -W "-n --name-filter -s --status-filter -c --csv -q --hide-legend" -- "${cmdline[$count]}"
|
builtin compgen -W "-n --name-filter -s --status-filter -c --csv -q --hide-legend" -- "${cmdline[$count]}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
r|results)
|
r|results)
|
||||||
if ((count == 1)) ; then
|
if ((count == 1)) ; then
|
||||||
builtin compgen -W 'r results' -- "${cmdline[1]}"
|
builtin compgen -W 'r results' -- "${cmdline[1]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 2)) ; then
|
if ((count == 2)) ; then
|
||||||
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
builtin compgen -W "$(command cat ~/.osc.projects)" -- "${cmdline[2]}"
|
||||||
fi
|
fi
|
||||||
if ((count == 3)) ; then
|
if ((count == 3)) ; then
|
||||||
builtin compgen -W "$(command osc ls "${cmdline[2]}")" -- "${cmdline[3]}"
|
builtin compgen -W "$(command osc ls "${cmdline[2]}")" -- "${cmdline[3]}"
|
||||||
fi
|
fi
|
||||||
if ((count > 3)) ; then
|
if ((count > 3)) ; then
|
||||||
builtin compgen -W "-r --repo -a --arch -l --last-build --xml" -- "${cmdline[$count]}"
|
builtin compgen -W "-r --repo -a --arch -l --last-build --xml" -- "${cmdline[$count]}"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
14
mktar.py
14
mktar.py
@ -9,21 +9,21 @@ from osc import core
|
|||||||
release = False
|
release = False
|
||||||
v = core.__version__
|
v = core.__version__
|
||||||
if (len(sys.argv) > 1 and sys.argv[1] == '-r'):
|
if (len(sys.argv) > 1 and sys.argv[1] == '-r'):
|
||||||
release = True
|
release = True
|
||||||
|
|
||||||
if release:
|
if release:
|
||||||
if (v.endswith('_SVN')):
|
if (v.endswith('_SVN')):
|
||||||
v=v[:-4]
|
v=v[:-4]
|
||||||
print "don't forget to increase version in osc/core.py after release"
|
print "don't forget to increase version in osc/core.py after release"
|
||||||
else:
|
else:
|
||||||
v += subprocess.Popen(["svnversion", "."], stdout=subprocess.PIPE).stdout.read().strip()
|
v += subprocess.Popen(["svnversion", "."], stdout=subprocess.PIPE).stdout.read().strip()
|
||||||
|
|
||||||
d = "osc-" + v
|
d = "osc-" + v
|
||||||
f = d+".tar.bz2"
|
f = d+".tar.bz2"
|
||||||
subprocess.check_call(["svn", "export", ".", d])
|
subprocess.check_call(["svn", "export", ".", d])
|
||||||
if release:
|
if release:
|
||||||
# TODO: create tag for release
|
# TODO: create tag for release
|
||||||
subprocess.check_call(["sed", "-ie", "/^__version__/s/_SVN//", d+"/osc/core.py"])
|
subprocess.check_call(["sed", "-ie", "/^__version__/s/_SVN//", d+"/osc/core.py"])
|
||||||
subprocess.check_call(["tar", "--force-local", "--owner=root", "--group=root", "-cjf", f, d])
|
subprocess.check_call(["tar", "--force-local", "--owner=root", "--group=root", "-cjf", f, d])
|
||||||
subprocess.call(["rm", "-rf", d]) # XXX how to do this in python properly?
|
subprocess.call(["rm", "-rf", d]) # XXX how to do this in python properly?
|
||||||
print f
|
print f
|
||||||
|
@ -3,10 +3,9 @@
|
|||||||
# this wrapper exists so it can be put into /usr/bin, but still allows the
|
# this wrapper exists so it can be put into /usr/bin, but still allows the
|
||||||
# python module to be called within the source directory during development
|
# python module to be called within the source directory during development
|
||||||
|
|
||||||
|
|
||||||
import sys, locale
|
import sys, locale
|
||||||
# this is a hack to make osc work as expected with utf-8 characters, no matter
|
# this is a hack to make osc work as expected with utf-8 characters,
|
||||||
# how site.py is set...
|
# no matter how site.py is set...
|
||||||
reload(sys)
|
reload(sys)
|
||||||
loc = locale.getdefaultlocale()[1]
|
loc = locale.getdefaultlocale()[1]
|
||||||
if not loc:
|
if not loc:
|
||||||
@ -21,6 +20,3 @@ osccli = commandline.Osc()
|
|||||||
|
|
||||||
r = babysitter.run(osccli)
|
r = babysitter.run(osccli)
|
||||||
sys.exit(r)
|
sys.exit(r)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
58
osc/build.py
58
osc/build.py
@ -83,7 +83,7 @@ class Buildinfo:
|
|||||||
self.buildarch = root.find('arch').text
|
self.buildarch = root.find('arch').text
|
||||||
self.release = "0"
|
self.release = "0"
|
||||||
if root.find('release') != None:
|
if root.find('release') != None:
|
||||||
self.release = root.find('release').text
|
self.release = root.find('release').text
|
||||||
self.downloadurl = root.get('downloadurl')
|
self.downloadurl = root.get('downloadurl')
|
||||||
self.debuginfo = 0
|
self.debuginfo = 0
|
||||||
if root.find('debuginfo') != None:
|
if root.find('debuginfo') != None:
|
||||||
@ -373,23 +373,23 @@ def main(opts, argv):
|
|||||||
bi_file = None
|
bi_file = None
|
||||||
try:
|
try:
|
||||||
if opts.noinit:
|
if opts.noinit:
|
||||||
if not os.path.isfile(bi_file_name):
|
if not os.path.isfile(bi_file_name):
|
||||||
print >>sys.stderr, '--noinit is not possible, no local build info file'
|
print >>sys.stderr, '--noinit is not possible, no local build info file'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
print 'Use local .buildinfo.xml file as build description'
|
print 'Use local .buildinfo.xml file as build description'
|
||||||
bi_file = open(bi_file_name, 'r')
|
bi_file = open(bi_file_name, 'r')
|
||||||
else:
|
else:
|
||||||
print 'Getting buildinfo from server and store to local directory as .buildinfo.xml'
|
print 'Getting buildinfo from server and store to local directory as .buildinfo.xml'
|
||||||
bi_file = open(bi_file_name, 'w+')
|
bi_file = open(bi_file_name, 'w+')
|
||||||
bi_text = ''.join(get_buildinfo(apiurl,
|
bi_text = ''.join(get_buildinfo(apiurl,
|
||||||
prj,
|
prj,
|
||||||
pac,
|
pac,
|
||||||
repo,
|
repo,
|
||||||
arch,
|
arch,
|
||||||
specfile=build_descr_data,
|
specfile=build_descr_data,
|
||||||
addlist=extra_pkgs))
|
addlist=extra_pkgs))
|
||||||
bi_file.write(bi_text)
|
bi_file.write(bi_text)
|
||||||
bi_file.flush()
|
bi_file.flush()
|
||||||
except urllib2.HTTPError, e:
|
except urllib2.HTTPError, e:
|
||||||
if e.code == 404:
|
if e.code == 404:
|
||||||
# check what caused the 404
|
# check what caused the 404
|
||||||
@ -445,7 +445,7 @@ def main(opts, argv):
|
|||||||
# transform 'url1, url2, url3' form into a list
|
# transform 'url1, url2, url3' form into a list
|
||||||
if 'urllist' in config:
|
if 'urllist' in config:
|
||||||
if type(config['urllist']) == str:
|
if type(config['urllist']) == str:
|
||||||
re_clist = re.compile('[, ]+')
|
re_clist = re.compile('[, ]+')
|
||||||
urllist = [ i.strip() for i in re_clist.split(config['urllist'].strip()) ]
|
urllist = [ i.strip() for i in re_clist.split(config['urllist'].strip()) ]
|
||||||
else:
|
else:
|
||||||
urllist = config['urllist']
|
urllist = config['urllist']
|
||||||
@ -535,17 +535,17 @@ def main(opts, argv):
|
|||||||
|
|
||||||
vm_options=""
|
vm_options=""
|
||||||
if config['build-device'] and config['build-memory'] and config['build-type']:
|
if config['build-device'] and config['build-memory'] and config['build-type']:
|
||||||
if config['build-type'] == "kvm":
|
if config['build-type'] == "kvm":
|
||||||
vm_options="--kvm " + config['build-device']
|
vm_options="--kvm " + config['build-device']
|
||||||
elif config['build-type'] == "xen":
|
elif config['build-type'] == "xen":
|
||||||
vm_options="--xen " + config['build-device']
|
vm_options="--xen " + config['build-device']
|
||||||
else:
|
else:
|
||||||
print "ERROR: unknown VM is set ! (" + config['build-type'] + ")"
|
print "ERROR: unknown VM is set ! (" + config['build-type'] + ")"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if config['build-swap']:
|
if config['build-swap']:
|
||||||
vm_options+=" --swap " + config['build-swap']
|
vm_options+=" --swap " + config['build-swap']
|
||||||
if config['build-memory']:
|
if config['build-memory']:
|
||||||
vm_options+=" --memory " + config['build-memory']
|
vm_options+=" --memory " + config['build-memory']
|
||||||
|
|
||||||
print 'Running build'
|
print 'Running build'
|
||||||
# special handling for overlay and rsync-src/dest
|
# special handling for overlay and rsync-src/dest
|
||||||
|
@ -542,11 +542,11 @@ class Osc(cmdln.Cmdln):
|
|||||||
src_update = None
|
src_update = None
|
||||||
# we should check here for home:<id>:branch and default to update, but that would require OBS 1.7 server
|
# we should check here for home:<id>:branch and default to update, but that would require OBS 1.7 server
|
||||||
if opts.cleanup:
|
if opts.cleanup:
|
||||||
src_update = "cleanup"
|
src_update = "cleanup"
|
||||||
elif opts.no_cleanup:
|
elif opts.no_cleanup:
|
||||||
src_update = "update"
|
src_update = "update"
|
||||||
elif opts.no_update:
|
elif opts.no_update:
|
||||||
src_update = "noupdate"
|
src_update = "noupdate"
|
||||||
|
|
||||||
args = slash_split(args)
|
args = slash_split(args)
|
||||||
|
|
||||||
@ -616,15 +616,15 @@ Warning: failed to fetch meta data for '%s' package '%s' (new package?) """ \
|
|||||||
% (dst_project, dst_package)
|
% (dst_project, dst_package)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if devloc \
|
if devloc and \
|
||||||
and dst_project != devloc \
|
dst_project != devloc and \
|
||||||
and src_project != devloc:
|
src_project != devloc:
|
||||||
print """\
|
print """\
|
||||||
Sorry, but a different project, %s, is defined as the place where development
|
Sorry, but a different project, %s, is defined as the place where development
|
||||||
of the package %s primarily takes place.
|
of the package %s primarily takes place.
|
||||||
Please submit there instead, or use --nodevelproject to force direct submission.""" \
|
Please submit there instead, or use --nodevelproject to force direct submission.""" \
|
||||||
% (devloc, dst_package)
|
% (devloc, dst_package)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if opts.diff:
|
if opts.diff:
|
||||||
print 'old: %s/%s\nnew: %s/%s' %(dst_project, dst_package, src_project, src_package)
|
print 'old: %s/%s\nnew: %s/%s' %(dst_project, dst_package, src_project, src_package)
|
||||||
rdiff = server_diff(apiurl,
|
rdiff = server_diff(apiurl,
|
||||||
@ -681,7 +681,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
project = args[0]
|
project = args[0]
|
||||||
package = None
|
package = None
|
||||||
if len(args) > 1:
|
if len(args) > 1:
|
||||||
package = args[1]
|
package = args[1]
|
||||||
|
|
||||||
if not opts.message:
|
if not opts.message:
|
||||||
opts.message = edit_message()
|
opts.message = edit_message()
|
||||||
@ -717,7 +717,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
package = args[1]
|
package = args[1]
|
||||||
devel_package = package
|
devel_package = package
|
||||||
if len(args) > 3:
|
if len(args) > 3:
|
||||||
devel_package = args[3]
|
devel_package = args[3]
|
||||||
|
|
||||||
if not opts.message:
|
if not opts.message:
|
||||||
opts.message = edit_message()
|
opts.message = edit_message()
|
||||||
@ -1036,9 +1036,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
for p in packages:
|
for p in packages:
|
||||||
print "setting revision for package", p
|
print "setting revision for package", p
|
||||||
if opts.unset:
|
if opts.unset:
|
||||||
rev=-1
|
rev=-1
|
||||||
else:
|
else:
|
||||||
rev, dummy = parseRevisionOption(opts.revision)
|
rev, dummy = parseRevisionOption(opts.revision)
|
||||||
set_link_rev(apiurl, project, p, rev)
|
set_link_rev(apiurl, project, p, rev)
|
||||||
|
|
||||||
|
|
||||||
@ -1092,7 +1092,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
if opts.current:
|
if opts.current:
|
||||||
rev = show_upstream_rev(conf.config['apiurl'], src_project, src_package);
|
rev = show_upstream_rev(conf.config['apiurl'], src_project, src_package)
|
||||||
|
|
||||||
if rev and not checkRevision(src_project, src_package, rev):
|
if rev and not checkRevision(src_project, src_package, rev):
|
||||||
print >>sys.stderr, 'Revision \'%s\' does not exist' % rev
|
print >>sys.stderr, 'Revision \'%s\' does not exist' % rev
|
||||||
@ -1207,7 +1207,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
if src_project == dst_project and \
|
if src_project == dst_project and \
|
||||||
src_package == dst_package and \
|
src_package == dst_package and \
|
||||||
src_apiurl == dst_apiurl:
|
src_apiurl == dst_apiurl:
|
||||||
raise oscerr.WrongArgs('Source and destination are the same.')
|
raise oscerr.WrongArgs('Source and destination are the same.')
|
||||||
|
|
||||||
if src_apiurl != dst_apiurl:
|
if src_apiurl != dst_apiurl:
|
||||||
opts.client_side_copy = True
|
opts.client_side_copy = True
|
||||||
@ -1218,7 +1218,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
comment = opts.message
|
comment = opts.message
|
||||||
else:
|
else:
|
||||||
if not rev:
|
if not rev:
|
||||||
rev = show_upstream_rev(src_apiurl, src_project, src_package);
|
rev = show_upstream_rev(src_apiurl, src_project, src_package)
|
||||||
comment = 'osc copypac from project:%s package:%s revision:%s' % ( src_project, src_package, rev )
|
comment = 'osc copypac from project:%s package:%s revision:%s' % ( src_project, src_package, rev )
|
||||||
|
|
||||||
r = copy_pac(src_apiurl, src_project, src_package,
|
r = copy_pac(src_apiurl, src_project, src_package,
|
||||||
@ -1311,7 +1311,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
|
|
||||||
package = args[1]
|
package = args[1]
|
||||||
if tpackage:
|
if tpackage:
|
||||||
package = tpackage
|
package = tpackage
|
||||||
if opts.checkout:
|
if opts.checkout:
|
||||||
checkout_package(conf.config['apiurl'], r, package,
|
checkout_package(conf.config['apiurl'], r, package,
|
||||||
expand_link=True, prj_dir=r)
|
expand_link=True, prj_dir=r)
|
||||||
@ -1353,11 +1353,11 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
pkgs = args[1:]
|
pkgs = args[1:]
|
||||||
|
|
||||||
if pkgs:
|
if pkgs:
|
||||||
for pkg in pkgs:
|
for pkg in pkgs:
|
||||||
# careful: if pkg is an empty string, the package delete request results
|
# careful: if pkg is an empty string, the package delete request results
|
||||||
# into a project delete request - which works recursively...
|
# into a project delete request - which works recursively...
|
||||||
if pkg:
|
if pkg:
|
||||||
delete_package(conf.config['apiurl'], prj, pkg)
|
delete_package(conf.config['apiurl'], prj, pkg)
|
||||||
elif len(meta_get_packagelist(conf.config['apiurl'], prj)) >= 1 and not opts.force:
|
elif len(meta_get_packagelist(conf.config['apiurl'], prj)) >= 1 and not opts.force:
|
||||||
print >>sys.stderr, 'Project contains packages. It must be empty before deleting it. ' \
|
print >>sys.stderr, 'Project contains packages. It must be empty before deleting it. ' \
|
||||||
'If you are sure that you want to remove this project and all its ' \
|
'If you are sure that you want to remove this project and all its ' \
|
||||||
@ -1532,9 +1532,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
|
|
||||||
args = slash_split(args)
|
args = slash_split(args)
|
||||||
args = expand_proj_pack(args)
|
args = expand_proj_pack(args)
|
||||||
cmd = "sudo zypper -p http://download.opensuse.org/repositories/%s/%s --no-refresh -v in %s" % (re.sub(':',':/',args[0]), 'openSUSE_11.1', args[1])
|
cmd = "sudo zypper -p http://download.opensuse.org/repositories/%s/%s --no-refresh -v in %s" % (re.sub(':',':/',args[0]), 'openSUSE_11.1', args[1])
|
||||||
print self.do_install.__doc__
|
print self.do_install.__doc__
|
||||||
print "Example: \n" + cmd
|
print "Example: \n" + cmd
|
||||||
|
|
||||||
|
|
||||||
def do_repourls(self, subcmd, opts, *args):
|
def do_repourls(self, subcmd, opts, *args):
|
||||||
@ -1631,7 +1631,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
|
|
||||||
rev, dummy = parseRevisionOption(opts.revision)
|
rev, dummy = parseRevisionOption(opts.revision)
|
||||||
if rev==None:
|
if rev==None:
|
||||||
rev="latest"
|
rev="latest"
|
||||||
|
|
||||||
if rev and rev != "latest" and not checkRevision(project, package, rev):
|
if rev and rev != "latest" and not checkRevision(project, package, rev):
|
||||||
print >>sys.stderr, 'Revision \'%s\' does not exist' % rev
|
print >>sys.stderr, 'Revision \'%s\' does not exist' % rev
|
||||||
@ -1827,7 +1827,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
continue
|
continue
|
||||||
# ignore foo.rXX, foo.mine for files which are in 'C' state
|
# ignore foo.rXX, foo.mine for files which are in 'C' state
|
||||||
if os.path.splitext(filename)[0] in p.in_conflict:
|
if os.path.splitext(filename)[0] in p.in_conflict:
|
||||||
continue
|
continue
|
||||||
state = p.status(filename)
|
state = p.status(filename)
|
||||||
|
|
||||||
if state == '?':
|
if state == '?':
|
||||||
@ -2098,11 +2098,11 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
if not p.todo:
|
if not p.todo:
|
||||||
prj_dir, pac_dir = getPrjPacPaths(p.absdir)
|
prj_dir, pac_dir = getPrjPacPaths(p.absdir)
|
||||||
if is_project_dir(prj_dir):
|
if is_project_dir(prj_dir):
|
||||||
if conf.config['do_package_tracking']:
|
if conf.config['do_package_tracking']:
|
||||||
prj = Project(prj_dir, False)
|
prj = Project(prj_dir, False)
|
||||||
prj.delPackage(p, opts.force)
|
prj.delPackage(p, opts.force)
|
||||||
else:
|
else:
|
||||||
print "WARNING: package tracking is disabled, operation skipped !"
|
print "WARNING: package tracking is disabled, operation skipped !"
|
||||||
else:
|
else:
|
||||||
pathn = getTransActPath(p.dir)
|
pathn = getTransActPath(p.dir)
|
||||||
for filename in p.todo:
|
for filename in p.todo:
|
||||||
@ -2678,20 +2678,20 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if len(args) == 4:
|
if len(args) == 4:
|
||||||
apiurl = conf.config['apiurl']
|
apiurl = conf.config['apiurl']
|
||||||
project = args[0]
|
project = args[0]
|
||||||
package = args[1]
|
package = args[1]
|
||||||
repository = args[2]
|
repository = args[2]
|
||||||
arch = args[3]
|
arch = args[3]
|
||||||
elif len(args) == 2:
|
elif len(args) == 2:
|
||||||
wd = os.curdir
|
wd = os.curdir
|
||||||
package = store_read_package(wd)
|
package = store_read_package(wd)
|
||||||
project = store_read_project(wd)
|
project = store_read_project(wd)
|
||||||
repository = args[0]
|
repository = args[0]
|
||||||
arch = args[1]
|
arch = args[1]
|
||||||
apiurl = store_read_apiurl(wd)
|
apiurl = store_read_apiurl(wd)
|
||||||
else:
|
else:
|
||||||
raise oscerr.WrongArgs('Wrong number of arguments')
|
raise oscerr.WrongArgs('Wrong number of arguments')
|
||||||
|
|
||||||
format = 'text'
|
format = 'text'
|
||||||
if opts.csv:
|
if opts.csv:
|
||||||
@ -2951,14 +2951,14 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
architecture = args[3]
|
architecture = args[3]
|
||||||
elif len(args) == 2:
|
elif len(args) == 2:
|
||||||
if is_package_dir(os.getcwd()):
|
if is_package_dir(os.getcwd()):
|
||||||
project = Project(os.getcwd()).name
|
project = Project(os.getcwd()).name
|
||||||
p = Package(os.getcwd())
|
p = Package(os.getcwd())
|
||||||
package = p.name
|
package = p.name
|
||||||
apiurl = p.apiurl
|
apiurl = p.apiurl
|
||||||
repository = args[0]
|
repository = args[0]
|
||||||
architecture = args[1]
|
architecture = args[1]
|
||||||
else:
|
else:
|
||||||
sys.exit('Local directory is no checkout package, neither it is specified. ' )
|
sys.exit('Local directory is no checkout package, neither it is specified. ' )
|
||||||
else:
|
else:
|
||||||
sys.exit('Need either 2 or 4 arguments.' )
|
sys.exit('Need either 2 or 4 arguments.' )
|
||||||
|
|
||||||
@ -3019,14 +3019,13 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
if not args:
|
if not args:
|
||||||
raise oscerr.WrongArgs('Please specify one of projects/packages/requests')
|
raise oscerr.WrongArgs('Please specify one of projects/packages/requests')
|
||||||
|
|
||||||
if args[0] in ('requests', 'request', 'req', 'rq',
|
if args[0] in ('requests', 'request', 'req', 'rq', 'submitrequest', 'submitreq', 'submit', 'sr'):
|
||||||
'submitrequest', 'submitreq', 'submit', 'sr'):
|
|
||||||
## FIXME: involvement bugowner is not reported here.
|
## FIXME: involvement bugowner is not reported here.
|
||||||
## this only reports usernames found in request history.
|
## this only reports usernames found in request history.
|
||||||
opts.state = 'all'
|
opts.state = 'all'
|
||||||
opts.type = ''
|
opts.type = ''
|
||||||
if args[0] in ('submitrequest', 'submitreq', 'submit', 'sr'):
|
if args[0] in ('submitrequest', 'submitreq', 'submit', 'sr'):
|
||||||
opts.type = 'submit'
|
opts.type = 'submit'
|
||||||
opts.days = conf.config['request_list_days']
|
opts.days = conf.config['request_list_days']
|
||||||
opts.mine = False
|
opts.mine = False
|
||||||
opts.bugowner = True
|
opts.bugowner = True
|
||||||
@ -3422,17 +3421,17 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
m = show_package_meta(conf.config['apiurl'], prj, pac)
|
m = show_package_meta(conf.config['apiurl'], prj, pac)
|
||||||
tree = ET.parse(StringIO(''.join(m)))
|
tree = ET.parse(StringIO(''.join(m)))
|
||||||
if not opts.nodevelproject and not opts.delete and not opts.add:
|
if not opts.nodevelproject and not opts.delete and not opts.add:
|
||||||
while tree.findall('devel'):
|
while tree.findall('devel'):
|
||||||
d = tree.find('devel')
|
d = tree.find('devel')
|
||||||
prj = d.get('project', prj)
|
prj = d.get('project', prj)
|
||||||
pac = d.get('package', pac)
|
pac = d.get('package', pac)
|
||||||
print "Following to the development space:", prj, "/", pac
|
print "Following to the development space:", prj, "/", pac
|
||||||
m = show_package_meta(conf.config['apiurl'], prj, pac)
|
m = show_package_meta(conf.config['apiurl'], prj, pac)
|
||||||
tree = ET.parse(StringIO(''.join(m)))
|
tree = ET.parse(StringIO(''.join(m)))
|
||||||
if not tree.findall('person'):
|
if not tree.findall('person'):
|
||||||
print "No dedicated persons in package defined, showing the project persons !"
|
print "No dedicated persons in package defined, showing the project persons !"
|
||||||
m = show_project_meta(conf.config['apiurl'], prj)
|
m = show_project_meta(conf.config['apiurl'], prj)
|
||||||
tree = ET.parse(StringIO(''.join(m)))
|
tree = ET.parse(StringIO(''.join(m)))
|
||||||
else:
|
else:
|
||||||
raise oscerr.WrongArgs('I need at least one argument.')
|
raise oscerr.WrongArgs('I need at least one argument.')
|
||||||
|
|
||||||
@ -3451,7 +3450,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
print role, ":"
|
print role, ":"
|
||||||
for person in tree.findall('person'):
|
for person in tree.findall('person'):
|
||||||
if person.get('role') == role:
|
if person.get('role') == role:
|
||||||
maintainers.append(person.get('userid'))
|
maintainers.append(person.get('userid'))
|
||||||
|
|
||||||
if opts.email:
|
if opts.email:
|
||||||
emails = []
|
emails = []
|
||||||
@ -3492,11 +3491,11 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
|
|
||||||
if len(args) == 1 and (args[0].startswith('http://') or
|
if len(args) == 1 and (args[0].startswith('http://') or
|
||||||
args[0].startswith('https://')):
|
args[0].startswith('https://')):
|
||||||
opts.method = 'GET'
|
opts.method = 'GET'
|
||||||
opts.headers = None
|
opts.headers = None
|
||||||
opts.data = None
|
opts.data = None
|
||||||
opts.file = None
|
opts.file = None
|
||||||
return self.do_api('list', opts, *args)
|
return self.do_api('list', opts, *args)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -3555,7 +3554,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
package = target_package = args[1]
|
package = target_package = args[1]
|
||||||
target_prj = args[2]
|
target_prj = args[2]
|
||||||
if len(args) == 4:
|
if len(args) == 4:
|
||||||
target_package = args[3]
|
target_package = args[3]
|
||||||
elif len(args) == 2:
|
elif len(args) == 2:
|
||||||
target_prj = prj = args[0]
|
target_prj = prj = args[0]
|
||||||
target_package = package = args[1]
|
target_package = package = args[1]
|
||||||
@ -3656,8 +3655,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
os.chdir(destdir)
|
os.chdir(destdir)
|
||||||
init_package_dir(apiurl, target_prj, target_package, destdir, files=False)
|
init_package_dir(apiurl, target_prj, target_package, destdir, files=False)
|
||||||
os.chdir(olddir)
|
os.chdir(olddir)
|
||||||
store_write_string(destdir, '_files', ''.join(meta));
|
store_write_string(destdir, '_files', ''.join(meta))
|
||||||
store_write_string(destdir, '_linkrepair', '');
|
store_write_string(destdir, '_linkrepair', '')
|
||||||
pac = Package(destdir)
|
pac = Package(destdir)
|
||||||
|
|
||||||
storedir = os.path.join(destdir, store)
|
storedir = os.path.join(destdir, store)
|
||||||
@ -3768,14 +3767,14 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
raise oscerr.WrongArgs('Please specify just the project')
|
raise oscerr.WrongArgs('Please specify just the project')
|
||||||
|
|
||||||
if opts.create:
|
if opts.create:
|
||||||
url = makeurl(apiurl, ['source', prj], query='cmd=createkey')
|
url = makeurl(apiurl, ['source', prj], query='cmd=createkey')
|
||||||
f = http_POST(url)
|
f = http_POST(url)
|
||||||
elif opts.delete:
|
elif opts.delete:
|
||||||
url = makeurl(apiurl, ['source', prj, "_pubkey"])
|
url = makeurl(apiurl, ['source', prj, "_pubkey"])
|
||||||
f = http_DELETE(url)
|
f = http_DELETE(url)
|
||||||
else:
|
else:
|
||||||
url = makeurl(apiurl, ['source', prj, "_pubkey"])
|
url = makeurl(apiurl, ['source', prj, "_pubkey"])
|
||||||
f = http_GET(url)
|
f = http_GET(url)
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
buf = f.read(16384)
|
buf = f.read(16384)
|
||||||
|
35
osc/conf.py
35
osc/conf.py
@ -45,18 +45,18 @@ try:
|
|||||||
GENERIC_KEYRING = True
|
GENERIC_KEYRING = True
|
||||||
|
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
import gobject
|
import gobject
|
||||||
gobject.set_application_name('osc')
|
gobject.set_application_name('osc')
|
||||||
import gnomekeyring
|
import gnomekeyring
|
||||||
if os.environ['GNOME_DESKTOP_SESSION_ID']:
|
if os.environ['GNOME_DESKTOP_SESSION_ID']:
|
||||||
# otherwise gnome keyring bindings spit out errors, when you have
|
# otherwise gnome keyring bindings spit out errors, when you have
|
||||||
# it installed, but you are not under gnome
|
# it installed, but you are not under gnome
|
||||||
# (even though hundreds of gnome-keyring daemons got started in parallel)
|
# (even though hundreds of gnome-keyring daemons got started in parallel)
|
||||||
# another option would be to support kwallet here
|
# another option would be to support kwallet here
|
||||||
GNOME_KEYRING = gnomekeyring.is_available()
|
GNOME_KEYRING = gnomekeyring.is_available()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
DEFAULTS = { 'apiurl': 'https://api.opensuse.org',
|
DEFAULTS = { 'apiurl': 'https://api.opensuse.org',
|
||||||
'user': 'your_username',
|
'user': 'your_username',
|
||||||
@ -361,7 +361,7 @@ def init_basicauth(config):
|
|||||||
if ctx.load_verify_locations(capath=capath, cafile=cafile) != 1: raise Exception('No CA certificates found')
|
if ctx.load_verify_locations(capath=capath, cafile=cafile) != 1: raise Exception('No CA certificates found')
|
||||||
opener = m2urllib2.build_opener(ctx, urllib2.HTTPCookieProcessor(cookiejar), authhandler)
|
opener = m2urllib2.build_opener(ctx, urllib2.HTTPCookieProcessor(cookiejar), authhandler)
|
||||||
else:
|
else:
|
||||||
import sys;
|
import sys
|
||||||
print >>sys.stderr, "WARNING: SSL certificate checks disabled. Connection is insecure!\n"
|
print >>sys.stderr, "WARNING: SSL certificate checks disabled. Connection is insecure!\n"
|
||||||
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar), authhandler)
|
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar), authhandler)
|
||||||
|
|
||||||
@ -581,10 +581,10 @@ def get_config(override_conffile = None,
|
|||||||
passwordx = cp.get(url, 'passx', raw=True) # especially on password!
|
passwordx = cp.get(url, 'passx', raw=True) # especially on password!
|
||||||
if password is None or password == 'your_password':
|
if password is None or password == 'your_password':
|
||||||
try:
|
try:
|
||||||
password = passwordx.decode('base64').decode('bz2');
|
password = passwordx.decode('base64').decode('bz2')
|
||||||
except:
|
except:
|
||||||
print "%s: no credentials known" % url
|
print "%s: no credentials known" % url
|
||||||
password = 'your_password'
|
password = 'your_password'
|
||||||
else:
|
else:
|
||||||
if not passwordx:
|
if not passwordx:
|
||||||
print "%s: rewriting from plain pass to encoded pass\n" % url
|
print "%s: rewriting from plain pass to encoded pass\n" % url
|
||||||
@ -640,7 +640,8 @@ def get_config(override_conffile = None,
|
|||||||
# override values which we were called with
|
# override values which we were called with
|
||||||
if override_verbose:
|
if override_verbose:
|
||||||
config['verbose'] = override_verbose + 1
|
config['verbose'] = override_verbose + 1
|
||||||
if not config.has_key('verbose') : config['verbose'] = 1;
|
if not config.has_key('verbose'):
|
||||||
|
config['verbose'] = 1
|
||||||
|
|
||||||
if override_debug:
|
if override_debug:
|
||||||
config['debug'] = override_debug
|
config['debug'] = override_debug
|
||||||
|
190
osc/core.py
190
osc/core.py
@ -193,10 +193,10 @@ buildstatus_symbols = {'succeeded': '.',
|
|||||||
|
|
||||||
# os.path.samefile is available only under Unix
|
# os.path.samefile is available only under Unix
|
||||||
def os_path_samefile(path1, path2):
|
def os_path_samefile(path1, path2):
|
||||||
try:
|
try:
|
||||||
return os.path.samefile(path1, path2)
|
return os.path.samefile(path1, path2)
|
||||||
except:
|
except:
|
||||||
return os.path.realpath(path1) == os.path.realpath(path2)
|
return os.path.realpath(path1) == os.path.realpath(path2)
|
||||||
|
|
||||||
class File:
|
class File:
|
||||||
"""represent a file, including its metadata"""
|
"""represent a file, including its metadata"""
|
||||||
@ -229,9 +229,9 @@ class Serviceinfo:
|
|||||||
name = service.get('name')
|
name = service.get('name')
|
||||||
try:
|
try:
|
||||||
for param in service.findall('param'):
|
for param in service.findall('param'):
|
||||||
option = param.get('name', None)
|
option = param.get('name', None)
|
||||||
value = param.text
|
value = param.text
|
||||||
name += " --" + option + " '" + value + "'"
|
name += " --" + option + " '" + value + "'"
|
||||||
self.commands.append(name)
|
self.commands.append(name)
|
||||||
except:
|
except:
|
||||||
msg = 'invalid service format:\n%s' % ET.tostring(root)
|
msg = 'invalid service format:\n%s' % ET.tostring(root)
|
||||||
@ -244,16 +244,16 @@ class Serviceinfo:
|
|||||||
temp_dir = tempfile.mkdtemp()
|
temp_dir = tempfile.mkdtemp()
|
||||||
name = call.split(None, 1)[0]
|
name = call.split(None, 1)[0]
|
||||||
if not os.path.exists("/usr/lib/obs/service/"+name):
|
if not os.path.exists("/usr/lib/obs/service/"+name):
|
||||||
msg = "ERROR: service is not installed !"
|
msg = "ERROR: service is not installed !"
|
||||||
msg += "Can maybe solved with: zypper in obs-server-" + name
|
msg += "Can maybe solved with: zypper in obs-server-" + name
|
||||||
raise oscerr.APIError(msg)
|
raise oscerr.APIError(msg)
|
||||||
c = "/usr/lib/obs/service/" + call + " --outdir " + temp_dir
|
c = "/usr/lib/obs/service/" + call + " --outdir " + temp_dir
|
||||||
ret = subprocess.call(c, shell=True)
|
ret = subprocess.call(c, shell=True)
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
print "ERROR: service call failed: " + c
|
print "ERROR: service call failed: " + c
|
||||||
|
|
||||||
for file in os.listdir(temp_dir):
|
for file in os.listdir(temp_dir):
|
||||||
os.rename( os.path.join(temp_dir, file), os.path.join(dir, "_service:"+name+":"+file) )
|
os.rename( os.path.join(temp_dir, file), os.path.join(dir, "_service:"+name+":"+file) )
|
||||||
os.rmdir(temp_dir)
|
os.rmdir(temp_dir)
|
||||||
|
|
||||||
class Linkinfo:
|
class Linkinfo:
|
||||||
@ -511,7 +511,7 @@ class Project:
|
|||||||
rev = p.linkinfo.lsrcmd5
|
rev = p.linkinfo.lsrcmd5
|
||||||
print 'Unexpanding to rev', rev
|
print 'Unexpanding to rev', rev
|
||||||
elif p.islink() and p.isexpanded():
|
elif p.islink() and p.isexpanded():
|
||||||
rev = p.latest_rev();
|
rev = p.latest_rev()
|
||||||
print 'Updating %s' % p.name
|
print 'Updating %s' % p.name
|
||||||
p.update(rev, service_files)
|
p.update(rev, service_files)
|
||||||
elif state == 'D':
|
elif state == 'D':
|
||||||
@ -792,7 +792,7 @@ class Package:
|
|||||||
|
|
||||||
def commit(self, msg=''):
|
def commit(self, msg=''):
|
||||||
# commit only if the upstream revision is the same as the working copy's
|
# commit only if the upstream revision is the same as the working copy's
|
||||||
upstream_rev = self.latest_rev();
|
upstream_rev = self.latest_rev()
|
||||||
if self.rev != upstream_rev:
|
if self.rev != upstream_rev:
|
||||||
raise oscerr.WorkingCopyOutdated((self.absdir, self.rev, upstream_rev))
|
raise oscerr.WorkingCopyOutdated((self.absdir, self.rev, upstream_rev))
|
||||||
|
|
||||||
@ -804,15 +804,15 @@ class Package:
|
|||||||
have_conflicts = False
|
have_conflicts = False
|
||||||
for filename in self.todo:
|
for filename in self.todo:
|
||||||
if not filename.startswith('_service:') and not filename.startswith('_service_'):
|
if not filename.startswith('_service:') and not filename.startswith('_service_'):
|
||||||
st = self.status(filename)
|
st = self.status(filename)
|
||||||
if st == 'A' or st == 'M':
|
if st == 'A' or st == 'M':
|
||||||
self.todo_send.append(filename)
|
self.todo_send.append(filename)
|
||||||
print statfrmt('Sending', os.path.join(pathn, filename))
|
print statfrmt('Sending', os.path.join(pathn, filename))
|
||||||
elif st == 'D':
|
elif st == 'D':
|
||||||
self.todo_delete.append(filename)
|
self.todo_delete.append(filename)
|
||||||
print statfrmt('Deleting', os.path.join(pathn, filename))
|
print statfrmt('Deleting', os.path.join(pathn, filename))
|
||||||
elif st == 'C':
|
elif st == 'C':
|
||||||
have_conflicts = True
|
have_conflicts = True
|
||||||
|
|
||||||
if have_conflicts:
|
if have_conflicts:
|
||||||
print 'Please resolve all conflicts before committing using "osc resolved FILE"!'
|
print 'Please resolve all conflicts before committing using "osc resolved FILE"!'
|
||||||
@ -882,8 +882,8 @@ class Package:
|
|||||||
if self.filenamelist.count('_service'):
|
if self.filenamelist.count('_service'):
|
||||||
print 'The package contains a source service.'
|
print 'The package contains a source service.'
|
||||||
for filename in self.todo:
|
for filename in self.todo:
|
||||||
if filename.startswith('_service:') and os.path.exists(filename):
|
if filename.startswith('_service:') and os.path.exists(filename):
|
||||||
os.unlink(filename) #remove local files
|
os.unlink(filename) # remove local files
|
||||||
print_request_list(self.apiurl, self.prjname, self.name)
|
print_request_list(self.apiurl, self.prjname, self.name)
|
||||||
|
|
||||||
def write_conflictlist(self):
|
def write_conflictlist(self):
|
||||||
@ -922,12 +922,12 @@ class Package:
|
|||||||
os.utime(upfilename, (-1, mtime))
|
os.utime(upfilename, (-1, mtime))
|
||||||
|
|
||||||
if binary_file(myfilename) or binary_file(upfilename):
|
if binary_file(myfilename) or binary_file(upfilename):
|
||||||
# don't try merging
|
# don't try merging
|
||||||
shutil.copy2(upfilename, filename)
|
shutil.copy2(upfilename, filename)
|
||||||
shutil.copy2(upfilename, storefilename)
|
shutil.copy2(upfilename, storefilename)
|
||||||
self.in_conflict.append(n)
|
self.in_conflict.append(n)
|
||||||
self.write_conflictlist()
|
self.write_conflictlist()
|
||||||
return 'C'
|
return 'C'
|
||||||
else:
|
else:
|
||||||
# try merging
|
# try merging
|
||||||
# diff3 OPTIONS... MINE OLDER YOURS
|
# diff3 OPTIONS... MINE OLDER YOURS
|
||||||
@ -1295,14 +1295,14 @@ rev: %s
|
|||||||
print 'At revision %s.' % self.rev
|
print 'At revision %s.' % self.rev
|
||||||
|
|
||||||
if not service_files:
|
if not service_files:
|
||||||
self.run_source_services()
|
self.run_source_services()
|
||||||
|
|
||||||
def run_source_services(self):
|
def run_source_services(self):
|
||||||
if self.filenamelist.count('_service'):
|
if self.filenamelist.count('_service'):
|
||||||
service = ET.parse(os.path.join(self.absdir, '_service')).getroot()
|
service = ET.parse(os.path.join(self.absdir, '_service')).getroot()
|
||||||
si = Serviceinfo()
|
si = Serviceinfo()
|
||||||
si.read(service)
|
si.read(service)
|
||||||
si.execute(self.absdir)
|
si.execute(self.absdir)
|
||||||
|
|
||||||
def prepare_filelist(self):
|
def prepare_filelist(self):
|
||||||
"""Prepare a list of files, which will be processed by process_filelist
|
"""Prepare a list of files, which will be processed by process_filelist
|
||||||
@ -1447,18 +1447,18 @@ class Request:
|
|||||||
try:
|
try:
|
||||||
src_prj = src_pkg = src_rev = dst_prj = dst_pkg = src_update = None
|
src_prj = src_pkg = src_rev = dst_prj = dst_pkg = src_update = None
|
||||||
if action.findall('source'):
|
if action.findall('source'):
|
||||||
n = action.find('source')
|
n = action.find('source')
|
||||||
src_prj = n.get('project', None)
|
src_prj = n.get('project', None)
|
||||||
src_pkg = n.get('package', None)
|
src_pkg = n.get('package', None)
|
||||||
src_rev = n.get('rev', None)
|
src_rev = n.get('rev', None)
|
||||||
if action.findall('target'):
|
if action.findall('target'):
|
||||||
n = action.find('target')
|
n = action.find('target')
|
||||||
dst_prj = n.get('project', None)
|
dst_prj = n.get('project', None)
|
||||||
dst_pkg = n.get('package', None)
|
dst_pkg = n.get('package', None)
|
||||||
if action.findall('options'):
|
if action.findall('options'):
|
||||||
n = action.find('options')
|
n = action.find('options')
|
||||||
if n.findall('sourceupdate'):
|
if n.findall('sourceupdate'):
|
||||||
src_update = n.find('sourceupdate').text.strip()
|
src_update = n.find('sourceupdate').text.strip()
|
||||||
self.add_action(type, src_prj, src_pkg, src_rev, dst_prj, dst_pkg, src_update)
|
self.add_action(type, src_prj, src_pkg, src_rev, dst_prj, dst_pkg, src_update)
|
||||||
except:
|
except:
|
||||||
msg = 'invalid request format:\n%s' % ET.tostring(root)
|
msg = 'invalid request format:\n%s' % ET.tostring(root)
|
||||||
@ -1502,18 +1502,18 @@ class Request:
|
|||||||
ret = '%6d State:%-7s By:%-12s When:%-12s' % (self.reqid, self.state.name, self.state.who, self.state.when)
|
ret = '%6d State:%-7s By:%-12s When:%-12s' % (self.reqid, self.state.name, self.state.who, self.state.when)
|
||||||
|
|
||||||
for a in self.actions:
|
for a in self.actions:
|
||||||
dst = "%s/%s" % (a.dst_project, a.dst_package)
|
dst = "%s/%s" % (a.dst_project, a.dst_package)
|
||||||
if a.src_package == a.dst_package:
|
if a.src_package == a.dst_package:
|
||||||
dst = a.dst_project
|
dst = a.dst_project
|
||||||
|
|
||||||
sr_source=""
|
sr_source=""
|
||||||
if a.type=="submit":
|
if a.type=="submit":
|
||||||
sr_source="%s/%s -> " % (a.src_project, a.src_package)
|
sr_source="%s/%s -> " % (a.src_project, a.src_package)
|
||||||
if a.type=="change_devel":
|
if a.type=="change_devel":
|
||||||
dst = "developed in %s/%s" % (a.src_project, a.src_package)
|
dst = "developed in %s/%s" % (a.src_project, a.src_package)
|
||||||
sr_source="%s/%s" % (a.dst_project, a.dst_package)
|
sr_source="%s/%s" % (a.dst_project, a.dst_package)
|
||||||
|
|
||||||
ret += '\n %s: %-50s %-20s ' % \
|
ret += '\n %s: %-50s %-20s ' % \
|
||||||
(a.type, sr_source, dst)
|
(a.type, sr_source, dst)
|
||||||
|
|
||||||
if self.statehistory and self.statehistory[0]:
|
if self.statehistory and self.statehistory[0]:
|
||||||
@ -1536,21 +1536,21 @@ class Request:
|
|||||||
for action in self.actions:
|
for action in self.actions:
|
||||||
action_list=" %s: " % (action.type)
|
action_list=" %s: " % (action.type)
|
||||||
if action.type=="submit":
|
if action.type=="submit":
|
||||||
r=""
|
r=""
|
||||||
if action.src_rev:
|
if action.src_rev:
|
||||||
r="(r%s)" % (action.src_rev)
|
r="(r%s)" % (action.src_rev)
|
||||||
m=""
|
m=""
|
||||||
if action.src_update:
|
if action.src_update:
|
||||||
m="(%s)" % (action.src_update)
|
m="(%s)" % (action.src_update)
|
||||||
action_list=action_list+" %s/%s%s%s -> %s" % ( action.src_project, action.src_package, r, m, action.dst_project )
|
action_list=action_list+" %s/%s%s%s -> %s" % ( action.src_project, action.src_package, r, m, action.dst_project )
|
||||||
if action.dst_package:
|
if action.dst_package:
|
||||||
action_list=action_list+"/%s" % ( action.dst_package )
|
action_list=action_list+"/%s" % ( action.dst_package )
|
||||||
elif action.type=="delete":
|
elif action.type=="delete":
|
||||||
action_list=action_list+" %s" % ( action.dst_project )
|
action_list=action_list+" %s" % ( action.dst_project )
|
||||||
if action.dst_package:
|
if action.dst_package:
|
||||||
action_list=action_list+"/%s" % ( action.dst_package )
|
action_list=action_list+"/%s" % ( action.dst_package )
|
||||||
elif action.type=="change_devel":
|
elif action.type=="change_devel":
|
||||||
action_list=action_list+" %s/%s developed in %s/%s" % \
|
action_list=action_list+" %s/%s developed in %s/%s" % \
|
||||||
( action.dst_project, action.dst_package, action.src_project, action.src_package )
|
( action.dst_project, action.dst_package, action.src_project, action.src_package )
|
||||||
action_list=action_list+"\n"
|
action_list=action_list+"\n"
|
||||||
|
|
||||||
@ -2343,9 +2343,9 @@ def create_delete_request(apiurl, project, package, message):
|
|||||||
import cgi
|
import cgi
|
||||||
|
|
||||||
if package:
|
if package:
|
||||||
package = """package="%s" """ % (package)
|
package = """package="%s" """ % (package)
|
||||||
else:
|
else:
|
||||||
package = ""
|
package = ""
|
||||||
|
|
||||||
xml = """\
|
xml = """\
|
||||||
<request>
|
<request>
|
||||||
@ -2401,7 +2401,7 @@ def create_submit_request(apiurl,
|
|||||||
import cgi
|
import cgi
|
||||||
options_block=""
|
options_block=""
|
||||||
if src_update:
|
if src_update:
|
||||||
options_block="""<options><sourceupdate>%s</sourceupdate></options> """ % (src_update)
|
options_block="""<options><sourceupdate>%s</sourceupdate></options> """ % (src_update)
|
||||||
|
|
||||||
# XXX: keep the old template for now in order to work with old obs instances
|
# XXX: keep the old template for now in order to work with old obs instances
|
||||||
xml = """\
|
xml = """\
|
||||||
@ -2454,10 +2454,10 @@ def get_request_list(apiurl, project, package, req_who='', req_state=('new',), r
|
|||||||
match = ''
|
match = ''
|
||||||
m = ''
|
m = ''
|
||||||
if not "all" in req_state:
|
if not "all" in req_state:
|
||||||
for state in req_state:
|
for state in req_state:
|
||||||
if len(m): m += '%20or%20'
|
if len(m): m += '%20or%20'
|
||||||
m += 'state/@name=\'%s\'' % quote_plus(state)
|
m += 'state/@name=\'%s\'' % quote_plus(state)
|
||||||
if len(m): match += "(" + m + ")"
|
if len(m): match += "(" + m + ")"
|
||||||
m = ''
|
m = ''
|
||||||
if req_who:
|
if req_who:
|
||||||
if len(m): m += '%20and%20'
|
if len(m): m += '%20and%20'
|
||||||
@ -2923,9 +2923,9 @@ def checkout_package(apiurl, project, package,
|
|||||||
|
|
||||||
for filename in p.filenamelist:
|
for filename in p.filenamelist:
|
||||||
if service_files or not filename.startswith('_service:'):
|
if service_files or not filename.startswith('_service:'):
|
||||||
p.updatefile(filename, revision)
|
p.updatefile(filename, revision)
|
||||||
#print 'A ', os.path.join(project, package, filename)
|
# print 'A ', os.path.join(project, package, filename)
|
||||||
print statfrmt('A', os.path.join(pathname, filename))
|
print statfrmt('A', os.path.join(pathname, filename))
|
||||||
if conf.config['do_package_tracking']:
|
if conf.config['do_package_tracking']:
|
||||||
# check if we can re-use an existing project object
|
# check if we can re-use an existing project object
|
||||||
if prj_obj == None:
|
if prj_obj == None:
|
||||||
@ -3862,21 +3862,21 @@ def search(apiurl, search_list, kind, search_term, verbose = False, exact_matche
|
|||||||
def set_link_rev(apiurl, project, package, revision = None):
|
def set_link_rev(apiurl, project, package, revision = None):
|
||||||
url = makeurl(apiurl, ['source', project, package, '_link'])
|
url = makeurl(apiurl, ['source', project, package, '_link'])
|
||||||
try:
|
try:
|
||||||
f = http_GET(url)
|
f = http_GET(url)
|
||||||
root = ET.parse(f).getroot()
|
root = ET.parse(f).getroot()
|
||||||
except urllib2.HTTPError, e:
|
except urllib2.HTTPError, e:
|
||||||
e.osc_msg = 'Unable to get _link file in package \'%s\' for project \'%s\'' % (package, project)
|
e.osc_msg = 'Unable to get _link file in package \'%s\' for project \'%s\'' % (package, project)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# set revision element
|
# set revision element
|
||||||
if not revision:
|
if not revision:
|
||||||
src_project = root.attrib['project']
|
src_project = root.attrib['project']
|
||||||
src_package = root.attrib['package']
|
src_package = root.attrib['package']
|
||||||
root.attrib['rev'] = show_upstream_rev(apiurl, src_project, src_package);
|
root.attrib['rev'] = show_upstream_rev(apiurl, src_project, src_package)
|
||||||
elif revision == -1:
|
elif revision == -1:
|
||||||
del root.attrib['rev']
|
del root.attrib['rev']
|
||||||
else:
|
else:
|
||||||
root.attrib['rev'] = revision
|
root.attrib['rev'] = revision
|
||||||
|
|
||||||
l = ET.tostring(root)
|
l = ET.tostring(root)
|
||||||
# upload _link file again
|
# upload _link file again
|
||||||
@ -4069,15 +4069,15 @@ def setDevelProject(apiurl, prj, pac, dprj, dpkg=None):
|
|||||||
ET.SubElement(tree, 'devel')
|
ET.SubElement(tree, 'devel')
|
||||||
elem = tree.find('devel')
|
elem = tree.find('devel')
|
||||||
if dprj:
|
if dprj:
|
||||||
elem.attrib['project'] = dprj
|
elem.attrib['project'] = dprj
|
||||||
else:
|
else:
|
||||||
if elem.attrib.has_key('project'):
|
if elem.attrib.has_key('project'):
|
||||||
del elem.attrib['project']
|
del elem.attrib['project']
|
||||||
if dpkg:
|
if dpkg:
|
||||||
elem.attrib['package'] = dpkg
|
elem.attrib['package'] = dpkg
|
||||||
else:
|
else:
|
||||||
if elem.attrib.has_key('package'):
|
if elem.attrib.has_key('package'):
|
||||||
del elem.attrib['package']
|
del elem.attrib['package']
|
||||||
edit_meta(metatype='pkg',
|
edit_meta(metatype='pkg',
|
||||||
path_args=path,
|
path_args=path,
|
||||||
data=ET.tostring(tree))
|
data=ET.tostring(tree))
|
||||||
@ -4230,7 +4230,7 @@ def getStatus(pacs, prj_obj=None, verbose=False, quiet=False):
|
|||||||
if prj_obj and conf.config['do_package_tracking']:
|
if prj_obj and conf.config['do_package_tracking']:
|
||||||
state = prj_obj.get_state(p.name)
|
state = prj_obj.get_state(p.name)
|
||||||
if state != None and (state != ' ' or verbose):
|
if state != None and (state != ' ' or verbose):
|
||||||
lines.append(statfrmt(state, os.path.normpath(os.path.join(prj_obj.dir, p.name))))
|
lines.append(statfrmt(state, os.path.normpath(os.path.join(prj_obj.dir, p.name))))
|
||||||
|
|
||||||
for filename in p.todo:
|
for filename in p.todo:
|
||||||
if filename in p.excluded:
|
if filename in p.excluded:
|
||||||
|
@ -67,8 +67,8 @@ class Fetcher:
|
|||||||
# for use by the failure callback
|
# for use by the failure callback
|
||||||
self.curpac = pac
|
self.curpac = pac
|
||||||
|
|
||||||
if self.offline:
|
if self.offline:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
MirrorGroup._join_url = join_url
|
MirrorGroup._join_url = join_url
|
||||||
mg = MirrorGroup(self.gr, pac.urllist)
|
mg = MirrorGroup(self.gr, pac.urllist)
|
||||||
@ -109,7 +109,7 @@ class Fetcher:
|
|||||||
pac.filename = canonname
|
pac.filename = canonname
|
||||||
pac.fullfilename = os.path.join(pac.localdir, canonname)
|
pac.fullfilename = os.path.join(pac.localdir, canonname)
|
||||||
|
|
||||||
os.rename(pac.fullpartname, pac.fullfilename);
|
os.rename(pac.fullpartname, pac.fullfilename)
|
||||||
|
|
||||||
def dirSetup(self, pac):
|
def dirSetup(self, pac):
|
||||||
dir = os.path.join(self.cachedir, pac.localdir)
|
dir = os.path.join(self.cachedir, pac.localdir)
|
||||||
@ -166,7 +166,7 @@ def verify_pacs(pac_list):
|
|||||||
stderr=subprocess.STDOUT, close_fds=True).stdout
|
stderr=subprocess.STDOUT, close_fds=True).stdout
|
||||||
|
|
||||||
# restore locale
|
# restore locale
|
||||||
if saved_LC_ALL: os.environ['LC_ALL'] = saved_LC_ALL;
|
if saved_LC_ALL: os.environ['LC_ALL'] = saved_LC_ALL
|
||||||
else: os.environ.pop('LC_ALL')
|
else: os.environ.pop('LC_ALL')
|
||||||
|
|
||||||
for line in o.readlines():
|
for line in o.readlines():
|
||||||
|
@ -17,15 +17,15 @@ class UserAbort(OscBaseError):
|
|||||||
|
|
||||||
class ConfigError(OscBaseError):
|
class ConfigError(OscBaseError):
|
||||||
"""Exception raised when there is an error in the config file"""
|
"""Exception raised when there is an error in the config file"""
|
||||||
def __init__(self, msg, file):
|
def __init__(self, msg, fname):
|
||||||
OscBaseError.__init__(self)
|
OscBaseError.__init__(self)
|
||||||
self.msg = msg
|
self.msg = msg
|
||||||
self.file = file
|
self.file = fname
|
||||||
|
|
||||||
class ConfigMissingApiurl(ConfigError):
|
class ConfigMissingApiurl(ConfigError):
|
||||||
"""Exception raised when a apiurl does not exist in the config file"""
|
"""Exception raised when a apiurl does not exist in the config file"""
|
||||||
def __init__(self, msg, file, url):
|
def __init__(self, msg, fname, url):
|
||||||
ConfigError.__init__(self, msg, file)
|
ConfigError.__init__(self, msg, fname)
|
||||||
self.url = url
|
self.url = url
|
||||||
|
|
||||||
class APIError(OscBaseError):
|
class APIError(OscBaseError):
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
# 2008-03-25, jw, v0.3 -- go via api using iChains and ~/.oscrc
|
# 2008-03-25, jw, v0.3 -- go via api using iChains and ~/.oscrc
|
||||||
# 2008-03-26, jw, v0.4 -- added linked file retrieval and usage.
|
# 2008-03-26, jw, v0.4 -- added linked file retrieval and usage.
|
||||||
|
|
||||||
|
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
use LWP::UserAgent;
|
use LWP::UserAgent;
|
||||||
use HTTP::Status;
|
use HTTP::Status;
|
||||||
@ -46,20 +45,20 @@ my $cfg = {
|
|||||||
|
|
||||||
unless ($self->{auth})
|
unless ($self->{auth})
|
||||||
{
|
{
|
||||||
print STDERR "Auth for $realm at $netloc\n";
|
print STDERR "Auth for $realm at $netloc\n";
|
||||||
unless (open IN, "<", "$ENV{HOME}/.oscrc")
|
unless (open IN, "<", "$ENV{HOME}/.oscrc")
|
||||||
{
|
{
|
||||||
print STDERR "$ENV{HOME}/.oscrc: $!\n";
|
print STDERR "$ENV{HOME}/.oscrc: $!\n";
|
||||||
return (undef, undef);
|
return (undef, undef);
|
||||||
}
|
}
|
||||||
while (defined (my $line = <IN>))
|
while (defined (my $line = <IN>))
|
||||||
{
|
{
|
||||||
chomp $line;
|
chomp $line;
|
||||||
$self->{auth}{pass} = $1 if $line =~ m{^pass\s*=\s*(\S+)};
|
$self->{auth}{pass} = $1 if $line =~ m{^pass\s*=\s*(\S+)};
|
||||||
$self->{auth}{user} = $1 if $line =~ m{^user\s*=\s*(\S+)};
|
$self->{auth}{user} = $1 if $line =~ m{^user\s*=\s*(\S+)};
|
||||||
}
|
}
|
||||||
close IN;
|
close IN;
|
||||||
print STDERR "~/.oscrc: user=$self->{auth}{user}\n";
|
print STDERR "~/.oscrc: user=$self->{auth}{user}\n";
|
||||||
}
|
}
|
||||||
return ($self->{auth}{user},$self->{auth}{pass});
|
return ($self->{auth}{user},$self->{auth}{pass});
|
||||||
}
|
}
|
||||||
@ -127,30 +126,30 @@ to retrieve the original specfile behind a link.
|
|||||||
if ($url =~ m{^(.*/)?linked/(.*)$})
|
if ($url =~ m{^(.*/)?linked/(.*)$})
|
||||||
{
|
{
|
||||||
$url = (defined $1) ? $1 : "$cfg->{project}/$cfg->{package}";
|
$url = (defined $1) ? $1 : "$cfg->{project}/$cfg->{package}";
|
||||||
my $file = $2;
|
my $file = $2;
|
||||||
$url = "$source/$url" if $cfg->{apiurl} and $url !~ m{://};
|
$url = "$source/$url" if $cfg->{apiurl} and $url !~ m{://};
|
||||||
print STDERR "$url\n";
|
print STDERR "$url\n";
|
||||||
my $dir = xml_parse(cred_get($url), 'merge');
|
my $dir = xml_parse(cred_get($url), 'merge');
|
||||||
my $li = $dir->{directory}{linkinfo} || die "no linkinfo in $url\n";
|
my $li = $dir->{directory}{linkinfo} || die "no linkinfo in $url\n";
|
||||||
$url = "$source/$li->{project}/$li->{package}";
|
$url = "$source/$li->{project}/$li->{package}";
|
||||||
mkdir("linked");
|
mkdir("linked");
|
||||||
|
|
||||||
if ($file =~ m{\*})
|
if ($file =~ m{\*})
|
||||||
{
|
{
|
||||||
my $dir = xml_parse(cred_get($url), 'merge');
|
my $dir = xml_parse(cred_get($url), 'merge');
|
||||||
$dir = $dir->{directory} if $dir->{directory};
|
$dir = $dir->{directory} if $dir->{directory};
|
||||||
my @list = sort map { $_->{name} } @{$dir->{entry}};
|
my @list = sort map { $_->{name} } @{$dir->{entry}};
|
||||||
my $file_re = "\Q$file\E"; $file_re =~ s{\\\*}{\.\*}g;
|
my $file_re = "\Q$file\E"; $file_re =~ s{\\\*}{\.\*}g;
|
||||||
my @match = grep { $_ =~ m{^$file_re$} } @list;
|
my @match = grep { $_ =~ m{^$file_re$} } @list;
|
||||||
die "pattern $file not found in\n @list\n" unless @match;
|
die "pattern $file not found in\n @list\n" unless @match;
|
||||||
$file = $match[0];
|
$file = $match[0];
|
||||||
}
|
}
|
||||||
$url .= "/$file";
|
$url .= "/$file";
|
||||||
|
|
||||||
print STDERR "$url -> linked/$file\n";
|
print STDERR "$url -> linked/$file\n";
|
||||||
my $r = cred_getstore($url, "linked/$file");
|
my $r = cred_getstore($url, "linked/$file");
|
||||||
print STDERR " Error: $r\n" if $r != RC_OK;
|
print STDERR " Error: $r\n" if $r != RC_OK;
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = "$cfg->{project}/$cfg->{package}/$url" unless $url =~ m{/};
|
$url = "$cfg->{project}/$cfg->{package}/$url" unless $url =~ m{/};
|
||||||
@ -179,19 +178,19 @@ for my $file (@{$dir->{entry}})
|
|||||||
if (-f $file->{name})
|
if (-f $file->{name})
|
||||||
{
|
{
|
||||||
## check the md5sum of the existing file and be happy.
|
## check the md5sum of the existing file and be happy.
|
||||||
$md5 = Digest::MD5->new;
|
$md5 = Digest::MD5->new;
|
||||||
open IN, "<", $file->{name} or die "md5sum($file->{name} failed: $!";
|
open IN, "<", $file->{name} or die "md5sum($file->{name} failed: $!";
|
||||||
$md5->addfile(*IN);
|
$md5->addfile(*IN);
|
||||||
close IN;
|
close IN;
|
||||||
if ($md5->hexdigest eq $file->{md5})
|
if ($md5->hexdigest eq $file->{md5})
|
||||||
{
|
{
|
||||||
print STDERR " - $file->{name} (md5 unchanged)\n";
|
print STDERR " - $file->{name} (md5 unchanged)\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print STDERR "Modified: $file->{name}, please commit changes!\n";
|
print STDERR "Modified: $file->{name}, please commit changes!\n";
|
||||||
}
|
}
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
print STDERR " get $file->{name}";
|
print STDERR " get $file->{name}";
|
||||||
# fixme: xsrcmd5 is obsolete.
|
# fixme: xsrcmd5 is obsolete.
|
||||||
@ -236,13 +235,13 @@ sub xml_parse
|
|||||||
my $s = $tags[$i]->{offset} + $tags[$i]->{tag_len};
|
my $s = $tags[$i]->{offset} + $tags[$i]->{tag_len};
|
||||||
if (defined $tags[$i+1])
|
if (defined $tags[$i+1])
|
||||||
{
|
{
|
||||||
my $l = $tags[$i+1]->{offset} - $s;
|
my $l = $tags[$i+1]->{offset} - $s;
|
||||||
$cdata = substr $text, $s, $l;
|
$cdata = substr $text, $s, $l;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$cdata = substr $text, $s;
|
$cdata = substr $text, $s;
|
||||||
}
|
}
|
||||||
|
|
||||||
# print "tag=$tag\n";
|
# print "tag=$tag\n";
|
||||||
my $name = $1 if $tag =~ s{<([\?/]?[\w:-]+)\s*}{};
|
my $name = $1 if $tag =~ s{<([\?/]?[\w:-]+)\s*}{};
|
||||||
@ -256,29 +255,29 @@ sub xml_parse
|
|||||||
xml_add_attr($x, $tag, $attr) unless $tag eq '';
|
xml_add_attr($x, $tag, $attr) unless $tag eq '';
|
||||||
|
|
||||||
if (!$close)
|
if (!$close)
|
||||||
{
|
{
|
||||||
delete $t->{-cdata} if $t->{-cdata} and $t->{-cdata} =~ m{^\s*$};
|
delete $t->{-cdata} if $t->{-cdata} and $t->{-cdata} =~ m{^\s*$};
|
||||||
unless ($t->{$name})
|
unless ($t->{$name})
|
||||||
{
|
{
|
||||||
$t->{$name} = $x;
|
$t->{$name} = $x;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$t->{$name} = [ $t->{$name} ] unless ref $t->{$name} eq 'ARRAY';
|
$t->{$name} = [ $t->{$name} ] unless ref $t->{$name} eq 'ARRAY';
|
||||||
push @{$t->{$name}}, $x;
|
push @{$t->{$name}}, $x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($close)
|
if ($close)
|
||||||
{
|
{
|
||||||
$t = pop @stack;
|
$t = pop @stack;
|
||||||
}
|
}
|
||||||
elsif ($nest)
|
elsif ($nest)
|
||||||
{
|
{
|
||||||
push @stack, $t;
|
push @stack, $t;
|
||||||
$t = $x;
|
$t = $x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print "stack=", Data::Dumper::Dumper(\@stack) if $verbose > 2;
|
print "stack=", Data::Dumper::Dumper(\@stack) if $verbose > 2;
|
||||||
@ -360,29 +359,28 @@ sub scalar_cdata
|
|||||||
my $val = $hash->{$key};
|
my $val = $hash->{$key};
|
||||||
if (ref $val eq 'ARRAY')
|
if (ref $val eq 'ARRAY')
|
||||||
{
|
{
|
||||||
for my $i (0..$#$val)
|
for my $i (0..$#$val)
|
||||||
{
|
{
|
||||||
scalar_cdata($hash->{$key}[$i]);
|
scalar_cdata($hash->{$key}[$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif (ref $val eq 'HASH')
|
elsif (ref $val eq 'HASH')
|
||||||
{
|
{
|
||||||
my @k = keys %$val;
|
my @k = keys %$val;
|
||||||
if (scalar(@k) == 1 && ($k[0] eq '-cdata'))
|
if (scalar(@k) == 1 && ($k[0] eq '-cdata'))
|
||||||
{
|
{
|
||||||
$hash->{$key} = $hash->{$key}{-cdata};
|
$hash->{$key} = $hash->{$key}{-cdata};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete $hash->{$key}{-cdata} if exists $val->{-cdata} && $val->{-cdata} =~ m{^\s*$};
|
delete $hash->{$key}{-cdata} if exists $val->{-cdata} && $val->{-cdata} =~ m{^\s*$};
|
||||||
scalar_cdata($hash->{$key});
|
scalar_cdata($hash->{$key});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete $hash->{$selftag};
|
delete $hash->{$selftag};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
## find_tags -- a brute force tag finder.
|
## find_tags -- a brute force tag finder.
|
||||||
## This code is robust enough to parse the weirdest HTML.
|
## This code is robust enough to parse the weirdest HTML.
|
||||||
@ -405,39 +403,39 @@ sub find_tags
|
|||||||
|
|
||||||
if ($inquotes)
|
if ($inquotes)
|
||||||
{
|
{
|
||||||
$inquotes = 0 if $what eq '"';
|
$inquotes = 0 if $what eq '"';
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($incomment)
|
if ($incomment)
|
||||||
{
|
{
|
||||||
$incomment = 0 if $what eq '-->';
|
$incomment = 0 if $what eq '-->';
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($what eq '"')
|
if ($what eq '"')
|
||||||
{
|
{
|
||||||
$inquotes = 1;
|
$inquotes = 1;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($what eq '<!--')
|
if ($what eq '<!--')
|
||||||
{
|
{
|
||||||
$incomment = 1;
|
$incomment = 1;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
next if $what eq $last; # opening and closing angular brackets are polar.
|
next if $what eq $last; # opening and closing angular brackets are polar.
|
||||||
|
|
||||||
if ($what eq '>' and scalar @tags)
|
if ($what eq '>' and scalar @tags)
|
||||||
{
|
{
|
||||||
$tags[$#tags]{tag_len} = 1 + $offset - $tags[$#tags]{offset};
|
$tags[$#tags]{tag_len} = 1 + $offset - $tags[$#tags]{offset};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($what eq '<')
|
if ($what eq '<')
|
||||||
{
|
{
|
||||||
push @tags, {name => $name, offset => $offset };
|
push @tags, {name => $name, offset => $offset };
|
||||||
}
|
}
|
||||||
|
|
||||||
$last = $what;
|
$last = $what;
|
||||||
}
|
}
|
||||||
@ -470,22 +468,20 @@ sub xml_add_attr
|
|||||||
{
|
{
|
||||||
while ($text =~ m{([\w_:-]+)\s*=("[^"]*"|'[^']'|\S*)\s*}g)
|
while ($text =~ m{([\w_:-]+)\s*=("[^"]*"|'[^']'|\S*)\s*}g)
|
||||||
{
|
{
|
||||||
my ($key, $val) = ($1, $2);
|
my ($key, $val) = ($1, $2);
|
||||||
$val =~ s{^"(.*)"$}{$1} unless $val =~ s{^'(.*)'$}{$1};
|
$val =~ s{^"(.*)"$}{$1} unless $val =~ s{^'(.*)'$}{$1};
|
||||||
if (defined($hash->{$key}))
|
if (defined($hash->{$key}))
|
||||||
{
|
{
|
||||||
## redefinition. promote to array and push.
|
## redefinition. promote to array and push.
|
||||||
$hash->{$key} = [ $hash->{$key} ] unless ref $hash->{$key};
|
$hash->{$key} = [ $hash->{$key} ] unless ref $hash->{$key};
|
||||||
push @{$hash->{$key}}, $val;
|
push @{$hash->{$key}}, $val;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$hash->{$key} = $val;
|
$hash->{$key} = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $hash;
|
return $hash;
|
||||||
}
|
}
|
||||||
die "xml_expand_attr: unknown method '$how'\n";
|
die "xml_expand_attr: unknown method '$how'\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
#################################################################
|
|
||||||
|
Loading…
Reference in New Issue
Block a user