-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathBUILDING
233 lines (184 loc) · 7.53 KB
/
BUILDING
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
BUILD INSTRUCTIONS:
- Android SDK and NDK
- bash shell
- 7Zip command line tool '7z'
- wget
- awk
# ############################################################################
# Environment as typically set in ~/.bashrc
# ############################################################################
export JAVA_HOME=/cygdrive/c/d/jdk/
export PATH=${JAVA_HOME}/bin:${PATH}
# Android SDK location
SDK=/cygdrive/c/d/sdk
# Android NDK location/version; upgrade as needed/wanted
NDK=${SDK}/ndk/27.2.12479018
# Android minSdkVersion. The minimal version is 26, upgrade as needed/wanted
export ANDROID_MIN_SDK=26
# Only choose ONE of these, depending on your device...
# the first, "aarch64", is most likely the one you want.
export ANDROID_TARGET=aarch64-linux-android
# export ANDROID_TARGET=armv7a-linux-androideabi
# export ANDROID_TARGET=i686-linux-android
# export ANDROID_TARGET=x86_64-linux-android
export TOOLCHAIN=${NDK}/toolchains/llvm/prebuilt/windows-x86_64
export PATH=${SDK}/platform-tools:${TOOLCHAIN}/bin:${PATH}
# ############################################################################
# Define the versions for the external project code
#
# https://download.samba.org/pub/rsync/src/rsync-3.3.0.tar.gz
# https://mirror.ox.ac.uk/pub/OpenBSD/OpenSSH/portable/openssh-9.9p1.tar.gz
# https://matt.ucc.asn.au/dropbear/dropbear-2024.86.tar.bz2
# ############################################################################
export RSYNC_VERSION="rsync-3.3.0"
export OPENSSH_VERSION="openssh-9.9p1"
export DROPBEAR_VERSION="dropbear-2024.86"
# ############################################################################
# Setting up the toolchain
# ############################################################################
# The root directory of th Ssh4d project (i.e. where the projects .git is)
export PROJECT_ROOT=/cygdrive/c/Data/AndroidStudioProjects/Sshd4a/
# The working directory where the tarballs will be downloaded and git remotes will be setup.
# Defaults to current directory. Either make sure you are where you want to be,
# or modify the next line with an absolute path.
export SRC_ROOT=`pwd`
# Sanity checks for the .bashrc settings.
# TOOLCHAIN is expected to point to your ndk environment toolchain.
[ -n "${TOOLCHAIN}" ] || { echo "TOOLCHAIN must be set"; exit 1; }
if [ ! -d "$NDK" ]; then
echo "$NDK does not exist."
exit 1
fi
# info dump as reminder...
echo "ANDROID_TARGET=${ANDROID_TARGET}"
echo "ANDROID_MIN_SDK=${ANDROID_MIN_SDK}"
export AR=${TOOLCHAIN}/bin/llvm-ar
export CC=${TOOLCHAIN}/bin/${ANDROID_TARGET}${ANDROID_MIN_SDK}-clang
export AS=${CC}
export CXX=${TOOLCHAIN}/bin/${ANDROID_TARGET}${ANDROID_MIN_SDK}-clang++
export LD=${TOOLCHAIN}/bin/ld
export RANLIB=${TOOLCHAIN}/bin/llvm-ranlib
export STRIP=${TOOLCHAIN}/bin/llvm-strip
# content for ".gitattributes"
export GATRR="* text eol=lf\n*.txt text\n*.png binary\n"
# ############################################################################
# Step 2.1 - RSYNC - https://rsync.samba.org/
# ############################################################################
cd ${SRC_ROOT}
wget -q https://download.samba.org/pub/rsync/src/${RSYNC_VERSION}.tar.gz
7z x -so ${RSYNC_VERSION}* | tar xf -
# remove broken and/or unneeded rsync symlink
rm ${RSYNC_VERSION}/md2man
# rename the directory so we don't need to change the git remote names
export RSYNC="upstream-rsync"
mkdir -p ${RSYNC}/app/src/main/cpp/
mv ${RSYNC_VERSION} ${RSYNC}/app/src/main/cpp/rsync
# Prep rsync
cd ${RSYNC}
echo -e "${GATRR}" >.gitattributes
git init .
git add * .gitattributes
git commit -a -m "${RSYNC_VERSION}"
cd ${SRC_ROOT}
# Configure rsync
cd ${SRC_ROOT}/${RSYNC}/app/src/main/cpp/rsync
./configure --host ${ANDROID_TARGET} --disable-openssl --disable-xxhash --disable-zstd \
--disable-lz4 \
--disable-md2man --disable-roll-simd --disable-md5-asm --disable-roll-asm \
--enable-largefile
cd ${PROJECT_ROOT}
# Add remote: "upstream-rsync" pointing to the location used above
git remote add upstream-rsync ${SRC_ROOT}/${RSYNC}
git fetch upstream-rsync
git merge --allow-unrelated-histories upstream-rsync/dev
# All changes are (should be) marked with SSHD4A_*
# Merge and solve conflicts as usual.
cd ${PROJECT_ROOT}/app/src/main/cpp/
./prebuild-rsyn.sh
# Commit and build...
# ############################################################################
# Step 2.2 - OPENSSH - https://github.com/openssh/openssh-portable
# ############################################################################
cd ${SRC_ROOT}
wget -q https://mirror.ox.ac.uk/pub/OpenBSD/OpenSSH/portable/${OPENSSH_VERSION}.tar.gz
7z x -so ${OPENSSH_VERSION}* | tar xf -
# rename the directory so we don't need to change the git remote names
export OPENSSH="upstream-openssh"
mkdir -p ${OPENSSH}/app/src/main/cpp/
mv ${OPENSSH_VERSION} ${OPENSSH}/app/src/main/cpp/openssh
# Prep openssh
cd ${OPENSSH}
echo -e "${GATRR}" >.gitattributes
git init .
git add * .gitattributes
git commit -a -m "${OPENSSH_VERSION}"
cd ${SRC_ROOT}
# Configure openssh
cd ${SRC_ROOT}/${OPENSSH}/app/src/main/cpp/openssh
# autoreconf is normally in /usr/bin
autoreconf
./configure --host ${ANDROID_TARGET} --disable-lastlog --disable-utmp --disable-wtmp \
--enable-largefile --without-openssl
cd ${PROJECT_ROOT}
# Add remote: "upstream-openssh" pointing to the location used above
git remote add upstream-openssh ${SRC_ROOT}/${OPENSSH}
git fetch upstream-openssh
git merge --allow-unrelated-histories upstream-openssh/dev
# Merge and solve conflicts as usual.
# Typically just "Accept theirs" for all files
# EXCEPT for our mandatory changes which are (should be) marked with SSHD4A_*
#
# 2024-11-29: files modified:
# cpp/openssh/openbsd-compat/explicit_bzero.c
#
# Commit and build...
# ############################################################################
# Step 2.3 - DROPBEAR - https://matt.ucc.asn.au/dropbear/dropbear.html
# ############################################################################
cd ${SRC_ROOT}
wget -q https://matt.ucc.asn.au/dropbear/${DROPBEAR_VERSION}.tar.bz2
7z x -so ${DROPBEAR_VERSION}* | tar xf -
# rename the directory so we don't need to change the git remote names
export DROPBEAR="upstream-dropbear"
mkdir -p ${DROPBEAR}/app/src/main/cpp/
mv ${DROPBEAR_VERSION} ${DROPBEAR}/app/src/main/cpp/dropbear
# Prep dropbear
cd ${DROPBEAR}
echo -e "${GATRR}" >.gitattributes
git init .
# ignore warnings about txt files in "rsa-testvectors"
git add * .gitattributes
git commit -a -m "${DROPBEAR_VERSION}"
cd ${SRC_ROOT}
# Configure dropbear
cd ${SRC_ROOT}/${DROPBEAR}/app/src/main/cpp/dropbear
./configure --host ${ANDROID_TARGET} --disable-syslog --disable-lastlog \
--disable-utmp --disable-wtmp \
--enable-bundled-libtom --enable-largefile
cd ${PROJECT_ROOT}
# Add remote: "upstream-dropbear" pointing to the location used above
git remote add upstream-dropbear ${SRC_ROOT}/${DROPBEAR}
git fetch upstream-dropbear
git merge --allow-unrelated-histories upstream-dropbear/dev
# Merge and solve conflicts as usual.
# Typically just "Accept theirs" for all files
# EXCEPT for our mandatory changes which are (should be) marked with SSHD4A_*
#
# 2024-11-29: files modified:
# cpp/dropbear/src/
# common-session.c
# dbrandom.c
# dbutil.c
# localoptions.h
# scp.c
# signkey.c
# svr-auth.c
# svr-authpasswd.c
# svr-authpubkey.c
# svr-chansession.c
# svr-main.c
#
# Merge and solve conflicts as usual.
cd ${PROJECT_ROOT}/app/src/main/cpp
./prebuild-dropbear.sh
# Commit and build...