Commit fcf31d0e authored by Vitaly Lipatov's avatar Vitaly Lipatov

rpmgp: use parse_cmd_pre, rewrite parsing, update help

parent a872be35
...@@ -139,11 +139,10 @@ update_cache_list() ...@@ -139,11 +139,10 @@ update_cache_list()
done done
} }
Usage="Usage: $name [options] [system] pkgname" Usage="Usage: rpmgp [options] [-$CURRENTBRANCHNAME] [system] pkgname"
function mygetopts() mygetopts()
{ {
name=${0##*/} Descr="rpmgp - various package download operations"
Descr="$name - various package download operations"
phelp() phelp()
{ {
...@@ -151,8 +150,7 @@ phelp() ...@@ -151,8 +150,7 @@ phelp()
echog "$Descr" echog "$Descr"
echog "$Usage" echog "$Usage"
echog "Options:" echog "Options:"
echog "rpmgp [options] [system] pkgname - download src.rpm from 'system' repository" echog " pkgname - installed package name or src.rpm"
echog " name - installed package name or src.rpm"
echog " system - name of system (ALT Linux by default if -a missed)" echog " system - name of system (ALT Linux by default if -a missed)"
echog " -a search pkgname in all known repositories" echog " -a search pkgname in all known repositories"
echog " -c check if this package exists in the ALT Linux repository" echog " -c check if this package exists in the ALT Linux repository"
...@@ -195,15 +193,11 @@ if [ $# -gt 0 ]; then ...@@ -195,15 +193,11 @@ if [ $# -gt 0 ]; then
fi fi
# pass other options to RPM: # pass other options to RPM:
LISTARGS=$@ LISTRPMARGS=$@
} }
mygetopts "$@" parse_cmd_pre "$@"
mygetopts $LISTARGS
# remove args that were options
if [ $# -gt 0 ]; then
shift $((OPTIND - 1))
fi
# optional arg # optional arg
if [ -n "$UPDATECACHE" ] ; then if [ -n "$UPDATECACHE" ] ; then
...@@ -211,8 +205,8 @@ if [ -n "$UPDATECACHE" ] ; then ...@@ -211,8 +205,8 @@ if [ -n "$UPDATECACHE" ] ; then
exit 0 exit 0
fi fi
test -z "$LISTARGS" && fatal "Please run with spec/package name" PKGNAME=$(strip_spaces $LISTRPMARGS $LISTNAMES)
test -z "$PKGNAME" && fatal "Please run with spec/package name"
# список названий систем, адресов (с зеркалами?), и режимов фильтрации # список названий систем, адресов (с зеркалами?), и режимов фильтрации
# название кэш-файла строить из названия системы # название кэш-файла строить из названия системы
...@@ -222,7 +216,7 @@ test -z "$LISTARGS" && fatal "Please run with spec/package name" ...@@ -222,7 +216,7 @@ test -z "$LISTARGS" && fatal "Please run with spec/package name"
# install required for build binary packages # install required for build binary packages
if [ -n "$INSTALLBINARY" ] ; then if [ -n "$INSTALLBINARY" ] ; then
parse_cmd_pre "$@" # pack by LISTNAMES list
pack_src_rpm --commit $LISTRPMARGS pack_src_rpm --commit $LISTRPMARGS
LISTPKG=$(rpmquery --requires -p $LISTBUILT | clean_pkgreq | sed -e "s|rpm-build-altlinux-compat||g") LISTPKG=$(rpmquery --requires -p $LISTBUILT | clean_pkgreq | sed -e "s|rpm-build-altlinux-compat||g")
DISTRVENDOR=$(distr_vendor -d) DISTRVENDOR=$(distr_vendor -d)
...@@ -232,7 +226,6 @@ if [ -n "$INSTALLBINARY" ] ; then ...@@ -232,7 +226,6 @@ if [ -n "$INSTALLBINARY" ] ; then
fi fi
if [ -n "$MIGRATEGEAR" ] ; then if [ -n "$MIGRATEGEAR" ] ; then
parse_cmd_pre "$@"
for INFILE in $LISTNAMES ; do for INFILE in $LISTNAMES ; do
# call for each file due generated BASENAME # call for each file due generated BASENAME
LISTNAMES=$INFILE pack_src_rpm $INFILE $LISTRPMARGS LISTNAMES=$INFILE pack_src_rpm $INFILE $LISTRPMARGS
...@@ -256,7 +249,6 @@ fi ...@@ -256,7 +249,6 @@ fi
# clone remote git # clone remote git
if [ -n "$CLONEGIT" ] ; then if [ -n "$CLONEGIT" ] ; then
PKGNAME=$1
INITLETTER=$(echo $PKGNAME | cut -c1) INITLETTER=$(echo $PKGNAME | cut -c1)
# http://git.altlinux.org/gears/N/NAME.git # http://git.altlinux.org/gears/N/NAME.git
...@@ -293,16 +285,15 @@ fi ...@@ -293,16 +285,15 @@ fi
if [ -n "$CHECKONLINE" ] ; then if [ -n "$CHECKONLINE" ] ; then
# possible it is spec # possible it is spec
if [ -f $1 ] ; then if [ -f "$PKGNAME" ] ; then
build_rpms_name "$1" build_rpms_name "$PKGNAME"
SRCRPM=$NAMESRPMIN SRCRPM=$NAMESRPMIN
PKGNAME=$(get_pkgname_from_filename $SRCRPM) PKGNAME=$(get_pkgname_from_filename $SRCRPM)
else else
if echo $1 | grep -q rpm ; then if echo $PKGNAME | grep -q rpm ; then
SRCRPM=$1 SRCRPM=$PKGNAME
PKGNAME=$(get_pkgname_from_filename $SRCRPM) PKGNAME=$(get_pkgname_from_filename $SRCRPM)
else else
PKGNAME=$1
SRCRPM=$(querypackage $PKGNAME "" "%{SOURCERPM}\n" | tail -n 1) SRCRPM=$(querypackage $PKGNAME "" "%{SOURCERPM}\n" | tail -n 1)
fi fi
fi fi
...@@ -316,10 +307,9 @@ if [ -n "$CHECKONLINE" ] ; then ...@@ -316,10 +307,9 @@ if [ -n "$CHECKONLINE" ] ; then
fi fi
fi fi
list_git_package $PKGNAME list_git_package $PKGNAME
# TODO: BINARYREPO set_binaryrepo $MENV
echo -n "ACL list for sisyphus: " echo -n "ACL list for $BINARYREPO: "
ssh $GIRARHOST acl sisyphus $PKGNAME show ssh $GIRARHOST acl $BINARYREPO $PKGNAME show
RET="MISSED" RET="MISSED"
if [ -n "$SRCRPM" ] ; then if [ -n "$SRCRPM" ] ; then
for i in $REPOSITORY ; do for i in $REPOSITORY ; do
...@@ -336,6 +326,8 @@ if [ -n "$CHECKONLINE" ] ; then ...@@ -336,6 +326,8 @@ if [ -n "$CHECKONLINE" ] ; then
exit 0 exit 0
fi fi
# FIXME: use mygetopts (LISTRPMARGS and so)
if [ -n "$2" ] && [ "$1" = "all" ] ; then if [ -n "$2" ] && [ "$1" = "all" ] ; then
shift shift
ALLSYSTEM=1 ALLSYSTEM=1
......
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