Commit c9ec915d authored by Vitaly Lipatov's avatar Vitaly Lipatov

commit packed 3.18.0

parent c2d77d3f
...@@ -339,7 +339,7 @@ set_sudo() ...@@ -339,7 +339,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
...@@ -519,6 +519,10 @@ get_package_type() ...@@ -519,6 +519,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
...@@ -2978,10 +2982,11 @@ epm_install_files() ...@@ -2978,10 +2982,11 @@ epm_install_files()
ALTLinux|ALTServer) ALTLinux|ALTServer)
# TODO: replace with name changed function # TODO: replace with name changed function
__epm_check_if_try_install_deb $@ && return __epm_check_if_try_install_pkgtype deb $@ && return $RES
__epm_check_if_try_install_pkgtype AppImage $@ && return $RES
__epm_check_if_src_rpm $@ __epm_check_if_src_rpm $@
# do not using low-level for install by file path (FIXME: reasons?) # do not use low-level for install by file path (FIXME: reasons?)
if ! is_dirpath "$@" || [ "$(get_package_type "$@")" = "rpm" ] ; then if ! is_dirpath "$@" || [ "$(get_package_type "$@")" = "rpm" ] ; then
__epm_check_vendor $@ __epm_check_vendor $@
__epm_check_if_needed_repack $@ __epm_check_if_needed_repack $@
...@@ -3024,7 +3029,8 @@ epm_install_files() ...@@ -3024,7 +3029,8 @@ epm_install_files()
;; ;;
*-rpm) *-rpm)
__epm_check_if_try_install_deb $@ && return __epm_check_if_try_install_pkgtype deb $@ && return $RES
__epm_check_if_try_install_pkgtype AppImage $@ && return $RES
__epm_check_if_src_rpm $@ __epm_check_if_src_rpm $@
sudocmd rpm -Uvh $force $noscripts $nodeps $@ && return sudocmd rpm -Uvh $force $noscripts $nodeps $@ && return
local RES=$? local RES=$?
...@@ -3827,8 +3833,14 @@ if [ "$1" = "--remove" ] || [ "$1" = "remove" ] ; then ...@@ -3827,8 +3833,14 @@ if [ "$1" = "--remove" ] || [ "$1" = "remove" ] ; then
#__check_installed_app "$1" || warning "$1 is not installed" #__check_installed_app "$1" || warning "$1 is not installed"
prescription="$1" prescription="$1"
shift shift
if __check_play_script "$prescription" ; then
__epm_play_run $prescription --remove "$@" __epm_play_run $prescription --remove "$@"
__remove_installed_app "$prescription" __remove_installed_app "$prescription"
else
psdir=$prsdir
__check_play_script "$prescription" || fatal "We have no idea how to remove $prescription (checked in $psdir and $prsdir)"
__epm_play_run "$prescription" --remove "$@" || fatal "There was some error during run the script."
fi
exit exit
fi fi
...@@ -6261,12 +6273,16 @@ __apply_fix_code() ...@@ -6261,12 +6273,16 @@ __apply_fix_code()
__create_rpmmacros() __create_rpmmacros()
{ {
[ -n "$TMPDIR" ] || TMPDIR=/tmp
cat <<EOF >$HOME/.rpmmacros cat <<EOF >$HOME/.rpmmacros
%_topdir $HOME/RPM %_topdir $HOME/RPM
%_tmppath $TMPDIR %_tmppath $TMPDIR
%packager EPM <support@etersoft.ru> %packager EPM <support@etersoft.ru>
%_gpg_name support@etersoft.ru %_gpg_name support@etersoft.ru
%_allow_root_build 1
EOF EOF
to_remove_pkg_files="$to_remove_pkg_files $HOME/.rpmmacros" to_remove_pkg_files="$to_remove_pkg_files $HOME/.rpmmacros"
} }
...@@ -6283,9 +6299,8 @@ __epm_repack_to_rpm() ...@@ -6283,9 +6299,8 @@ __epm_repack_to_rpm()
esac esac
# install epm-repack for static (package based) dependencies # install epm-repack for static (package based) dependencies
assure_exists fakeroot || fatal
assure_exists alien || fatal assure_exists alien || fatal
assure_exists /usr/bin/rpmbuild || fatal assure_exists /usr/bin/rpmbuild rpm-build || fatal
# TODO: improve # TODO: improve
if echo "$pkgs" | grep -q "\.deb" ; then if echo "$pkgs" | grep -q "\.deb" ; then
...@@ -6323,8 +6338,22 @@ __epm_repack_to_rpm() ...@@ -6323,8 +6338,22 @@ __epm_repack_to_rpm()
PKGNAME='' PKGNAME=''
VERSION='' VERSION=''
SUBGENERIC=''
# convert tarballs to tar (for alien) # convert tarballs to tar (for alien)
if ! echo "$pkg" | grep -q "\.rpm" && ! echo "$pkg" | grep -q "\.deb" ; then if rhas "$pkg" "\.(rpm|deb)$" ; then
:
elif rhas "$pkg" "\.AppImage$" ; then
VERSION="$(echo "$alpkg" | grep -o -P "[-_.]([0-9])([0-9])*(\.[0-9])*" | head -n1 | sed -e 's|^[-_.]||')" #"
[ -n "$VERSION" ] || fatal "Can't get version from $alpkg."
PKGNAME="$(echo "$alpkg" | sed -e "s|[-_.]$VERSION.*||")"
# TODO: move repack archive to erc?
[ -x "$alpkg" ] || docmd chmod u+x -v "$alpkg"
#[ -x "$alpkg" ] || sudocmd chmod u+x -v "$abspkg"
SUBGENERIC='appimage'
./$alpkg --appimage-extract || fatal
alpkg=$PKGNAME-$VERSION.tar
erc a $alpkg squashfs-root
else
VERSION="$(echo "$alpkg" | grep -o -P "[-_.]([0-9])([0-9])*(\.[0-9])*" | head -n1 | sed -e 's|^[-_.]||')" #" VERSION="$(echo "$alpkg" | grep -o -P "[-_.]([0-9])([0-9])*(\.[0-9])*" | head -n1 | sed -e 's|^[-_.]||')" #"
if [ -n "$VERSION" ] ; then if [ -n "$VERSION" ] ; then
PKGNAME="$(echo "$alpkg" | sed -e "s|[-_.]$VERSION.*||")" PKGNAME="$(echo "$alpkg" | sed -e "s|[-_.]$VERSION.*||")"
...@@ -6345,10 +6374,10 @@ __epm_repack_to_rpm() ...@@ -6345,10 +6374,10 @@ __epm_repack_to_rpm()
cd $tmpbuilddir/ || fatal cd $tmpbuilddir/ || fatal
if [ -n "$verbose" ] ; then if [ -n "$verbose" ] ; then
docmd fakeroot alien --generate --to-rpm $verbose $scripts "../$alpkg" || fatal docmd alien --generate --to-rpm $verbose $scripts "../$alpkg" || fatal
else else
showcmd fakeroot alien --generate --to-rpm $scripts "../$alpkg" showcmd alien --generate --to-rpm $scripts "../$alpkg"
a='' fakeroot alien --generate --to-rpm $scripts "../$alpkg" >/dev/null || fatal a='' alien --generate --to-rpm $scripts "../$alpkg" >/dev/null || fatal
fi fi
local subdir="$(echo *)" local subdir="$(echo *)"
...@@ -6367,14 +6396,15 @@ __epm_repack_to_rpm() ...@@ -6367,14 +6396,15 @@ __epm_repack_to_rpm()
__fix_spec $pkgname $tmpbuilddir/$subdir $spec __fix_spec $pkgname $tmpbuilddir/$subdir $spec
__apply_fix_code "generic" $tmpbuilddir/$subdir $spec __apply_fix_code "generic" $tmpbuilddir/$subdir $spec
[ -n "$SUBGENERIC" ] && __apply_fix_code "generic-$SUBGENERIC" $tmpbuilddir/$subdir $spec
__apply_fix_code $pkgname $tmpbuilddir/$subdir $spec __apply_fix_code $pkgname $tmpbuilddir/$subdir $spec
# TODO: we need these dirs to be created # TODO: we need these dirs to be created
to_remove_pkg_dirs="$to_remove_pkg_dirs $HOME/RPM/BUILD $HOME/RPM" to_remove_pkg_dirs="$to_remove_pkg_dirs $HOME/RPM/BUILD $HOME/RPM"
showcmd fakeroot rpmbuild --buildroot $tmpbuilddir/$subdir --define='_allow_root_build 1' -bb $spec showcmd rpmbuild --buildroot $tmpbuilddir/$subdir -bb $spec
if [ -n "$verbose" ] ; then if [ -n "$verbose" ] ; then
a='' fakeroot rpmbuild --buildroot $tmpbuilddir/$subdir --define='_allow_root_build 1' -bb $spec || fatal a='' rpmbuild --buildroot $tmpbuilddir/$subdir -bb $spec || fatal
else else
a='' fakeroot rpmbuild --buildroot $tmpbuilddir/$subdir --define='_allow_root_build 1' -bb $spec >/dev/null || fatal a='' rpmbuild --buildroot $tmpbuilddir/$subdir -bb $spec >/dev/null || fatal
fi fi
# remove copy of source binary package (don't mix with generated) # remove copy of source binary package (don't mix with generated)
rm -f $tmpbuilddir/../$alpkg rm -f $tmpbuilddir/../$alpkg
...@@ -6396,14 +6426,16 @@ __epm_repack_to_rpm() ...@@ -6396,14 +6426,16 @@ __epm_repack_to_rpm()
true true
} }
__epm_check_if_try_install_deb() __epm_check_if_try_install_pkgtype()
{ {
__epm_split_by_pkg_type deb "$@" || return 1 local PKG="$1"
__epm_repack_to_rpm $split_replaced_pkgs || fatal shift
__epm_split_by_pkg_type $PKG "$@" || return 1
__epm_repack_to_rpm $split_replaced_pkgs || { RES=$? ; return 0 ; }
# TODO: move to install # TODO: move to install
docmd epm install $repacked_rpms docmd epm install $repacked_rpms
RES=$?
# TODO: move it to exit handler # TODO: move it to exit handler
if [ -z "$DEBUG" ] ; then if [ -z "$DEBUG" ] ; then
# TODO: reinvent # TODO: reinvent
...@@ -9680,6 +9712,8 @@ fatal() ...@@ -9680,6 +9712,8 @@ fatal()
exit 1 exit 1
} }
# TODO:
arch="$(uname -m)"
# copied from eepm project # copied from eepm project
...@@ -9756,10 +9790,14 @@ docmd() ...@@ -9756,10 +9790,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()
{ {
...@@ -9767,50 +9805,85 @@ set_quiet() ...@@ -9767,50 +9805,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
...@@ -9853,6 +9926,9 @@ TARGETFILE='' ...@@ -9853,6 +9926,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:
...@@ -9865,16 +9941,23 @@ fi ...@@ -9865,16 +9941,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
...@@ -9908,10 +9991,11 @@ fi ...@@ -9908,10 +9991,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"
...@@ -9948,7 +10032,8 @@ is_url() ...@@ -9948,7 +10032,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
} }
...@@ -9963,7 +10048,8 @@ fi ...@@ -9963,7 +10048,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
...@@ -10528,7 +10614,7 @@ Examples: ...@@ -10528,7 +10614,7 @@ Examples:
print_version() print_version()
{ {
echo "EPM package manager version 3.17.2 https://wiki.etersoft.ru/Epm" echo "EPM package manager version 3.18.0 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."
...@@ -10538,7 +10624,7 @@ print_version() ...@@ -10538,7 +10624,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.17.2 EPMVERSION=3.18.0
verbose=$EPM_VERBOSE verbose=$EPM_VERBOSE
quiet= quiet=
nodeps= nodeps=
......
...@@ -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