Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
eepm
Commits
db3edf22
Commit
db3edf22
authored
Apr 12, 2023
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit packed 3.50.0
parent
714d5b32
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
859 additions
and
57 deletions
+859
-57
epm.sh
packed/epm.sh
+852
-52
serv.sh
packed/serv.sh
+7
-5
No files found.
packed/epm.sh
View file @
db3edf22
...
@@ -33,9 +33,15 @@ SHAREDIR=$PROGDIR
...
@@ -33,9 +33,15 @@ SHAREDIR=$PROGDIR
# will replaced with /etc/eepm during install
# will replaced with /etc/eepm during install
CONFIGDIR
=
$PROGDIR
/../etc
CONFIGDIR
=
$PROGDIR
/../etc
EPMVERSION
=
"3.
42
.0"
EPMVERSION
=
"3.
50
.0"
if
[
"
$EPMVERSION
"
=
"@""VERSION""@"
]
;
then
# package, single (file), pipe, git
EPMMODE
=
"package"
[
"
$SHAREDIR
"
=
"
$PROGDIR
"
]
&&
EPMMODE
=
"single"
[
"
$EPMVERSION
"
=
"@""VERSION""@"
]
&&
EPMMODE
=
"git"
[
"
$PROGNAME
"
=
""
]
&&
EPMMODE
=
"pipe"
if
[
"
$EPMMODE
"
=
"git"
]
;
then
EPMVERSION
=
$(
head
$PROGDIR
/../eepm.spec |
grep
"^Version: "
|
sed
-e
's|Version: ||'
)
EPMVERSION
=
$(
head
$PROGDIR
/../eepm.spec |
grep
"^Version: "
|
sed
-e
's|Version: ||'
)
fi
fi
...
@@ -511,7 +517,7 @@ disabled_eget()
...
@@ -511,7 +517,7 @@ disabled_eget()
local
EGET
local
EGET
# use internal eget only if exists
# use internal eget only if exists
if
[
-s
$SHAREDIR
/tools_eget
]
;
then
if
[
-s
$SHAREDIR
/tools_eget
]
;
then
$SHAREDIR
/tools_eget
"
$@
"
(
EGET_BACKEND
=
$eget_backend
$SHAREDIR
/tools_eget
"
$@
"
)
return
return
fi
fi
fatal
"Internal error: missed tools_eget"
fatal
"Internal error: missed tools_eget"
...
@@ -1366,6 +1372,9 @@ case $PMTYPE in
...
@@ -1366,6 +1372,9 @@ case $PMTYPE in
pkgng
)
pkgng
)
sudocmd pkg audit
-F
sudocmd pkg audit
-F
;;
;;
apk
)
sudocmd apk audit
;;
*
)
*
)
fatal
"Have no suitable command for
$PMTYPE
"
fatal
"Have no suitable command for
$PMTYPE
"
;;
;;
...
@@ -1993,6 +2002,9 @@ case $PMTYPE in
...
@@ -1993,6 +2002,9 @@ case $PMTYPE in
xbps
)
xbps
)
sudocmd xbps-pkgdb
-a
sudocmd xbps-pkgdb
-a
;;
;;
apk
)
sudocmd apk fix
;;
*
)
*
)
fatal
"Have no suitable command for
$PMTYPE
"
fatal
"Have no suitable command for
$PMTYPE
"
;;
;;
...
@@ -2024,6 +2036,9 @@ check_pkg_integrity()
...
@@ -2024,6 +2036,9 @@ check_pkg_integrity()
# FIXME: debsums -ca package ?
# FIXME: debsums -ca package ?
docmd dpkg
--contents
$PKG
>
/dev/null
&&
echo
"Package
$PKG
is correct."
docmd dpkg
--contents
$PKG
>
/dev/null
&&
echo
"Package
$PKG
is correct."
;;
;;
apk
)
docmd apkg verify
$PKG
;;
exe
)
exe
)
file
$PKG
|
grep
-q
"executable for MS Windows"
file
$PKG
|
grep
-q
"executable for MS Windows"
;;
;;
...
@@ -2871,8 +2886,8 @@ __epm_korinf_list() {
...
@@ -2871,8 +2886,8 @@ __epm_korinf_list() {
__epm_korinf_install
()
{
__epm_korinf_install
()
{
#
skip interactive for install eepm from stdin
#
enable interactive for install eepm from console
if
inputisatty
&&
[
-n
"
$PROGDIR
"
]
&&
[
"
$1
"
!
=
"eepm"
]
;
then
if
inputisatty
&&
[
-n
"
$PROGDIR
"
]
&&
[
"
$1
"
=
"eepm"
]
;
then
[
-n
"
$non_interactive
"
]
||
interactive
=
"--interactive"
[
-n
"
$non_interactive
"
]
||
interactive
=
"--interactive"
fi
fi
...
@@ -3063,6 +3078,10 @@ __epm_filelist_name()
...
@@ -3063,6 +3078,10 @@ __epm_filelist_name()
opkg
)
opkg
)
CMD
=
"opkg files"
CMD
=
"opkg files"
;;
;;
apk
)
docmd apk manifest
$@
|
sed
-e
's|^sha1.* |/|'
return
;;
eopkg
)
eopkg
)
docmd eopkg
--files
-s
info
$@
|
grep
"^/"
docmd eopkg
--files
-s
info
$@
|
grep
"^/"
return
return
...
@@ -3439,6 +3458,9 @@ case $PMTYPE in
...
@@ -3439,6 +3458,9 @@ case $PMTYPE in
opkg
)
opkg
)
docmd opkg info
$pkg_names
docmd opkg info
$pkg_names
;;
;;
apk
)
docmd apk info
$pkg_names
;;
pkgng
)
pkgng
)
docmd pkg info
$pkg_names
docmd pkg info
$pkg_names
;;
;;
...
@@ -3765,6 +3787,12 @@ __epm_if_command_path()
...
@@ -3765,6 +3787,12 @@ __epm_if_command_path()
is_dirpath
"
$1
"
&&
rhas
"
$1
"
"bin/"
is_dirpath
"
$1
"
&&
rhas
"
$1
"
"bin/"
}
}
__epm_get_replacepkgs
()
{
[
-n
"
$2
"
]
&&
echo
'--replacepkgs'
&&
return
# don't use --replacepkgs when install only one file
}
epm_install_files
()
epm_install_files
()
{
{
local
files
=
"
$*
"
local
files
=
"
$*
"
...
@@ -3802,9 +3830,7 @@ epm_install_files()
...
@@ -3802,9 +3830,7 @@ epm_install_files()
fi
fi
# --replacepkgs: Install the Package Even If Already Installed
# --replacepkgs: Install the Package Even If Already Installed
local
replacepkgs
=
'--replacepkgs'
local
replacepkgs
=
"
$(
__epm_get_replacepkgs
$files
)
"
# don't use --replacepkgs when install only one file
[
-f
"
$files
"
]
&&
replacepkgs
=
''
sudocmd rpm
-Uvh
$replacepkgs
$(
subst_option dryrun
--test
)
$force
$noscripts
$nodeps
$files
&&
save_installed_packages
$files
&&
return
sudocmd rpm
-Uvh
$replacepkgs
$(
subst_option dryrun
--test
)
$force
$noscripts
$nodeps
$files
&&
save_installed_packages
$files
&&
return
local
RES
=
$?
local
RES
=
$?
# TODO: check rpm result code and convert it to compatible format if possible
# TODO: check rpm result code and convert it to compatible format if possible
...
@@ -3826,9 +3852,7 @@ epm_install_files()
...
@@ -3826,9 +3852,7 @@ epm_install_files()
epm
install
$(
epm req
--short
$files
)
||
return
epm
install
$(
epm req
--short
$files
)
||
return
# retry with rpm
# retry with rpm
# --replacepkgs: Install the Package Even If Already Installed
# --replacepkgs: Install the Package Even If Already Installed
local
replacepkgs
=
'--replacepkgs'
local
replacepkgs
=
"
$(
__epm_get_replacepkgs
$files
)
"
# don't use --replacepkgs when install only one file
[
-f
"
$files
"
]
&&
replacepkgs
=
''
sudocmd rpm
-Uvh
$replacepkgs
$(
subst_option dryrun
--test
)
$force
$noscripts
$nodeps
$files
&&
save_installed_packages
$files
sudocmd rpm
-Uvh
$replacepkgs
$(
subst_option dryrun
--test
)
$force
$noscripts
$nodeps
$files
&&
save_installed_packages
$files
return
return
fi
fi
...
@@ -3915,9 +3939,7 @@ epm_install_files()
...
@@ -3915,9 +3939,7 @@ epm_install_files()
__epm_check_if_src_rpm
$files
__epm_check_if_src_rpm
$files
# --replacepkgs: Install the Package Even If Already Installed
# --replacepkgs: Install the Package Even If Already Installed
local
replacepkgs
=
'--replacepkgs'
local
replacepkgs
=
"
$(
__epm_get_replacepkgs
$files
)
"
# don't use --replacepkgs when install only one file
[
-f
"
$files
"
]
&&
replacepkgs
=
''
sudocmd rpm
-Uvh
$replacepkgs
$(
subst_option dryrun
--test
)
$force
$noscripts
$nodeps
$files
&&
return
sudocmd rpm
-Uvh
$replacepkgs
$(
subst_option dryrun
--test
)
$force
$noscripts
$nodeps
$files
&&
return
local
RES
=
$?
local
RES
=
$?
...
@@ -5084,7 +5106,7 @@ __run_script()
...
@@ -5084,7 +5106,7 @@ __run_script()
[
-f
"
$script
.rpmnew"
]
&&
warning
"There is .rpmnew file(s) in
$psdir
dir. The play script can be outdated."
[
-f
"
$script
.rpmnew"
]
&&
warning
"There is .rpmnew file(s) in
$psdir
dir. The play script can be outdated."
shift
shift
(
unset
EPMCURDIR
;
$script
"
$@
"
)
(
unset
EPMCURDIR
;
export
PATH
=
$PROGDIR
:
$PATH
;
$script
"
$@
"
)
return
return
}
}
...
@@ -5170,8 +5192,6 @@ __epm_play_run()
...
@@ -5170,8 +5192,6 @@ __epm_play_run()
local
script
=
"
$psdir
/
$1
.sh"
local
script
=
"
$psdir
/
$1
.sh"
shift
shift
# TODO: use epm print info instead of one?
# we will have DISTRVENDOR there
export
PATH
=
$PROGDIR
:
$PATH
export
PATH
=
$PROGDIR
:
$PATH
set_sudo
set_sudo
...
@@ -5367,6 +5387,7 @@ __epm_play_install()
...
@@ -5367,6 +5387,7 @@ __epm_play_install()
epm_play
()
epm_play
()
{
{
[
"
$EPMMODE
"
=
"package"
-o
"
$EPMMODE
"
=
"git"
]
||
fatal
"epm play is not supported in single file mode"
local
psdir
=
"
$(
realpath
$CONFIGDIR
/play.d
)
"
local
psdir
=
"
$(
realpath
$CONFIGDIR
/play.d
)
"
local
prsdir
=
"
$(
realpath
$CONFIGDIR
/prescription.d
)
"
local
prsdir
=
"
$(
realpath
$CONFIGDIR
/prescription.d
)
"
...
@@ -5375,6 +5396,23 @@ if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
...
@@ -5375,6 +5396,23 @@ if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
exit
exit
fi
fi
if
[
"
$1
"
=
"--ipfs"
]
;
then
shift
if
[
-d
"
$(
dirname
"
$epm_ipfs_db
"
)
"
]
;
then
export
EGET_IPFS_DB
=
"
$eget_ipfs_db
"
if
[
!
-r
"
$EGET_IPFS_DB
"
]
;
then
sudorun
touch
"
$EGET_IPFS_DB
"
>
&2
sudorun
chmod
-v
a+rw
"
$EGET_IPFS_DB
"
>
&2
# get initial db from server
local
URL
=
"https://eepm.ru/app-versions"
info
"Initialize IPFS DB in
$EGET_IPFS_DB
file and fill it with data from
$URL
/eget-ipfs-db.txt"
docmd eget
-q
-O
$EGET_IPFS_DB
"
$URL
/eget-ipfs-db.txt"
fi
else
warning
"ipfs db dir
$eget_ipfs_db
is not exists, skipping --ipfs"
fi
fi
if
[
"
$1
"
=
"--remove"
]
||
[
"
$1
"
=
"remove"
]
;
then
if
[
"
$1
"
=
"--remove"
]
||
[
"
$1
"
=
"remove"
]
;
then
shift
shift
...
@@ -5477,6 +5515,9 @@ case $PMTYPE in
...
@@ -5477,6 +5515,9 @@ case $PMTYPE in
packagekit
)
packagekit
)
docmd pkcon resolve
$pkg_names
docmd pkcon resolve
$pkg_names
;;
;;
apk
)
docmd apk policy
$pkg_names
;;
*
)
*
)
fatal
"Have no suitable command for
$PMTYPE
"
fatal
"Have no suitable command for
$PMTYPE
"
;;
;;
...
@@ -7946,6 +7987,10 @@ __epm_have_repack_rule()
...
@@ -7946,6 +7987,10 @@ __epm_have_repack_rule()
# skip repacking on non ALT systems
# skip repacking on non ALT systems
[
"
$BASEDISTRNAME
"
=
"alt"
]
||
return
1
[
"
$BASEDISTRNAME
"
=
"alt"
]
||
return
1
local
packager
=
"
$(
epm print field Packager
for
"
$1
"
2>/dev/null
)
"
[
"
$packager
"
=
"EPM <support@etersoft.ru>"
]
&&
return
1
[
"
$packager
"
=
"EPM <support@eepm.ru>"
]
&&
return
1
# FIXME: use real way (for any archive)
# FIXME: use real way (for any archive)
local
pkgname
=
"
$(
epm print name
for
package
"
$1
"
)
"
local
pkgname
=
"
$(
epm print name
for
package
"
$1
"
)
"
local
repackcode
=
"
$EPM_REPACK_SCRIPTS_DIR
/
$pkgname
.sh"
local
repackcode
=
"
$EPM_REPACK_SCRIPTS_DIR
/
$pkgname
.sh"
...
@@ -7955,7 +8000,8 @@ __epm_have_repack_rule()
...
@@ -7955,7 +8000,8 @@ __epm_have_repack_rule()
__epm_check_if_needed_repack
()
__epm_check_if_needed_repack
()
{
{
__epm_have_repack_rule
"
$@
"
||
return
__epm_have_repack_rule
"
$@
"
||
return
warning
"There is repack rule for
$pkgname
package. It is better install this package via 'epm --repack install' or 'epm play'."
local
pkgname
=
"
$(
epm print name
for
package
"
$1
"
)
"
warning
"There is repack rule for '
$pkgname
' package. It is better install this package via 'epm install --repack' or 'epm play'."
}
}
__epm_split_by_pkg_type
()
__epm_split_by_pkg_type
()
...
@@ -8258,7 +8304,7 @@ __create_rpmmacros()
...
@@ -8258,7 +8304,7 @@ __create_rpmmacros()
%_topdir
$HOME
/RPM
%_topdir
$HOME
/RPM
%_tmppath
$TMPDIR
%_tmppath
$TMPDIR
%packager
EPM <support@etersoft
.ru>
%packager
EPM <support@eepm
.ru>
%_vendor EEPM
%_vendor EEPM
%_gpg_name support@etersoft.ru
%_gpg_name support@etersoft.ru
...
@@ -10903,6 +10949,22 @@ done
...
@@ -10903,6 +10949,22 @@ done
}
}
# File bin/epm-stats:
epm_stats
()
{
case
$PMTYPE
in
apk
)
CMD
=
"apk stats"
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
esac
docmd
$CMD
"
$@
"
}
# File bin/epm-tool:
# File bin/epm-tool:
epm_tool_help
()
epm_tool_help
()
...
@@ -10950,6 +11012,9 @@ epm_tool()
...
@@ -10950,6 +11012,9 @@ epm_tool()
showcmd json
"
$@
"
showcmd json
"
$@
"
internal_tools_json
"
$@
"
internal_tools_json
"
$@
"
;;
;;
"which"
)
print_command_path
"
$@
"
# HELPCMD: which like command (no output to stderr, can works without which package)
;;
*
)
*
)
fatal
"Unknown command
$
epm tool
$WHAT
. Use epm print help for get help."
fatal
"Unknown command
$
epm tool
$WHAT
. Use epm print help for get help."
;;
;;
...
@@ -10969,7 +11034,7 @@ get_latest_version()
...
@@ -10969,7 +11034,7 @@ get_latest_version()
__check_for_epm_version
()
__check_for_epm_version
()
{
{
local
latest
=
"
$(
get_latest_version
"epm"
2>/dev/null
)
"
local
latest
=
"
$(
get_latest_version
eepm
)
"
#[ -z "$latest" ] && return
#[ -z "$latest" ] && return
local
res
=
"
$(
epm print compare
"
$EPMVERSION
"
"
$latest
"
)
"
local
res
=
"
$(
epm print compare
"
$EPMVERSION
"
"
$latest
"
)
"
[
"
$res
"
=
"-1"
]
&&
info
"Latest EPM version in Korinf repository is
$latest
. You have version
$EPMVERSION
running."
[
"
$res
"
=
"-1"
]
&&
info
"Latest EPM version in Korinf repository is
$latest
. You have version
$EPMVERSION
running."
...
@@ -11184,6 +11249,9 @@ epm_upgrade()
...
@@ -11184,6 +11249,9 @@ epm_upgrade()
pkgng
)
pkgng
)
CMD
=
"pkg upgrade"
CMD
=
"pkg upgrade"
;;
;;
apk
)
CMD
=
"apk upgrade"
;;
chocolatey
)
chocolatey
)
CMD
=
"chocolatey update all"
CMD
=
"chocolatey update all"
;;
;;
...
@@ -11413,6 +11481,7 @@ is_command()
...
@@ -11413,6 +11481,7 @@ is_command()
firstupper
()
firstupper
()
{
{
# FIXME: works with GNU sed only
echo
"
$*
"
|
sed
's/.*/\u&/'
echo
"
$*
"
|
sed
's/.*/\u&/'
}
}
...
@@ -11549,7 +11618,7 @@ case $DISTRIB_ID in
...
@@ -11549,7 +11618,7 @@ case $DISTRIB_ID in
Cygwin
)
Cygwin
)
CMD
=
"aptcyg"
CMD
=
"aptcyg"
;;
;;
alpine
)
AlpineLinux
)
CMD
=
"apk"
CMD
=
"apk"
;;
;;
TinyCoreLinux
)
TinyCoreLinux
)
...
@@ -11667,7 +11736,8 @@ normalize_name()
...
@@ -11667,7 +11736,8 @@ normalize_name()
;;
;;
*
)
*
)
#echo "${1// /}"
#echo "${1// /}"
firstupper
"
$1
"
|
sed
-e
"s/ //g"
-e
's|(.*||'
#firstupper "$1" | sed -e "s/ //g" -e 's|(.*||'
echo
"
$1
"
|
sed
-e
"s/ //g"
-e
's|(.*||'
;;
;;
esac
esac
}
}
...
@@ -12363,7 +12433,7 @@ case "$1" in
...
@@ -12363,7 +12433,7 @@ case "$1" in
;;
;;
--bug-report-url
)
--bug-report-url
)
print_bug_report_url
print_bug_report_url
exit
return
;;
;;
-s
|
-n
|
--vendor-name
)
-s
|
-n
|
--vendor-name
)
override_distrib
"
$2
"
override_distrib
"
$2
"
...
@@ -12421,12 +12491,40 @@ internal_tools_eget()
...
@@ -12421,12 +12491,40 @@ internal_tools_eget()
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
PROGDIR
=
$(
dirname
"
$0
"
)
PROGNAME
=
$(
basename
"
$0
"
)
CMDSHELL
=
"/bin/sh"
[
"
$PROGDIR
"
=
"."
]
&&
PROGDIR
=
"
$(
pwd
)
"
if
[
"
$0
"
=
"/dev/stdin"
]
||
[
"
$0
"
=
"sh"
]
;
then
PROGDIR
=
""
PROGNAME
=
""
fi
fatal
()
fatal
()
{
{
echo
"FATAL:
$*
"
>
&2
echo
"FATAL:
$*
"
>
&2
exit
1
exit
1
}
}
info
()
{
echo
"
$*
"
>
&2
}
eget
()
{
if
[
-n
"
$PROGNAME
"
]
;
then
local
bashopt
=
''
[
-n
"
$verbose
"
]
&&
bashopt
=
'-x'
(
unset
EGET_IPFS_GATEWAY
;
unset
EGET_IPFS_API
;
unset
EGET_IPFS_DB
;
$CMDSHELL
$bashopt
$PROGDIR
/
$PROGNAME
"
$@
"
)
else
#epm_main --inscript "$@"
fatal
"Improve me"
fi
}
# TODO:
# TODO:
arch
=
"
$(
uname
-m
)
"
arch
=
"
$(
uname
-m
)
"
...
@@ -12540,6 +12638,15 @@ is_command()
...
@@ -12540,6 +12638,15 @@ is_command()
print_command_path
"
$1
"
>
/dev/null
print_command_path
"
$1
"
>
/dev/null
}
}
# add realpath if missed
if
!
is_command
realpath
;
then
realpath
()
{
[
-n
"
$*
"
]
||
return
readlink
-f
"
$@
"
}
fi
# check man glob
# check man glob
filter_glob
()
filter_glob
()
...
@@ -12566,7 +12673,7 @@ is_fileurl()
...
@@ -12566,7 +12673,7 @@ is_fileurl()
echo
"
$1
"
|
grep
-q
"^file:/"
echo
"
$1
"
|
grep
-q
"^file:/"
}
}
dir
_from_url
()
path
_from_url
()
{
{
echo
"
$1
"
|
sed
-e
's|^file://*|/|'
echo
"
$1
"
|
sed
-e
's|^file://*|/|'
}
}
...
@@ -12576,6 +12683,36 @@ is_url()
...
@@ -12576,6 +12683,36 @@ is_url()
echo
"
$1
"
|
grep
-q
"^[filehtps]*:/"
echo
"
$1
"
|
grep
-q
"^[filehtps]*:/"
}
}
is_strange_url
()
{
local
URL
=
"
$1
"
is_url
"
$URL
"
||
return
echo
"
$URL
"
|
grep
-q
"[?&]"
}
is_ipfs_hash
()
{
echo
"
$1
"
|
grep
-q
-E
"^Qm[[:alnum:]]{44}$"
}
is_ipfsurl
()
{
is_ipfs_hash
"
$1
"
&&
return
echo
"
$1
"
|
grep
-q
"^ipfs://"
}
is_httpurl
()
{
# TODO: improve
echo
"
$1
"
|
grep
-q
"^https://"
&
return
echo
"
$1
"
|
grep
-q
"^http://"
&
return
}
cid_from_url
()
{
echo
"
$1
"
|
sed
-e
's|^ipfs://*||'
}
# args: cmd <URL> <options>
# args: cmd <URL> <options>
# will run cmd <options> <URL>
# will run cmd <options> <URL>
...
@@ -12610,17 +12747,25 @@ WGETUSERAGENT=''
...
@@ -12610,17 +12747,25 @@ WGETUSERAGENT=''
CURLUSERAGENT
=
''
CURLUSERAGENT
=
''
WGETQ
=
''
#-q
WGETQ
=
''
#-q
CURLQ
=
''
#-s
CURLQ
=
''
#-s
# TODO: aria2c
# TODO: wget --trust-server-names
# TODO:
WGETNAMEOPTIONS
=
'--content-disposition'
WGETNAMEOPTIONS
=
'--content-disposition'
CURLNAMEOPTIONS
=
'--remote-name --remote-header-name'
CURLNAMEOPTIONS
=
'--remote-name --remote-
time --remote-
header-name'
LISTONLY
=
''
LISTONLY
=
''
CHECKURL
=
''
CHECKURL
=
''
GETRESPONSE
=
''
GETFILENAME
=
''
GETREALURL
=
''
GETIPFSCID
=
''
LATEST
=
''
LATEST
=
''
SECONDLATEST
=
''
SECONDLATEST
=
''
CHECKMIRRORS
=
''
CHECKMIRRORS
=
''
TARGETFILE
=
''
TARGETFILE
=
''
FORCEIPV
=
''
FORCEIPV
=
''
set_quiet
()
set_quiet
()
{
{
WGETQ
=
'-q'
WGETQ
=
'-q'
...
@@ -12649,11 +12794,21 @@ Options:
...
@@ -12649,11 +12794,21 @@ Options:
--list|--list-only - print only URLs
--list|--list-only - print only URLs
--check URL - check if the URL is accessible (returns HTTP 200 OK)
--check URL - check if the URL is accessible (returns HTTP 200 OK)
--get-response URL - get response with all headers (ever if HEAD is not acceptable)
--get-filename URL - print filename for the URL (via Content-Disposition if applicable)
--get-real-url URL - print URL after all redirects
Supported URLs:
ftp:// http:// https:// file:/ ipfs://
Supported backends (set like EGET_BACKEND=curl)
wget curl (todo: aria2c)
Examples:
Examples:
$
eget http://ftp.somesite.ru/package-*.x64.tar
$
eget http://ftp.somesite.ru/package-*.x64.tar
$
eget http://ftp.somesite.ru/package *.tar
$
eget http://ftp.somesite.ru/package *.tar
$
eget https://github.com/owner/project package*.ext
$
eget https://github.com/owner/project package*.ext
$
eget -O myname ipfs://QmVRUjnsnxHWkjq91KreCpUk4D9oZEbMwNQ3rzdjwND5dR
$
eget --list http://ftp.somesite.ru/package-*.tar
$
eget --list http://ftp.somesite.ru/package-*.tar
$
eget --check http://ftp.somesite.ru/test
$
eget --check http://ftp.somesite.ru/test
$
eget --list http://download.somesite.ru 'package-*.tar.xz'
$
eget --list http://download.somesite.ru 'package-*.tar.xz'
...
@@ -12703,6 +12858,18 @@ while [ -n "$1" ] ; do
...
@@ -12703,6 +12858,18 @@ while [ -n "$1" ] ; do
CHECKURL
=
"
$1
"
CHECKURL
=
"
$1
"
#set_quiet
#set_quiet
;;
;;
--get-filename
)
GETFILENAME
=
"
$1
"
;;
--get-response
)
GETRESPONSE
=
"
$1
"
;;
--get-real-url
)
GETREALURL
=
"
$1
"
;;
--get-ipfs-cid
)
GETIPFSCID
=
"
$1
"
;;
--latest
)
--latest
)
LATEST
=
"
$1
"
LATEST
=
"
$1
"
;;
;;
...
@@ -12727,39 +12894,384 @@ while [ -n "$1" ] ; do
...
@@ -12727,39 +12894,384 @@ while [ -n "$1" ] ; do
done
done
#############################3
# defaults
# https://github.com/ipfs/kubo/issues/5541
ipfs_diag_timeout
=
'--timeout 10s'
ipfs_api_local
=
"/ip4/127.0.0.1/tcp/5001"
[
-n
"
$EGET_IPFS_API
"
]
&&
ipfs_api_local
=
"
$EGET_IPFS_API
"
ipfs_api_brave
=
"/ip4/127.0.0.1/tcp/45005"
ipfs_gateway
=
"https://cloudflare-ipfs.com/ipfs"
[
-n
"
$EGET_IPFS_GATEWAY
"
]
&&
ipfs_gateway
=
"
$EGET_IPFS_GATEWAY
"
IPFS_GATEWAY
=
"
$ipfs_gateway
"
# Test data: https://etersoft.ru/templates/etersoft/images/logo.png
ipfs_checkQm
=
"QmYwf2GAMvHxfFiUFL2Mr6KUG6QrDiupqGc8ms785ktaYw"
get_ipfs_brave
()
{
local
ipfs_brave
=
"
$(
ls
~/.config/BraveSoftware/Brave-Browser/
*
/
*
/go-ipfs_
*
2>/dev/null
)
"
[
-n
"
$ipfs_brave
"
]
&&
[
-x
"
$ipfs_brave
"
]
||
return
echo
"
$ipfs_brave
"
}
ipfs_access
()
{
[
-n
"
$IPFS_CMD
"
]
||
fatal
"IPFS is disabled"
$IPFS_CMD
--api
$IPFS_API
$ipfs_diag_timeout
diag sys
>
/dev/null 2>/dev/null
}
ipfs_check
()
{
[
-n
"
$IPFS_CMD
"
]
||
fatal
"IPFS is disabled"
$IPFS_CMD
--api
$IPFS_API
$ipfs_diag_timeout
cat
"
$1
"
>
/dev/null
}
select_ipfs_mode
()
{
IPFS_CMD
=
"
$(
get_ipfs_brave
)
"
# if no EGET_IPFS_API, check brave
if
[
-z
"
$EGET_IPFS_API
"
]
&&
[
-n
"
$IPFS_CMD
"
]
;
then
IPFS_API
=
"
$ipfs_api_brave
"
if
ipfs_access
;
then
if
ipfs_check
"
$ipfs_checkQm
"
;
then
ipfs_mode
=
"brave"
&&
return
else
info
"Skipped Brave: it is accessible via
$IPFS_CMD
--api
$IPFS_API
, but can't return shared
$ipfs_checkQm
"
fi
fi
fi
IPFS_CMD
=
"
$(
print_command_path ipfs
)
"
if
[
-n
"
$IPFS_CMD
"
]
;
then
IPFS_API
=
"
$ipfs_api_local
"
if
ipfs_access
;
then
if
ipfs_check
"
$ipfs_checkQm
"
;
then
ipfs_mode
=
"local"
&&
return
else
info
"Skipped local: it is accessible via
$IPFS_CMD
--api
$IPFS_API
, but can't return shared
$ipfs_checkQm
"
fi
fi
fi
# TODO: check checksum
if
docmd eget
--check
"
$ipfs_gateway
/
$ipfs_checkQm
"
;
then
ipfs_mode
=
"gateway"
return
fi
IPFS_GATEWAY
=
''
if
docmd eget
--check
"
$(
dirname
$ipfs_gateway
)
"
;
then
info
"IPFS gateway
$ipfs_gateway
is accessible, but can't return shared
$ipfs_checkQm
"
else
info
"IPFS gateway
$(
dirname
$ipfs_gateway
)
is not accessible"
fi
ipfs_mode
=
"disabled"
}
# Functions for work with eget ipfs db
get_cid_by_url
()
{
local
URL
=
"
$1
"
[
-r
"
$EGET_IPFS_DB
"
]
||
return
is_fileurl
"
$URL
"
&&
return
1
grep
-F
"
$URL
Qm"
"
$EGET_IPFS_DB
"
|
head
-n1
|
cut
-f2
-d
" "
}
put_cid_and_url
()
{
local
URL
=
"
$1
"
local
CID
=
"
$2
"
local
FN
=
"
$3
"
[
-w
"
$EGET_IPFS_DB
"
]
||
return
is_fileurl
"
$URL
"
&&
return
echo
"
$URL
$CID
$FN
"
>>
"
$EGET_IPFS_DB
"
echo
"Placed in
$EGET_IPFS_DB
:
$URL
$CID
$FN
"
}
get_filename_by_cid
()
{
local
CID
=
"
$1
"
[
-z
"
$EGET_IPFS_DB
"
]
&&
echo
"
$CID
"
&&
return
grep
-F
"
$CID
"
"
$EGET_IPFS_DB
"
|
head
-n1
|
cut
-f3
-d
" "
}
get_url_by_cid
()
{
local
CID
=
"
$1
"
[
-z
"
$EGET_IPFS_DB
"
]
&&
echo
"
$CID
"
&&
return
grep
-F
"
$CID
"
"
$EGET_IPFS_DB
"
|
head
-n1
|
cut
-f1
-d
" "
}
###################
ipfs_mode
=
"
$EGET_IPFS
"
# enable auto mode when set $EGET_IPFS_DB
[
-z
"
$ipfs_mode
"
]
&&
[
-n
"
$EGET_IPFS_DB
"
]
&&
ipfs_mode
=
"auto"
if
[
-n
"
$LISTONLY$CHECKURL
"
]
;
then
ipfs_mode
=
"disabled"
EGET_IPFS_DB
=
''
fi
if
[
"
$ipfs_mode
"
!=
"disabled"
]
&&
[
-n
"
$EGET_IPFS_DB
"
]
;
then
ddb
=
"
$(
dirname
"
$EGET_IPFS_DB
"
)
"
if
[
-d
"
$ddb
"
]
;
then
info
"Using eget IPFS db
$EGET_IPFS_DB
"
[
-r
"
$EGET_IPFS_DB
"
]
||
touch
"
$EGET_IPFS_DB
"
else
EGET_IPFS_DB
=
''
fi
fi
# detect if we run with ipfs:// or with auto
if
is_ipfsurl
"
$1
"
&&
[
-z
"
$ipfs_mode
"
]
||
[
"
$ipfs_mode
"
=
"auto"
]
;
then
select_ipfs_mode
info
"Auto selected IPFS mode:
$ipfs_mode
"
else
[
-n
"
$ipfs_mode
"
]
&&
info
"IPFS mode:
$ipfs_mode
"
fi
IPFS_CMD
=
''
if
[
"
$ipfs_mode
"
=
"disabled"
]
;
then
ipfs_get
()
{
fatal
"IPFS is disabled"
}
ipfs_put
()
{
fatal
"IPFS is disabled"
}
ipfs_cat
()
{
fatal
"IPFS is disabled"
}
elif
[
"
$ipfs_mode
"
=
"brave"
]
;
then
IPFS_CMD
=
"
$(
get_ipfs_brave
)
"
||
fatal
"Can't find ipfs command in Brave"
IPFS_PRETTY_CMD
=
"~Brave-Browser/
$(
basename
$IPFS_CMD
)
"
IPFS_API
=
"
$ipfs_api_brave
"
ipfs_access
||
fatal
"Can't access to Brave IPFS API (Brave browser is not running and IPFS is not activated?)"
info
"Will use
$IPFS_PRETTY_CMD
--api
$IPFS_API
"
elif
[
"
$ipfs_mode
"
=
"local"
]
;
then
IPFS_CMD
=
"
$(
print_command_path ipfs
)
"
||
fatal
"Can't find ipfs command"
IPFS_PRETTY_CMD
=
"
$IPFS_CMD
"
IPFS_API
=
"
$ipfs_api_local
"
ipfs_access
||
fatal
"Can't access to IPFS API (ipfs daemon is not running?)"
info
"Will use
$IPFS_PRETTY_CMD
--api
$IPFS_API
"
elif
[
"
$ipfs_mode
"
=
"gateway"
]
;
then
info
"Will use eget
$IPFS_GATEWAY
/HASH"
ipfs_get
()
{
[
-n
"
$IPFS_GATEWAY
"
]
||
fatal
"ipfs http gateway is not set"
# FIXME:
if
[
-n
"
$2
"
]
;
then
docmd eget
-O
"
$2
"
"
$IPFS_GATEWAY
/
$1
"
else
docmd eget
"
$IPFS_GATEWAY
/
$1
"
fi
}
ipfs_cat
()
{
# FIXME:
ipfs_get
"
$1
"
"-"
}
ipfs_put
()
{
fatal
"IPFS add disabled if a gateway is used"
}
elif
[
-z
"
$ipfs_mode
"
]
;
then
:
else
fatal
"Unsupported eget ipfs mode
$ipfs_mode
"
fi
if
[
-n
"
$IPFS_CMD
"
]
;
then
ipfs_get
()
{
[
-n
"
$IPFS_CMD
"
]
||
fatal
"ipfs api is not usable"
if
[
-n
"
$2
"
]
;
then
showcmd
$IPFS_PRETTY_CMD
--api
$IPFS_API
get
-o
"
$2
"
"
$1
"
$IPFS_CMD
--api
$IPFS_API
get
-o
"
$2
"
"
$1
"
else
showcmd
$IPFS_PRETTY_CMD
--api
$IPFS_API
get
"
$1
"
$IPFS_CMD
--api
$IPFS_API
get
"
$1
"
fi
}
ipfs_put
()
{
[
-n
"
$IPFS_CMD
"
]
||
fatal
"ipfs api is not usable"
# detect if -q is used (will output Qm instead of addded Qm)
local
qu
=
"
$1
"
[
"
$qu
"
=
"-q"
]
||
qu
=
''
showcmd
$IPFS_PRETTY_CMD
--api
$IPFS_API
add
"
$@
"
local
res
res
=
"
$(
$IPFS_CMD
--api
$IPFS_API
add
"
$@
"
)
"
||
return
if
[
-z
"
$qu
"
]
;
then
res
=
"
$(
echo
"
$res
"
|
grep
"^added Qm"
)
"
||
return
res
=
"
$(
echo
"
$res
"
|
cut
-f2
-d
" "
)
"
fi
is_ipfs_hash
"
$res
"
&&
echo
"
$res
"
&&
return
fatal
"Can't recognize
$res
IPFS hash"
}
ipfs_cat
()
{
[
-n
"
$IPFS_CMD
"
]
||
fatal
"ipfs api is not usable"
showcmd
$IPFS_PRETTY_CMD
--api
$IPFS_API
cat
"
$1
"
$IPFS_CMD
--api
$IPFS_API
cat
"
$1
"
}
fi
###############################
WGET
=
"
$(
print_command_path wget
)
"
WGET
=
"
$(
print_command_path wget
)
"
CURL
=
"
$(
print_command_path curl
)
"
if
is_fileurl
"
$1
"
;
then
if
is_fileurl
"
$1
"
;
then
EGET_BACKEND
=
"file"
elif
is_ipfsurl
"
$1
"
;
then
EGET_BACKEND
=
"ipfs"
fi
case
"
$EGET_BACKEND
"
in
file|ipfs
)
;;
wget
)
[
-n
"
$WGET
"
]
||
fatal
"There are no wget in the system but you forced using it via EGET_BACKEND. Install it with
$
epm install wget"
;;
curl
)
[
-n
"
$CURL
"
]
||
fatal
"There are no curl in the system but you forced using it via EGET_BACKEND. Install it with
$
epm install curl"
;;
''
)
[
-n
"
$WGET
"
]
&&
EGET_BACKEND
=
"wget"
[
-z
"
$EGET_BACKEND
"
]
&&
[
-n
"
$CURL
"
]
&&
EGET_BACKEND
=
"curl"
[
-n
"
$EGET_BACKEND
"
]
||
fatal
"There are no wget nor curl in the system. Install something with
$
epm install wget"
;;
*
)
fatal
"Uknown EGET_BACKEND
$EGET_BACKEND
"
;;
esac
if
[
"
$EGET_BACKEND
"
=
"file"
]
;
then
# put remote content to stdout
# put remote content to stdout
scat
()
url_
scat
()
{
{
local
URL
=
"
$1
"
local
URL
=
"
$1
"
cat
"
$(
dir
_from_url
"
$URL
"
)
"
cat
"
$(
path
_from_url
"
$URL
"
)
"
}
}
# download to default name of to $2
# download to default name of to $2
sget
()
url_
sget
()
{
{
local
URL
=
"
$1
"
local
URL
=
"
$1
"
if
[
"
$2
"
=
"/dev/stdout"
]
||
[
"
$2
"
=
"-"
]
;
then
if
[
"
$2
"
=
"/dev/stdout"
]
||
[
"
$2
"
=
"-"
]
;
then
scat
"
$URL
"
scat
"
$URL
"
return
return
elif
[
-n
"
$2
"
]
;
then
elif
[
-n
"
$2
"
]
;
then
cp
-av
"
$(
dir
_from_url
"
$URL
"
)
"
"
$2
"
cp
-av
"
$(
path
_from_url
"
$URL
"
)
"
"
$2
"
return
return
fi
fi
cp
-av
"
$(
dir
_from_url
"
$URL
"
)
"
.
cp
-av
"
$(
path
_from_url
"
$URL
"
)
"
.
}
}
check_url_is_accessible
()
url_check
()
{
{
local
URL
=
"
$1
"
local
URL
=
"
$1
"
test
-f
"
$(
dir_from_url
"
$URL
"
)
"
test
-f
"
$(
path_from_url
"
$URL
"
)
"
}
url_get_filename
()
{
basename
"
$1
"
}
url_get_real_url
()
{
echo
"
$1
"
}
}
elif
[
-n
"
$WGET
"
]
;
then
elif
[
"
$EGET_BACKEND
"
=
"ipfs"
]
;
then
# put remote content to stdout
url_scat
()
{
local
URL
=
"
$1
"
ipfs_cat
"
$(
cid_from_url
"
$URL
"
)
"
}
# download to default name of to $2
url_sget
()
{
local
URL
=
"
$1
"
if
[
"
$2
"
=
"/dev/stdout"
]
||
[
"
$2
"
=
"-"
]
;
then
scat
"
$URL
"
return
elif
[
-n
"
$2
"
]
;
then
ipfs_get
"
$(
cid_from_url
"
$URL
"
)
"
"
$2
"
return
fi
ipfs_get
"
$(
cid_from_url
"
$URL
"
)
"
}
url_check
()
{
local
URL
=
"
$1
"
# TODO: improve me
scat
"
$URL
"
>
/dev/null
}
url_get_filename
()
{
local
URL
=
"
$1
"
local
CID
=
"
$(
cid_from_url
"
$URL
"
)
"
get_filename_by_cid
"
$CID
"
}
url_get_real_url
()
{
local
URL
=
"
$1
"
local
CID
=
"
$(
cid_from_url
"
$URL
"
)
"
get_url_by_cid
"
$CID
"
}
elif
[
"
$EGET_BACKEND
"
=
"wget"
]
;
then
__wget
()
__wget
()
{
{
if
[
-n
"
$WGETUSERAGENT
"
]
;
then
if
[
-n
"
$WGETUSERAGENT
"
]
;
then
...
@@ -12770,13 +13282,13 @@ __wget()
...
@@ -12770,13 +13282,13 @@ __wget()
}
}
# put remote content to stdout
# put remote content to stdout
scat
()
url_
scat
()
{
{
local
URL
=
"
$1
"
local
URL
=
"
$1
"
download_with_mirroring __wget
"
$URL
"
-O-
download_with_mirroring __wget
"
$URL
"
-O-
}
}
# download to default name of to $2
# download to default name of to $2
sget
()
url_
sget
()
{
{
local
URL
=
"
$1
"
local
URL
=
"
$1
"
if
[
"
$2
"
=
"/dev/stdout"
]
||
[
"
$2
"
=
"-"
]
;
then
if
[
"
$2
"
=
"/dev/stdout"
]
||
[
"
$2
"
=
"-"
]
;
then
...
@@ -12793,15 +13305,22 @@ sget()
...
@@ -12793,15 +13305,22 @@ sget()
download_with_mirroring __wget
"
$URL
"
$WGETNAMEOPTIONS
download_with_mirroring __wget
"
$URL
"
$WGETNAMEOPTIONS
}
}
check_url_is_accessibl
e
()
url_get_respons
e
()
{
{
local
URL
=
"
$1
"
local
URL
=
"
$1
"
__wget
--spider
-S
"
$URL
"
2>&1 |
grep
"HTTP/"
|
tail
-n1
|
grep
-q
"200"
local
answer
answer
=
"
$(
__wget
--spider
-S
"
$URL
"
2>&1
)
"
# HTTP/1.1 405 Method Not Allowed
if
echo
"
$answer
"
|
grep
-q
"^ *HTTP/[12.]* 405"
;
then
__wget
--start-pos
=
5000G
-S
"
$URL
"
2>&1
return
fi
echo
"
$answer
"
}
}
else
CURL
=
"
$(
print_command_path curl
)
"
elif
[
"
$EGET_BACKEND
"
=
"curl"
]
;
then
[
-n
"
$CURL
"
]
||
fatal
"There are no wget nor curl in the system. Install it with
$
epm install curl"
__curl
()
__curl
()
{
{
if
[
-n
"
$CURLUSERAGENT
"
]
;
then
if
[
-n
"
$CURLUSERAGENT
"
]
;
then
...
@@ -12811,13 +13330,13 @@ __curl()
...
@@ -12811,13 +13330,13 @@ __curl()
fi
fi
}
}
# put remote content to stdout
# put remote content to stdout
scat
()
url_
scat
()
{
{
local
URL
=
"
$1
"
local
URL
=
"
$1
"
download_with_mirroring __curl
"
$URL
"
--output
-
download_with_mirroring __curl
"
$URL
"
--output
-
}
}
# download to default name of to $2
# download to default name of to $2
sget
()
url_
sget
()
{
{
local
URL
=
"
$1
"
local
URL
=
"
$1
"
local
res
local
res
...
@@ -12832,15 +13351,279 @@ sget()
...
@@ -12832,15 +13351,279 @@ sget()
download_with_mirroring __curl
"
$URL
"
$CURLNAMEOPTIONS
download_with_mirroring __curl
"
$URL
"
$CURLNAMEOPTIONS
}
}
check_url_is_accessible
()
url_get_response
()
{
local
URL
=
"
$1
"
local
answer
answer
=
"
$(
__curl
-LI
"
$URL
"
2>&1
)
"
# HTTP/1.1 405 Method Not Allowed
if
echo
"
$answer
"
|
grep
-q
"^ *HTTP/[12.]* 405"
;
then
__curl
-L
-i
-r0-0
"
$URL
"
2>&1
return
fi
echo
"
$answer
"
}
fi
# Common code for both wget and curl (http related)
if
[
"
$EGET_BACKEND
"
=
"wget"
]
||
[
"
$EGET_BACKEND
"
=
"curl"
]
;
then
url_get_headers
()
{
local
URL
=
"
$1
"
url_get_response
"
$URL
"
|
grep
-i
"^ *[[:alpha:]].*: "
|
sed
-e
's|^ *||'
-e
's|\r$||'
}
url_check
()
{
local
URL
=
"
$1
"
url_get_response |
grep
"HTTP/"
|
tail
-n1
|
grep
-q
-w
"200
\|
404"
}
url_get_header
()
{
local
URL
=
"
$1
"
local
HEADER
=
"
$2
"
url_get_headers
"
$URL
"
|
grep
-i
"^ *
$HEADER
: "
|
sed
-e
"s|^ *
$HEADER
: ||i"
}
url_get_real_url
()
{
local
URL
=
"
$1
"
!
is_httpurl
"
$URL
"
&&
echo
"
$URL
"
&&
return
# don't check location if we have made form of the URL
[
-n
"
$MADEURL
"
]
&&
[
"
$MADEURL
"
=
"
$URL
"
]
&&
echo
"
$URL
"
&&
return
local
loc
for
loc
in
$(
url_get_header
"
$URL
"
"Location"
|
tac
)
;
do
if
!
is_strange_url
"
$loc
"
;
then
echo
"
$loc
"
return
fi
done
echo
"
$URL
"
}
url_get_filename
()
{
{
local
URL
=
"
$1
"
local
URL
=
"
$1
"
__curl
-LI
"
$URL
"
2>&1 |
grep
"HTTP/"
|
tail
-n1
|
grep
-q
-w
"200
\|
404"
!
is_httpurl
"
$URL
"
&&
basename
"
$URL
"
&&
return
# FIXME with wget
local cd
=
"
$(
url_get_header
"
$URL
"
"Content-Disposition"
)
"
if
echo
"
$cd
"
|
grep
-q
"filename="
;
then
#Content-Disposition: attachment; filename=postman-linux-x64.tar.gz
#content-disposition: attachment; filename="code-1.77.1-1680651749.el7.x86_64.rpm"
echo
"
$cd
"
|
sed
-e
's|.*filename=||'
-e
's|^"||'
-e
's|";$||'
-e
's|"$||'
return
fi
basename
"
$(
url_get_real_url
"
$URL
"
)
"
}
}
fi
fi
if
[
"
$ipfs_mode
"
!=
"disabled"
]
&&
[
-n
"
$EGET_IPFS_DB
"
]
&&
!
is_ipfsurl
"
$1
"
;
then
download_to_ipfs
()
{
local
URL
=
"
$1
"
local
res
#res="$(url_scat "$URL" | ipfs_put )" || return
#res="$(echo "$res" | grep "^added Qm")" || return 1
#CID="$(echo "$res" | cut -f2 -d" ")"
# with -q to disable progress (mixed with download progress)
res
=
"
$(
url_scat
"
$URL
"
| ipfs_put
-q
)
"
||
return
is_ipfs_hash
"
$res
"
||
return
1
echo
"
$res
"
}
# put remote content to stdout
scat
()
{
local
URL
=
"
$1
"
url_scat
"
$URL
"
# It is list only function. Don't save to IPFS
return
###################
local
CID
=
"
$(
get_cid_by_url
"
$URL
"
)
"
if
[
-n
"
$CID
"
]
;
then
info
"
$URL
->
$CID
"
ipfs_cat
"
$CID
"
return
fi
CID
=
"
$(
download_to_ipfs
"
$URL
"
)
"
||
return
ipfs_cat
"
$CID
"
||
return
local
FN
=
"
$(
url_get_filename
"
$URL
"
)
"
||
return
put_cid_and_url
"
$URL
"
"
$CID
"
"
$FN
"
}
# download to default name of to $2
sget
()
{
local
URL
=
"
$1
"
local
TARGET
=
"
$2
"
if
[
-n
"
$GETFILENAME
"
]
;
then
get_filename
"
$URL
"
return
fi
local
REALURL
=
"
$(
get_real_url
"
$URL
"
)
"
||
return
if
[
-n
"
$GETREALURL
"
]
;
then
echo
"
$REALURL
"
return
fi
# skip ipfs for cat
if
[
"
$TARGET
"
=
"/dev/stdout"
]
||
[
"
$TARGET
"
=
"-"
]
;
then
url_scat
"
$URL
"
return
fi
#if is_strange_url "$REALURL" ; then
# info "Just download strange URL $REALURL, skipping IPFS"
# url_sget "$REALURL" "$TARGET"
# return
#fi
local
CID
=
"
$(
get_cid_by_url
"
$REALURL
"
)
"
if
[
-n
"
$CID
"
]
;
then
if
[
-n
"
$GETIPFSCID
"
]
;
then
echo
"
$CID
"
return
fi
if
[
-n
"
$GETFILENAME
"
]
;
then
get_filename_by_cid
"
$CID
"
return
fi
if
[
-n
"
$GETREALURL
"
]
;
then
get_url_by_cid
"
$CID
"
return
fi
if
[
-z
"
$TARGET
"
]
;
then
# TODO: in some cases we can get name from URL...
TARGET
=
"
$(
get_filename_by_cid
"
$CID
"
)
"
if
[
-z
"
$TARGET
"
]
;
then
TARGET
=
"
$CID
"
fi
fi
[
"
$URL
"
=
"
$REALURL
"
]
&&
info
"
$URL
->
$CID
->
$TARGET
"
||
info
"
$URL
->
$REALURL
->
$CID
->
$TARGET
"
ipfs_get
"
$CID
"
"
$TARGET
"
&&
return
# fail get from IPFS, fallback
url_sget
"
$REALURL
"
"
$TARGET
"
return
fi
# download and put to IPFS
local
FN
=
"
$(
url_get_filename
"
$REALURL
"
)
"
||
return
if
[
-z
"
$TARGET
"
]
;
then
TARGET
=
"
$FN
"
fi
if
[
-n
"
$GETIPFSCID
"
]
;
then
# add to IPFS and print out CID
CID
=
"
$(
ipfs_put
--progress
"
$REALURL
"
)
"
||
return
echo
"
$CID
"
return
fi
# download file and add to IPFS
url_sget
"
$REALURL
"
"
$TARGET
"
||
return
CID
=
"
$(
ipfs_put
--progress
"
$TARGET
"
)
"
||
return
put_cid_and_url
"
$REALURL
"
"
$CID
"
"
$FN
"
}
check_url_is_accessible
()
{
local
URL
=
"
$1
"
local
REALURL
=
"
$(
get_real_url
"
$URL
"
)
"
||
return
local
CID
=
"
$(
get_cid_by_url
"
$REALURL
"
)
"
if
[
-n
"
$CID
"
]
;
then
[
"
$URL
"
=
"
$REALURL
"
]
&&
info
"
$URL
->
$CID
"
||
info
"
$URL
->
$REALURL
->
$CID
"
ipfs_check
"
$CID
"
return
fi
CID
=
"
$(
download_to_ipfs
"
$REALURL
"
)
"
||
return
local
FN
=
"
$(
url_get_filename
"
$REALURL
"
)
"
||
return
ipfs_cat
"
$CID
"
>
/dev/null
||
return
put_cid_and_url
"
$REALURL
"
"
$CID
"
"
$FN
"
}
get_filename
()
{
url_get_filename
"
$1
"
}
get_real_url
()
{
url_get_real_url
"
$1
"
}
else
scat
()
{
url_scat
"
$@
"
}
sget
()
{
if
[
-n
"
$GETFILENAME
"
]
;
then
get_filename
"
$1
"
return
fi
if
[
-n
"
$GETREALURL
"
]
;
then
get_real_url
"
$1
"
return
fi
url_sget
"
$@
"
}
check_url_is_accessible
()
{
url_check
"
$@
"
}
get_filename
()
{
url_get_filename
"
$1
"
}
get_real_url
()
{
url_get_real_url
"
$1
"
}
fi
get_github_urls
()
get_github_urls
()
{
{
...
@@ -12868,6 +13651,9 @@ concatenate_url_and_filename()
...
@@ -12868,6 +13651,9 @@ concatenate_url_and_filename()
echo
"
$(
echo
"
$url
"
|
sed
-e
's|/*$||'
)
/
$fn
"
echo
"
$(
echo
"
$url
"
|
sed
-e
's|/*$||'
)
/
$fn
"
}
}
# MADEURL filled with latest made URL as flag it is end form of URL
MADEURL
=
''
# Args: URL filename
# Args: URL filename
make_fileurl
()
make_fileurl
()
{
{
...
@@ -12887,13 +13673,14 @@ make_fileurl()
...
@@ -12887,13 +13673,14 @@ make_fileurl()
url
=
"
$(
dirname
"
$url
"
)
"
url
=
"
$(
dirname
"
$url
"
)
"
fi
fi
concatenate_url_and_filename
"
$url
"
"
$fn
"
MADEURL
=
"
$(
concatenate_url_and_filename
"
$url
"
"
$fn
"
)
"
echo
"
$MADEURL
"
}
}
get_urls
()
get_urls
()
{
{
if
is_fileurl
"
$URL
"
;
then
if
is_fileurl
"
$URL
"
;
then
ls
-1
"
$(
dir
_from_url
"
$URL
"
)
"
ls
-1
"
$(
path
_from_url
"
$URL
"
)
"
return
return
fi
fi
...
@@ -12903,13 +13690,17 @@ get_urls()
...
@@ -12903,13 +13690,17 @@ get_urls()
}
}
if
[
-n
"
$CHECKURL
"
]
;
then
if
[
-n
"
$CHECKURL
"
]
;
then
#set_quiet
#set_quiet
check_url_is_accessible
"
$1
"
check_url_is_accessible
"
$1
"
return
return
fi
fi
if
[
-n
"
$GETRESPONSE
"
]
;
then
url_get_response
"
$1
"
return
fi
# separate part for github downloads
# separate part for github downloads
if
echo
"
$1
"
|
grep
-q
"^https://github.com/"
&&
\
if
echo
"
$1
"
|
grep
-q
"^https://github.com/"
&&
\
...
@@ -12923,12 +13714,18 @@ if echo "$1" | grep -q "^https://github.com/" && \
...
@@ -12923,12 +13714,18 @@ if echo "$1" | grep -q "^https://github.com/" && \
ERROR
=
0
ERROR
=
0
for
fn
in
$(
get_github_urls
"
$1
"
| filter_glob
"
$MASK
"
| filter_order
)
;
do
for
fn
in
$(
get_github_urls
"
$1
"
| filter_glob
"
$MASK
"
| filter_order
)
;
do
MADEURL
=
"
$fn
"
# mark it is the end form of the URL
sget
"
$fn
"
"
$TARGETFILE
"
||
ERROR
=
1
sget
"
$fn
"
"
$TARGETFILE
"
||
ERROR
=
1
[
-n
"
$TARGETFILE
"
]
&&
[
"
$ERROR
"
=
"0"
]
&&
break
[
-n
"
$TARGETFILE
"
]
&&
[
"
$ERROR
"
=
"0"
]
&&
break
done
done
return
return
fi
fi
if
is_ipfsurl
"
$1
"
;
then
[
-n
"
$2
"
]
&&
fatal
"too many args when ipfs://Qm... used: extra '
$2
' arg"
sget
"
$1
"
"
$TARGETFILE
"
return
fi
# if mask is the second arg
# if mask is the second arg
if
[
-n
"
$2
"
]
;
then
if
[
-n
"
$2
"
]
;
then
...
@@ -12973,10 +13770,6 @@ fi
...
@@ -12973,10 +13770,6 @@ fi
# If there is no wildcard symbol like asterisk, just download
# If there is no wildcard symbol like asterisk, just download
if
echo
"
$MASK
"
|
grep
-qv
"[*?]"
||
echo
"
$MASK
"
|
grep
-q
"[?].*="
;
then
if
echo
"
$MASK
"
|
grep
-qv
"[*?]"
||
echo
"
$MASK
"
|
grep
-q
"[?].*="
;
then
if
is_fileurl
"
$1
"
;
then
sget
"
$(
dir_from_url
"
$1
"
)
"
"
$TARGEFILE
"
return
fi
sget
"
$1
"
"
$TARGETFILE
"
sget
"
$1
"
"
$TARGETFILE
"
return
return
fi
fi
...
@@ -14152,6 +14945,9 @@ pkg_urls=
...
@@ -14152,6 +14945,9 @@ pkg_urls=
quoted_args
=
quoted_args
=
direct_args
=
direct_args
=
eget_backend
=
$EGET_BACKEND
eget_ipfs_db
=
/var/lib/eepm/eget-ipfs-db.txt
# load system wide config
# load system wide config
[
-f
$CONFIGDIR
/eepm.conf
]
&&
.
$CONFIGDIR
/eepm.conf
[
-f
$CONFIGDIR
/eepm.conf
]
&&
.
$CONFIGDIR
/eepm.conf
...
@@ -14351,6 +15147,10 @@ check_command()
...
@@ -14351,6 +15147,10 @@ check_command()
epm_cmd
=
remove_old_kernels
epm_cmd
=
remove_old_kernels
direct_args
=
1
direct_args
=
1
;;
;;
stats
)
# HELPCMD: show statistics about repositories and installations
epm_cmd
=
stats
direct_args
=
1
;;
# HELPCMD: PART: Other commands:
# HELPCMD: PART: Other commands:
clean|delete-cache|dc
)
# HELPCMD: clean local package cache
clean|delete-cache|dc
)
# HELPCMD: clean local package cache
...
@@ -14594,7 +15394,7 @@ if [ -n "$quiet" ] ; then
...
@@ -14594,7 +15394,7 @@ if [ -n "$quiet" ] ; then
fi
fi
# fill
# fill
export
EPM_OPTIONS
=
"
$nodeps
$force
$verbose
$quiet
$non_interactive
$save_only
$download_only
"
export
EPM_OPTIONS
=
"
$nodeps
$force
$verbose
$quiet
$
interactive
$
non_interactive
$save_only
$download_only
"
# if input is not console and run script from file, get pkgs from stdin too
# if input is not console and run script from file, get pkgs from stdin too
if
[
!
-n
"
$inscript
"
]
&&
!
inputisatty
&&
[
-n
"
$PROGDIR
"
]
;
then
if
[
!
-n
"
$inscript
"
]
&&
!
inputisatty
&&
[
-n
"
$PROGDIR
"
]
;
then
...
...
packed/serv.sh
View file @
db3edf22
...
@@ -492,7 +492,7 @@ disabled_eget()
...
@@ -492,7 +492,7 @@ disabled_eget()
local
EGET
local
EGET
# use internal eget only if exists
# use internal eget only if exists
if
[
-s
$SHAREDIR
/tools_eget
]
;
then
if
[
-s
$SHAREDIR
/tools_eget
]
;
then
$SHAREDIR
/tools_eget
"
$@
"
(
EGET_BACKEND
=
$eget_backend
$SHAREDIR
/tools_eget
"
$@
"
)
return
return
fi
fi
fatal
"Internal error: missed tools_eget"
fatal
"Internal error: missed tools_eget"
...
@@ -1512,6 +1512,7 @@ is_command()
...
@@ -1512,6 +1512,7 @@ is_command()
firstupper
()
firstupper
()
{
{
# FIXME: works with GNU sed only
echo
"
$*
"
|
sed
's/.*/\u&/'
echo
"
$*
"
|
sed
's/.*/\u&/'
}
}
...
@@ -1648,7 +1649,7 @@ case $DISTRIB_ID in
...
@@ -1648,7 +1649,7 @@ case $DISTRIB_ID in
Cygwin
)
Cygwin
)
CMD
=
"aptcyg"
CMD
=
"aptcyg"
;;
;;
alpine
)
AlpineLinux
)
CMD
=
"apk"
CMD
=
"apk"
;;
;;
TinyCoreLinux
)
TinyCoreLinux
)
...
@@ -1766,7 +1767,8 @@ normalize_name()
...
@@ -1766,7 +1767,8 @@ normalize_name()
;;
;;
*
)
*
)
#echo "${1// /}"
#echo "${1// /}"
firstupper
"
$1
"
|
sed
-e
"s/ //g"
-e
's|(.*||'
#firstupper "$1" | sed -e "s/ //g" -e 's|(.*||'
echo
"
$1
"
|
sed
-e
"s/ //g"
-e
's|(.*||'
;;
;;
esac
esac
}
}
...
@@ -2462,7 +2464,7 @@ case "$1" in
...
@@ -2462,7 +2464,7 @@ case "$1" in
;;
;;
--bug-report-url
)
--bug-report-url
)
print_bug_report_url
print_bug_report_url
exit
return
;;
;;
-s
|
-n
|
--vendor-name
)
-s
|
-n
|
--vendor-name
)
override_distrib
"
$2
"
override_distrib
"
$2
"
...
@@ -2562,7 +2564,7 @@ print_version()
...
@@ -2562,7 +2564,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.
42
.0 https://wiki.etersoft.ru/Epm"
echo
"Service manager version 3.
50
.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."
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment