Skip to content

Commit 376844e

Browse files
authored
chore: bake rootAVD and use tar.gz storage for addon payloads (#52)
Drop the runtime `git clone https://gitlab.com/newbit/rootAVD.git` (the last remaining external download for the rooting flow). The rootAVD repo (rootAVD.sh + bundled Magisk.zip) is now downloaded as a tarball at image build time. While at it, switch the existing ndk_translation bake to the same shape so both addons store their upstream tar.gz verbatim at /opt/<name>.tar.gz instead of pre-extracted trees. install_root, install_arm_translation, and install_gapps all extract their payload into /tmp/<name>/ at the top of the install, work from there, and clean up at the end — same pattern across the three. Why: - No runtime gitlab.com dependency for rooting (previously 84.7 MB git clone with full history, now a ~12 MB tar.gz baked at build time). - ~26 MB smaller image disk footprint after pull (the upstream tar.gz files are still LZMA/gzip-compressed in /opt; we only pay decompression on install). - Lazy work: an addon that isn't enabled never gets extracted. - Symmetric layout — install_root, install_arm_translation, and install_gapps all stage under /tmp/<name>/ now. Verified end-to-end on a fresh AVD with ROOT_SETUP=GAPPS_SETUP= ARM_TRANSLATION=1: all four markers land, /data/adb/modules/ contains gapps and ndk_translation, ABI list advertises arm64-v8a, Google services visible at /system/priv-app/ via Magisk overlay, and an arm64-v8a-only APK installs cleanly.
1 parent 4fc03ac commit 376844e

2 files changed

Lines changed: 38 additions & 31 deletions

File tree

Dockerfile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,18 @@ RUN apt-get update && \
2020

2121
# Bake in Google ndk_translation prebuilts (ARM-on-x86 native bridge).
2222
# Source: Kaz205 fork (Chrome OS Android 11 / guybrush_cheets) — matches the emulator's API 30.
23+
# Stored as the upstream tarball; install_arm_translation extracts on demand.
2324
ARG NDK_TRANSLATION_REPO=Kaz205/vendor_google_proprietary_ndk_translation-prebuilt
2425
ARG NDK_TRANSLATION_REF=chromeos_guybrush
25-
RUN mkdir -p /opt/ndk-translation && \
26-
wget -q -O /tmp/ndk.tar.gz \
27-
"https://codeload.github.com/${NDK_TRANSLATION_REPO}/tar.gz/refs/heads/${NDK_TRANSLATION_REF}" && \
28-
tar -xzf /tmp/ndk.tar.gz \
29-
--strip-components=2 \
30-
-C /opt/ndk-translation \
31-
"$(basename "$NDK_TRANSLATION_REPO")-${NDK_TRANSLATION_REF}/prebuilts" && \
32-
rm /tmp/ndk.tar.gz
26+
RUN wget -q -O /opt/ndk-translation.tar.gz \
27+
"https://codeload.github.com/${NDK_TRANSLATION_REPO}/tar.gz/refs/heads/${NDK_TRANSLATION_REF}"
28+
29+
# Bake in rootAVD (Magisk-based AVD rooting tool + bundled Magisk.zip).
30+
# Source: https://gitlab.com/newbit/rootAVD — install_root extracts on demand.
31+
ARG ROOTAVD_REPO=newbit/rootAVD
32+
ARG ROOTAVD_REF=master
33+
RUN wget -q -O /opt/rootavd.tar.gz \
34+
"https://gitlab.com/${ROOTAVD_REPO}/-/archive/${ROOTAVD_REF}/$(basename "$ROOTAVD_REPO")-${ROOTAVD_REF}.tar.gz"
3335

3436
# Set up Android SDK
3537
RUN mkdir -p /opt/android-sdk/cmdline-tools && \

first-boot.sh

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ magisk_active() {
5050
install_gapps_magisk_module() {
5151
echo "Installing GAPPS as a Magisk module ..."
5252
local MOD=/data/adb/modules/gapps
53-
adb push gapps-11/etc /data/local/tmp/gapps-etc
54-
adb push gapps-11/framework /data/local/tmp/gapps-framework
55-
adb push gapps-11/app /data/local/tmp/gapps-app
56-
adb push gapps-11/priv-app /data/local/tmp/gapps-priv-app
53+
adb push /tmp/gapps/etc /data/local/tmp/gapps-etc
54+
adb push /tmp/gapps/framework /data/local/tmp/gapps-framework
55+
adb push /tmp/gapps/app /data/local/tmp/gapps-app
56+
adb push /tmp/gapps/priv-app /data/local/tmp/gapps-priv-app
5757
adb shell "
5858
rm -rf $MOD
5959
mkdir -p $MOD/system
@@ -74,29 +74,30 @@ PROP
7474

7575
install_gapps_system() {
7676
prepare_system
77-
adb push gapps-11/etc /system
78-
adb push gapps-11/framework /system
79-
adb push gapps-11/app /system
80-
adb push gapps-11/priv-app /system
77+
adb push /tmp/gapps/etc /system
78+
adb push /tmp/gapps/framework /system
79+
adb push /tmp/gapps/app /system
80+
adb push /tmp/gapps/priv-app /system
8181
}
8282

8383
install_gapps() {
8484
adb wait-for-device
8585
adb root
8686
echo "Installing GAPPS ..."
87-
wget https://sourceforge.net/projects/opengapps/files/x86_64/20220503/open_gapps-x86_64-11.0-pico-20220503.zip/download -O gapps-11.zip
88-
unzip gapps-11.zip 'Core/*' -d gapps-11 && rm gapps-11.zip
89-
rm gapps-11/Core/setup*
90-
lzip -d gapps-11/Core/*.lz
91-
for f in gapps-11/Core/*.tar; do
92-
tar -x --strip-components 2 -f "$f" -C gapps-11
87+
mkdir -p /tmp/gapps
88+
wget https://sourceforge.net/projects/opengapps/files/x86_64/20220503/open_gapps-x86_64-11.0-pico-20220503.zip/download -O /tmp/gapps.zip
89+
unzip /tmp/gapps.zip 'Core/*' -d /tmp/gapps && rm /tmp/gapps.zip
90+
rm /tmp/gapps/Core/setup*
91+
lzip -d /tmp/gapps/Core/*.lz
92+
for f in /tmp/gapps/Core/*.tar; do
93+
tar -x --strip-components 2 -f "$f" -C /tmp/gapps
9394
done
9495
if magisk_active; then
9596
install_gapps_magisk_module
9697
else
9798
install_gapps_system
9899
fi
99-
rm -r gapps-11
100+
rm -rf /tmp/gapps
100101
adb reboot
101102
adb wait-for-device
102103
touch /data/.gapps-done
@@ -107,8 +108,9 @@ install_root() {
107108
adb root
108109
echo "Root Script Starting..."
109110
# Root the AVD by patching the ramdisk.
110-
git clone https://gitlab.com/newbit/rootAVD.git
111-
pushd rootAVD
111+
mkdir -p /tmp/rootavd
112+
tar -xzf /opt/rootavd.tar.gz --strip-components=1 -C /tmp/rootavd
113+
pushd /tmp/rootavd
112114
sed -i 's/read -t 10 choice/choice=1/' rootAVD.sh
113115
./rootAVD.sh system-images/android-30/default/x86_64/ramdisk.img
114116
cp /opt/android-sdk/system-images/android-30/default/x86_64/ramdisk.img /data/android.avd/ramdisk.img
@@ -142,14 +144,14 @@ install_root() {
142144
popd
143145
echo "Root Done"
144146
sleep 10
145-
rm -r rootAVD
147+
rm -rf /tmp/rootavd
146148
touch /data/.root-done
147149
}
148150

149151
install_arm_translation_magisk_module() {
150152
echo "Installing ARM translation as a Magisk module ..."
151153
local MOD=/data/adb/modules/ndk_translation
152-
adb push /opt/ndk-translation /data/local/tmp/ndk
154+
adb push /tmp/ndk-translation /data/local/tmp/ndk
153155
adb shell "
154156
rm -rf $MOD
155157
mkdir -p $MOD/system/bin $MOD/system/etc $MOD/system/lib $MOD/system/lib64
@@ -197,10 +199,10 @@ install_arm_translation_system() {
197199
prepare_system
198200
echo "Installing ARM translation (ndk_translation) ..."
199201

200-
adb push /opt/ndk-translation/bin /system/
201-
adb push /opt/ndk-translation/etc /system/
202-
adb push /opt/ndk-translation/lib /system/
203-
adb push /opt/ndk-translation/lib64 /system/
202+
adb push /tmp/ndk-translation/bin /system/
203+
adb push /tmp/ndk-translation/etc /system/
204+
adb push /tmp/ndk-translation/lib /system/
205+
adb push /tmp/ndk-translation/lib64 /system/
204206

205207
adb shell '
206208
chmod 755 /system/bin/ndk_translation_program_runner_binfmt_misc /system/bin/ndk_translation_program_runner_binfmt_misc_arm64
@@ -230,13 +232,16 @@ EOF
230232
install_arm_translation() {
231233
adb wait-for-device
232234
adb root
235+
mkdir -p /tmp/ndk-translation
236+
tar -xzf /opt/ndk-translation.tar.gz --strip-components=2 --wildcards -C /tmp/ndk-translation '*/prebuilts/*'
233237
# On a live-Magisk device, /system is wrapped in a read-only magic mount;
234238
# install as a Magisk module so the changes land via Magisk's own overlay.
235239
if magisk_active; then
236240
install_arm_translation_magisk_module
237241
else
238242
install_arm_translation_system
239243
fi
244+
rm -rf /tmp/ndk-translation
240245
adb reboot
241246
adb wait-for-device
242247
touch /data/.arm-translation-done

0 commit comments

Comments
 (0)