Commit 9c1f59b4 authored by Pierre-Yves Fourmond's avatar Pierre-Yves Fourmond

Add Download user agent aria2c

parent db3ff13b
......@@ -21,7 +21,7 @@ It is developed and tested on [Debian GNU/Linux] (https://www.debian.org) versio
- Installation of software archives located on filesystem or network
- Destination folder selection
- Internal software archives cache, optional for local archives
- Download user agent choice (wget or curl) for network archives
- Download user agent choice (wget, curl or aria2c) for network archives
- Download resume (network archives)
- Secure installation to prevent software duplicates in a given destination folder
- Integrity for non `liar` installed software or unknown folder as `liar` does not remove nor list software it has not installed itself
......@@ -241,7 +241,7 @@ To get help and examples of `liar` usage, simply enter:
-l Create symbolic links in /home/user/bin folder after installation.
-s Specify the folder for SYMBOLIC links creation.
-p Specify the file PATTERN to restrict symbolic links creation.
-a Specify the download user AGENT: wget or curl. By default, wget is used.
-a Specify the download user AGENT: wget, curl or aria2c. By default, wget is used.
-v Activate VERBOSE mode.
-r Allow ROOT usage.
......@@ -395,6 +395,7 @@ When installing an archive that is downloaded from the internet, the default use
It is possible to change this behavior using `-a` flag with one of the following values:
- aria2c
- curl
- wget
......@@ -409,7 +410,7 @@ It is possible to change this behavior using `-a` flag with one of the following
- **mawk**
- **tar**
Additionally, **wget** or **curl** package is required when using archive download feature.
Additionally, **wget**, **curl** or **aria2** package is required when using archive download feature.
**unzip** and **compress** commands are also required when using the respective archive formats **.zip** and **.tar.Z**.
......
......@@ -49,7 +49,7 @@ Usage: $LIAR [OPTIONS...] COMMAND [PARAMETERS...]
-l Create symbolic links in $HOME/bin folder after installation.
-s Specify the folder for SYMBOLIC links creation.
-p Specify the file PATTERN to restrict symbolic links creation.
-a Specify the download user AGENT: wget or curl. By default, wget is used.
-a Specify the download user AGENT: wget, curl or aria2c. By default, wget is used.
-v Activate VERBOSE mode.
-r Allow ROOT usage.
......@@ -148,18 +148,22 @@ download() {
echo "Downloading '$source_file_path' to '$file_path' using $USER_AGENT"
fi
create_cache
if [ "$USER_AGENT" = "wget" ]; then
create_cache
if ! wget --continue "$source_file_path" --output-document "$file_path"; then
echo "Failed to download '$source_file_path' to '$file_path' using $USER_AGENT !" >&2
return 1
fi
elif [ "$USER_AGENT" = "curl" ]; then
create_cache
if ! curl --location --continue-at - "$source_file_path" --output "$file_path"; then
echo "Failed to download '$source_file_path' to '$file_path' using $USER_AGENT !" >&2
return 1
fi
elif [ "$USER_AGENT" = "aria2c" ]; then
if ! aria2c --continue=true "$source_file_path" --dir="$(dirname $file_path)" --out="$(basename $file_path)"; then
echo "Failed to download '$source_file_path' to '$file_path' using $USER_AGENT !" >&2
return 1
fi
else
echo "Failed to download '$source_file_path' to '$file_path' using $USER_AGENT !" >&2
return 1
......@@ -286,7 +290,7 @@ parse() {
;;
p) BIN_PATTERN=$OPTARG
;;
a) if [ "$OPTARG" != "wget" ] && [ "$OPTARG" != "curl" ]; then
a) if [ "$OPTARG" != "wget" ] && [ "$OPTARG" != "curl" ] && [ "$OPTARG" != "aria2c" ]; then
echo "Unhandled download user AGENT: $OPTARG !" >&2
return 1
fi
......
......@@ -84,7 +84,7 @@ _liar() {
;;
"-a")
# Complete with the option possible values
COMPREPLY=("wget" "curl")
COMPREPLY=("wget" "curl" "aria2c")
return 0
;;
"-l" | "-r")
......
......@@ -104,6 +104,7 @@ if [ -z "$TEST_CASES" ]; then
testCacheBypassedScenario \
testDownloadScenarioCurl \
testDownloadScenarioWget \
testDownloadScenarioAria2 \
testInstallMetadataContent"
fi
......@@ -257,6 +258,15 @@ testDownloadScenarioWget() {
assertTrue "$CACHE_FOLDER/$(basename $ROBOMONGO_URL) should have been created !" "[ -f $CACHE_FOLDER/$(basename $ROBOMONGO_URL) ]"
}
testDownloadScenarioAria2() {
output=$(createTmpFile)
$LIAR -v -a aria2c install sublime "$SUBLIME_URL" > "$output"
assertEquals "'install' command should return 0 !" 0 $?
assertTrue "$DEST_FOLDER/sublime/sublime_text_3 should have been created !" "[ -d $DEST_FOLDER/sublime/sublime_text_3 ]"
assertEquals "'install' command has incorrect output !" "17 $output" "$(wc -l "$output")"
assertTrue "$CACHE_FOLDER/$(basename $SUBLIME_URL) should have been created !" "[ -f $CACHE_FOLDER/$(basename $SUBLIME_URL) ]"
}
testInstallMetadataContent() {
$LIAR install robomongo "$ROBOMONGO_FILE_PATH"
assertEquals "'install' command should return 0 !" 0 $?
......
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