Commit bd750195 authored by Vitaly Lipatov's avatar Vitaly Lipatov

commit packed 3.21.8

parent ef6ee9d4
...@@ -10170,6 +10170,12 @@ sget() ...@@ -10170,6 +10170,12 @@ sget()
fi fi
} }
check_url_http()
{
local URL="$1"
__wget --spider -S "$URL" 2>&1 | grep "HTTP" | tail -n1 | grep -q -w "200\|301"
}
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"
...@@ -10197,6 +10203,13 @@ sget() ...@@ -10197,6 +10203,13 @@ sget()
__curl $CURLNAMEOPTIONS "$1" __curl $CURLNAMEOPTIONS "$1"
fi fi
} }
check_url_http()
{
local URL="$1"
__curl -I "$URL" 2>&1 | grep "HTTP" | tail -n1 | grep -q -w "200\|301"
}
fi fi
LISTONLY='' LISTONLY=''
...@@ -10206,6 +10219,14 @@ if [ "$1" = "--list" ] ; then ...@@ -10206,6 +10219,14 @@ if [ "$1" = "--list" ] ; then
shift shift
fi fi
if [ "$1" = "--check" ] ; then
set_quiet
shift
check_url_http "$1"
return
fi
LATEST='' LATEST=''
if [ "$1" = "--latest" ] ; then if [ "$1" = "--latest" ] ; then
LATEST="$1" LATEST="$1"
...@@ -10260,6 +10281,7 @@ if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then ...@@ -10260,6 +10281,7 @@ if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
echo " -U|-A|--user-agent - send browser like UserAgent" 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 " --check - check if URL is accessible (returns HTTP 200 OK)"
echo " --latest - print only latest version of a 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"
...@@ -10267,6 +10289,7 @@ if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then ...@@ -10267,6 +10289,7 @@ if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
echo "Examples:" echo "Examples:"
echo " $ eget --list http://ftp.somesite.ru/package-*.tar" echo " $ eget --list http://ftp.somesite.ru/package-*.tar"
echo " $ eget http://ftp.somesite.ru/package-*.x64.tar" echo " $ eget http://ftp.somesite.ru/package-*.x64.tar"
echo " $ eget --check http://ftp.somesite.ru/test"
echo " $ eget --list http://download.somesite.ru 'package-*.tar.xz'" echo " $ eget --list http://download.somesite.ru 'package-*.tar.xz'"
echo " $ eget --list --latest https://github.com/telegramdesktop/tdesktop/releases 'tsetup.*.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"
...@@ -10341,6 +10364,16 @@ is_url() ...@@ -10341,6 +10364,16 @@ is_url()
echo "$1" | grep -q "://" echo "$1" | grep -q "://"
} }
# Args: URL filename
make_fileurl()
{
local url="$1"
local fn="$2"
fn="$(echo "$fn" | sed -e 's|^./||' -e 's|^/+||')"
# workaround for a slash in the end of URL
echo "$(echo "$url" | sed -e 's|/*$||')/$fn"
}
get_urls() get_urls()
{ {
# cat html, divide to lines by tags and cut off hrefs only # cat html, divide to lines by tags and cut off hrefs only
...@@ -10351,15 +10384,14 @@ get_urls() ...@@ -10351,15 +10384,14 @@ get_urls()
if [ -n "$LISTONLY" ] ; then if [ -n "$LISTONLY" ] ; then
for fn in $(get_urls | filter_glob "$MASK" | filter_order) ; do for fn in $(get_urls | filter_glob "$MASK" | filter_order) ; do
is_url "$fn" && echo $fn && continue is_url "$fn" && echo $fn && continue
fn="$(echo "$fn" | sed -e 's|^./||' -e 's|^/+||')" make_fileurl "$URL" "$fn"
echo "$URL/$fn"
done done
return return
fi 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
is_url "$fn" || fn="$URL/$(basename "$fn")" is_url "$fn" || fn="$(make_fileurl "$URL" "$(basename "$fn")" )" #"
sget "$fn" || ERROR=1 sget "$fn" || ERROR=1
done done
return $ERROR return $ERROR
...@@ -10950,7 +10982,7 @@ Examples: ...@@ -10950,7 +10982,7 @@ Examples:
print_version() print_version()
{ {
echo "EPM package manager version 3.21.7 https://wiki.etersoft.ru/Epm" echo "EPM package manager version 3.21.8 https://wiki.etersoft.ru/Epm"
echo "Running on $($DISTRVENDOR -e) ('$PMTYPE' package manager uses '$PKGFORMAT' package format)" echo "Running on $($DISTRVENDOR -e) ('$PMTYPE' package manager uses '$PKGFORMAT' package format)"
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."
...@@ -10960,7 +10992,7 @@ print_version() ...@@ -10960,7 +10992,7 @@ print_version()
Usage="Usage: epm [options] <command> [package name(s), package files]..." Usage="Usage: epm [options] <command> [package name(s), package files]..."
Descr="epm - EPM package manager" Descr="epm - EPM package manager"
EPMVERSION=3.21.7 EPMVERSION=3.21.8
verbose=$EPM_VERBOSE verbose=$EPM_VERBOSE
quiet= quiet=
nodeps= nodeps=
......
...@@ -2260,7 +2260,7 @@ print_version() ...@@ -2260,7 +2260,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.21.7 https://wiki.etersoft.ru/Epm" echo "Service manager version 3.21.8 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