Commit a373c3d4 authored by Vitaly Lipatov's avatar Vitaly Lipatov

rpmbugs: rewrite very obsoleted code, add spec detection

parent 44cce1b5
...@@ -22,7 +22,7 @@ show_bugs() ...@@ -22,7 +22,7 @@ show_bugs()
URL=$1 URL=$1
if [ -z "$TEXT" ] ; then if [ -z "$TEXT" ] ; then
#echog "Opening URL '$URL' in browser $BROWSER" #echog "Opening URL '$URL' in browser $BROWSER"
docmd $BROWSER $URL & docmd $BROWSER $URL
else else
#echo "@Fetching from '$URL'..." #echo "@Fetching from '$URL'..."
# FIXME: BROWSER can be some unknown program called links # FIXME: BROWSER can be some unknown program called links
...@@ -37,12 +37,28 @@ show_bugbyid() ...@@ -37,12 +37,28 @@ show_bugbyid()
show_bugs "$URLSHOWBUG" show_bugs "$URLSHOWBUG"
} }
clean_args()
{
if [ -n "$2" ] && rhas "$1" ".spec" ; then
shift
fi
echo "$@"
}
check_qf()
{
[ "$1" = "-qf" ] || return
shift
docmd epmqf --short "$1" | xargs --no-run-if-empty -- $ETERBUILDBIN/rpmbugs
}
#parse_cmd_pre "$@"
mygetopts()
{
if [ "$1" = "-h" ]; then if [ "$1" = "-h" ]; then
echog "rpmbugs - open bugs in BROWSER" echog "rpmbugs - open bugs in BROWSER"
echog "rpmbugs [-t] spec | bug number | package name | -qf command_name | /path/to/file" echog "rpmbugs [-t] [spec] | bug number | package name | -qf command_name | /path/to/file"
echo echo
echog "Options:" echog "Options:"
echog " -t list in text console" echog " -t list in text console"
...@@ -60,37 +76,41 @@ if [ "$1" = "-t" ] ; then ...@@ -60,37 +76,41 @@ if [ "$1" = "-t" ] ; then
which links >/dev/null && BROWSER=links which links >/dev/null && BROWSER=links
fi fi
}
parse_cmd_pre_spec "$@"
LISTNAMES=$(clean_args $LISTNAMES $LISTRPMARGS $LISTARGS)
mygetopts $LISTARGS
check_qf $LISTNAMES && exit
if ! check_display ; then if ! check_display ; then
TEXT=1 TEXT=1
which links >/dev/null && BROWSER=links which links >/dev/null && BROWSER=links
fi fi
SPECLIST=$@
if [ "$1" = "-qf" ]
then
shift
SPECLIST=$(rpmqf "$1")
if [ -e "$1" ] ; then
SPECLIST=$(querypackage $SPECLIST NAME)
fi
fi
# if param is number is_number()
if [ -z `echo ${1} | sed -e "s/[0-9]*//"` ] ; then {
show_bugbyid "$1" rhas "$@" "^[0-9]+$"
}
if is_number "$LISTNAMES" ; then
show_bugbyid "$LISTNAMES"
exit exit
fi fi
for i in $SPECLIST ; do i=$LISTNAMES
if [ -f $i ] if [ -f $i ]
then then
# TODO: strange code
if [ -z ${i/*rpm/} ] if [ -z ${i/*rpm/} ]
then then
# it is rpm package # it is rpm package
PKGNAME=$(querypackage $i NAME) PKGNAME=$(querypackage $i NAME)
else else
PKGNAME=$(get_name $i) PKGNAME=$(get_name $i)
test -z ${PKGNAME} && fatal "Cannot get package name" test -z ${PKGNAME} && fatal "Cannot get package name from $i"
fi fi
else else
# yes, DD=$(false) || DD=other works # yes, DD=$(false) || DD=other works
...@@ -110,5 +130,3 @@ for i in $SPECLIST ; do ...@@ -110,5 +130,3 @@ for i in $SPECLIST ; do
URLBUGLIST="$BUGZILLAURL/buglist.cgi?product=$PRODUCT&component=$PKGNAME&component_type=equals&simple=1" URLBUGLIST="$BUGZILLAURL/buglist.cgi?product=$PRODUCT&component=$PKGNAME&component_type=equals&simple=1"
show_bugs "$URLBUGLIST" | grep "@" show_bugs "$URLBUGLIST" | grep "@"
fi fi
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment