Gentoo Archives: gentoo-soc

From: heroxbd@×××××.com
To: gentoo-soc@l.g.o
Cc: EBo <ebo@×××××××.com>, Duncan <1i5t5.duncan@×××.net>, Ruud Koolen <redlizard@×××××××××.nl>, Richard Farina <zerochaos@g.o>, Steven Trogdon <strogdon@×××××.edu>, Greg Turner <gmt@×××××.us>
Subject: [gentoo-soc] Gentoo on Android: Final Report
Date: Wed, 25 Sep 2013 01:59:04
Message-Id: 868uyl8xwi.fsf@moguhome00.in.awa.tohoku.ac.jp
1 Gentoo on Android: Final Report
2 ===============================
3
4 Author: Benda Xu
5 Date: 2013-09-25 10:55:24 JST
6
7
8 Table of Contents
9 =================
10 1 Overview
11 2 Toolchain
12 2.1 Remaining Issue
13 2.2 Credits
14 3 Profiles
15 3.1 Credits
16 4 GLEP
17 4.1 Credits
18 5 Bootstrap Script
19 5.1 Credits
20 6 Stage 3 Tarball
21 6.1 Remaining Issue
22 7 SD card partition
23 7.1 Remaining Issue
24 8 Cross triplet-prefix a native toolchain
25 8.1 Credits
26 9 Prefix Portage Escalation
27 10 Future
28 11 Final Acknowledgment
29
30
31 1 Overview
32 ===========
33 The project is finished. A Gentoo RAP (:=Rap Ain't Prefix, also
34 known as Prefix with libc) solution is developed and brought on to
35 Android devices.
36
37
38 2 Toolchain
39 ============
40 This is the central part of the RAP magic. The final solution is to
41 use the sysroot feature in the GNU toolchain.
42
43 - sys-libs/glibc is Prefixified, bug 473728
44 - a bug in sys-apps/portage was fixed for sys-kernel/linux-headers in Prefix, bug 470992
45 - sys-devel/gcc is patched to output ELF pointing its interpreter field to the dynamic linker in EPREFIX
46 - sys-devel/gcc-config is updated for such purpose
47 - sys-devel/binutils is patched to have an option to disable runtime
48
49 submitted upstream[1]
50 - sys-devel/binutils-config is prefixified
51
52 In the Prefix overlay, sys-devel/binutils-config is a wrapper that do the rpath injection
53
54 An old deprecated solution was
55 - sys-devel/gcc untouched
56 - use sys-devel/binutils-config from Prefix overlay to inject dynamic linker instead of rpath
57
58 The solution is documented in the wiki[2] for archiving purpose.
59
60 2.1 Remaining Issue
61 --------------------
62
63 Guys in toolchain and kernel herd are too busy. A list of
64 outstanding pending bugs are 478436(kernel-2.eclass),
65 478434(toolchain-bintuils.eclass), 474358(toolchain.eclass),
66 473728(sys-libs/glibc).
67
68 Can I accelerate the progress of merging these patches by joining
69 to toolchain herd, Luca?
70
71
72 2.2 Credits
73 ------------
74
75 Ruud Koolen (redlizard) developed the first solution of Prefix with
76 libc, and discuss/debated with me back and forth to pin down the
77 final solution. Of course the debate will go on as we refine it,
78 and especially after he joins Gentoo as well (bug 485618).
79
80 3 Profiles
81 ===========
82 Lightweight profiles are created, thanks to the similarity of RAP to
83 gentoo-x86.
84
85 At the time of writing, the profiles are organized as followed.
86
87 .
88 |-- default
89 | `-- linux
90 | |-- amd64
91 | | `-- 13.0
92 | | |-- eapi
93 | | `-- rap
94 | | |-- make.defaults
95 | | `-- parent
96 | |-- arm
97 | | `-- 13.0
98 | | |-- armv5te
99 | | | `-- rap
100 | | | |-- make.defaults
101 | | | `-- parent
102 | | `-- armv7a
103 | | `-- rap
104 | | |-- make.defaults
105 | | `-- parent
106 | `-- x86
107 | `-- 13.0
108 | `-- rap
109 | |-- make.defaults
110 | `-- parent
111 |-- eapi
112 `-- features
113 `-- rap
114 |-- make.defaults
115 |-- packages
116 |-- profile.bashrc
117 |-- use.force
118 `-- use.mask
119
120 amd64, x86, armv5te (Marvell Kirkwood-based NAS), armv7a (for
121 Android devices) are supported and tested.
122
123 3.1 Credits
124 ------------
125
126 Richard Farina (zerochaos) suggested to derive RAP profiles from
127 default instead of prefix, which lead to this elegant layout.
128
129
130 4 GLEP
131 =======
132
133 A GLEP draft [3] is composed to standardize RAP. The development
134 of RAP is encouraged by the council, and the GLEP will be refined by
135 a newly formed GLEP team[4].
136
137 4.1 Credits
138 ------------
139
140 Duncan helped with the English expressions of the GLEP draft.
141
142 5 Bootstrap Script
143 ===================
144
145 A bootstrap script deriving from bootstrap-prefix.sh[5] is
146 developed[6].
147
148 An alternative bootstrap script by redlizard is being heavily
149 tested, it is expected to be more elegant and general than the
150 current script.
151
152 5.1 Credits
153 ------------
154
155 Steven Trogdon and Richard Farina(zerochaos) helped with the early
156 testing of the bootstrap script.
157
158 6 Stage 3 Tarball
159 ==================
160
161 An instance of Gentoo RAP armv7a is bootstrapped on a smartphone, and
162 distributed by the Gentoo Infrastructure[7], which in turn is
163 tested on a tablet[8].
164
165 A installation guide for normal users is composed as well[9].
166
167 6.1 Remaining Issue
168 --------------------
169
170 Needs a better solution to configure the glibc DNS resolve and
171 uid/gid mapping. Generating the config files from the brother
172 Android is preferred.
173
174 The Android usually mount user writable partition with /noexec/,
175 which prevents Gentoo RAP from running. Therefore at the time of
176 writing we only have a solution for rooted devices. However, it
177 might be circumvented by creating a dedicated apk.
178
179 7 SD card partition
180 ====================
181
182 A study has been carried out on the optimized partition and
183 filesystem strategy for SD card[10], which is the main extendable
184 storage media on Android devices.
185
186 Performance of Gentoo is boosted more than 5 times on small
187 files[10], for example portage sync and emerging, on SD cards of
188 Android devices after such tuning.
189
190 7.1 Remaining Issue
191 --------------------
192
193 The technical details are still not well understood. The present
194 tuning is based trial-and-error and educated guesses.
195
196
197 8 Cross triplet-prefix a native toolchain
198 ==========================================
199
200 For the case no compiler is available in the target device, cross
201 compiling a native toolchain is needed.
202
203 A related work is to let crossdev support Prefix, bug 384167.
204
205 A workable solution to make a RAP compatible native toolchain for
206 the target device by cross compiling is found and documented[11].
207
208 8.1 Credits
209 ------------
210
211 Greg Turner gave many insights on crossdev and toolchain of Prefix,
212 and shared his patch for crossdev.
213
214 9 Prefix Portage Escalation
215 ============================
216
217 In some cases, the user does have root privilege and still want to
218 install a Gentoo Prefix as normal user and give it root privilege
219 when necessary, such as setting suid root and setcap some binaries.
220
221 A simple wrapper proves the concept.
222
223
224 #!/bin/bash
225 ESCULATE="sudo"
226
227 scriptpath=${BASH_SOURCE[0]}
228 scriptname=${scriptpath##*/}
229
230 IFS=':'
231
232 for path in ${PATH}; do
233 [[ -x ${path}/${scriptname} ]] || continue
234 [[ ${path}/${scriptname} -ef ${scriptpath} ]] && continue
235
236 elog "using ${ESCULATE} to execute ${path}/${scriptname} $@ as root..."
237 ${ESCULATE} ${path}/${scriptname} $@
238
239 exit 0
240 done
241 exit 1
242
243
244 10 Future
245 ==========
246 This Google Summer of Code project is only a beginning of a larger
247 roadmap[12].
248
249 Gentoo will share the graphics with Android by leveraging the
250 technology of Wayland[13] or Mir[14], instead of only staying
251 inside a terminal emulator. To cooperation the development effort, a
252 Gentoo subproject[15] has been created. Join it if you are
253 interested.
254
255 11 Final Acknowledgment
256 ========================
257
258 I am very appreciated to my mentor Luca Barbato. I had a very
259 pleasant experience with him since the OpenRC project last year. He
260 has a style that matches me quite well, namely pointing at the
261 correct direction while not interfering with the very details.
262
263 I have learned a lot in the project. The knowledge gained was
264 profound, which *transformed* me: last years' OpenRC project opens
265 the blackbox of system booting process, while this years' Android
266 project unleashed the magic of toolchain.
267
268 Having such deeper understandings of the operating system, I feel
269 more confident and powerful than ever.
270
271 This would be my final year of participation in Google Summer of
272 Code, as I am going to get my PhD (on particle physics) and no
273 longer a student next year. I will be happy to be a mentor
274 myself. Actually I am co-mentoring this years' project of OpenRC
275 Debian port[16], as an offshoot of last years' OpenRC project.
276
277 Finally, thanks to all the people who have encouraged, commented on
278 or critized the project. Enjoy this, and we will make the universe a
279 better place to live =)
280
281 All the best,
282 Benda
283
284 [1] [http://article.gmane.org/gmane.comp.gnu.binutils/63137]
285
286
287 [2] [https://wiki.gentoo.org/wiki/Prefix/libc]
288
289
290 [3] [http://git.heroxbd.z.tuna.tsinghua.edu.cn/?p=doc.git;a=blob;f=glep-gap.rst]
291
292
293 [4] [https://www.gentoo.org/proj/en/council/meeting-logs/20130917-summary.txt]
294
295
296 [5] [http://overlays.gentoo.org/proj/alt/browser/trunk/prefix-overlay/scripts/bootstrap-prefix.sh]
297
298
299 [6] [http://dev.gentoo.org/~heroxbd/bootstrap-rap.sh]
300
301
302 [7] [http://distfiles.gentoo.org/experimental/prefix/rap/rap-stage3-armv7a_hardfp-20130924.tar.bz2]
303
304
305 [8] [http://wiki.gentoo.org/wiki/Project:Android/devices]
306
307
308 [9] [http://wiki.gentoo.org/wiki/Project:Android/tarball]
309
310
311 [10] [http://wiki.gentoo.org/wiki/SDCard]
312
313
314 [11] [http://wiki.gentoo.org/wiki/Project:Android/build]
315
316
317 [12] [http://thread.gmane.org/gmane.linux.gentoo.devel/87475]
318
319
320 [13] [http://wayland.freedesktop.org]
321
322
323 [14] [https://wiki.ubuntu.com/Mir]
324
325
326 [15] [http://wiki.gentoo.org/wiki/Project:Android]
327
328
329 [16] [http://anonscm.debian.org/gitweb/?p=collab-maint/openrc.git]