Commit c9ec915d authored by Vitaly Lipatov's avatar Vitaly Lipatov

commit packed 3.18.0

parent c2d77d3f
......@@ -330,7 +330,7 @@ set_sudo()
else
# use sudo if one is tuned and tuned without password
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"
fi
fi
......@@ -510,6 +510,10 @@ get_package_type()
echo "msi"
return
;;
*.AppImage)
echo "AppImage"
return
;;
*)
#fatal "Don't know type of $1"
# return package name for info
......@@ -2165,6 +2169,8 @@ fatal()
exit 1
}
# TODO:
arch="$(uname -m)"
# copied from eepm project
......@@ -2241,10 +2247,14 @@ docmd()
check_tty
WGETNOSSLCHECK=''
CURLNOSSLCHECK=''
WGETUSERAGENT=''
CURLUSERAGENT=''
WGETQ='' #-q
CURLQ='' #-s
WGETOPTIONS='--content-disposition'
CURLOPTIONS='--remote-name --remote-header-name'
WGETNAMEOPTIONS='--content-disposition'
CURLNAMEOPTIONS='--remote-name --remote-header-name'
set_quiet()
{
......@@ -2252,50 +2262,85 @@ set_quiet()
CURLQ='-s'
}
# TODO: parse options in a good way
# TODO: passthrou all wget options
if [ "$1" = "-q" ] ; then
set_quiet
shift
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)"
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
scat()
{
docmd $WGET $WGETQ -O- "$1"
__wget -O- "$1"
}
# download to default name of to $2
sget()
{
if [ -n "$2" ] ; then
docmd $WGET $WGETQ $WGETOPTIONS -O "$2" "$1"
if [ "$2" = "/dev/stdout" ] || [ "$2" = "-" ] ; then
scat "$1"
elif [ -n "$2" ] ; then
docmd __wget -O "$2" "$1"
else
# TODO: поддержка rsync для известных хостов?
# Не качать, если одинаковый размер и дата
# -nc
# TODO: overwrite always
docmd $WGET $WGETQ $WGETOPTIONS "$1"
docmd __wget $WGETNAMEOPTIONS "$1"
fi
}
else
CURL="$(which curl 2>/dev/null)"
[ -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
scat()
{
$CURL -L $CURLQ "$1"
__curl "$1"
}
# download to default name of to $2
sget()
{
if [ -n "$2" ] ; then
docmd $CURL -L $CURLQ $CURLOPTIONS --output "$2" "$1"
if [ "$2" = "/dev/stdout" ] || [ "$2" = "-" ] ; then
scat "$1"
elif [ -n "$2" ] ; then
__curl --output "$2" "$1"
else
docmd $CURL -L $CURLQ $CURLOPTIONS -O "$1"
__curl $CURLNAMEOPTIONS "$1"
fi
}
fi
......@@ -2338,6 +2383,9 @@ TARGETFILE=''
if [ "$1" = "-O" ] ; then
TARGETFILE="$2"
shift 2
elif [ "$1" = "-O-" ] ; then
TARGETFILE="-"
shift 1
fi
# TODO:
......@@ -2350,16 +2398,23 @@ fi
if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
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 "Options:"
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 " --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 "eget supports --list and download for https://github.com/owner/project urls"
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"
return
fi
......@@ -2393,10 +2448,11 @@ fi
# 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"
fi
# TODO: curl?
# If ftp protocol, just download
if echo "$1" | grep -q "^ftp://" ; then
[ -n "$LISTONLY" ] && fatal "TODO: list files for ftp:// do not supported yet"
......@@ -2433,7 +2489,8 @@ is_url()
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
}
......@@ -2448,7 +2505,8 @@ fi
ERROR=0
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
return $ERROR
......@@ -3081,7 +3139,7 @@ print_version()
local on_text="(host system)"
local virt="$($DISTRVENDOR -i)"
[ "$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 "Copyright (c) Etersoft 2012-2021"
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