Project

General

Profile

Upstream » History » Version 431

Denis 'GNUtoo' Carikli, 11/26/2022 04:39 PM
Design decisions: fix depth

1 12 Denis 'GNUtoo' Carikli
h1. Upstream Linux
2 1 Denis 'GNUtoo' Carikli
3 57 Denis 'GNUtoo' Carikli
{{>toc}}
4
5 362 Denis 'GNUtoo' Carikli
h2. Tracking upstream patches
6 100 Denis 'GNUtoo' Carikli
7 362 Denis 'GNUtoo' Carikli
We have a "new issue tracker":https://redmine.replicant.us/projects/upstreaming/issues for tracking upstream status of various patches.
8 100 Denis 'GNUtoo' Carikli
9 11 Denis 'GNUtoo' Carikli
h2. Benefits of using Upstream Linux
10 2 Denis 'GNUtoo' Carikli
11 11 Denis 'GNUtoo' Carikli
Currently, Replicant uses device specific Hardware Abstraction Layers, because device manufacturers implemented non-standard kernel interfaces. However, Android works with upstream kernels and supports plug-n-play hardware nowadays, so it makes sense to have generic Hardware Abstraction Layers for the standard interfaces of the Linux kernel (ALSA, V4L2, etc).
12 2 Denis 'GNUtoo' Carikli
13
Benefits:
14
* It would allow supporting external WiFi dongles such as the ones supported by the ath9k_htc driver and free firmwares without the need for a specific application or configuration.
15 46 Denis 'GNUtoo' Carikli
* It would make devices last longer by alleviating the device specific maintenance burden: If LineageOS stops supporting a Replicant supported device, Replicant would need to maintain it by its own. This would require a lot of work, unless the device is already supported the upstream Linux kernel and generic hardware abstractions layers. This would also enable Replicant to support devices that are not currently supported by LineageOS with a lot less work.
16 11 Denis 'GNUtoo' Carikli
* It would enable the support for devices that are or will be added to upstream Linux.
17 2 Denis 'GNUtoo' Carikli
18 22 Denis 'GNUtoo' Carikli
As GNU/Linux expects standard kernel interfaces, this would also enable to run GNU/Linux out of the box on such devices.
19
This has some interesting outcomes:
20 46 Denis 'GNUtoo' Carikli
* The device specific work could be shared between GNU/Linux communities and Replicant communities. This could result in less work to do to support individual devices. Since Android libraries depends on Android's libc, non-standard proprietary libraries might be harder to reuse than the free software implementations, so we might get even more collaboration thanks to that.
21
* It would enable GNU/Linux distributions to more easily support smartphones and tablets, which would hopefully enable FSDG distributions to be able to focus on usability instead of hardware support. This way, if one day Android devices stop using the Linux kernel, stops being free software, or if the code takes directions that are too much problematic, already having GNU/Linux based Android alternatives would reduce the amount of work needed to be able to get again a fully free software distribution for smartphones and tablets.
22 23 Denis 'GNUtoo' Carikli
* Older devices with less amount of RAM than Replicant current minimum requirements could be used with GNU/Linux and possibly repurposed for other usages, reducing the amount of electronic devices waste.
23 22 Denis 'GNUtoo' Carikli
24 2 Denis 'GNUtoo' Carikli
h2. Requirements
25
26 404 Fil Lupin
* For the other standard interfaces (like ALSA, etc) a device running a upstream Linux Kernel with as few patches as possible is required.
27 2 Denis 'GNUtoo' Carikli
28 4 Denis 'GNUtoo' Carikli
h2. Devices
29
30 5 Denis 'GNUtoo' Carikli
It is best to use a device that requires the least amount of work to be functional under Replicant.
31
More precisely we want to minimize:
32 11 Denis 'GNUtoo' Carikli
* The work needed to have the device usable with upstream Linux.
33 5 Denis 'GNUtoo' Carikli
* The work porting or writing Android hardware abstractions layers.
34
35
To achieve that we can choose a device that:
36
* requires no or very minimal work to be fully supported by Linux.
37
* have less hardware features (so we don't need to support them in Linux and in the HALs).
38
* is easy to buy, so the work can be shared among multiple people.
39 53 Denis 'GNUtoo' Carikli
* doesn't have more freedom flaws than the devices currently supported by Replicant
40 5 Denis 'GNUtoo' Carikli
41 54 Denis 'GNUtoo' Carikli
It is also a good idea to keep one image per device at first, as trying to make a single image that
42 55 Denis 'GNUtoo' Carikli
would work on all ARM device supported by upstream Linux is complicated: Even GNU/Linux
43
distributions have a hard time doing that for ARM devices.
44 6 Denis 'GNUtoo' Carikli
45 58 Denis 'GNUtoo' Carikli
h2. Linux upstream status
46
47 403 Kurtis Hanna
In some cases, even if the upstream status looks good, nonfree bootloaders can get in the way. We have a list of stock bootloaders incompatible with upstream Linux in this page: [[BootloadersIncompatibleWithLinux]].
48 363 Denis 'GNUtoo' Carikli
49 400 Denis 'GNUtoo' Carikli
See "LinuxSupportedDevices":https://redmine.replicant.us/projects/upstreaming/wiki/LinuxSupportedDevices in the upstreaming sub project for the upstream status for various devices.
50 78 Denis 'GNUtoo' Carikli
51 134 Denis 'GNUtoo' Carikli
h1. Bootloaders
52 1 Denis 'GNUtoo' Carikli
53
h2. Bootloader status
54
55 402 Denis 'GNUtoo' Carikli
See the "BootloaderStatus":https://redmine.replicant.us/projects/upstreaming/wiki/BootloaderStatus page on the upstream subproject.
56 121 Denis 'GNUtoo' Carikli
57 1 Denis 'GNUtoo' Carikli
h2. See also
58
59
* [[Google Summer of Code 2018]]
60 12 Denis 'GNUtoo' Carikli
61 379 Denis 'GNUtoo' Carikli
h1. GNU/Linux components
62 19 Denis 'GNUtoo' Carikli
63 182 Denis 'GNUtoo' Carikli
h2. Modem support
64 1 Denis 'GNUtoo' Carikli
65 183 Denis 'GNUtoo' Carikli
|_. Protocols |_. Implmentation |_. comments |
66 190 Denis 'GNUtoo' Carikli
| QMI | Android <-> RIL <-> libqmi-ril to be completed <-> libqmi | |
67 184 Denis 'GNUtoo' Carikli
|/2. * QMI
68 1 Denis 'GNUtoo' Carikli
* AT
69 190 Denis 'GNUtoo' Carikli
* Other | Android <-> RIL <-> libraries to be written | 
70 226 Denis 'GNUtoo' Carikli
| "android_frameworks_opt_telephony_ril_ofono":https://github.com/scintill/android_frameworks_opt_telephony_ril_ofono + ofono + ofono backend (AT, QMI, etc) | * Using ofono would enable us to share more effort with upstream GNU/Linux and support many other protocol like AT for the GTA04 or qmi-ril for the Galaxy SIII 4G (I9305) or the Galaxy Note II 4G (N7105)
71 405 Fil Lupin
* According to the "README":https://github.com/scintill/android_frameworks_opt_telephony_ril_ofono/blob/master/README.md, it has already been tested with most of Replicant 6 code but on a smartphones not yet supported by Replicant. Calls, Audio, SMS, etc are known to work.
72 281 Kurtis Hanna
* "BuildRilWrapper.java":https://github.com/scintill/android_frameworks_opt_telephony_ril_ofono/blob/master/build/java/net/scintill/ril_ofono/BuildRilWrapper.java seems to use introspection to automatically generate the API between the Framework Java RIL and itself (which replaces rild) (See the "official documentation":https://source.android.com/devices/tech/connect/ril for background information on the Android architecture)
73 282 Kurtis Hanna
* Replicant and oFono based Java RIL "video presentation":https://redmine.replicant.us/projects/replicant/wiki/ContributorsMeetingJuly2019#Presentations |
74 198 Denis 'GNUtoo' Carikli
|/5. samsung-ipc | Ofono (rilmodem backend/driver) <-> rild <-> libsamsung-ril <-> libsamsung-ipc | * Might be usable for GNU/Linux distributions with "libhybris":https://en.wikipedia.org/wiki/Hybris_%28software%29
75 1 Denis 'GNUtoo' Carikli
* Could be usable for testing Replicant as ofono could run on the host computer and the rild socket could be exported with adb
76 197 Denis 'GNUtoo' Carikli
* Some forks exist: check if they still have interesting patches
77 281 Kurtis Hanna
* https://github.com/rilmodem/ofono|
78 347 Denis 'GNUtoo' Carikli
| Android <-> rild <-> libsamsung-ril <-> libsamsung-ipc | * Currently in use in Replicant
79
* Well integrated with Android
80
* Potentially usable by other distributions
81
* No known way to support different modems protocols in the same Replicant image with that |
82 189 Denis 'GNUtoo' Carikli
| Android <-> Ofono <-> libsamsung-ipc | * "An ofono fork with libsamsung-ipc support is available":https://github.com/fourkbomb/ofono
83 346 Denis 'GNUtoo' Carikli
"Patches":https://lists.ofono.org/pipermail/ofono/2012-September/013777.html to add that upstream were "refused":https://lists.ofono.org/pipermail/ofono/2012-September/013778.html because upstream didn't want to make the project become GPLv3 (libsamsung-ipc was GPLv3 at the time) but now libsamsung-ipc has been relicensed to GPLv2+
84
* Could be used to have generic a Replicant image supporting many devices with very different modems protocols (like libsamsung-ipc or QMI based ones) and have ofono do the modem detection |
85 185 Denis 'GNUtoo' Carikli
|
86 197 Denis 'GNUtoo' Carikli
| FSO <-> libsamsung-ipc | * Probably not easily usable in Replicant
87 194 Denis 'GNUtoo' Carikli
* Is FSO still actively maintained?
88 193 Denis 'GNUtoo' Carikli
* Was used by SHR and potentially other GNU/Linux distributions supporting the Openmoko GTA04 smartphones |
89 182 Denis 'GNUtoo' Carikli
90
h2. Upstream userspace hardware support libraries
91
92
|_. Usage |_. Replicant |_. GNU/Linux |_. comments |
93
| Bluetooth stack | BlueDroid | Bluez | |
94
| GPS hardware support | ? | gpsd | |
95
96 16 Denis 'GNUtoo' Carikli
97 20 Denis 'GNUtoo' Carikli
h2. Upstream non-hardware specific userspace
98 18 Denis 'GNUtoo' Carikli
99
|_. Usage |_. Replicant |_. GNU/Linux |_. comments |
100 151 Denis 'GNUtoo' Carikli
| Unix command line tools | ? | * Busybox
101
* Coreutils | * Busybox already has Android specific code in it but no Android.mk 
102
* Busybox build is very similar to Linux, and Linux can be built by Android |
103 44 Denis 'GNUtoo' Carikli
104 354 Denis 'GNUtoo' Carikli
h2. MTP
105
106 355 Denis 'GNUtoo' Carikli
TODO: 
107
* look at https://github.com/viveris/uMTP-Responder to see if it can be integrated in Android. It is known to work with the upstream kernel.
108
* Also compare with other implementation, including the Android one.
109 354 Denis 'GNUtoo' Carikli
110 229 Denis 'GNUtoo' Carikli
h2. libc
111
112
|_. Feature |_. Advantages |_. Disadvantages |_. sustainability |
113
| glibc + libhybris | * You just need an Android.mk to compile GNU/Linux software | * You need to link the Android part that need bionic functions to libhybris | TODO: Evaluate how close to bionic is libhybris |
114
| bionic | Android default | * You spend lot of time trying to run GNU/Linux debug tools like evtest on Android:
115
* Parabola cannot be used on old kenrels (FATAL: kernel too old)
116
* GuiX and libreCMC might not have the package and might need tweaking to be recompiled with an old glibc and kernel headers
117
* TODO: try crosstool-ng
118 230 Denis 'GNUtoo' Carikli
* Most of the other GNU/Linux distributions are not FSDG compliant or do not support ARM
119
* The software might not work on Android due to missing bionic functions like versionsort(...) |
120 229 Denis 'GNUtoo' Carikli
121 44 Denis 'GNUtoo' Carikli
h2. Other projects interested in using upstream Linux and/or contributing to it
122
123 339 Kurtis Hanna
h3. PostmarketOS
124
"pmOS wiki: upstream kernel":https://wiki.postmarketos.org/wiki/The_Mainline_Kernel
125
"pmOS wiki: i9305 with upstream kernel":https://wiki.postmarketos.org/wiki/Samsung_Galaxy_SIII_LTE_(samsung-i9305)#Mainline_Kernel
126
127 340 Kurtis Hanna
h3. O-DROID
128
129
h3. osmocomBB
130
131
h3. Mali
132
133
h3. LineageOS
134
135
h3. oFono
136
137
h3. Parabola
138 116 Denis 'GNUtoo' Carikli
139 380 Denis 'GNUtoo' Carikli
h1. GNU/Linux distributions
140 318 Denis 'GNUtoo' Carikli
141 430 Denis 'GNUtoo' Carikli
See [[GNULinuxDistributions]] for more details.
142 318 Denis 'GNUtoo' Carikli
143 378 Denis 'GNUtoo' Carikli
h1. Android distributions
144 1 Denis 'GNUtoo' Carikli
145 429 Denis 'GNUtoo' Carikli
See [[AndroidDistributions]] for more details.
146 426 Denis 'GNUtoo' Carikli
147
h1. Comparison of distributions
148
149
h2. AOSP and LineageOS
150
151
| Feature | AOSP | LineageOS |
152
| Code quality | Better than LineageOS | |
153
| Documentation | Better than LineageOS | |
154
| root | Not sure if supported or not | Supported |
155
| Minor release versioning | supported with Git tags | Not supported.
156
For instance frameworks/native has no LineageOS tags (only cm-1x tags) and has no other branch for lineage OS 16.0 than the lineage-16.0 branch, as the other branches name are for other things. This was confirmed after running 'git fetch github' in frameworks/native to fetch the other branches that are not fetched by repo by default.
157
Despite that, some code was even merged in after the lineage-16.0 release:
158
<pre>
159
commit 22abc3cf4077644463a2dc1c59a5a74e9518ea16
160
Merge: 9e96d54 8a6b6c3
161
Date:   Sat Jul 13 18:57:45 2019 +0200
162
163
    Merge remote-tracking branch 'aosp/pie-gsi' into lineage-16.0-pie-gsi
164
</pre> |
165
| GUI features for developers
166
* Advanced reboot | ? | Supported |
167
| Integrated kernel builds | Unsupported | Supported |
168
169 431 Denis 'GNUtoo' Carikli
h1. Design decisions
170 210 Denis 'GNUtoo' Carikli
171 1 Denis 'GNUtoo' Carikli
Some decisions have been taken by upstream projects, for instance the the Android Open Source Project (AOSP) is pushing device manufacturers to use "signed bootloaders":https://source.android.com/security/verifiedboot/device-state#root-of-trust and not give the users the ability to replace those bootloaders. Therefor it is best to revisit such decisions and decide whether or not to implement a given feature.
172 377 Denis 'GNUtoo' Carikli
173 431 Denis 'GNUtoo' Carikli
h2. Various
174 377 Denis 'GNUtoo' Carikli
175 210 Denis 'GNUtoo' Carikli
| Feature | Advantages | Disadvantages |
176
| adb and root at boot | Easier to debug:
177
* We get the logs at boot
178
* May be able to diagnose non-booting devices (partition not mountable, etc) | Way less secure:
179
* Vulnerable to "Juice_Jacking":https://en.wikipedia.org/wiki/
180
* Vulnerable to an attacker that just connect an usb cable to a running phone
181
* Breaks the user's expectation of security (lock screen etc) |
182
183
We can get both: we can enable users to get logs at boot while avoiding any security issues. 
184 1 Denis 'GNUtoo' Carikli
185 160 Denis 'GNUtoo' Carikli
To do that we can keep disable adb and root disabled at boot, and enable users to add it back by editing the boot.img or recovery images. We have a tutorial for that in the [[AddingADBRootToAnImage]] page and we are working on script to automate it even more.
186
187 431 Denis 'GNUtoo' Carikli
h2. root filesystem related
188 209 Denis 'GNUtoo' Carikli
189 1 Denis 'GNUtoo' Carikli
|_. Feature |_. Advantages |_. Disadvantages |_. sustainability |
190 161 Denis 'GNUtoo' Carikli
| System as root | * The kernel size can be bigger
191 213 Denis 'GNUtoo' Carikli
* You have to hardcode the root partition in the cmdline or use PARTLABEL which might be a security issue: if a microSD has a partition named SYSTEM, the kernel may boot on it instead | having an initramfs adds some flexibility:
192
* Selecting partitions can potentially be more  flexible | |
193 1 Denis 'GNUtoo' Carikli
| System as root + dm-verity + "dm-init":https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/device-mapper/dm-init.txt | * The kernel size can be bigger
194 294 Kurtis Hanna
* The partition selection is flexible and secure  | | |
195 215 Denis 'GNUtoo' Carikli
| read-only /system | * more secure and more easily understandable by users and developers | * need to ship in replicant user-scripts or add them to vendor/ | |
196 408 Fil Lupin
197 431 Denis 'GNUtoo' Carikli
h2. Gatekeeper HAL backend
198 294 Kurtis Hanna
199 214 Denis 'GNUtoo' Carikli
*Background information*: Gatekeeper is a daemon that is used to store passwords and other secrets.
200 294 Kurtis Hanna
201 165 Denis 'GNUtoo' Carikli
| Backend used | Advantages | Disadvantages |
202 160 Denis 'GNUtoo' Carikli
| simple userspace implementation | * Fast to do
203
* Simple to understand 
204
* Good enough for most use cases| |
205 203 Denis 'GNUtoo' Carikli
| kernel keyring (man 7 keyrings) | * Secure
206
* The Linux kernel is well known and updated regularly
207
* Some users are already used to the userspace/kernel security model
208 219 Denis 'GNUtoo' Carikli
* Probably fun to implement, can learn how to implement Android daemons and how to use the keyring along the way |
209 207 Denis 'GNUtoo' Carikli
| Free software Trusted Execution Environment (TEE) | * Android does it | * Require access to TrustZone, which doesn't work for all SOCs
210 203 Denis 'GNUtoo' Carikli
* Unfamiliar to users and developers (it's supposed to tick in suspend, knowledge about TrustZone is less spread than Linux, etc)
211 205 Denis 'GNUtoo' Carikli
* Probably requires to port a TrustZone OS to every SOC or phone 
212 204 Denis 'GNUtoo' Carikli
* The Linux kernel is well known and updated regularly |
213 1 Denis 'GNUtoo' Carikli
| Proprietary software Trusted Execution Environment (TEE) | None: we really want to get rid of it if possible | 
214 204 Denis 'GNUtoo' Carikli
Cannot be trusted:
215
* Not free software
216
* Not under the user control |
217 294 Kurtis Hanna
218 431 Denis 'GNUtoo' Carikli
h2. Handling dynamic major/minor /dev/ nodes
219 1 Denis 'GNUtoo' Carikli
220 219 Denis 'GNUtoo' Carikli
*Background information*: We can manage to avoid this use case for now.
221
222
| Backend used | Advantages | Disadvantages | sustainability |
223
| Android default + Upstream Linux | | * does not work by default, probably impossible to make it work as-is |
224
| Android default + Upstream Linux + very dirty userspace scripts | * Minimal changes | * Not robust
225
* Might eat up resources
226 220 Denis 'GNUtoo' Carikli
* Already implemented cleanly in mdev | |
227 1 Denis 'GNUtoo' Carikli
| Android default + hacked drivers to use fixed major/minor | * Minimal changes in Linux
228 296 Denis 'GNUtoo' Carikli
* No changes required on Android side | * Require to change userspace software (libsamsung-ipc) | * Not upstreamable in Linux |
229 299 dl lud
| devtmpfs + hacked Android init | * Minimal changes if upstreamed
230 1 Denis 'GNUtoo' Carikli
* Init is hard to debug | * Complex to do as debugging at this stage is complicated | * Need to be upstreamed in Android |
231
| Stock Andrdroid init + mdev (busybox) | * Bad integration in the Android build system | * Changes are minimal | * Android build system integration need to be upstreamed or maintained |
232
233 431 Denis 'GNUtoo' Carikli
h2. Firmware loading
234 305 dl lud
235
| Backend used | Advantages | Disadvantages | sustainability |
236 299 dl lud
| system/core/init/firmware_handler.cpp | * Stock Android implementation | None | Already upstream in Android |
237
| Something else | None | The stock Android implementation is good enough and firmware loading is trivial anyway | Not upstream in Android |
238
239 431 Denis 'GNUtoo' Carikli
h2. Embeddable web engine
240 299 dl lud
241 304 Denis 'GNUtoo' Carikli
The Android API for embedding a web engine is WebView.
242 296 Denis 'GNUtoo' Carikli
243
| Project | Comments |
244 312 Denis 'GNUtoo' Carikli
| "AOSP WebView API implemented with Chromium":https://developer.android.com/reference/android/webkit/WebView | * Built from Chromium compiled for WebView
245 296 Denis 'GNUtoo' Carikli
* Latest additions to the API seem more and more tied to Chromium (e.g. getWebViewRenderProcess, getWebChromeClient) | 
246 313 Denis 'GNUtoo' Carikli
| Old AOSP WebView API implemented with WebKit | * Not used anymore, since Android 4.4
247
* Does not implement the current WebView API |
248
| "GeckoView":https://mozilla.github.io/geckoview/ | * Not the same API as WebView 
249
* Could be used to implement WebView
250
* Would need to be modified to expose more features from Gecko (e.g. zoom) while others are straightforward |
251
| "Qt WebEngine":https://doc.qt.io/qt-5/qtwebengine-index.html | * Not the same API (C++ instead of Java)
252 314 Denis 'GNUtoo' Carikli
* Probably the smallest subset of Chromium available |
253
| "Wine Internet Explorer implementation":https://wiki.winehq.org/Gecko | * Uses Gecko under the hood
254
* Might be interesting to look at how they did it |
255 313 Denis 'GNUtoo' Carikli
256 298 Denis 'GNUtoo' Carikli
h1. Web engine backend
257 296 Denis 'GNUtoo' Carikli
258 315 Denis 'GNUtoo' Carikli
We have an issue with webview (bug #1780):
259 1 Denis 'GNUtoo' Carikli
* Using a recent webview based on chromium would create freedom issues as we don't know the license of chromium
260 315 Denis 'GNUtoo' Carikli
* Using and old webview based on webkit would bring back many security issues
261
262 1 Denis 'GNUtoo' Carikli
To solve that we need to find a solution that depends on a good upstream as we are not going to write a web browser engine ourselves.
263 315 Denis 'GNUtoo' Carikli
264
h2. Upstream web browser engine comparison
265
266
This lists upstream projects that are not forks tracking another upstream project.
267 220 Denis 'GNUtoo' Carikli
268 317 Denis 'GNUtoo' Carikli
| Project | Comments |
269
| Gecko | * Clear licensing
270
* Friendly upstream: The tor-browser project works with Mozilla to upstream privacy features in Firefox. So we could probably work with them as well too. |
271
| Chromium | * Unclear licensing 
272 307 Denis 'GNUtoo' Carikli
* Google has goals for Chromium that are directly opposed to our goals (tracking, linked to google)
273
* Probably unfriendly upstream because of the opposed goals |
274
| Webkit | ? |
275
276
h2. Forked web browser engine comparison
277
278
TODO: Add various chromium versions here.
279
280 309 Denis 'GNUtoo' Carikli
h2. How and if to implement a webview compatible API
281 1 Denis 'GNUtoo' Carikli
282 310 Denis 'GNUtoo' Carikli
TODO
283 308 Denis 'GNUtoo' Carikli
284 309 Denis 'GNUtoo' Carikli
h1. Tools and build systems
285 396 Denis 'GNUtoo' Carikli
286 395 Denis 'GNUtoo' Carikli
Replicant has an issue with licensing (bug #1973) where we don't know under which license is Replicant. This due to the fact that the Android build system doesn't use a package manager during the build, and so it doesn't have license definition for each repositories.
287 398 Denis 'GNUtoo' Carikli
288 395 Denis 'GNUtoo' Carikli
A good way to fix that and also gain the ability to natively build GNU/Linux components like MESA or ofono would be to use a build system that use a package during at least during the build.
289
290 397 Denis 'GNUtoo' Carikli
Some other communities have issues that do or could also benefit from that:
291 395 Denis 'GNUtoo' Carikli
* GNU/Linux distributions need to package Android tools which are built with the custom Android build system
292 392 Denis 'GNUtoo' Carikli
* Some distributions mixes GNU/Linux and Android
293 395 Denis 'GNUtoo' Carikli
294
h2. Projects
295
296
|_. Project |_. use case |_. Comments |
297
| Android | - Build images
298
- Build the Android NDK and SDK
299 410 Denis 'GNUtoo' Carikli
- Build the Android tools | - Wrapping build systems (like autotools, cmake, etc) is way too primitive:
300 1 Denis 'GNUtoo' Carikli
-- In LineageOS (not AOSP) The kernel is wrapped with .mk files, but the downside is that it runs make inside Linux source each time it needs to compile something
301 410 Denis 'GNUtoo' Carikli
-- In AOSP there is no infrastructure for building software with other build systems, still mesa is built in it, but not the kernel |
302
| Archlinux | - Build and package Android tools(Fastboot, adb, etc) | - relies on a "fragile script":https://git.archlinux.org/svntogit/community.git/tree/android-tools/trunk/generate_build.rb
303 412 Denis 'GNUtoo' Carikli
- The package for Android tools is self contained and doesn't have its dependencies (like liblog, libcutils, etc) splited in other packages | 
304 309 Denis 'GNUtoo' Carikli
| Debian | | relies on "custom Makefiles":https://salsa.debian.org/android-tools-team/android-tools/tree/master/debian/makefiles |
305 316 Denis 'GNUtoo' Carikli
| [[GuixBuildSystem|Guix]] | - Build android tools 
306 1 Denis 'GNUtoo' Carikli
                             - Build the android ndk | Findings:
307 413 Denis 'GNUtoo' Carikli
                                                       - Guix uses "android-make-stub":https://github.com/daym/android-make-stub.git to wrap Android.mk 
308 417 Denis 'GNUtoo' Carikli
                                                       - We have real packaging of dependencies, however not all dependencies are exported, most are though
309
                                                       - The Android build system is wrapper in a ndk-android-build-system function
310 420 Denis 'GNUtoo' Carikli
                                                       - The package definition needs very light and straigtforward patching. See [[GuixBuildSystem|Guix]] for more details. |
311
| "Robotnix":https://github.com/danielfullmer/robotnix |  - Build AOSP images with Nix with package definitions | This project is being funded by NLnet.
312
                                                                                                                              Once completed it has the potential to replace the Android build system.
313 421 Denis 'GNUtoo' Carikli
                                                                                                                              Since it uses package definitions it could fix many issues we have in Replicant but we will need to understand how much maintenance from our side it would need (probably not a lot)
314
Findings:
315 417 Denis 'GNUtoo' Carikli
- It depends on NixOS: @inherit (inputs) nixpkgs nixpkgsUnstable androidPkgs;@ (from "pkgs/default.nix":https://github.com/danielfullmer/robotnix/blob/master/pkgs/default.nix). => We need to also look at how much work it would be to cleanup the nixOS dependencies (if we just have a toolchain we might just need to replace linux-headers by linux-libre-headers and remove what is not used). Alternatively it might be possible to reuse NixOS packages definition and create guix packages from them through guix import. |
316 421 Denis 'GNUtoo' Carikli
| "The GNU/Linux distribution of quectel-modems":https://osmocom.org/projects/quectel-modems | Mix an Android kernel with GNU/Linux userspace | |
317 423 Denis 'GNUtoo' Carikli
| "AsteroidOS":https://github.com/AsteroidOS/asteroid/blob/master/prepare-build.sh#L68 | Mix an Android kernel with GNU/Linux userspace | |
318
| "openembedded-android":https://github.com/anguslees/openembedded-android | Build the Android NDK? | strongly outdated version of openembedded |
319
320
h2. Approaches
321
322 422 Denis 'GNUtoo' Carikli
| Keep the Android build system | + Reduced maintenance cost
323
                                  - Hard to integrate software with other build systems (linux, mesa) 
324
                                  - Hard to audit the licenses                                        |
325
| Package everything in Guix    | + Fixes the licensing situation
326
                                  + Fixes prebuilt situation
327
                                  /!\ Replicant is dead if we can't maintain all the packages
328 1 Denis 'GNUtoo' Carikli
                                  /!\ Replicant is dead if we depend on non-bootstrapable software    |
329 424 Denis 'GNUtoo' Carikli
| Wrap Android build system to 
330
  enable other build systems 
331
  like autotools                | - Cannot use native Android build commands (they are wrapped)       
332
                                  + Can use more build systems
333 417 Denis 'GNUtoo' Carikli
                                  ? Unknown if solves the licensing issue                             |
334 413 Denis 'GNUtoo' Carikli
| Make guix produce tarball
335
  packages with Android.bp to 
336 414 Denis 'GNUtoo' Carikli
  import the prebuild and 
337 1 Denis 'GNUtoo' Carikli
  extract it in Android build 
338 414 Denis 'GNUtoo' Carikli
  system                        | + Integrated well enough in Android
339 416 Denis 'GNUtoo' Carikli
                                  + Fixes the licensing situation
340 415 Denis 'GNUtoo' Carikli
                                  + Incremental steps that can be reverted more easily 
341 414 Denis 'GNUtoo' Carikli
                                    than packaging everything in Guix
342
                                  /!\ We need to make sure to only depend on things that are buildable
343
                                      with AOSP build system if we want to be able to revert to that 
344
                                      build system                                                     |
345 413 Denis 'GNUtoo' Carikli
346
h1. Coding standards and style:
347
348
| Language | Stadards             | Used in                  | Tools                                                            | Comments                       |
349
| C        | Kernel coding style  | * Linux kernel
350
                                    * libsamsung-ipc         | * Has scripts/checkpatch.pl to check that can easily be imported |                                |
351
| C        | curl[3]              | * curl                   | * Has scripts/checksrc.pl in (lib)curl source code               |                                |
352
| C        | GNU coding style     | GNU projects (GRUB, etc) | ?                                                                |                                |
353 416 Denis 'GNUtoo' Carikli
| C        | pep7[1]              | * Python C code          | ?                                                                |                                |
354 1 Denis 'GNUtoo' Carikli
| C        | sysexits.h           | * libsamsung-ipc tools   | ?                                                                | used to standardize exit codes |
355
| Guile    | ?                    | * Guix                   | * Has guix style (and guix lint)                                 |                                |
356
357
358
Having a code style is good because: 
359
* Having inconsistent style makes it harder to read the code, spot bugs, etc
360
* Fixing inconsistent style too late results in commits that are extremely hard to review[2].
361
* Fixing inconsistent style in unrelated commits makes rebasing code painful
362
363
fn1. https://peps.python.org/pep-0007/
364
fn2. Example: https://git.replicant.us/replicant/hardware_replicant_libsamsung-ipc/commit/?id=3f706fe2556b5efe29aa16a1232a3dc5d5646f55
365
fn3. https://curl.se/dev/code-style.html