Skip to content

Commit 4b2f0f3

Browse files
author
P3TERX
committed
Add enhancement patch
1 parent 569883e commit 4b2f0f3

8 files changed

+393
-38
lines changed

aria2-gnu-linux-build.sh

+12-11
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,18 @@
55
# Description: Build aria2 on the target architecture
66
# System Required: Debian & Ubuntu & Fedora & Arch Linux
77
# Lisence: GPLv3
8-
# Version: 1.3
8+
# Version: 1.4
99
# Author: P3TERX
1010
# Blog: https://p3terx.com (chinese)
1111
#===========================================================
1212
set -e
1313
[ $EUID != 0 ] && SUDO=sudo
1414
$SUDO echo
15-
16-
## DEPENDENCES ##
17-
ZLIB='http://sourceforge.net/projects/libpng/files/zlib/1.2.11/zlib-1.2.11.tar.gz'
18-
EXPAT='https://github.com/libexpat/libexpat/releases/download/R_2_2_9/expat-2.2.9.tar.bz2'
19-
C_ARES='http://c-ares.haxx.se/download/c-ares-1.16.0.tar.gz'
20-
OPENSSL='http://www.openssl.org/source/openssl-1.1.1f.tar.gz'
21-
SQLITE3='https://www.sqlite.org/2020/sqlite-autoconf-3310100.tar.gz'
22-
LIBSSH2='https://www.libssh2.org/download/libssh2-1.9.0.tar.gz'
15+
SCRIPT_DIR=$PWD
2316

2417
## CONFIG ##
2518
ARCH="$(uname -m)"
26-
OPENSSL_ARCH="linux-x86_64"
19+
OPENSSL_ARCH="linux-elf"
2720
BUILD_DIR="/tmp"
2821
OUTPUT_DIR="$HOME/output"
2922
PREFIX="$BUILD_DIR/aria2-build-libs"
@@ -38,6 +31,9 @@ export RANLIB="ranlib"
3831
export AR="ar"
3932
export LD="ld"
4033

34+
## DEPENDENCES ##
35+
source dependences
36+
4137
DEBIAN_INSTALL() {
4238
$SUDO apt-get update
4339
$SUDO apt-get -y install build-essential git curl ca-certificates \
@@ -130,7 +126,7 @@ LIBSSH2_BUILD() {
130126
make install -j$(nproc)
131127
}
132128

133-
ARIA2_SRC() {
129+
ARIA2_SOURCE() {
134130
[ -e $BUILD_DIR/aria2 ] && {
135131
cd $BUILD_DIR/aria2
136132
git reset --hard origin || git reset --hard
@@ -150,8 +146,13 @@ ARIA2_RELEASE() {
150146
cut -d ' ' -f 2 | xargs -I % curl -Ls -o - '%' | tar Jxvf - --strip-components=1
151147
}
152148

149+
ARIA2_PATCH() {
150+
git apply $SCRIPT_DIR/patch/*.patch
151+
}
152+
153153
ARIA2_BUILD() {
154154
ARIA2_RELEASE || ARIA2_SOURCE
155+
ARIA2_PATCH
155156
./configure \
156157
--prefix=${ARIA2_PREFIX:-'/usr/loacl'} \
157158
--without-libxml2 \

aria2-gnu-linux-cross-build-arm64.sh

+10-9
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,14 @@
55
# Description: Cross build Aria2 arm64 version
66
# System Required: Debian & Ubuntu & Fedora & Arch Linux
77
# Lisence: GPLv3
8-
# Version: 1.3
8+
# Version: 1.4
99
# Author: P3TERX
1010
# Blog: https://p3terx.com (chinese)
1111
#===========================================================
1212
set -e
1313
[ $EUID != 0 ] && SUDO=sudo
1414
$SUDO echo
15-
16-
## DEPENDENCES ##
17-
ZLIB='http://sourceforge.net/projects/libpng/files/zlib/1.2.11/zlib-1.2.11.tar.gz'
18-
EXPAT='https://github.com/libexpat/libexpat/releases/download/R_2_2_9/expat-2.2.9.tar.bz2'
19-
C_ARES='http://c-ares.haxx.se/download/c-ares-1.16.0.tar.gz'
20-
OPENSSL='http://www.openssl.org/source/openssl-1.1.1f.tar.gz'
21-
SQLITE3='https://www.sqlite.org/2020/sqlite-autoconf-3310100.tar.gz'
22-
LIBSSH2='https://www.libssh2.org/download/libssh2-1.9.0.tar.gz'
15+
SCRIPT_DIR=$PWD
2316

2417
## CONFIG ##
2518
ARCH="arm64"
@@ -39,6 +32,9 @@ export RANLIB="$HOST-ranlib"
3932
export AR="$HOST-ar"
4033
export LD="$HOST-ld"
4134

35+
## DEPENDENCES ##
36+
source dependences
37+
4238
DEBIAN_INSTALL() {
4339
$SUDO apt-get update
4440
$SUDO apt-get -y install build-essential git curl ca-certificates \
@@ -161,8 +157,13 @@ ARIA2_RELEASE() {
161157
tar Jxvf - --strip-components=1
162158
}
163159

160+
ARIA2_PATCH() {
161+
git apply $SCRIPT_DIR/patch/*.patch
162+
}
163+
164164
ARIA2_BUILD() {
165165
ARIA2_RELEASE || ARIA2_SOURCE
166+
ARIA2_PATCH
166167
./configure \
167168
--host=$HOST \
168169
--prefix=${ARIA2_PREFIX:-'/usr'} \

aria2-gnu-linux-cross-build-armhf.sh

+10-9
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,14 @@
55
# Description: Cross build Aria2 armhf version
66
# System Required: Ubuntu 14.04/16.04
77
# Lisence: GPLv3
8-
# Version: 1.3
8+
# Version: 1.4
99
# Author: P3TERX
1010
# Blog: https://p3terx.com (chinese)
1111
#===========================================================
1212
set -e
1313
[ $EUID != 0 ] && SUDO=sudo
1414
$SUDO echo
15-
16-
## DEPENDENCES ##
17-
ZLIB='http://sourceforge.net/projects/libpng/files/zlib/1.2.11/zlib-1.2.11.tar.gz'
18-
EXPAT='https://github.com/libexpat/libexpat/releases/download/R_2_2_9/expat-2.2.9.tar.bz2'
19-
C_ARES='http://c-ares.haxx.se/download/c-ares-1.16.0.tar.gz'
20-
OPENSSL='http://www.openssl.org/source/openssl-1.1.1f.tar.gz'
21-
SQLITE3='https://www.sqlite.org/2020/sqlite-autoconf-3310100.tar.gz'
22-
LIBSSH2='https://www.libssh2.org/download/libssh2-1.9.0.tar.gz'
15+
SCRIPT_DIR=$PWD
2316

2417
## CONFIG ##
2518
ARCH="armhf"
@@ -39,6 +32,9 @@ export RANLIB="$HOST-ranlib"
3932
export AR="$HOST-ar"
4033
export LD="$HOST-ld"
4134

35+
## DEPENDENCES ##
36+
source dependences
37+
4238
DEBIAN_INSTALL() {
4339
$SUDO apt-get update
4440
$SUDO apt-get -y install build-essential git curl ca-certificates \
@@ -147,8 +143,13 @@ ARIA2_RELEASE() {
147143
tar Jxvf - --strip-components=1
148144
}
149145

146+
ARIA2_PATCH() {
147+
git apply $SCRIPT_DIR/patch/*.patch
148+
}
149+
150150
ARIA2_BUILD() {
151151
ARIA2_RELEASE || ARIA2_SOURCE
152+
ARIA2_PATCH
152153
./configure \
153154
--host=$HOST \
154155
--prefix=${ARIA2_PREFIX:-'/usr'} \

aria2-gnu-linux-cross-build-i386.sh

+10-9
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,14 @@
55
# Description: Cross build Aria2 i386 version
66
# System Required: Debian & Ubuntu & Fedora & Arch Linux
77
# Lisence: GPLv3
8-
# Version: 1.3
8+
# Version: 1.4
99
# Author: P3TERX
1010
# Blog: https://p3terx.com (chinese)
1111
#===========================================================
1212
set -e
1313
[ $EUID != 0 ] && SUDO=sudo
1414
$SUDO echo
15-
16-
## DEPENDENCES ##
17-
ZLIB='http://sourceforge.net/projects/libpng/files/zlib/1.2.11/zlib-1.2.11.tar.gz'
18-
EXPAT='https://github.com/libexpat/libexpat/releases/download/R_2_2_9/expat-2.2.9.tar.bz2'
19-
C_ARES='http://c-ares.haxx.se/download/c-ares-1.16.0.tar.gz'
20-
OPENSSL='http://www.openssl.org/source/openssl-1.1.1f.tar.gz'
21-
SQLITE3='https://www.sqlite.org/2020/sqlite-autoconf-3310100.tar.gz'
22-
LIBSSH2='https://www.libssh2.org/download/libssh2-1.9.0.tar.gz'
15+
SCRIPT_DIR=$PWD
2316

2417
## CONFIG ##
2518
ARCH="i386"
@@ -39,6 +32,9 @@ export RANLIB="$HOST-ranlib"
3932
export AR="$HOST-ar"
4033
export LD="$HOST-ld"
4134

35+
## DEPENDENCES ##
36+
source dependences
37+
4238
DEBIAN_INSTALL() {
4339
$SUDO apt-get update
4440
$SUDO apt-get -y install build-essential git curl ca-certificates \
@@ -161,8 +157,13 @@ ARIA2_RELEASE() {
161157
tar Jxvf - --strip-components=1
162158
}
163159

160+
ARIA2_PATCH() {
161+
git apply $SCRIPT_DIR/patch/*.patch
162+
}
163+
164164
ARIA2_BUILD() {
165165
ARIA2_RELEASE || ARIA2_SOURCE
166+
ARIA2_PATCH
166167
./configure \
167168
--host=$HOST \
168169
--prefix=${ARIA2_PREFIX:-'/usr'} \

dependences

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ZLIB='http://sourceforge.net/projects/libpng/files/zlib/1.2.11/zlib-1.2.11.tar.gz'
2+
EXPAT='https://github.com/libexpat/libexpat/releases/download/R_2_2_9/expat-2.2.9.tar.bz2'
3+
C_ARES='http://c-ares.haxx.se/download/c-ares-1.16.0.tar.gz'
4+
OPENSSL='http://www.openssl.org/source/openssl-1.1.1g.tar.gz'
5+
SQLITE3='https://www.sqlite.org/2020/sqlite-autoconf-3310100.tar.gz'
6+
LIBSSH2='https://www.libssh2.org/download/libssh2-1.9.0.tar.gz'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
From fe86c68505cd21d51682f14824216cb16af0b149 Mon Sep 17 00:00:00 2001
2+
From: P3TERX <[email protected]>
3+
Date: Sat, 2 May 2020 17:40:09 +0800
4+
Subject: [PATCH] options: unlock connection-per-server limit
5+
6+
---
7+
src/OptionHandlerFactory.cc | 6 +++---
8+
1 file changed, 3 insertions(+), 3 deletions(-)
9+
10+
diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc
11+
index 6bff4caa..600a9128 100644
12+
--- a/src/OptionHandlerFactory.cc
13+
+++ b/src/OptionHandlerFactory.cc
14+
@@ -440,7 +440,7 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
15+
{
16+
OptionHandler* op(new NumberOptionHandler(PREF_MAX_CONNECTION_PER_SERVER,
17+
TEXT_MAX_CONNECTION_PER_SERVER,
18+
- "1", 1, 16, 'x'));
19+
+ "1", 1, -1, 'x'));
20+
op->addTag(TAG_BASIC);
21+
op->addTag(TAG_FTP);
22+
op->addTag(TAG_HTTP);
23+
@@ -501,7 +501,7 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
24+
}
25+
{
26+
OptionHandler* op(new UnitNumberOptionHandler(
27+
- PREF_MIN_SPLIT_SIZE, TEXT_MIN_SPLIT_SIZE, "20M", 1_m, 1_g, 'k'));
28+
+ PREF_MIN_SPLIT_SIZE, TEXT_MIN_SPLIT_SIZE, "20M", 1_k, 1_g, 'k'));
29+
op->addTag(TAG_BASIC);
30+
op->addTag(TAG_FTP);
31+
op->addTag(TAG_HTTP);
32+
@@ -905,7 +905,7 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
33+
}
34+
{
35+
OptionHandler* op(new UnitNumberOptionHandler(
36+
- PREF_PIECE_LENGTH, TEXT_PIECE_LENGTH, "1M", 1_m, 1_g));
37+
+ PREF_PIECE_LENGTH, TEXT_PIECE_LENGTH, "1M", 1_k, 1_g));
38+
op->addTag(TAG_ADVANCED);
39+
op->addTag(TAG_FTP);
40+
op->addTag(TAG_HTTP);
41+
--
42+
2.20.1
43+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
From 66524bee738e98742c908d93c993d0a78a2d9891 Mon Sep 17 00:00:00 2001
2+
From: myfreeer <[email protected]>
3+
Date: Sat, 18 Nov 2017 11:55:04 +0800
4+
Subject: [PATCH 3/4] download: retry on slow speed and conection close
5+
6+
This would provide better speed on bad network conditions
7+
---
8+
src/DownloadCommand.cc | 2 +-
9+
src/SocketBuffer.cc | 3 ++-
10+
src/SocketCore.cc | 2 +-
11+
3 files changed, 4 insertions(+), 3 deletions(-)
12+
13+
diff --git a/src/DownloadCommand.cc b/src/DownloadCommand.cc
14+
index 2db41e4..f49eb80 100644
15+
--- a/src/DownloadCommand.cc
16+
+++ b/src/DownloadCommand.cc
17+
@@ -306,7 +306,7 @@ void DownloadCommand::checkLowestDownloadSpeed() const
18+
startupIdleTime_) {
19+
int nowSpeed = peerStat_->calculateDownloadSpeed();
20+
if (nowSpeed <= lowestDownloadSpeedLimit_) {
21+
- throw DL_ABORT_EX2(fmt(EX_TOO_SLOW_DOWNLOAD_SPEED, nowSpeed,
22+
+ throw DL_RETRY_EX2(fmt(EX_TOO_SLOW_DOWNLOAD_SPEED, nowSpeed,
23+
lowestDownloadSpeedLimit_,
24+
getRequest()->getHost().c_str()),
25+
error_code::TOO_SLOW_DOWNLOAD_SPEED);
26+
diff --git a/src/SocketBuffer.cc b/src/SocketBuffer.cc
27+
index 62862ff..1906173 100644
28+
--- a/src/SocketBuffer.cc
29+
+++ b/src/SocketBuffer.cc
30+
@@ -39,6 +39,7 @@
31+
32+
#include "SocketCore.h"
33+
#include "DlAbortEx.h"
34+
+#include "DlRetryEx.h"
35+
#include "message.h"
36+
#include "fmt.h"
37+
#include "LogFactory.h"
38+
@@ -158,7 +159,7 @@ ssize_t SocketBuffer::send()
39+
}
40+
ssize_t slen = socket_->writeVector(iov, num);
41+
if (slen == 0 && !socket_->wantRead() && !socket_->wantWrite()) {
42+
- throw DL_ABORT_EX(fmt(EX_SOCKET_SEND, "Connection closed."));
43+
+ throw DL_RETRY_EX(fmt(EX_SOCKET_SEND, "Connection closed."));
44+
}
45+
// A2_LOG_NOTICE(fmt("num=%zu, amount=%d, bufq.size()=%zu, SEND=%d",
46+
// num, amount, bufq_.size(), slen));
47+
diff --git a/src/SocketCore.cc b/src/SocketCore.cc
48+
index 77dc30c..537375a 100644
49+
--- a/src/SocketCore.cc
50+
+++ b/src/SocketCore.cc
51+
@@ -1009,7 +1009,7 @@ bool SocketCore::tlsHandshake(TLSContext* tlsctx, const std::string& hostname)
52+
53+
if (rv == TLS_ERR_ERROR) {
54+
// Damn those error.
55+
- throw DL_ABORT_EX(fmt("SSL/TLS handshake failure: %s",
56+
+ throw DL_RETRY_EX(fmt("SSL/TLS handshake failure: %s",
57+
handshakeError.empty()
58+
? tlsSession_->getLastErrorString().c_str()
59+
: handshakeError.c_str()));
60+
--
61+
2.17.1
62+

0 commit comments

Comments
 (0)