|
1 |
| -# android-tools |
| 1 | +# android-tools-static |
| 2 | +android-tools-static is a fork of [nmeum/android-tools][upstream] with the following added features: |
2 | 3 |
|
3 |
| -Git repository to make it easier to package certain command line |
4 |
| -utilities provided by [android-tools][android-tools]. |
| 4 | +- prebuilt executables for a plethora of architectures and operating systems |
| 5 | + - [SBOMs][SBOM] for prebuilt release archives are provided |
| 6 | + - prebuilt executables have minimal external dependencies (they are fully statically linked for Linux targets with the help of [musl libc][musl]) |
| 7 | + - several ["layouts"](#release-artifacts) of release archives are provided, some are optimized for best end user experience and some are optimized for embedding in other programs |
| 8 | + - in comparison to official Google release archives, archives provided by this repository are legally redistributable (see [license considerations](license_considerations.md)) |
| 9 | +- Windows support (taken from [MSYS2][msys2_source]) |
| 10 | +- nmeum/android-tools' CMake build system is rewritten in Meson |
| 11 | + - external dependencies are handled using Meson's [WrapDB][meson_wraps] system; if they aren't found on the system, they will be automatically downloaded and built alongside android-tools-static (this is fully configurable) |
5 | 12 |
|
6 |
| -# Motivation |
| 13 | +> [!NOTE] |
| 14 | +> Testers for MacOS targets would be greatly appreciated, as I do not have the capacity to perform testing myself. |
| 15 | +> |
| 16 | +> To test android-tools-static, download the latest `android-tools-static-<ver>-macos-nativelayout-universal2.tar.gz` release archive or build the project yourself and test basic functionality (test whether adb push/pull works, whether adb shell works, whether adb install works (not required if your phone blocks such requests), whether adb reboot works, whether fastboot reboot works + anything else you find important). If you need help, feel free to message me through the methods described below. |
| 17 | +> |
| 18 | +> You can then [start a new discussion](https://github.com/meator/android-tools-static/discussions/new?category=general). If that is not possible for you, you can e-mail me at [email protected] (but please prefer GitHub Discussions if you can, it is not likely that I will notice your e-mail if it ends up in my spam). |
7 | 19 |
|
8 |
| -[Many][void-linux] [Linux][arch-linux] [distributions][alpine-linux] have |
9 |
| -[a package called android-tools][repology] which ships essential Android command |
10 |
| -line tools like adb or fastboot. Sadly the upstream build system for |
11 |
| -those tools is rather complex and doesn't allow building the command |
12 |
| -line tools only. |
| 20 | +# Building |
| 21 | +## Build dependencies |
| 22 | +- [Meson][meson] version 0.63.0 or higher |
| 23 | +- [CMake][cmake] |
| 24 | +- `git` or `patch` available (used to patch vendor projects) if you're not using the pre-patched release source archive |
| 25 | +- a reasonably recent C++ compiler (C++20 support required, this project might require other more recent features) |
| 26 | +- a reasonably recent C compiler (C11 support required, this project might require other more recent features) |
| 27 | +- Linux headers (such as `linux/usbdevice_fs.h`, usually provided by a `linux-headers` package) on Linux |
13 | 28 |
|
14 |
| -Linux distributions therefore mostly ship their own build systems for |
15 |
| -building the command line utilities. This repository aims to make |
16 |
| -packaging of android command utilities easier by providing a simple |
17 |
| -CMake based build system and a ready-to-use tarball which doesn't |
18 |
| -require cloning all of the required git repositories manually. Besides |
19 |
| -this makes it easy to collect all patches required to build standalone |
20 |
| -Android command line utilities in a central place. |
| 29 | +This project is buildable with packages from current Debian stable (v12 _bookworm_). |
21 | 30 |
|
22 |
| -# Status |
| 31 | +The following dependencies are provided as [Meson Wraps][meson_wraps]. This means that if you do not have these dependencies installed, Meson will download them and build them for you. They are fully configurable using Meson standard flags. |
23 | 32 |
|
24 |
| -Currently the following tools are supported: |
| 33 | +- [libusb][libusb] |
| 34 | +- [PCRE][PCRE] |
| 35 | +- [Google Test][gtest] |
| 36 | +- [protobuf][protobuf] |
| 37 | +- [brotli][brotli] |
| 38 | +- [zstd][zstd] |
| 39 | +- [lz4][lz4] |
25 | 40 |
|
26 |
| -* adb |
27 |
| -* fastboot |
28 |
| -* mke2fs.android (required by fastboot) |
29 |
| -* simg2img, img2simg, append2simg |
30 |
| -* lpdump, lpmake, lpadd, lpflash, lpunpack |
31 |
| -* mkbootimg, unpack_bootimg, repack_bootimg, avbtool |
32 |
| -* mkdtboimg |
| 41 | +## Simple build process |
| 42 | +Go to the [Releases](https://github.com/meator/android-tools-static/releases) section, download and extract the latest `android-tools-static-<version>-src.tar.gz` archive and build the project as follows: |
33 | 43 |
|
34 |
| -The build system itself works quite well and is already being used for |
35 |
| -the Alpine Linux [android-tools package][alpine-linux] which I maintain. |
| 44 | +```sh |
| 45 | +meson setup build |
| 46 | +meson compile -C build |
| 47 | +meson install -C build |
| 48 | +``` |
36 | 49 |
|
37 |
| -I personally don't use any android-tools except adb and fastboot. Thus |
38 |
| -my motivation to add support for additional tools is rather low at the |
39 |
| -moment. However, patches adding support for new tools in a clean way are |
40 |
| -welcome. Additionally, patches needed to make the software compile on |
41 |
| -other Linux distributions are welcome as well. Please create new patches |
42 |
| -using `git format-patch --no-numbered --no-signature …`. |
| 50 | +## Other build configurations |
| 51 | +- [I am a packager](docs/packaging.md) |
| 52 | +- [I want to build from master](docs/building_from_git.md) |
43 | 53 |
|
44 |
| -# Dependencies |
| 54 | +# Release artifacts |
| 55 | +This project provides three "flavors" of release artifacts: |
45 | 56 |
|
46 |
| -The following libraries are required by android-tools: |
| 57 | +1. `standardlayout` |
47 | 58 |
|
48 |
| -1. [libusb][libusb] |
49 |
| -2. [PCRE][PCRE] |
50 |
| -3. [Google Test][gtest] |
51 |
| -4. [protobuf][protobuf] |
52 |
| -5. [brotli][brotli] |
53 |
| -6. [zstd][zstd] |
54 |
| -7. [lz4][lz4] |
| 59 | + `standardlayout` archives are best suited for use by other programs and/or libraries, since they provide the same layout for all supported operating systems. |
55 | 60 |
|
56 |
| -Python 3 is optionally needed as a run-time dependency in order to use |
57 |
| -the `mkbootimg`, `unpack_bootimg`, and `repack_bootimg` scripts which |
58 |
| -are all written in Python. |
| 61 | + Here are the guaranteed contents of the archive: |
59 | 62 |
|
60 |
| -Additionally the following software is required at compile-time: |
| 63 | + ``` |
| 64 | + android-tools-static/adb |
| 65 | + android-tools-static/append2simg |
| 66 | + android-tools-static/fastboot |
| 67 | + android-tools-static/img2simg |
| 68 | + android-tools-static/simg2img |
| 69 | + ``` |
61 | 70 |
|
62 |
| -1. A C and C++ compiler (either [GCC][gcc] >= 10.X or [clang][clang]) |
63 |
| -2. The [Go compiler][golang] |
64 |
| -3. [CMake][cmake] |
65 |
| -4. [Perl][perl] |
| 71 | + The archive may include extra files (for example `android-tools-static/AdbWinApi.dll` and `android-tools-static/AdbWinUsbApi.dll` on Windows). |
66 | 72 |
|
67 |
| -*Currently the build system doesn't check whether all of these are installed.* |
| 73 | + All `standardlayout` release archives are compressed into `.tar.gz` files (even on Windows). |
68 | 74 |
|
69 |
| -# Installation |
| 75 | + **All executables do not have a suffix (even on Windows!)** This is done to make the layout more standard. |
70 | 76 |
|
71 |
| -Source tarballs containing an already patched version of all vendored |
72 |
| -dependencies are available on the [GitHub Release Page][release-page]. |
| 77 | + The top-level directory in the archive does not include any "dynamic" information (version of the release archive, layout type etc.). The top-level directory is `android-tools-static` on all targets. |
73 | 78 |
|
74 |
| -These tarballs should be used for packaging and general installation. |
75 |
| -After the tarball was downloaded and extracted android-tools can be |
76 |
| -build and installed as follows: |
| 79 | + The filenames of the source archives also do not include their version number. |
| 80 | +2. `standardlayout-extra` |
77 | 81 |
|
78 |
| - $ mkdir build && cd build |
79 |
| - $ cmake .. |
80 |
| - $ make |
81 |
| - $ make install |
| 82 | + `standardlayout-extra` is same as `standardlayout`, but it includes the following additional executables on Linux and MacOS: |
82 | 83 |
|
83 |
| -# Generating tarballs |
| 84 | + ``` |
| 85 | + android-tools-static/lpadd |
| 86 | + android-tools-static/lpdump |
| 87 | + android-tools-static/lpflash |
| 88 | + android-tools-static/lpmake |
| 89 | + android-tools-static/lpunpack |
| 90 | + ``` |
84 | 91 |
|
85 |
| -New source tarballs can be created from the Git repository using: |
| 92 | + If the information above is out of date, please [file an issue](https://github.com/meator/android-tools-static/issues/new). |
86 | 93 |
|
87 |
| - $ mkdir build && cd build |
88 |
| - $ cmake .. |
89 |
| - $ make package_source |
| 94 | + The executables above are not included in `standardlayout` because they cannot currently be built for Windows targets. |
90 | 95 |
|
91 |
| -Before a new release is uploaded a new `git-tag(1)` should be created |
92 |
| -for the release. Afterwards the tarball can be uploaded to the [GitHub |
93 |
| -Release Page][release-page]. |
| 96 | + This means that `standardlayout` and `standardlayout-extra` release archives for Windows targets will feature comparable contents (they may be identical). |
| 97 | +3. `nativelayout` |
94 | 98 |
|
95 |
| -# See also |
| 99 | + This is the layout best suited for end users. |
96 | 100 |
|
97 |
| -[The build script][android-tools-legacy] for android platform tools by [Anatol Pomozov][anatol.pomozov] |
98 |
| -which inspired this project. Most definitions in the `CMakeLists.txt` |
99 |
| -have been copied from Anatol's ruby script. |
| 101 | + The top-level directory of the archive includes the release version (unlike `standardlayout` and `standardlayout-extra`). |
| 102 | + |
| 103 | + Executable files end in `.exe` for Windows targets. |
| 104 | + |
| 105 | + `nativelayout` release archives are compressed into `.zip` for Windows targets. |
| 106 | + |
| 107 | + "Miscellaneous" files may be included (manpages, shell completions...). |
| 108 | + |
| 109 | +# Releases |
| 110 | + |
| 111 | +> [!NOTE] |
| 112 | +> The maintainers of this repository reserve the right to modify and delete tags published in this repository for 24 hours after their publishing. If a release tag more than two days old, it is safe to use. |
| 113 | +
|
| 114 | +Major updates will most likely be bound to the release schedule of [nmeum/android-tools][upstream]. |
| 115 | + |
| 116 | +Like [nmeum/android-tools][upstream], android-tools-static follows a |
| 117 | + |
| 118 | +``` |
| 119 | +<major>.<minor>.<patch>[p<revision>][-rc.<release candidate number>] |
| 120 | +``` |
| 121 | + |
| 122 | +where `<major>`, `<minor>` and `<patch>` represent the version of android-tools and boringssl being used. If bugfixes needed to be applied to a currently released version, a `p<revision>` suffix is added (examples: `35.0.2`, `35.0.2p1`, `35.0.2p2`...). |
| 123 | + |
| 124 | +Release candidates are denoted with a `-rc.<release candidate number>` suffix. This is an addition to [nmeum/android-tools][upstream]'s versioning system. |
| 125 | + |
| 126 | +## Trusted sources |
| 127 | +Here is a list of sources which are trusted during release artifact build: |
| 128 | +1. files in this repository (most of which come from the parent project https://github.com/nmeum/android-tools), all the git submodules (coming from official Google repositories), all the Meson wrap dependencies (coming from their official sources with Meson buildsystems and patches from https://github.com/mesonbuild/wrapdb and/or this repository) |
| 129 | +2. programs in GitHub official containers (Ubuntu, MacOS and Windows) - mainly pip, brew, MSVC, CMake, Python |
| 130 | +3. pinned Meson (and its dependencies) from pip |
| 131 | +4. ucrt64, msys and mingw32 MSYS2 official repositories |
| 132 | +5. Homebrew official repositories |
| 133 | +6. release artifacts of https://github.com/meator/AdbWinApi |
| 134 | + |
| 135 | +Here is a list of trusted GitHub Actions which are trusted (excluding those from <https://github.com/actions>[^actions]): |
| 136 | + |
| 137 | +1. https://github.com/msys2/setup-msys2 - provided officially by MSYS2 |
| 138 | +2. https://github.com/ilammy/msvc-dev-cmd - used by https://github.com/meator/AdbWinApi, it is less trustworthy than the rest of the GitHub Actions used, but its functionality is very useful and semi-difficult to replace |
| 139 | +3. https://github.com/softprops/action-gh-release - the [official GitHub Action which handles making releases](https://github.com/actions/create-release) was deprecated, this action is one of its one of the alternatives mentioned in its README |
| 140 | +4. https://github.com/jirutka/setup-alpine - maintained by Alpine Linux developers |
| 141 | +5. https://github.com/docker/setup-buildx-action, https://github.com/docker/login-action, https://github.com/docker/metadata-action, https://github.com/docker/bake-action - provided officially by Docker |
| 142 | + |
| 143 | +All the actions listed above are pinned to commit hash of a released version. |
| 144 | + |
| 145 | +# FAQ |
| 146 | +## Why rewrite nmeum/android-tools in Meson? Fully static builds can be achieved in CMake with FetchContent or using similar methods. |
| 147 | +The main aim of this fork, supporting fully static builds of android-tools, is achievable in CMake. I chose not to simply contribute these changes to nmeum/android-tools for these reasons: |
| 148 | + |
| 149 | +1. I, [meator](https://github.com/meator), have little experience with CMake. I am much more knowledgeable of Meson. |
| 150 | +2. [Meson's Wrap][meson_wraps] is (in my opinion) more robust than CMake's solution to the problem. |
| 151 | + 1. It is fully controllable by the user (you can use `--force-fallback-for`, `--wrap-mode` etc) |
| 152 | + 2. It is forthcoming to packagers (who might not appreciate the build system downloading things at configure time) |
| 153 | + 3. It is standard (see the two points above) |
| 154 | + 4. They were easy to implement ([wrapdb][wrapdb] contributors did most of the work for me, I could just do `meson wrap install <dep>` to take advantage of it) |
| 155 | + 5. Wraps are interchangeable for system installed dependencies |
| 156 | +3. Meson adds a lot of nicities (`compile_commands.json` enabled by default, ASAN/UBSAN etc. work without additional configuration, nicer syntax and more) |
| 157 | + |
| 158 | +## What else does android-tools-static add to nmeum/android-tools? |
| 159 | +It adds a more customized vendor patching mechanism (nmeum/android-tools one is rather simplistic and strictly requires `git`). |
| 160 | + |
| 161 | +Another focus of this project is improved documentation and UX. The `meson.build` files are already more readable thanks to Meson's intuitive syntax. On top of that, I've tried to add more comments and print customized error messages when common errors are detected. |
| 162 | + |
| 163 | +A lot of effort has been put in to make sure that cross compilation works without problems (since it is used to build release archives for some targets). |
| 164 | + |
| 165 | +## What architecture/OS names do you use? |
| 166 | +This project uses the same architecture and OS identifiers used in Meson: https://mesonbuild.com/Reference-tables.html A more human-readable form is sometimes provided in verbose output (for example `x86 (32bit)`, `aarch64 (ARM64)` - ARM64 is the more commonly used name on Windows). |
| 167 | + |
| 168 | +## What version of Windows do I need to use to be able to run Windows prebuilt executables? |
| 169 | +Windows 10 or newer is required. See the writeup [here](windows-compatibility.md). |
| 170 | + |
| 171 | +# Credits |
| 172 | +This project would not exist without https://github.com/nmeum/android-tools, so thank you [nmeum](https://github.com/nmeum) and nmeum/android-tools contributors! |
| 173 | + |
| 174 | +Windows support is based off of the [MSYS2 package][msys2_pkg] ([source][msys2_source]). Thank you [Biswa96](https://github.com/Biswa96)! |
| 175 | + |
| 176 | +Some patches were taken from [Void Linux][void] and [Chimera Linux][chimera]. Thanks! |
| 177 | + |
| 178 | +# TODO |
| 179 | +- [ ] port boringssl to Meson, removing the need for a CMake dependency |
| 180 | + |
| 181 | + This is pretty hard to do, it might make the most sense to keep the |
| 182 | + CMake dependency for the sake of stability. |
| 183 | +- [ ] `fastboot` may require `mke2fs` to function correctly; `mke2fs` isn't currently built by android-tools-static |
| 184 | + |
| 185 | +[^actions]: Actions from https://github.com/actions are considered to be trustworthy and safe; they are not pinned to a commit SHA and they are not included in SBOMs. |
| 186 | + |
| 187 | +[upstream]: https://github.com/nmeum/android-tools |
| 188 | +[SBOM]: https://en.wikipedia.org/wiki/Software_supply_chain |
| 189 | +[musl]: https://www.musl-libc.org/ |
| 190 | +[meson]: https://mesonbuild.com/ |
| 191 | +[meson_wraps]: https://mesonbuild.com/Wrap-dependency-system-manual.html |
| 192 | +[wrapdb]: https://github.com/mesonbuild/wrapdb |
| 193 | +[cmake]: https://cmake.org/ |
100 | 194 |
|
101 |
| -[android-tools]: https://developer.android.com/tools/releases/platform-tools |
102 |
| -[void-linux]: https://github.com/void-linux/void-packages/tree/master/srcpkgs/android-tools |
103 |
| -[arch-linux]: https://archlinux.org/packages/extra/x86_64/android-tools/ |
104 |
| -[alpine-linux]: https://pkgs.alpinelinux.org/package/edge/community/x86_64/android-tools |
105 |
| -[repology]: https://repology.org/project/android-tools/versions |
106 |
| -[release-page]: https://github.com/nmeum/android-tools/releases |
107 | 195 | [libusb]: https://libusb.info/
|
108 | 196 | [PCRE]: https://pcre.sourceforge.net/
|
109 | 197 | [gtest]: https://github.com/google/googletest
|
110 |
| -[gcc]: https://gcc.gnu.org/ |
111 |
| -[clang]: https://clang.llvm.org/ |
112 |
| -[golang]: https://go.dev/ |
113 |
| -[cmake]: https://cmake.org/ |
114 |
| -[perl]: https://www.perl.org/ |
115 | 198 | [protobuf]: https://github.com/protocolbuffers/protobuf
|
116 | 199 | [brotli]: https://github.com/google/brotli
|
117 | 200 | [zstd]: https://facebook.github.io/zstd/
|
118 | 201 | [lz4]: https://github.com/lz4/lz4
|
119 |
| -[android-tools-legacy]: https://github.com/anatol/android-platform-tools-build |
120 |
| -[anatol.pomozov]: https://github.com/anatol |
| 202 | + |
| 203 | +[msys2_pkg]: https://packages.msys2.org/packages/mingw-w64-x86_64-android-tools |
| 204 | +[msys2_source]: https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-android-tools |
| 205 | +[void]: https://github.com/void-linux/void-packages/tree/master/srcpkgs/android-tools/patches |
| 206 | +[chimera]: https://github.com/chimera-linux/cports/tree/master/user/android-tools/patches |
0 commit comments