1 |
Hello Benda, |
2 |
|
3 |
|
4 |
|
5 |
On Sat, 25 Jan 2020 at 23:58, Benda Xu <heroxbd@g.o> wrote: |
6 |
|
7 |
> Hi Sam, |
8 |
> |
9 |
> Sam Pfeiffer <sammypfeiffer@×××××.com> writes: |
10 |
> |
11 |
> > To be more specific... To easily go thru it I made a gist with the |
12 |
> > latest version of bootstrap-prefix.sh and I'll be pointing to specific |
13 |
> > lines (this also helps me recap why I did this, as I remember using |
14 |
> > stage{1,2,3} didn't work for me when I first came into this): |
15 |
> > |
16 |
> > When you execute bootstrap-prefix.sh without arguments (other than the |
17 |
> > EPREFIX, ./bootstrap-prefix.sh /MY/EPREFIX) it calls this line: |
18 |
> > |
19 |
> https://gist.github.com/awesomebytes/ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L3033 |
20 |
> > Calling bootstrap_interactive |
21 |
> > |
22 |
> > If you give an extra argument (./bootstrap-prefix.sh /MY/EPREFIX |
23 |
> > [noninteractive, stage{1,2,3}]) it calls this line: |
24 |
> > |
25 |
> https://gist.github.com/awesomebytes/ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L3082 |
26 |
> > bootstrap_${TODO#non} || exit 1 |
27 |
> > |
28 |
> > Which, on the noninteractive case, goes to the same place than no |
29 |
> > arguments (bootstrap_interactive). But in the stage{1,2,3} calls |
30 |
> > directly the bootstrap_stageX function. |
31 |
> > |
32 |
> > The thing is, noninteractive does some checks, finds resources and |
33 |
> > sets up environment variables like: |
34 |
> > |
35 |
> > * Check for bad flags: |
36 |
> > |
37 |
> https://gist.github.com/awesomebytes/ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2200-L2247 |
38 |
> > * We find a gcc: |
39 |
> > |
40 |
> https://gist.github.com/awesomebytes/ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2273-L2433 |
41 |
> > * We get a cpu count and adjust -j for Make: |
42 |
> > |
43 |
> https://gist.github.com/awesomebytes/ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2443-L2501 |
44 |
> > * Check if we deal with multilib systems: |
45 |
> > |
46 |
> https://gist.github.com/awesomebytes/ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2503-L2576 |
47 |
> > * Check if we are boostrapping from a Gentoo system: |
48 |
> > |
49 |
> https://gist.github.com/awesomebytes/ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2578-L2608 |
50 |
> > * Set our EPREFIX: |
51 |
> > |
52 |
> https://gist.github.com/awesomebytes/ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2610-L2681 |
53 |
> > |
54 |
> > Which is summarised at the end by setting the environment variables |
55 |
> EPREFIX, CHOST, PATH, MAKEOPTS. |
56 |
> > |
57 |
> > And then finally calls bootstrap_stage1_log, which runs |
58 |
> > bootstrap_stage1 itself. |
59 |
> > |
60 |
> https://gist.github.com/awesomebytes/ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L2724-L2726 |
61 |
> > |
62 |
> > Then, we compare with calling bootstrap-prefix.sh EPREFIX stage1... |
63 |
> > Calls bootstrap_stage1(): |
64 |
> > |
65 |
> https://gist.github.com/awesomebytes/ba4df9c6ef3ab5742cb9aceed7998c3d#file-bootstrap-prefix-sh-L1355 |
66 |
> > |
67 |
> > And as you can see it won't do any of the extra work done in |
68 |
> > bootstrap_interactive(). |
69 |
> |
70 |
> Perfect! You are correct in understanding the script. |
71 |
> |
72 |
|
73 |
Great, that's kind of a relief. |
74 |
|
75 |
> |
76 |
> > I'm not that versed in this script, so I may be missing something easy |
77 |
> > to overcome this (or I don't know enough about what is going on), but |
78 |
> > there is no separate function that does everything in |
79 |
> > bootstrap_interactive without calling bootstrap_stage1. And |
80 |
> > bootstrap_stage1 does not do all that setup that bootstrap_interactive |
81 |
> > does. So that's how I came to my proposal. |
82 |
> > |
83 |
> > If there is some patch to enable that setup from bootstrap_interactive |
84 |
> > with bootstrap_stage1, that would be a good alternative, I guess. I |
85 |
> > still like the fact that with my approach you are just saying |
86 |
> > "bootstrap everything until this step" instead of needing to manually |
87 |
> > do bootstrap_setup (imaginary function I just named) then |
88 |
> > bootstrap_stage1, then bootstrap_stage2, then bootstrap_stage3, and |
89 |
> > then no argument for the last emerge -e system, to get to a specific |
90 |
> > bootstrap stage, but that's just commodity. |
91 |
> |
92 |
> Why manually do bootstrap_setup then stage 1-3, emerge -e @system a bad |
93 |
> thing? That gives you more control of what to do in the CI system. I |
94 |
> would prefer to have the explicit steps than environmental switches. |
95 |
> |
96 |
|
97 |
It took me a while to figure out how to do it with minimal changes... but |
98 |
this is the new version I came up with: |
99 |
|
100 |
https://gist.github.com/awesomebytes/c930100ca97dd4195123104c5396b645 |
101 |
|
102 |
The changes to the current bootstrap_prefix.sh are these (in .patch |
103 |
format): |
104 |
https://gist.github.com/awesomebytes/ab1f237feea2f51ae65a5ecca203842e |
105 |
|
106 |
That patch in words: I've wrapped the setup stuff in a function called |
107 |
*bootstrap_get_defaults* (as that's what it is doing). Then the complete |
108 |
bootstrap |
109 |
process is named *bootstrap_all_stages*. I also separated the last step |
110 |
calling it *bootstrap_emerge_emptytree_system*. |
111 |
|
112 |
This keeps the usage of the script the same for the interactive case, the |
113 |
non interactive case, but...There is a 'maybe' breaking change, |
114 |
as now giving the name of the function to execute first calls |
115 |
*bootstrap_get_defaults*, then calls the function... |
116 |
and does a couple of necessary workarounds. |
117 |
|
118 |
I say 'maybe' breaking, as it doesn't 'exactly' do the same it did before |
119 |
when executing |
120 |
*./bootstrap-prefix.sh EPREFIX stage2 * |
121 |
(but I think it was either broken or I don't know how it was used, which is |
122 |
the most likely option). |
123 |
|
124 |
If you don't like this new behaviour, my alternative implementation was to |
125 |
create extra functions like: |
126 |
*bootstrap_stage1_noninteractive, bootstrap_stage2_noninteractive, |
127 |
bootstrap_stage3_noninteractive, |
128 |
bootstrap_emerge_emptytree_system_noninteractive* |
129 |
Which would do the bootstrap_get_defaults and the workarounds. |
130 |
|
131 |
Let me know what you think. I can prepare a patch with that too. If that's |
132 |
the case, I'd love an explanation on how to use the current behaviour of |
133 |
the script. |
134 |
|
135 |
|
136 |
> |
137 |
> > Let me know if I'm wrong somewhere or you think of any better solution! |
138 |
> |
139 |
> You are nowhere wrong. I just prefer keeping the manual bootstrap |
140 |
> options up to date and have it drive our CI. |
141 |
> |
142 |
> Yours, |
143 |
> Benda |
144 |
> |
145 |
|
146 |
|
147 |
-- |
148 |
|
149 |
*Sammy Pfeiffer* |
150 |
PhD Candidate at The Magic Lab within UTS. |