Repository navigation
Build and Deployment
Primary maintained build paths in the repo:
- CMake for host/emulator and Android NDK builds
-
build_android.shas the Android/emulator convenience wrapper -
Android.bpfor Soong/AOSP integration -
apm-flashable-new/build_recovery_zip.shfor LineageOS Recovery flashables
Debian/Ubuntu:
sudo apt update
sudo apt install -y \
build-essential cmake pkg-config git \
ninja-build clang clangdFedora:
sudo dnf install -y \
@development-tools cmake pkgconf-pkg-config git \
ninja-build clang clang-tools-extraArch Linux:
sudo pacman -S --needed \
base-devel cmake pkgconf git ninja clangRecommended SDK packages:
sdkmanager --install \
"build-tools;36.1.0" \
"cmake;4.1.2" \
"ndk;r29"build_android.sh resolves the NDK from:
ANDROID_NDK_ROOTANDROID_NDK_HOME$ANDROID_SDK_ROOT/ndk/<latest>
The build requires Android API 29 or newer.
All builds expect staged BoringSSL prebuilts in prebuilt/boringssl/.
Required layout:
prebuilt/boringssl/include/openssl/base.h- Android:
prebuilt/boringssl/build-arm64-v8a/libssl.aprebuilt/boringssl/build-arm64-v8a/libcrypto.a- same pattern for
armeabi-v7a,x86, andx86_64
- Host/emulator:
-
prebuilt/boringssl/build-x86_64/orbuild-x86/
-
CMake 3.24 or newer is required. The first configure downloads hash-pinned XZ
(liblzma), Zstandard, and bzip2 sources and builds their static libraries for the
selected target. CMakeLists.txt also fetches/builds zlib when a system copy is
not available. Offline builds can supply these sources through
FETCHCONTENT_SOURCE_DIR_APM_XZ, FETCHCONTENT_SOURCE_DIR_APM_ZSTD, and
FETCHCONTENT_SOURCE_DIR_APM_BZIP2.
Archive extraction requires tar on the device, but does not require external
ar, xz, gzip, bzip2, or zstd commands. Soong builds link the AOSP
liblzma, libzstd, libbz, and libz modules.
The archive codec license notices are in THIRD_PARTY_NOTICES; the recovery
packager includes them under /system/etc/apm/.
./build_android.shSupported flags:
--api <level>--abi <abi>--all--emulator
Default behavior:
- default API:
34 - default Android ABI comes from prompt or
APM_ANDROID_ABI - Android outputs go to
build-<abi>/ - emulator output goes to
build/ - built binaries are stripped unless
APM_STRIP_BINARIES=0 - workspace
compile_commands.jsonis linked or copied from the active build directory
./build_android.sh --api 34 --abi arm64-v8a./build_android.sh --all./build_android.sh --emulatorThis produces native Linux x86_64 binaries compiled with APM_EMULATOR_MODE=ON.
Run emulator daemons with:
./build/apmd --emulator
./build/amsd --emulatorcmake -S . -B build -G Ninja -DAPM_EMULATOR_MODE=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel "$(nproc)"Android.bp defines these binaries:
apmapmdamsd
The binary definitions reference init_rc entries for daemon startup in Soong/AOSP builds. The maintained recovery flashable carries the concrete init scripts under apm-flashable-new/system/etc/init/.
The maintained deployment path is the LineageOS Recovery flashable under apm-flashable-new/.
Build a ZIP:
cd apm-flashable-new
./build_recovery_zip.shUseful options:
./build_recovery_zip.sh --abi arm64-v8a./build_recovery_zip.sh --all./build_recovery_zip.sh --api 34
Environment knobs:
-
APM_FORCE_REBUILD=1by default -
APM_FORCE_REBUILD=0to reuse existing built binaries -
APM_ANDROID_ABIto preselect an ABI -
APM_ANDROID_APIto set the default API -
APM_SELINUX_SOURCE_DIRto override the SELinux payload source directory
Current flashable builder behavior:
- rebuilds binaries from current source by default
- copies
apm,apmd, andamsdinto the template - syncs SELinux payload from
selinux-contexting/ - preserves shell PATH boot hooks in
system/bin/ - emits
apm-lineage-recovery-YYYYMMDD-<abi>.zip - verifies that critical payload entries are present in the final ZIP
The flashable ships:
/system/bin/apm/system/bin/apmd/system/bin/amsd/system/bin/apm-sh-path/system/bin/apm-bash-path/system/etc/init/init.apmd.rc/system/etc/init/init.amsd.rc/system/etc/selinux/apm.cil/system/etc/selinux/apm_file_contexts/system/etc/selinux/apm_property_contexts/system/etc/selinux/apm_service_contexts- addon.d template pieces used to create
/system/addon.d/30-apm.sh
The custom recovery installer is slot-aware and chooses its target from /mnt/system*.
During install, update-binary combines system/addon.d/addond_head, the final payload file list, and system/addon.d/addond_tail into system/addon.d/30-apm.sh.
It also detects recovery layouts where top-level bin or etc are symlinks and copies into the nested system/ root when needed.
init.amsd.rc:
- prepares
/data/ams - starts
amsdinpost-fs-data - restarts
amsdagain onsys.boot_completed=1
init.apmd.rc:
- exports boot-level fallback values for
ENVandBASH_ENV - prepares
/data/apmplus/data/local/tmp/apm - removes stale sockets and stale shim copies of
apm,apmd, andamsd - starts
apmdonly afteramsd.ready=1
Canonical SELinux payload sources:
selinux-contexting/apm.cilselinux-contexting/apm_file_contextsselinux-contexting/apm_property_contextsselinux-contexting/apm_service_contexts
The policy reflects the current socket-based runtime and keeps the service-context file only for packaging compatibility.
- Confirm
amsdsocket exists:/data/ams/amsd.sock
- Confirm
apmdis reachable:- Android uses abstract socket
@apmd - emulator uses
$HOME/APMEmulator/data/apm/apmd.socket
- Android uses abstract socket
- Confirm logs exist:
/data/apm/logs/apmd.log/data/ams/logs/amsd.log
- Confirm CLI connectivity:
apm ping- Confirm module operations:
apm module-list