forked from aria2/aria2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.android
148 lines (126 loc) · 4.45 KB
/
Dockerfile.android
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# vim: ft=dockerfile:
# Dockerfile to build aria2 android binary
#
# $ sudo docker build -t aria2-android - < Dockerfile.android
#
# After successful build, android binary is located under
# /root/build/aria2. You can copy the binary using docker cp. For
# example, to copy aria2c binary to host file system location
# /path/to/dest, do this:
#
# $ sudo docker run --rm -it -v /path/to/dest:/out aria2-android cp /root/build/aria2/src/aria2c /out
FROM ubuntu:22.04
MAINTAINER Tatsuhiro Tsujikawa
WORKDIR /root
RUN apt-get update && \
apt-get install -y --no-install-recommends \
unzip bzip2 make binutils autoconf automake autotools-dev autopoint \
libtool pkg-config git dpkg-dev curl ca-certificates \
python3-docutils && \
rm -rf /var/cache/apt/*
# NDK version
ENV NDK_VERSION=r25c
ENV NDK=/root/android-ndk-$NDK_VERSION
ENV TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64 \
HOST=aarch64-linux-android \
API=33
ENV AR=$TOOLCHAIN/bin/llvm-ar \
CC=$TOOLCHAIN/bin/$HOST$API-clang \
CXX=$TOOLCHAIN/bin/$HOST$API-clang++ \
LD=$TOOLCHAIN/bin/ld \
RANDLIB=$TOOLCHAIN/bin/llvm-ranlib \
STRIP=$TOOLCHAIN/bin/llvm-strip \
PREFIX=/root/usr/local
# Download NDK
RUN curl -L -O https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-linux.zip && \
unzip -q android-ndk-$NDK_VERSION-linux.zip && \
rm android-ndk-$NDK_VERSION-linux.zip
# aria2 version
ARG ARIA2_VERSION=master
# Library versions
ENV OPENSSL_VERSION=1.1.1w
ENV OPENSSL_ARCHIVE=openssl-$OPENSSL_VERSION.tar.gz
ENV OPENSSL_URI=https://www.openssl.org/source/$OPENSSL_ARCHIVE
ENV LIBEXPAT_VERSION=2.5.0
ENV LIBEXPAT_ARCHIVE=expat-$LIBEXPAT_VERSION.tar.bz2
ENV LIBEXPAT_URI=https://github.com/libexpat/libexpat/releases/download/R_2_5_0/$LIBEXPAT_ARCHIVE
ENV ZLIB_VERSION=1.3.1
ENV ZLIB_ARCHIVE=zlib-$ZLIB_VERSION.tar.gz
ENV ZLIB_URI=https://github.com/madler/zlib/releases/download/v1.3.1/$ZLIB_ARCHIVE
ENV CARES_VERSION=1.21.0
ENV CARES_ARCHIVE=c-ares-$CARES_VERSION.tar.gz
ENV CARES_URI=https://c-ares.haxx.se/download/$CARES_ARCHIVE
ENV LIBSSH2_VERSION=1.11.0
ENV LIBSSH2_ARCHIVE=libssh2-$LIBSSH2_VERSION.tar.bz2
ENV LIBSSH2_URI=https://libssh2.org/download/$LIBSSH2_ARCHIVE
# Build OpenSSL
WORKDIR /root/build
RUN curl -L -O $OPENSSL_URI && tar xf $OPENSSL_ARCHIVE && rm $OPENSSL_ARCHIVE
WORKDIR /root/build/openssl-$OPENSSL_VERSION
RUN export ANDROID_NDK_HOME=$NDK PATH=$TOOLCHAIN/bin:$PATH && \
./Configure no-shared --prefix=$PREFIX android-arm64 && \
make -j$(nproc) && make install_sw
# Build libexpat
WORKDIR /root/build
RUN curl -L -O $LIBEXPAT_URI && tar xf $LIBEXPAT_ARCHIVE && rm $LIBEXPAT_ARCHIVE
WORKDIR /root/build/expat-$LIBEXPAT_VERSION
RUN ./configure \
--host=$HOST \
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
--prefix=$PREFIX \
--disable-shared && \
make -j$(nproc) install
# Build zlib
WORKDIR /root/build
RUN curl -L -O $ZLIB_URI && tar xf $ZLIB_ARCHIVE && rm $ZLIB_ARCHIVE
WORKDIR /root/build/zlib-$ZLIB_VERSION
RUN ./configure \
--prefix=$PREFIX \
--libdir=$PREFIX/lib \
--includedir=$PREFIX/include \
--static && \
make -j$(nproc) install
# Build c-ares
WORKDIR /root/build
RUN curl -L -O $CARES_URI && tar xf $CARES_ARCHIVE && rm $CARES_ARCHIVE
WORKDIR /root/build/c-ares-$CARES_VERSION
RUN ./configure \
--host=$HOST \
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
--prefix=$PREFIX \
--disable-shared && \
make -j$(nproc) install
# Build libssh2
WORKDIR /root/build
RUN curl -L -O $LIBSSH2_URI && tar xf $LIBSSH2_ARCHIVE && rm $LIBSSH2_ARCHIVE
WORKDIR /root/build/libssh2-$LIBSSH2_VERSION
RUN ./configure \
--host=$HOST \
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
--prefix=$PREFIX \
--disable-shared && \
make -j$(nproc) install
# Build aria2
WORKDIR /root/build
RUN git clone -b $ARIA2_VERSION --depth 1 https://github.com/aria2/aria2
WORKDIR /root/build/aria2
RUN autoreconf -i && \
./configure \
--host=$HOST \
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
--disable-nls \
--without-gnutls \
--with-openssl \
--without-sqlite3 \
--without-libxml2 \
--with-libexpat \
--with-libcares \
--with-libz \
--with-libssh2 \
CXXFLAGS="-Os -g" \
CFLAGS="-Os -g" \
CPPFLAGS="-fPIE" \
LDFLAGS="-fPIE -pie -L$PREFIX/lib -static-libstdc++" \
PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig" && \
make -j$(nproc) && \
$STRIP src/aria2c