97.7. android-tools-37.0.0
Android platform tools — adb, fastboot, and the sparse-image and boot-image utilities
| Version | 37.0.0, release 1 |
| Shelf | mobile — Phones, media players and cameras over USB or the network |
| Phase | 41_system (System), 759 of 1047 in build order |
| Licence | Apache-2.0 |
| Homepage | https://github.com/nmeum/android-tools |
| Build time | 5.0 SBU |
| Installed size | 20.8 MiB in 33 files |
| Recipe | ports/core/mobile/android-tools/kpkgbuild |
About
android-tools is the Android platform tools built outside AOSP: adb, for a phone’s shell, logs, files and app installs, and fastboot, for flashing, with the image utilities beside them (img2simg, simg2img, lpmake, lpunpack, mkbootimg, unpack_bootimg, avbtool, mke2fs.android, make_f2fs and others). The release tarball carries the AOSP sources it builds under vendor/. The iPhone’s side of the same job is usbmuxd and ifuse.
Why it is in KDOS
The comment above it in script/phases/41_system/packages.d/mobile.txt:
adb and fastboot, for an Android phone's shell, logs, files and flashing. The iPhone's side is usbmuxd and ifuse; ifuse mounts through fuse.
Sources
android-tools-37.0.0.tar.xz(18.4 MiB)
sha2562725d09f892a3a38e534429f47a321f58ecf6a3169caa42c915fb2cb7d46be0e
upstream: https://github.com/nmeum/android-tools/releases/download/37.0.0/android-tools-37.0.0.tar.xz
archive copy: sources-3/mobile--android-tools-37.0.0.tar.xz
Dependencies
Depends on: cmake, ninja, pkgconf, libusb, protobuf, abseil-cpp, fmt, brotli, lz4, zstd, pcre2, gtest, python3.
Required by: no port names it.
Patches
build.sh applies these; kpkg applies nothing by itself.
protobuf-36-absl-log-macros.patch— adb: keep libbase logging macros after protobuf includesProtobuf 36's descriptor.h includes absl/log/log.h, which defines the short LOG and VLOG macros. Several adb sources include generated protobuf headers after adb's libbase logging/trace headers; those protobuf headers then replace adb's macros and make adb_trace.h's LOG(DEBUG) expand as Abseil logging, where DEBUG is not a valid severity.
sysdeps.h is the first include for most adb translation units. Extend its existing protobuf-first include to cover descriptor.h as well, so Abseil's short logging macros are seen before android-base/logging.h and adb_trace.h install adb's macros. Include sysdeps.h first from mdns_tracker.cpp too, matching the rest of adb host sources.
This keeps adb's logging behavior intact and avoids per-include macro save/restore blocks.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install android-tools'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/mobile/android-tools.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/mobile/android-tools
echo '2725d09f892a3a38e534429f47a321f58ecf6a3169caa42c915fb2cb7d46be0e android-tools-37.0.0.tar.xz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/android-tools
SRC=$SRC_ROOT/android-tools-37.0.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf android-tools-37.0.0.tar.xz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
export LDFLAGS="$LDFLAGS -Wl,--copy-dt-needed-entries -Wl,--strip-debug"
patch -p1 -d vendor/adb -i "$PORT_SRC/protobuf-36-absl-log-macros.patch"
cmake -B build -G Ninja -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=lib \
-DANDROID_TOOLS_PATCH_VENDOR=OFF \
-DANDROID_TOOLS_USE_BUNDLED_FMT=OFF \
-DANDROID_TOOLS_USE_BUNDLED_LIBUSB=OFF
cmake --build build
DESTDIR=$PKG cmake --install build
install -d "$PKG/usr/lib/udev/rules.d"
cat > "$PKG/usr/lib/udev/rules.d/70-android-tools.rules" <<'RULES'
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_USB_INTERFACES}=="*:ff4201:*|*:ff4203:*", GROUP="dialout", MODE="0660"
RULES
chmod 644 "$PKG/usr/lib/udev/rules.d/70-android-tools.rules"
The switches, and why each is set:
-Wl,--copy-dt-needed-entries— Let the linker follow theDT_NEEDEDentries of the shared libraries on the link line to resolve symbols. The protobuf code adb generates calls into abseil, and the build’s targets do not name every absl library it needs; libprotobuf’s ownDT_NEEDEDentries do, and with this flag the link takes them from there, where it can otherwise stop on unresolvedabsl::symbols.-Wl,--strip-debug— Drop debug information at the link. The bundled BoringSSL undervendor/adds-ggdbto its own compile flags, and kpkg does not strip debug sections, so without this flag adb and fastboot would carry the DWARF of the copy of BoringSSL they link (see What kpkg does around build.sh).-DANDROID_TOOLS_PATCH_VENDOR=OFF— Skip the step that appliespatches/to the vendored AOSP trees withgit submoduleandgit am. The release has nopatches/directory and the build tree is no git repository; the switch keeps the step off whatever the tarball holds.-DANDROID_TOOLS_USE_BUNDLED_FMT=OFF— With-DANDROID_TOOLS_USE_BUNDLED_LIBUSB=OFF, link the fmt and libusb ports instead of the copies undervendor/, so a fix to either reaches adb and fastboot. Both are upstream’s defaults, named.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/android-tools, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf android-tools-37.0.0-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/android-tools, and runs the triggers its paths call for.
Contents
Installed programs: adb, append2simg, avbtool, e2fsdroid, ext2simg, fastboot, img2simg, lpadd, lpdump, lpflash, lpmake, lpunpack, make_f2fs, mkbootimg, mkdtboimg, mke2fs.android, repack_bootimg, simg2img, sload_f2fs, unpack_bootimg.
Installed directories: /usr/share/android-tools, /usr/share/licenses/android-tools.
Notes
gtest is a build dependency only: fastboot’s socket.h and libziparchive’s zip_writer.h include gtest_prod.h.
build.sh writes a udev rule, /usr/lib/udev/rules.d/70-android-tools.rules, that gives the dialout group read and write access to a USB device offering interface class ff, subclass 42, protocol 01 (adb) or 03 (fastboot). Those are the numbers adb and fastboot themselves look for (ADB_CLASS, ADB_SUBCLASS and ADB_PROTOCOL in adb, match_fastboot_with_serial() in fastboot), so the rule matches a phone by its interface and needs no table of vendor IDs. Without the rule the device node is root’s alone and adb devices lists nothing for the console user, who is in dialout.