sterepando commited on
Commit
ab1a186
·
verified ·
1 Parent(s): c9c81a5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +23 -15
Dockerfile CHANGED
@@ -31,25 +31,33 @@ ENV STRIP="llvm-strip"
31
  ENV READELF="llvm-readelf"
32
  ENV PREFIX=/opt/android-libs
33
 
 
 
 
 
34
  RUN mkdir -p $PREFIX
35
 
36
- # 3. ZLIB (Static)
37
  WORKDIR /build/zlib
38
  RUN wget -q https://zlib.net/zlib-1.3.1.tar.gz && tar -xf zlib-1.3.1.tar.gz && cd zlib-1.3.1 && \
 
 
39
  ./configure --prefix=$PREFIX --static && \
40
  make -j4 && make install
41
 
42
- # 4. OpenSSL (Static)
43
  WORKDIR /build/openssl
44
  RUN wget -q https://www.openssl.org/source/openssl-3.2.0.tar.gz && tar -xf openssl-3.2.0.tar.gz && cd openssl-3.2.0 && \
 
45
  ./Configure android-arm64 \
46
  -D__ANDROID_API__=${ANDROID_API} \
47
  --prefix=$PREFIX \
48
  no-shared \
 
49
  && \
50
  make -j4 && make install_sw
51
 
52
- # 5. Curl (Static)
53
  WORKDIR /build/curl
54
  RUN wget -q https://curl.se/download/curl-8.5.0.tar.gz && tar -xf curl-8.5.0.tar.gz && cd curl-8.5.0 && \
55
  ./configure \
@@ -64,7 +72,7 @@ RUN wget -q https://curl.se/download/curl-8.5.0.tar.gz && tar -xf curl-8.5.0.tar
64
  CFLAGS="-I$PREFIX/include -fPIC" LDFLAGS="-L$PREFIX/lib" && \
65
  make -j4 && make install
66
 
67
- # 6. Python заголовки (нужны для сборки wheel)
68
  WORKDIR /opt/python-src
69
  ENV PY_VERSION=3.11.9
70
  RUN wget -q https://www.python.org/ftp/python/${PY_VERSION}/Python-${PY_VERSION}.tgz && \
@@ -83,18 +91,15 @@ RUN ./configure \
83
  CC="aarch64-linux-android${ANDROID_API}-clang" \
84
  CXX="aarch64-linux-android${ANDROID_API}-clang++"
85
 
86
- # 7. СБОРКА ПАКЕТОВ
87
  WORKDIR /build/wheels
88
  RUN pip install build wheel
89
 
90
- # === Создаем FAKE curl-config ===
91
- # PyCurl вызывает этот скрипт, чтобы узнать пути к либам.
92
- # Мы подсовываем ему наши статические пути.
93
  RUN echo '#!/bin/bash' > /usr/bin/curl-config-android && \
94
  echo 'case "$1" in' >> /usr/bin/curl-config-android && \
95
  echo ' --version) echo "libcurl 8.5.0";;' >> /usr/bin/curl-config-android && \
96
  echo ' --features) echo "SSL IPv6 UnixSockets libz AsynchDNS Largefile HSTS Alt-Svc HTTPS-proxy";;' >> /usr/bin/curl-config-android && \
97
- # Важно: перечисляем все либы (curl, ssl, crypto, z)
98
  echo ' --libs|--static-libs) echo "-L'${PREFIX}'/lib -lcurl -lssl -lcrypto -lz";;' >> /usr/bin/curl-config-android && \
99
  echo ' --cflags) echo "-I'${PREFIX}'/include -DANDROID";;' >> /usr/bin/curl-config-android && \
100
  echo ' --prefix) echo "'${PREFIX}'";;' >> /usr/bin/curl-config-android && \
@@ -102,10 +107,11 @@ RUN echo '#!/bin/bash' > /usr/bin/curl-config-android && \
102
  echo 'esac' >> /usr/bin/curl-config-android && \
103
  chmod +x /usr/bin/curl-config-android
104
 
105
- # Скрипт сборки wheels
106
  RUN echo '#!/bin/bash' > build_wheels.sh && \
107
  echo 'export CC="aarch64-linux-android'${ANDROID_API}'-clang"' >> build_wheels.sh && \
108
  echo 'export LDSHARED="aarch64-linux-android'${ANDROID_API}'-clang -shared"' >> build_wheels.sh && \
 
109
  echo 'export CFLAGS="-I/opt/python-src/python3-android -I/opt/python-src/python3-android/Include -I'${PREFIX}'/include -DANDROID -fPIC"' >> build_wheels.sh && \
110
  echo 'export LDFLAGS="-L/opt/python-src/python3-android -L'${PREFIX}'/lib -lcurl -lssl -lcrypto -lz"' >> build_wheels.sh && \
111
  \
@@ -113,9 +119,12 @@ RUN echo '#!/bin/bash' > build_wheels.sh && \
113
  echo 'echo "Building wget..."' >> build_wheels.sh && \
114
  echo 'pip wheel wget --no-binary :all: --no-deps -w dist/' >> build_wheels.sh && \
115
  \
116
- # 2. PYCURL
 
 
 
 
117
  echo 'echo "Building PyCurl..."' >> build_wheels.sh && \
118
- # Говорим PyCurl использовать наш фейковый конфиг
119
  echo 'export PYCURL_CURL_CONFIG=/usr/bin/curl-config-android' >> build_wheels.sh && \
120
  echo 'export PYCURL_SSL_LIBRARY=openssl' >> build_wheels.sh && \
121
  echo 'pip wheel pycurl --no-binary :all: --no-deps -w dist/' >> build_wheels.sh
@@ -123,16 +132,15 @@ RUN echo '#!/bin/bash' > build_wheels.sh && \
123
  RUN chmod +x build_wheels.sh
124
  RUN ./build_wheels.sh
125
 
126
- # 8. Переименование под Android
127
  WORKDIR /output
128
  RUN cd /build/wheels/dist && \
129
  for file in *.whl; do \
130
  PACKAGE_NAME=$(echo $file | cut -d'-' -f1) && \
131
  VERSION=$(echo $file | cut -d'-' -f2) && \
132
- # Жесткое имя, как вы просили
133
  NEW_NAME="${PACKAGE_NAME}-${VERSION}-cp311-cp311-android_21-30_arm64_v8a.whl" && \
134
  mv "$file" "/output/$NEW_NAME"; \
135
  done
136
 
137
- # 9. Выдача файлов
138
  CMD ["python3", "-m", "http.server", "7860", "--directory", "/output"]
 
31
  ENV READELF="llvm-readelf"
32
  ENV PREFIX=/opt/android-libs
33
 
34
+ # ВАЖНО: Добавляем -fPIC во все глобальные флаги
35
+ ENV CFLAGS="-fPIC"
36
+ ENV CXXFLAGS="-fPIC"
37
+
38
  RUN mkdir -p $PREFIX
39
 
40
+ # 3. ZLIB (Static + fPIC)
41
  WORKDIR /build/zlib
42
  RUN wget -q https://zlib.net/zlib-1.3.1.tar.gz && tar -xf zlib-1.3.1.tar.gz && cd zlib-1.3.1 && \
43
+ # zlib configure читает CFLAGS из окружения
44
+ export CFLAGS="-fPIC" && \
45
  ./configure --prefix=$PREFIX --static && \
46
  make -j4 && make install
47
 
48
+ # 4. OpenSSL (Static + fPIC)
49
  WORKDIR /build/openssl
50
  RUN wget -q https://www.openssl.org/source/openssl-3.2.0.tar.gz && tar -xf openssl-3.2.0.tar.gz && cd openssl-3.2.0 && \
51
+ # Добавляем -fPIC явно в опции конфигурации
52
  ./Configure android-arm64 \
53
  -D__ANDROID_API__=${ANDROID_API} \
54
  --prefix=$PREFIX \
55
  no-shared \
56
+ -fPIC \
57
  && \
58
  make -j4 && make install_sw
59
 
60
+ # 5. Curl (Static + fPIC)
61
  WORKDIR /build/curl
62
  RUN wget -q https://curl.se/download/curl-8.5.0.tar.gz && tar -xf curl-8.5.0.tar.gz && cd curl-8.5.0 && \
63
  ./configure \
 
72
  CFLAGS="-I$PREFIX/include -fPIC" LDFLAGS="-L$PREFIX/lib" && \
73
  make -j4 && make install
74
 
75
+ # 6. Python заголовки
76
  WORKDIR /opt/python-src
77
  ENV PY_VERSION=3.11.9
78
  RUN wget -q https://www.python.org/ftp/python/${PY_VERSION}/Python-${PY_VERSION}.tgz && \
 
91
  CC="aarch64-linux-android${ANDROID_API}-clang" \
92
  CXX="aarch64-linux-android${ANDROID_API}-clang++"
93
 
94
+ # 7. СБОРКА WHEELS
95
  WORKDIR /build/wheels
96
  RUN pip install build wheel
97
 
98
+ # FAKE curl-config
 
 
99
  RUN echo '#!/bin/bash' > /usr/bin/curl-config-android && \
100
  echo 'case "$1" in' >> /usr/bin/curl-config-android && \
101
  echo ' --version) echo "libcurl 8.5.0";;' >> /usr/bin/curl-config-android && \
102
  echo ' --features) echo "SSL IPv6 UnixSockets libz AsynchDNS Largefile HSTS Alt-Svc HTTPS-proxy";;' >> /usr/bin/curl-config-android && \
 
103
  echo ' --libs|--static-libs) echo "-L'${PREFIX}'/lib -lcurl -lssl -lcrypto -lz";;' >> /usr/bin/curl-config-android && \
104
  echo ' --cflags) echo "-I'${PREFIX}'/include -DANDROID";;' >> /usr/bin/curl-config-android && \
105
  echo ' --prefix) echo "'${PREFIX}'";;' >> /usr/bin/curl-config-android && \
 
107
  echo 'esac' >> /usr/bin/curl-config-android && \
108
  chmod +x /usr/bin/curl-config-android
109
 
110
+ # Скрипт сборки
111
  RUN echo '#!/bin/bash' > build_wheels.sh && \
112
  echo 'export CC="aarch64-linux-android'${ANDROID_API}'-clang"' >> build_wheels.sh && \
113
  echo 'export LDSHARED="aarch64-linux-android'${ANDROID_API}'-clang -shared"' >> build_wheels.sh && \
114
+ # Добавляем -fPIC и сюда для надежности
115
  echo 'export CFLAGS="-I/opt/python-src/python3-android -I/opt/python-src/python3-android/Include -I'${PREFIX}'/include -DANDROID -fPIC"' >> build_wheels.sh && \
116
  echo 'export LDFLAGS="-L/opt/python-src/python3-android -L'${PREFIX}'/lib -lcurl -lssl -lcrypto -lz"' >> build_wheels.sh && \
117
  \
 
119
  echo 'echo "Building wget..."' >> build_wheels.sh && \
120
  echo 'pip wheel wget --no-binary :all: --no-deps -w dist/' >> build_wheels.sh && \
121
  \
122
+ # 2. PyCryptodome (добавил, так как был в запросе выше, на всякий случай)
123
+ echo 'echo "Building PyCryptodome..."' >> build_wheels.sh && \
124
+ echo 'pip wheel pycryptodome --no-binary :all: --no-deps -w dist/' >> build_wheels.sh && \
125
+ \
126
+ # 3. PYCURL
127
  echo 'echo "Building PyCurl..."' >> build_wheels.sh && \
 
128
  echo 'export PYCURL_CURL_CONFIG=/usr/bin/curl-config-android' >> build_wheels.sh && \
129
  echo 'export PYCURL_SSL_LIBRARY=openssl' >> build_wheels.sh && \
130
  echo 'pip wheel pycurl --no-binary :all: --no-deps -w dist/' >> build_wheels.sh
 
132
  RUN chmod +x build_wheels.sh
133
  RUN ./build_wheels.sh
134
 
135
+ # 8. Переименование
136
  WORKDIR /output
137
  RUN cd /build/wheels/dist && \
138
  for file in *.whl; do \
139
  PACKAGE_NAME=$(echo $file | cut -d'-' -f1) && \
140
  VERSION=$(echo $file | cut -d'-' -f2) && \
 
141
  NEW_NAME="${PACKAGE_NAME}-${VERSION}-cp311-cp311-android_21-30_arm64_v8a.whl" && \
142
  mv "$file" "/output/$NEW_NAME"; \
143
  done
144
 
145
+ # 9. Выдача
146
  CMD ["python3", "-m", "http.server", "7860", "--directory", "/output"]