Skip to content

Commit f6d96b6

Browse files
committed
finally done with the module, tested on my own device
1 parent d63a2ac commit f6d96b6

File tree

9 files changed

+436
-13
lines changed

9 files changed

+436
-13
lines changed

root-module/META-INF/com/google/android/update-binary

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ mount /data 2>/dev/null
3030
[ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk
3131

3232
install_module
33-
exit 0
33+
exit 0

root-module/META-INF/com/google/android/update-script renamed to root-module/META-INF/com/google/android/updater-script

File renamed without changes.

root-module/customize.sh

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,51 @@
22

33
API_URL="https://aln.kavishdevar.me/api"
44
TEMP_DIR="$TMPDIR/aln_patch"
5+
UNZIP_DIR="/data/local/tmp/aln_unzip"
56
PATCHED_FILE_NAME=""
67
SOURCE_FILE=""
78
LIBRARY_NAME=""
89
APEX_DIR=false
910

1011
mkdir -p "$TEMP_DIR"
12+
mkdir -p "$UNZIP_DIR"
13+
14+
# Manually extract the $ZIPFILE to a temporary directory
15+
ui_print "Extracting $ZIPFILE to $UNZIP_DIR"
16+
unzip -o "$ZIPFILE" -d "$UNZIP_DIR" > /dev/null 2>&1
17+
if [ $? -ne 0 ]; then
18+
ui_print "Failed to unzip $ZIPFILE"
19+
abort "Failed to unzip $ZIPFILE"
20+
fi
21+
22+
ui_print "Extracted module files to $UNZIP_DIR"
23+
24+
# Determine architecture
25+
IS64BIT=false
26+
if [ "$(uname -m)" = "aarch64" ]; then
27+
IS64BIT=true
28+
fi
29+
30+
if [ "$IS64BIT" = true ]; then
31+
export LD_LIBRARY_PATH="$UNZIP_DIR/libcurl-android/libs/arm64-v8a"
32+
export PATH="$UNZIP_DIR/libcurl-android/bin/arm64-v8a:$PATH"
33+
export CURL_CMD="$UNZIP_DIR/libcurl-android/bin/arm64-v8a/curl"
34+
ln -s "$UNZIP_DIR/libcurl-android/libs/arm64-v8a/libz.so" "$UNZIP_DIR/libcurl-android/libs/arm64-v8a/libz.so.1"
35+
else
36+
export LD_LIBRARY_PATH="$UNZIP_DIR/libcurl-android/libs/armeabi-v7a"
37+
export PATH="$UNZIP_DIR/libcurl-android/bin/armeabi-v7a:$PATH"
38+
export CURL_CMD="$UNZIP_DIR/libcurl-android/bin/armeabi-v7a/curl"
39+
ln -s "$UNZIP_DIR/libcurl-android/libs/armeabi-v7a/libz.so" "$UNZIP_DIR/libcurl-android/libs/armeabi-v7a/libz.so.1"
40+
fi
1141

12-
CURL_CMD=$(command -v curl || echo "$MODPATH/system/bin/curl")
13-
export LD_LIBRARY_PATH="$MODPATH/system/lib64:$LD_LIBRARY_PATH"
42+
set_perm "$CURL_CMD" 0 0 755
43+
44+
if [ -f "$CURL_CMD" ]; then
45+
ui_print "curl binary found."
46+
else
47+
ui_print "curl binary not found. Exiting."
48+
abort "curl binary not found."
49+
fi
1450

1551
if [ -f "/apex/com.android.btservices/lib64/libbluetooth_jni.so" ]; then
1652
SOURCE_FILE="/apex/com.android.btservices/lib64/libbluetooth_jni.so"
@@ -41,11 +77,9 @@ ui_print "Uploading $LIBRARY_NAME to the API for patching..."
4177
ui_print "If you're concerned about privacy, review the source code of the API at https://github.com/kavishdevar/aln/blob/main/root-module-manual/server.py"
4278
PATCHED_FILE_NAME="patched_$LIBRARY_NAME"
4379

44-
$CURL_CMD -s -X POST "$API_URL" \
45-
-F "file=@$SOURCE_FILE" \
46-
-F "library_name=$LIBRARY_NAME" \
47-
-o "$TEMP_DIR/$PATCHED_FILE_NAME" \
48-
-D "$TEMP_DIR/headers.txt"
80+
ui_print "calling command $CURL_CMD --verbose -k -X POST $API_URL -F file=@$SOURCE_FILE -F library_name=$LIBRARY_NAME -o $TEMP_DIR/$PATCHED_FILE_NAME"
81+
82+
$CURL_CMD --verbose -k -X POST $API_URL -F file=@"$SOURCE_FILE" -F library_name="$LIBRARY_NAME" -o "$TEMP_DIR/$PATCHED_FILE_NAME" > "$TEMP_DIR/headers.txt" 2>&1
4983

5084
if [ -f "$TEMP_DIR/$PATCHED_FILE_NAME" ]; then
5185
ui_print "Received patched file from the API."
@@ -87,10 +121,7 @@ EOF
87121
ui_print "Created post-data-fs.sh script for apex library handling."
88122
fi
89123
else
90-
ERROR_MESSAGE=$(grep -oP '(?<="error": ")[^"]+' "$TEMP_DIR/headers.txt")
91-
ui_print "API Error: $ERROR_MESSAGE"
124+
ui_print "Failed to receive patched file from the API."
92125
rm -rf "$TEMP_DIR"
93126
abort "Failed to patch the library."
94-
fi
95-
96-
rm -rf "$TEMP_DIR"
127+
fi
254 KB
Binary file not shown.
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
#! /bin/sh
2+
#***************************************************************************
3+
# _ _ ____ _
4+
# Project ___| | | | _ \| |
5+
# / __| | | | |_) | |
6+
# | (__| |_| | _ <| |___
7+
# \___|\___/|_| \_\_____|
8+
#
9+
# Copyright (C) 2001 - 2022, Daniel Stenberg, <[email protected]>, et al.
10+
#
11+
# This software is licensed as described in the file COPYING, which
12+
# you should have received as part of this distribution. The terms
13+
# are also available at https://curl.se/docs/copyright.html.
14+
#
15+
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
16+
# copies of the Software, and permit persons to whom the Software is
17+
# furnished to do so, under the terms of the COPYING file.
18+
#
19+
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20+
# KIND, either express or implied.
21+
#
22+
# SPDX-License-Identifier: curl
23+
#
24+
###########################################################################
25+
26+
prefix="/app/libcurl-android/jni/build/curl/arm64-v8a"
27+
exec_prefix=${prefix}
28+
includedir=${prefix}/include
29+
cppflag_curl_staticlib=
30+
31+
usage()
32+
{
33+
cat <<EOF
34+
Usage: curl-config [OPTION]
35+
36+
Available values for OPTION include:
37+
38+
--built-shared says 'yes' if libcurl was built shared
39+
--ca ca bundle install path
40+
--cc compiler
41+
--cflags pre-processor and compiler flags
42+
--checkfor [version] check for (lib)curl of the specified version
43+
--configure the arguments given to configure when building curl
44+
--features newline separated list of enabled features
45+
--help display this help and exit
46+
--libs library linking information
47+
--prefix curl install prefix
48+
--protocols newline separated list of enabled protocols
49+
--ssl-backends output the SSL backends libcurl was built to support
50+
--static-libs static libcurl library linking information
51+
--version output version information
52+
--vernum output the version information as a number (hexadecimal)
53+
EOF
54+
55+
exit $1
56+
}
57+
58+
if test $# -eq 0; then
59+
usage 1
60+
fi
61+
62+
while test $# -gt 0; do
63+
case "$1" in
64+
# this deals with options in the style
65+
# --option=value and extracts the value part
66+
# [not currently used]
67+
-*=*) value=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
68+
*) value= ;;
69+
esac
70+
71+
case "$1" in
72+
--built-shared)
73+
echo yes
74+
;;
75+
76+
--ca)
77+
echo
78+
;;
79+
80+
--cc)
81+
echo "/app/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang"
82+
;;
83+
84+
--prefix)
85+
echo "$prefix"
86+
;;
87+
88+
--feature|--features)
89+
for feature in AsynchDNS HSTS HTTPS-proxy IPv6 Largefile NTLM NTLM_WB SSL TLS-SRP UnixSockets alt-svc libz threadsafe ""; do
90+
test -n "$feature" && echo "$feature"
91+
done
92+
;;
93+
94+
--protocols)
95+
for protocol in DICT FILE FTP FTPS GOPHER GOPHERS HTTP HTTPS IMAP IMAPS MQTT POP3 POP3S RTSP SMB SMBS SMTP SMTPS TELNET TFTP; do
96+
echo "$protocol"
97+
done
98+
;;
99+
100+
--version)
101+
echo libcurl 7.86.0-DEV
102+
exit 0
103+
;;
104+
105+
--checkfor)
106+
checkfor=$2
107+
cmajor=`echo $checkfor | cut -d. -f1`
108+
cminor=`echo $checkfor | cut -d. -f2`
109+
# when extracting the patch part we strip off everything after a
110+
# dash as that's used for things like version 1.2.3-CVS
111+
cpatch=`echo $checkfor | cut -d. -f3 | cut -d- -f1`
112+
113+
vmajor=`echo 7.86.0-DEV | cut -d. -f1`
114+
vminor=`echo 7.86.0-DEV | cut -d. -f2`
115+
# when extracting the patch part we strip off everything after a
116+
# dash as that's used for things like version 1.2.3-CVS
117+
vpatch=`echo 7.86.0-DEV | cut -d. -f3 | cut -d- -f1`
118+
119+
if test "$vmajor" -gt "$cmajor"; then
120+
exit 0;
121+
fi
122+
if test "$vmajor" -eq "$cmajor"; then
123+
if test "$vminor" -gt "$cminor"; then
124+
exit 0
125+
fi
126+
if test "$vminor" -eq "$cminor"; then
127+
if test "$cpatch" -le "$vpatch"; then
128+
exit 0
129+
fi
130+
fi
131+
fi
132+
133+
echo "requested version $checkfor is newer than existing 7.86.0-DEV"
134+
exit 1
135+
;;
136+
137+
--vernum)
138+
echo 075600
139+
exit 0
140+
;;
141+
142+
--help)
143+
usage 0
144+
;;
145+
146+
--cflags)
147+
if test "X$cppflag_curl_staticlib" = "X-DCURL_STATICLIB"; then
148+
CPPFLAG_CURL_STATICLIB="-DCURL_STATICLIB "
149+
else
150+
CPPFLAG_CURL_STATICLIB=""
151+
fi
152+
if test "X${prefix}/include" = "X/usr/include"; then
153+
echo "$CPPFLAG_CURL_STATICLIB"
154+
else
155+
echo "${CPPFLAG_CURL_STATICLIB}-I${prefix}/include"
156+
fi
157+
;;
158+
159+
--libs)
160+
if test "X${exec_prefix}/lib" != "X/usr/lib" -a "X${exec_prefix}/lib" != "X/usr/lib64"; then
161+
CURLLIBDIR="-L${exec_prefix}/lib "
162+
else
163+
CURLLIBDIR=""
164+
fi
165+
if test "Xyes" = "Xno"; then
166+
echo ${CURLLIBDIR}-lcurl -lssl -lcrypto -lssl -lcrypto -lz -lssl -lcrypto -lc++ -lz
167+
else
168+
echo ${CURLLIBDIR}-lcurl
169+
fi
170+
;;
171+
--ssl-backends)
172+
echo "OpenSSL v3+"
173+
;;
174+
175+
--static-libs)
176+
if test "Xyes" != "Xno" ; then
177+
echo "${exec_prefix}/lib/libcurl.a" -L/app/libcurl-android/jni/build/openssl/arm64-v8a/lib -L/app/libcurl-android/jni/build/zlib/arm64-v8a/lib -L/app/libcurl-android/jni/build/zlib/arm64-v8a/lib -L/app/libcurl-android/jni/build/openssl/arm64-v8a/lib -lssl -lcrypto -lssl -lcrypto -lz -lssl -lcrypto -lc++ -lz
178+
else
179+
echo "curl was built with static libraries disabled" >&2
180+
exit 1
181+
fi
182+
;;
183+
184+
--configure)
185+
echo " '--host=aarch64-linux-android' '--prefix=/app/libcurl-android/jni/build/curl/arm64-v8a' '--with-ssl=/app/libcurl-android/jni/build/openssl/arm64-v8a' '--with-zlib=/app/libcurl-android/jni/build/zlib/arm64-v8a' '--enable-static' '--enable-shared' '--disable-verbose' '--enable-threaded-resolver' '--enable-ipv6' 'host_alias=aarch64-linux-android' 'CC=/app/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang' 'CFLAGS=--sysroot=/app/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/sysroot -march=armv8-a -fPIC' 'LDFLAGS=-L/app/libcurl-android/jni/build/openssl/arm64-v8a/lib -L/app/libcurl-android/jni/build/zlib/arm64-v8a/lib' 'LIBS=-lssl -lcrypto -lc++ -lz' 'CPPFLAGS=-I/app/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include --sysroot=/app/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/sysroot'"
186+
;;
187+
188+
*)
189+
echo "unknown option: $1"
190+
usage 1
191+
;;
192+
esac
193+
shift
194+
done
195+
196+
exit 0
1010 KB
Binary file not shown.
262 KB
Binary file not shown.

0 commit comments

Comments
 (0)