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
Vladislav
eepm
Commits
128275aa
Commit
128275aa
authored
Mar 27, 2023
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eget: regroup functions
parent
5a8d5633
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
66 deletions
+65
-66
tools_eget
bin/tools_eget
+65
-66
No files found.
bin/tools_eget
View file @
128275aa
...
...
@@ -27,6 +27,7 @@ fatal()
exit
1
}
# TODO:
arch
=
"
$(
uname
-m
)
"
...
...
@@ -141,6 +142,24 @@ if [ "$1" = "-U" ] || [ "$1" = "-A" ] || [ "$1" = "--user-agent" ] ; then
shift
fi
# check man glob
filter_glob
()
{
[
-z
"
$1
"
]
&&
cat
&&
return
# translate glob to regexp
grep
"
$(
echo
"
$1
"
|
sed
-e
"s|
\*
|.*|g"
-e
"s|?|.|g"
)
$"
}
filter_order
()
{
if
[
-n
"
$SECONDLATEST
"
]
;
then
sort
-V
|
tail
-n2
|
head
-n1
return
fi
[
-z
"
$LATEST
"
]
&&
cat
&&
return
sort
-V
|
tail
-n1
}
# args: cmd <URL> <options>
# will run cmd <options> <URL>
download_with_mirroring
()
...
...
@@ -165,6 +184,52 @@ download_with_mirroring()
}
LISTONLY
=
''
if
[
"
$1
"
=
"--list"
]
;
then
LISTONLY
=
"
$1
"
set_quiet
shift
fi
if
[
"
$1
"
=
"--check"
]
;
then
set_quiet
shift
check_url_is_accessible
"
$1
"
exit
fi
LATEST
=
''
if
[
"
$1
"
=
"--latest"
]
;
then
LATEST
=
"
$1
"
shift
fi
SECONDLATEST
=
''
if
[
"
$1
"
=
"--second-latest"
]
;
then
SECONDLATEST
=
"
$1
"
shift
fi
CHECKMIRRORS
=
''
if
[
"
$1
"
=
"--check-mirrors"
]
;
then
CHECKMIRRORS
=
"
$1
"
shift
fi
# download to this file
TARGETFILE
=
''
if
[
"
$1
"
=
"-O"
]
;
then
TARGETFILE
=
"
$2
"
shift
2
elif
[
"
$1
"
=
"-O-"
]
;
then
TARGETFILE
=
"-"
shift
1
fi
WGET
=
"
$(
which wget 2>/dev/null
)
"
if
[
-n
"
$WGET
"
]
;
then
...
...
@@ -249,72 +314,6 @@ check_url_is_accessible()
fi
LISTONLY
=
''
if
[
"
$1
"
=
"--list"
]
;
then
LISTONLY
=
"
$1
"
set_quiet
shift
fi
if
[
"
$1
"
=
"--check"
]
;
then
set_quiet
shift
check_url_is_accessible
"
$1
"
exit
fi
LATEST
=
''
if
[
"
$1
"
=
"--latest"
]
;
then
LATEST
=
"
$1
"
shift
fi
SECONDLATEST
=
''
if
[
"
$1
"
=
"--second-latest"
]
;
then
SECONDLATEST
=
"
$1
"
shift
fi
CHECKMIRRORS
=
''
if
[
"
$1
"
=
"--check-mirrors"
]
;
then
CHECKMIRRORS
=
"
$1
"
shift
fi
fatal
()
{
echo
"
$*
"
>
&2
exit
1
}
# check man glob
filter_glob
()
{
[
-z
"
$1
"
]
&&
cat
&&
return
# translate glob to regexp
grep
"
$(
echo
"
$1
"
|
sed
-e
"s|
\*
|.*|g"
-e
"s|?|.|g"
)
$"
}
filter_order
()
{
if
[
-n
"
$SECONDLATEST
"
]
;
then
sort
-V
|
tail
-n2
|
head
-n1
return
fi
[
-z
"
$LATEST
"
]
&&
cat
&&
return
sort
-V
|
tail
-n1
}
# download to this file
TARGETFILE
=
''
if
[
"
$1
"
=
"-O"
]
;
then
TARGETFILE
=
"
$2
"
shift
2
elif
[
"
$1
"
=
"-O-"
]
;
then
TARGETFILE
=
"-"
shift
1
fi
# TODO:
# -P support
...
...
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