Commit c9ec915d authored by Vitaly Lipatov's avatar Vitaly Lipatov

commit packed 3.18.0

parent c2d77d3f
...@@ -330,7 +330,7 @@ set_sudo() ...@@ -330,7 +330,7 @@ set_sudo()
else else
# use sudo if one is tuned and tuned without password # use sudo if one is tuned and tuned without password
if ! $SUDO_CMD -l -n >/dev/null 2>/dev/null ; then if ! $SUDO_CMD -l -n >/dev/null 2>/dev/null ; then
[ "$nofail" = "nofail" ] || SUDO="fatal 'Can't use sudo (only without password sudo is supported). Please run epm under root.'" [ "$nofail" = "nofail" ] || SUDO="fatal 'Can't use sudo (only without password sudo is supported). Please run epm under root or check http://altlinux.org/sudo.'"
return "$SUDO_TESTED" return "$SUDO_TESTED"
fi fi
fi fi
...@@ -510,6 +510,10 @@ get_package_type() ...@@ -510,6 +510,10 @@ get_package_type()
echo "msi" echo "msi"
return return
;; ;;
*.AppImage)
echo "AppImage"
return
;;
*) *)
#fatal "Don't know type of $1" #fatal "Don't know type of $1"
# return package name for info # return package name for info
...@@ -2165,6 +2169,8 @@ fatal() ...@@ -2165,6 +2169,8 @@ fatal()
exit 1 exit 1
} }
# TODO:
arch="$(uname -m)"
# copied from eepm project # copied from eepm project
...@@ -2241,10 +2247,14 @@ docmd() ...@@ -2241,10 +2247,14 @@ docmd()
check_tty check_tty
WGETNOSSLCHECK=''
CURLNOSSLCHECK=''
WGETUSERAGENT=''
CURLUSERAGENT=''
WGETQ='' #-q WGETQ='' #-q
CURLQ='' #-s CURLQ='' #-s
WGETOPTIONS='--content-disposition' WGETNAMEOPTIONS='--content-disposition'
CURLOPTIONS='--remote-name --remote-header-name' CURLNAMEOPTIONS='--remote-name --remote-header-name'
set_quiet() set_quiet()
{ {
...@@ -2252,50 +2262,85 @@ set_quiet() ...@@ -2252,50 +2262,85 @@ set_quiet()
CURLQ='-s' CURLQ='-s'
} }
# TODO: parse options in a good way
# TODO: passthrou all wget options # TODO: passthrou all wget options
if [ "$1" = "-q" ] ; then if [ "$1" = "-q" ] ; then
set_quiet set_quiet
shift shift
fi fi
if [ "$1" = "-k" ] || [ "$1" = "--no-check-certificate" ] ; then
WGETNOSSLCHECK='--no-check-certificate'
CURLNOSSLCHECK='-k'
shift
fi
if [ "$1" = "-U" ] || [ "$1" = "-A" ] || [ "$1" = "--user-agent" ] ; then
user_agent="Mozilla/5.0 (X11; Linux $arch)"
WGETUSERAGENT="-U '$user_agent'"
CURLUSERAGENT="-A '$user_agent'"
shift
fi
WGET="$(which wget 2>/dev/null)" WGET="$(which wget 2>/dev/null)"
if [ -n "$WGET" ] ; then if [ -n "$WGET" ] ; then
__wget()
{
if [ -n "$WGETUSERAGENT" ] ; then
docmd $WGET $WGETQ $WGETNOSSLCHECK "$WGETUSERAGENT" "$@"
else
docmd $WGET $WGETQ $WGETNOSSLCHECK "$@"
fi
}
# put remote content to stdout # put remote content to stdout
scat() scat()
{ {
docmd $WGET $WGETQ -O- "$1" __wget -O- "$1"
} }
# download to default name of to $2 # download to default name of to $2
sget() sget()
{ {
if [ -n "$2" ] ; then if [ "$2" = "/dev/stdout" ] || [ "$2" = "-" ] ; then
docmd $WGET $WGETQ $WGETOPTIONS -O "$2" "$1" scat "$1"
elif [ -n "$2" ] ; then
docmd __wget -O "$2" "$1"
else else
# TODO: поддержка rsync для известных хостов? # TODO: поддержка rsync для известных хостов?
# Не качать, если одинаковый размер и дата # Не качать, если одинаковый размер и дата
# -nc # -nc
# TODO: overwrite always # TODO: overwrite always
docmd $WGET $WGETQ $WGETOPTIONS "$1" docmd __wget $WGETNAMEOPTIONS "$1"
fi fi
} }
else else
CURL="$(which curl 2>/dev/null)" CURL="$(which curl 2>/dev/null)"
[ -n "$CURL" ] || fatal "There are no wget nor curl in the system. Install it with $ epm install curl" [ -n "$CURL" ] || fatal "There are no wget nor curl in the system. Install it with $ epm install curl"
__curl()
{
if [ -n "$CURLUSERAGENT" ] ; then
docmd $CURL -L $CURLQ "$CURLUSERAGENT" $CURLNOSSLCHECK "$@"
else
docmd $CURL -L $CURLQ $CURLNOSSLCHECK "$@"
fi
}
# put remote content to stdout # put remote content to stdout
scat() scat()
{ {
$CURL -L $CURLQ "$1" __curl "$1"
} }
# download to default name of to $2 # download to default name of to $2
sget() sget()
{ {
if [ -n "$2" ] ; then if [ "$2" = "/dev/stdout" ] || [ "$2" = "-" ] ; then
docmd $CURL -L $CURLQ $CURLOPTIONS --output "$2" "$1" scat "$1"
elif [ -n "$2" ] ; then
__curl --output "$2" "$1"
else else
docmd $CURL -L $CURLQ $CURLOPTIONS -O "$1" __curl $CURLNAMEOPTIONS "$1"
fi fi
} }
fi fi
...@@ -2338,6 +2383,9 @@ TARGETFILE='' ...@@ -2338,6 +2383,9 @@ TARGETFILE=''
if [ "$1" = "-O" ] ; then if [ "$1" = "-O" ] ; then
TARGETFILE="$2" TARGETFILE="$2"
shift 2 shift 2
elif [ "$1" = "-O-" ] ; then
TARGETFILE="-"
shift 1
fi fi
# TODO: # TODO:
...@@ -2350,16 +2398,23 @@ fi ...@@ -2350,16 +2398,23 @@ fi
if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
echo "eget - wget like downloader wrapper with wildcard support in filename part of URL" echo "eget - wget like downloader wrapper with wildcard support in filename part of URL"
echo "Usage: eget [-q] [-O target file] [--list] http://somesite.ru/dir/na*.log" echo "Usage: eget [-q] [-k] [-U] [-O target file] [--list] http://somesite.ru/dir/na*.log"
echo echo
echo "Options:" echo "Options:"
echo " -q - quiet mode" echo " -q - quiet mode"
echo " -k|--no-check-certificate - skip SSL certificate chain support"
echo " -U|-A|--user-agent - send browser like UserAgent"
echo " -O file - download to this file (use filename from server if missed)" echo " -O file - download to this file (use filename from server if missed)"
echo " --list - print files from url with mask" echo " --list - print files from url with mask"
echo " --latest - print only latest version of file" echo " --latest - print only latest version of a file"
echo echo
echo "eget supports --list and download for https://github.com/owner/project urls" echo "eget supports --list and download for https://github.com/owner/project urls"
echo echo
echo "Examples:"
echo " $ eget --list http://ftp.somesite.ru/package-*.tar"
echo " $ eget http://ftp.somesite.ru/package-*.x64.tar"
echo " $ eget --list http://download.somesite.ru 'package-*.tar.xz'"
echo " $ eget --list --latest https://github.com/telegramdesktop/tdesktop/releases 'tsetup.*.tar.xz'"
# echo "See $ wget --help for wget options you can use here" # echo "See $ wget --help for wget options you can use here"
return return
fi fi
...@@ -2393,10 +2448,11 @@ fi ...@@ -2393,10 +2448,11 @@ fi
# do not support / # do not support /
if echo "$1" | grep -q "/$" ; then if echo "$1" | grep -q "/$" && [ -z "$2" ] ; then
fatal "Use http://example.com/e/* to download all files in dir" fatal "Use http://example.com/e/* to download all files in dir"
fi fi
# TODO: curl?
# If ftp protocol, just download # If ftp protocol, just download
if echo "$1" | grep -q "^ftp://" ; then if echo "$1" | grep -q "^ftp://" ; then
[ -n "$LISTONLY" ] && fatal "TODO: list files for ftp:// do not supported yet" [ -n "$LISTONLY" ] && fatal "TODO: list files for ftp:// do not supported yet"
...@@ -2433,7 +2489,8 @@ is_url() ...@@ -2433,7 +2489,8 @@ is_url()
get_urls() get_urls()
{ {
scat $URL/ | \ # cat html, divide to lines by tags and cut off hrefs only
scat $URL | sed -e 's|<|<\n|g' | \
grep -i -o -E 'href="(.+)"' | cut -d'"' -f2 grep -i -o -E 'href="(.+)"' | cut -d'"' -f2
} }
...@@ -2448,7 +2505,8 @@ fi ...@@ -2448,7 +2505,8 @@ fi
ERROR=0 ERROR=0
for fn in $(get_urls | filter_glob "$MASK" | filter_order) ; do for fn in $(get_urls | filter_glob "$MASK" | filter_order) ; do
sget "$URL/$(basename "$fn")" || ERROR=1 is_url "$fn" || fn="$URL/$(basename "$fn")"
sget "$fn" || ERROR=1
done done
return $ERROR return $ERROR
...@@ -3081,7 +3139,7 @@ print_version() ...@@ -3081,7 +3139,7 @@ print_version()
local on_text="(host system)" local on_text="(host system)"
local virt="$($DISTRVENDOR -i)" local virt="$($DISTRVENDOR -i)"
[ "$virt" = "(unknown)" ] || [ "$virt" = "(host system)" ] || on_text="(under $virt)" [ "$virt" = "(unknown)" ] || [ "$virt" = "(host system)" ] || on_text="(under $virt)"
echo "Service manager version 3.17.2 https://wiki.etersoft.ru/Epm" echo "Service manager version 3.18.0 https://wiki.etersoft.ru/Epm"
echo "Running on $($DISTRVENDOR -e) $on_text with $SERVICETYPE" echo "Running on $($DISTRVENDOR -e) $on_text with $SERVICETYPE"
echo "Copyright (c) Etersoft 2012-2021" echo "Copyright (c) Etersoft 2012-2021"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3." echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
......
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