You need to sign in or sign up before continuing.
Commit ff5e9fd2 authored by Vitaly Lipatov's avatar Vitaly Lipatov

upse getopt, add -d options for download package (list only by default)

parent 4e2ddf6f
...@@ -38,6 +38,8 @@ list_systems() ...@@ -38,6 +38,8 @@ list_systems()
for ((i=0; i < ${#SYSNAME[*]}; i++)) ; do for ((i=0; i < ${#SYSNAME[*]}; i++)) ; do
printf "[%-17s] %s\n" ${SYSNAME[$i]} ${SYSURL[$i]} printf "[%-17s] %s\n" ${SYSNAME[$i]} ${SYSURL[$i]}
done done
echo
echo "You can add system to /etc/eterbuild/repos"
} }
html_filter() html_filter()
...@@ -74,6 +76,9 @@ get_list() ...@@ -74,6 +76,9 @@ get_list()
get_system_idx() get_system_idx()
{ {
if [ -z "$1" ] ; then
return 1
fi
for ((i=0; i < ${#SYSNAME[*]}; i++)) ; do for ((i=0; i < ${#SYSNAME[*]}; i++)) ; do
if [ ${SYSNAME[$i]} = "$1" ] ; then if [ ${SYSNAME[$i]} = "$1" ] ; then
echo $i echo $i
...@@ -106,77 +111,117 @@ check_name() ...@@ -106,77 +111,117 @@ check_name()
check_system() check_system()
{ {
local i
local IDX=$1 local IDX=$1
local URL=${SYSURL[$IDX]} local URL=${SYSURL[$IDX]}
#echo "Check for $SYSTEM" #echo "Check for $SYSTEM"
get_list $IDX $FORCEUPDATE get_list $IDX
#ls -l $LIST #ls -l $LIST
check_name $NAME && wget -c $URL/$NLIST check_name $NAME
if [ "$DOWNLOADALL" ] ; then
for i in $NLIST ; do
wget -c $URL/$i
done
fi
} }
update_cache_list()
{
load_systems_list
# if followed by system name
IDX=`get_system_idx "$1"`
if [ -n "$IDX" ] ; then
get_list $IDX force
shift
exit 0
fi
# update all systems
for ((i=0; i < ${#SYSNAME[*]}; i++)) ; do
get_list $i force
done
}
if [ "$1" = "-h" ]; then Usage="Usage: $name [options] [system] pkgname"
echog "Using:" function mygetopts()
{
name=${0##*/}
Descr="$name - various package download operations"
phelp()
{
# TODO: improve description
echog "$Descr"
echog "$Usage"
echog "Options:"
echog "rpmgp [-a -c -n] [system] pkgname - download src.rpm from 'system' repository to RPM/SRPMS and install it" echog "rpmgp [-a -c -n] [system] pkgname - download src.rpm from 'system' repository to RPM/SRPMS and install it"
echog " name - 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 too)" echog " system - name of system (ALT Linux by default if -a missed too)"
echog " -a check for pkgname in all known repositories" echog " -a check for pkgname in all known repositories"
echog " -b install packages needed for build (installs with sudo apt-get) (need spec not package name)"
echog " -c check for exist the package in ALT Linux repository" echog " -c check for exist the package in ALT Linux repository"
echog " -b install packages needed for build (installs with sudo apt-get)" echog " -d download all matches packages from all repositories"
echog " -l lists packages needed for build (in local pkg system notation) (experimental)" echog " -l lists packages needed for build (in local pkg system notation) (experimental)"
echog " -n do not install in RPM after download, download in current dir" echog " -n do not install in RPM after download, download in current dir"
echog " -r refresh package list (download it again)" echog " -r refresh package list (download it again)"
echog " -s lists all known systems" echog " -s lists all known systems"
exit 0 exit 0
fi }
TRYINST="1" TRYINST="1"
if [ "$1" = "-n" ] ; then while getopts :habcdlnrs opt; do
shift case $opt in
TRYINST="" h) phelp; exit 0;;
fi a) ALLSYSTEM=1 ;;
b) INSTALLBYNARY=1 ;;
c) CHECKONLINE=1 ;;
d) DOWNLOADALL=1 ;;
l) LISTREQS=1 ;;
n) TRYINST="" ;;
r) UPDATECACHE=1 ;;
s) load_systems_list
list_systems
exit 0
;;
+?) echog "$name: options should not be preceded by a '+'." 1>&2; exit 2;;
# ?) echog "$name: $OPTARG: bad option. Use -h for help." 1>&2 ; exit 2;;
?) OPTIND=$((OPTIND-1)); break;
esac
done
# list systems # FIXME: (, -i, -b)
if [ "$1" = "-s" ] ; then # remove args that were options
load_systems_list if [ $# -gt 0 ]; then
list_systems shift $((OPTIND - 1))
exit 0
fi fi
# update cache list # pass other options to RPM:
if [ "$1" = "-r" ] ; then LISTARGS=$@
load_systems_list }
FORCEUPDATE=force
shift mygetopts "$@"
# if followed by system name
IDX=`get_system_idx "$2"` # remove args that were options
if [ -n "$IDX" ] ; then if [ $# -gt 0 ]; then
get_list $IDX $FORCEUPDATE shift $((OPTIND - 1))
shift
exit 0
fi
fi fi
# check for all repos # optional arg
if [ "$1" = "-a" ] ; then if [ -n "$UPDATECACHE" ] ; then
ALLSYSTEM=1 update_cache_list $1
shift exit 0
fi fi
test -z "$1" && fatal "Please run with spec/package name" test -z "$LISTARGS" && fatal "Please run with spec/package name"
#
# , ( ?), # , ( ?),
# - # -
# #
# #
# - [] # - []
# install binary packages # install binary packages
if [ "$1" = "-b" ] ; then if [ -n "$INSTALLBYNARY" ] ; then
shift
parse_cmd_pre "$@" parse_cmd_pre "$@"
pack_src_rpm $LISTRPMARGS pack_src_rpm $LISTRPMARGS
echog "Running apt-get for install needed packages for $LISTBUILT" echog "Running apt-get for install needed packages for $LISTBUILT"
...@@ -188,16 +233,13 @@ if [ "$1" = "-b" ] ; then ...@@ -188,16 +233,13 @@ if [ "$1" = "-b" ] ; then
fi fi
# lists packages for build # lists packages for build
if [ "$1" = "-l" ] ; then if [ -n "$LISTREQS" ] ; then
shift
print_target_buildreq $1 print_target_buildreq $1
exit 0 exit 0
fi fi
# Check online # Check online
if [ "$1" = "-c" ] ; then if [ -n "$CHECKONLINE" ] ; then
shift
CHECKONLINE=1
if [ -f $1 ] ; then if [ -f $1 ] ; then
build_rpms_name "$1" build_rpms_name "$1"
SRCRPM=$NAMESRPMIN SRCRPM=$NAMESRPMIN
......
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