Gentoo Archives: gentoo-alt

From: Sam Pfeiffer <sammypfeiffer@×××××.com>
To: gentoo-alt@l.g.o
Subject: Re: [gentoo-alt] Allow non-interactive bootstrap to be stopped at arbitrary stages
Date: Sun, 14 Jun 2020 11:18:22
Message-Id: CABVqfw8E82VfK5t48kx5RfuKLC1-MmAsVG591JwMgTLJNv8avw@mail.gmail.com
In Reply to: Re: [gentoo-alt] Allow non-interactive bootstrap to be stopped at arbitrary stages by Fabian Groffen
1 Thanks a lot Fabian!
2
3 I've just adopted it and the first jobs are running with it :) This implies
4 I won't need to sync my bootstrap-prefix.sh with upstream by hand anymore,
5 that's great news!
6
7 On Sat, 13 Jun 2020 at 23:54, Fabian Groffen <grobian@g.o> wrote:
8
9 > I think pretty late, but this is committed in f6bbc6f470.
10 >
11 > Thanks,
12 > Fabian
13 >
14 > On 03-02-2020 14:54:26 +1100, Sam Pfeiffer wrote:
15 > > Hey Fabian,
16 > >
17 > > Thanks for chipping in. I do think it's useful and user-friendly to be
18 > able to
19 > > control the target of the interactive/noninteractive script.
20 > > I proposed in my first email in the thread something similar with the
21 > > $STOP_AFTER_STAGE variable, even though I was capturing it from the
22 > commandline,
23 > > and as I understand
24 > > you propose, it would probably be better to capture it from an
25 > environment
26 > > variable (it would actually be more in-line with other existing
27 > variables).
28 > >
29 > > Benda, I'm sorry for the noise I'm causing. I just want to improve the
30 > > experience for the next person that tries to use this amazing project by
31 > > taking advantage of already implemented stuff. And also just having this
32 > > discussion is good to have more information archived to google about
33 > Gentoo
34 > > Prefix and its bootstrap process. I think.
35 > >
36 > > On Sun, 2 Feb 2020 at 23:08, Fabian Groffen <grobian@g.o[1]>
37 > wrote:
38 > > > What I gather from this discussion is that the bootstrap script is
39 > > > complex, and grew more complexity over the years.
40 > > >
41 > > > Back in the early days, there was just documentation, one needed to
42 > > > follow. Since this frequently needed an update, and people kept using
43 > > > older copies, at some point the bootstrap-prefix.sh script was
44 > > > introduced.
45 > > >
46 > > > This script followed the documentation to the letter. It was an exact
47 > > > replica of the instructions in the bootstrap document. This included
48 > > > the notions of 3 stages and a world recompile.
49 > > >
50 > > > Today, the purpose of the stages have blurred, and seem more like
51 > > > batches in which to do things. Some of the initial intentions still
52 > > > stand out, e.g. that stage1 is there to provide a working portage
53 > > > environment with some minimal efforts. Minimal got redefined as soon
54 > as
55 > > > we had to install python and more and more tools seemed necesary (sed,
56 > > > path, awk, etc.).
57 > > >
58 > > > Now, it seems you need to cut time and sort of bootstrap up-to a stage.
59 > > > Would it be an option to simply add a(nother) var that will control the
60 > > > interactive target in terms of how far it will run along. Normal
61 > resume
62 > > > strategies it employs already would simply allow a next run to run
63 > along
64 > > > further.
65 > > >
66 > > > I think above can be done easily with a few lines of code.
67 > > >
68 > > > Let me know what you think.
69 > > >
70 > > > Thanks,
71 > > > Fabian
72 > > >
73 > > > On 23-01-2020 13:31:05 +1100, Sam Pfeiffer wrote:
74 > > > > Grobian, any input about this?
75 > > > >
76 > > > > On Thu, Jan 16, 2020, 17:39 Sam Pfeiffer <[1]sammypfeiffer@×××××.com
77 > [2]>
78 > > > wrote:
79 > > > >
80 > > > > > Hello Benda,
81 > > > >
82 > > > > > To be more specific... To easily go thru it I made a gist with the
83 > latest
84 > > > > > version of bootstrap-prefix.sh and I'll be pointing to specific
85 > lines (this
86 > > > > > also helps me recap why I did this, as I remember using
87 > stage{1,2,3} didn't
88 > > > > > work for me when I first came into this):
89 > > > >
90 > > > > > When you execute bootstrap-prefix.sh without arguments (other than
91 > the
92 > > > > > EPREFIX, ./bootstrap-prefix.sh /MY/EPREFIX) it calls this line:
93 > > > >
94 > > > > > [2]https://gist.github.com/awesomebytes/
95 > > > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L3033[3]
96 > > > >
97 > > > > > Calling bootstrap_interactive
98 > > > >
99 > > > > > If you give an extra argument (./bootstrap-prefix.sh /MY/EPREFIX
100 > > > > > [noninteractive, stage{1,2,3}]) it calls this line:
101 > > > > > [3]https://gist.github.com/awesomebytes/
102 > > > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L3082[4]
103 > > > >
104 > > > > > bootstrap_${TODO#non} || exit 1
105 > > > >
106 > > > > > Which, on the noninteractive case, goes to the same place than no
107 > arguments
108 > > > > > (bootstrap_interactive). But in the stage{1,2,3} calls directly the
109 > > > > > bootstrap_stageX function.
110 > > > >
111 > > > > > The thing is, noninteractive does some checks, finds resources and
112 > sets up
113 > > > > > environment variables like:
114 > > > >
115 > > > > > * Check for bad flags:
116 > > > > > [4]https://gist.github.com/awesomebytes/
117 > > >
118 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2200-L2247[5]
119 > > > > > * We find a gcc:
120 > > > > > [5]https://gist.github.com/awesomebytes/
121 > > >
122 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2273-L2433[6]
123 > > > > > * We get a cpu count and adjust -j for Make:
124 > > > > > [6]https://gist.github.com/awesomebytes/
125 > > >
126 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2443-L2501[7]
127 > > > > > * Check if we deal with multilib systems:
128 > > > > > [7]https://gist.github.com/awesomebytes/
129 > > >
130 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2503-L2576[8]
131 > > > > > * Check if we are boostrapping from a Gentoo system:
132 > > > > > [8]https://gist.github.com/awesomebytes/
133 > > >
134 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2578-L2608[9]
135 > > > > > * Set our EPREFIX:
136 > > > > > [9]https://gist.github.com/awesomebytes/
137 > > >
138 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2610-L2681[10]
139 > > > >
140 > > > > > Which is summarised at the end by setting the environment
141 > variables EPREFIX,
142 > > > > > CHOST, PATH, MAKEOPTS.
143 > > > >
144 > > > > > And then finally calls bootstrap_stage1_log, which runs
145 > bootstrap_stage1
146 > > > > > itself.
147 > > > >
148 > > > > > [10]https://gist.github.com/awesomebytes/
149 > > >
150 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2724-L2726[11]
151 > > > >
152 > > > > > Then, we compare with calling bootstrap-prefix.sh EPREFIX stage1...
153 > > > >
154 > > > > > Calls bootstrap_stage1():
155 > > > > > [11]https://gist.github.com/awesomebytes/
156 > > > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L1355[12]
157 > > > >
158 > > > > > And as you can see it won't do any of the extra work done in
159 > > > > > bootstrap_interactive().
160 > > > >
161 > > > > > I'm not that versed in this script, so I may be missing something
162 > easy to
163 > > > > > overcome this (or I don't know enough about what is going on), but
164 > there is
165 > > > no
166 > > > > > separate function that does everything in bootstrap_interactive
167 > without
168 > > > > > calling bootstrap_stage1. And bootstrap_stage1 does not do all
169 > that setup
170 > > > that
171 > > > > > bootstrap_interactive does. So that's how I came to my proposal.
172 > > > >
173 > > > > > If there is some patch to enable that setup from
174 > bootstrap_interactive with
175 > > > > > bootstrap_stage1, that would be a good alternative, I guess. I
176 > still like
177 > > > the
178 > > > > > fact that with my approach you are just saying "bootstrap
179 > everything until
180 > > > > > this step" instead of needing to manually do bootstrap_setup
181 > (imaginary
182 > > > > > function I just named) then bootstrap_stage1, then
183 > bootstrap_stage2, then
184 > > > > > bootstrap_stage3, and then no argument for the last emerge -e
185 > system, to get
186 > > > > > to a specific bootstrap stage, but that's just commodity.
187 > > > >
188 > > > > > Let me know if I'm wrong somewhere or you think of any better
189 > solution!
190 > > > >
191 > > > > > On Thu, 16 Jan 2020 at 13:42, Sam Pfeiffer <[12]
192 > sammypfeiffer@×××××.com[13]>
193 > > > > > wrote:
194 > > > >
195 > > > > >> Hi Benda,
196 > > > >
197 > > > > >> Thanks for your reply.
198 > > > >
199 > > > > >> On Thu, 16 Jan 2020 at 13:01, Benda Xu <[13]heroxbd@g.o[14]>
200 > wrote:
201 > > > >
202 > > > > >>> Hi Sam,
203 > > > >
204 > > > > >>> Sam Pfeiffer <[14]sammypfeiffer@×××××.com[15]> writes:
205 > > > >
206 > > > > >>> > To ease automated building and debugging of the bootstrap of
207 > Gentoo
208 > > > > >>> > Prefix I would like to propose a patch to add the option to
209 > stop the
210 > > > > >>> > non-interactive bootstrap on specific stages of the bootstrap.
211 > > > > >>> >
212 > > > > >>> > I'm currently doing this in my CI projects [1][2] and I'd love
213 > to have
214 > > > > >>> > this added upstream.
215 > > > > >>> >
216 > > > > >>> > I propose a patch like this:
217 > > > > >>> >[15]
218 > https://gist.github.com/awesomebytes/3468477c6c90fe3d985372d50aabba9f
219 > > > [16]
220 > > > > >>> >
221 > > > > >>> > Which is what I'm currently using. It just adds another
222 > optional
223 > > > > >>> >parameter to the commandline (a 3rd one) in non-interactive
224 > mode which
225 > > > > >>> >you tell it after which stage to stop (stage1, stage2, stage3).
226 > > > >
227 > > > > >>> > I'm not the most versed person in bash, so maybe there is a
228 > more
229 > > > > >>> > conceptually beautiful way of doing this. My patch is just a
230 > proposal
231 > > > > >>> > (that has been tested and running).
232 > > > > >>> >
233 > > > > >>> > This patch is useful because it allows:
234 > > > > >>> > 1) Easier debugging by stages.
235 > > > >
236 > > > > >>> > 2) Allows to split the bootstrap job in parts in CI
237 > environments with
238 > > > > >>> > time limits on jobs to run (e.g. Azure Pipelines time limit is
239 > 6h*,
240 > > > > >>> > and the bootstrap takes in between 5h40-6h40 depending on
241 > random
242 > > > > >>> > things like time to download things, and load on the
243 > machine... or
244 > > > > >>> > packages just taking longer to build).
245 > > > > >>> >
246 > > > > >>> > And this patch should not change anything to anyone else
247 > (AFAIK).
248 > > > >
249 > > > > >>> Are you aware that in bootstrap-prefix.sh you can specify the
250 > stage you
251 > > > > >>> are after? e.g.
252 > > > >
253 > > > > >>> [16]https://wiki.gentoo.org/wiki/Project:Prefix/
254 > > > Manual_Bootstrap#Stage_1[17]
255 > > > >
256 > > > > >>> The text above that could be outdated, but PATH exports and
257 > stage1~3 are
258 > > > > >>> correct.
259 > > > >
260 > > > > >> I'm aware, but the behaviour (relating to environment variables
261 > and
262 > > > choosing
263 > > > > >> CPU numbers) differs from the
264 > > > >
265 > > > > >> noninteractive argument. I'd like to keep the CI environment as
266 > close as a
267 > > > > >> user executing ./bootstrap-prefix.sh EPREFIX as possible.
268 > > > >
269 > > > > >> That's why I'm proposing this addition. Another approach could be
270 > modifying
271 > > > > >> the current argument to do the same than the noninteractive one.
272 > > > >
273 > > > > >> But that may break the workflow of someone, and I don't want that.
274 > > > >
275 > > > > >>
276 > > > >
277 > > > > >>> > Thanks for your time and feedback!
278 > > > > >>> >
279 > > > > >>> > P.S.: I'm used to the GitHub/GitLab workflow of having a
280 > graphical
281 > > > > >>> > interface to do a Pull Request... I don't know how to do this
282 > with
283 > > > > >>> > [17]https://gitweb.gentoo.org/repo/proj/prefix.git/[18] If
284 > there is no
285 > > > way,
286 > > > > >>> > aside of the goal of this email, I'd propose to have a mirror
287 > in
288 > > > > >>> > GitHub.
289 > > > >
290 > > > > >>> Yes, that's a good to have for me, but not in high priority.
291 > > > >
292 > > > > >>> > *If you are curious, Stage 1 takes 8min~, Stage 2 takes
293 > 29min~, Stage
294 > > > > >>> > 3 takes 2h30min~, emerge system takes 2h35min~ on Azure
295 > Pipelines,
296 > > > > >>> > approximately.
297 > > > >
298 > > > > >>> Thank you so much for all your work! That's extremely helpful
299 > to keep
300 > > > > >>> the quality of Prefix codebase.
301 > > > >
302 > > > > >>> > [1] [18]https://github.com/awesomebytes/gentoo_prefix_ci[19]
303 > > > > >>> > [2] [19]
304 > https://github.com/awesomebytes/gentoo_prefix_ci_32b[20]
305 > > > >
306 > > > > >>> Yours,
307 > > > > >>> Benda
308 > > > >
309 > > > > >> --
310 > > > >
311 > > > > >> Sammy Pfeiffer
312 > > > > >> PhD Candidate at The Magic Lab within UTS.
313 > > > >
314 > > > > > --
315 > > > >
316 > > > > > Sammy Pfeiffer
317 > > > > > PhD Candidate at The Magic Lab within UTS.
318 > > > >
319 > > > >
320 > > > >
321 > > > > References:
322 > > > > 1. mailto:sammypfeiffer@×××××.com[21]
323 > > > > 2. https://gist.github.com/awesomebytes/
324 > > > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L3033[22]
325 > > > > 3. https://gist.github.com/awesomebytes/
326 > > > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L3082[23]
327 > > > > 4. https://gist.github.com/awesomebytes/
328 > > >
329 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2200-L2247[24]
330 > > > > 5. https://gist.github.com/awesomebytes/
331 > > >
332 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2273-L2433[25]
333 > > > > 6. https://gist.github.com/awesomebytes/
334 > > >
335 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2443-L2501[26]
336 > > > > 7. https://gist.github.com/awesomebytes/
337 > > >
338 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2503-L2576[27]
339 > > > > 8. https://gist.github.com/awesomebytes/
340 > > >
341 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2578-L2608[28]
342 > > > > 9. https://gist.github.com/awesomebytes/
343 > > >
344 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2610-L2681[29]
345 > > > > 10. https://gist.github.com/awesomebytes/
346 > > >
347 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2724-L2726[30]
348 > > > > 11. https://gist.github.com/awesomebytes/
349 > > > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L1355[31]
350 > > > > 12. mailto:sammypfeiffer@×××××.com[32]
351 > > > > 13. mailto:heroxbd@g.o[33]
352 > > > > 14. mailto:sammypfeiffer@×××××.com[34]
353 > > > > 15.
354 > https://gist.github.com/awesomebytes/3468477c6c90fe3d985372d50aabba9f
355 > > > [35]
356 > > > > 16.
357 > https://wiki.gentoo.org/wiki/Project:Prefix/Manual_Bootstrap#Stage_1[36]
358 > > > > 17. https://gitweb.gentoo.org/repo/proj/prefix.git/[37]
359 > > > > 18. https://github.com/awesomebytes/gentoo_prefix_ci[38]
360 > > > > 19. https://github.com/awesomebytes/gentoo_prefix_ci_32b[39]
361 > > > >
362 > > > > read_char: errno==EILSEQ; invalid byte sequence for UTF-8:
363 > > > --
364 > > > Fabian Groffen
365 > > > Gentoo on a different level
366 > >
367 > >
368 > > --
369 > >
370 > > Sammy Pfeiffer
371 > > PhD Candidate at The Magic Lab within UTS.
372 > >
373 > >
374 > > References
375 > > 1. mailto:grobian@g.o
376 > > 2. mailto:sammypfeiffer@×××××.com
377 > > 3. https://gist.github.com/awesomebytes/
378 > > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L3033
379 > > 4. https://gist.github.com/awesomebytes/
380 > > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L3082
381 > > 5. https://gist.github.com/awesomebytes/
382 > >
383 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2200-L2247
384 > > 6. https://gist.github.com/awesomebytes/
385 > >
386 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2273-L2433
387 > > 7. https://gist.github.com/awesomebytes/
388 > >
389 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2443-L2501
390 > > 8. https://gist.github.com/awesomebytes/
391 > >
392 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2503-L2576
393 > > 9. https://gist.github.com/awesomebytes/
394 > >
395 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2578-L2608
396 > > 10. https://gist.github.com/awesomebytes/
397 > >
398 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2610-L2681
399 > > 11. https://gist.github.com/awesomebytes/
400 > >
401 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2724-L2726
402 > > 12. https://gist.github.com/awesomebytes/
403 > > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L1355
404 > > 13. mailto:sammypfeiffer@×××××.com
405 > > 14. mailto:heroxbd@g.o
406 > > 15. mailto:sammypfeiffer@×××××.com
407 > > 16.
408 > https://gist.github.com/awesomebytes/3468477c6c90fe3d985372d50aabba9f
409 > > 17.
410 > https://wiki.gentoo.org/wiki/Project:Prefix/Manual_Bootstrap#Stage_1
411 > > 18. https://gitweb.gentoo.org/repo/proj/prefix.git/
412 > > 19. https://github.com/awesomebytes/gentoo_prefix_ci
413 > > 20. https://github.com/awesomebytes/gentoo_prefix_ci_32b
414 > > 21. mailto:sammypfeiffer@×××××.com
415 > > 22. https://gist.github.com/awesomebytes/
416 > > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L3033
417 > > 23. https://gist.github.com/awesomebytes/
418 > > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L3082
419 > > 24. https://gist.github.com/awesomebytes/
420 > >
421 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2200-L2247
422 > > 25. https://gist.github.com/awesomebytes/
423 > >
424 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2273-L2433
425 > > 26. https://gist.github.com/awesomebytes/
426 > >
427 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2443-L2501
428 > > 27. https://gist.github.com/awesomebytes/
429 > >
430 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2503-L2576
431 > > 28. https://gist.github.com/awesomebytes/
432 > >
433 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2578-L2608
434 > > 29. https://gist.github.com/awesomebytes/
435 > >
436 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2610-L2681
437 > > 30. https://gist.github.com/awesomebytes/
438 > >
439 > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2724-L2726
440 > > 31. https://gist.github.com/awesomebytes/
441 > > ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L1355
442 > > 32. mailto:sammypfeiffer@×××××.com
443 > > 33. mailto:heroxbd@g.o
444 > > 34. mailto:sammypfeiffer@×××××.com
445 > > 35.
446 > https://gist.github.com/awesomebytes/3468477c6c90fe3d985372d50aabba9f
447 > > 36.
448 > https://wiki.gentoo.org/wiki/Project:Prefix/Manual_Bootstrap#Stage_1
449 > > 37. https://gitweb.gentoo.org/repo/proj/prefix.git/
450 > > 38. https://github.com/awesomebytes/gentoo_prefix_ci
451 > > 39. https://github.com/awesomebytes/gentoo_prefix_ci_32b
452 >
453 > --
454 > Fabian Groffen
455 > Gentoo on a different level
456 >
457
458
459 --
460
461 *Sammy Pfeiffer*
462 PhD Candidate at The Magic Lab within UTS.