1 |
Dnia 2015-10-14, o godz. 20:24:22 |
2 |
Ulrich Mueller <ulm@g.o> napisał(a): |
3 |
|
4 |
> >>>>> On Wed, 14 Oct 2015, Michał Górny wrote: |
5 |
> |
6 |
> > --- |
7 |
> > pkg-mgr-commands.tex | 32 ++++++++++++++++++++++++++++---- |
8 |
> > 1 file changed, 28 insertions(+), 4 deletions(-) |
9 |
> |
10 |
> > // I'm aware this isn't perfect but I tried to keep the algorithm |
11 |
> > // readable and reasonably concise. Hope it's good enough for a start |
12 |
> > // though. |
13 |
> |
14 |
> Thanks, this will indeed serve well as a start. |
15 |
> |
16 |
> > diff --git a/pkg-mgr-commands.tex b/pkg-mgr-commands.tex |
17 |
> > index dbdbdfd..1d57d63 100644 |
18 |
> > --- a/pkg-mgr-commands.tex |
19 |
> > +++ b/pkg-mgr-commands.tex |
20 |
> > @@ -148,10 +148,12 @@ These commands are used during the \t{src\_prepare} phase to apply patches to th |
21 |
> > Ebuilds must not run any of these commands once the current phase function has returned. |
22 |
> > |
23 |
> > \begin{description} |
24 |
> > -\item[eapply] \featurelabel{eapply} |
25 |
> > - Only available in EAPIs listed in table~\ref{tab:patch-commands} as supporting \t{eapply}. |
26 |
> > +\item[eapply] \featurelabel{eapply} Takes zero or more patch(1) options, followed by one or more |
27 |
> |
28 |
> Should we say "GNU patch" here? We require it in ebuild-env-commands.tex. |
29 |
|
30 |
Sure, updated. |
31 |
|
32 |
> > + file or directory paths. Processes options and applies all patches found in specified locations |
33 |
> > + according to Algorithm~\ref{alg:eapply}. Only available in EAPIs listed in |
34 |
> > + table~\ref{tab:patch-commands} as supporting \t{eapply}. |
35 |
> > |
36 |
> |
37 |
> > -\item[eapply\_user] \featurelabel{eapply-user} Takes no arguments. Package managers supporting it |
38 |
> > +\item[eapply\_user] \featurelabel{eapply-user} Takes no arguments. Package managers supporting i |
39 |
> |
40 |
> Slip of fingers. |
41 |
|
42 |
Corrected. |
43 |
|
44 |
> |
45 |
> > apply user-provided patches to the source tree in the current working directory. Exact behaviour |
46 |
> > is implementation defined and beyond the scope of this specification. Package managers not |
47 |
> > supporting it must implement the function as a no-op. Only available in EAPIs listed in |
48 |
> > @@ -161,7 +163,29 @@ Ebuilds must not run any of these commands once the current phase function has r |
49 |
> > \begin{algorithm} |
50 |
> > \caption{eapply logic} \label{alg:eapply} |
51 |
> > \begin{algorithmic}[1] |
52 |
> > -\STATE \COMMENT{WORK IN PROGRESS} |
53 |
> > +\STATE let options=() |
54 |
> > +\STATE let infiles=FALSE |
55 |
> > +\FOR{\$x in parameters} |
56 |
> > + \IF{infiles is FALSE} |
57 |
> > + \IF{\$x is "\t{-{}-}"} |
58 |
> > + \STATE let infiles=TRUE |
59 |
> > + \ELSIF{\$x starts with "\t{-}"} |
60 |
> > + \STATE options+=( "\$x" ) |
61 |
> > + \ELSE |
62 |
> > + \STATE let infiles=TRUE |
63 |
> > + \ENDIF |
64 |
> > + \ENDIF |
65 |
> > + |
66 |
> > + \IF{infiles is TRUE} |
67 |
> |
68 |
> I wonder if it wouldn't be cleaner to do the whole option parsing |
69 |
> first. Something along the lines of this: |
70 |
|
71 |
Not sure about this. But maybe it makes sense if we can get the right |
72 |
wording... |
73 |
|
74 |
> IF first parameter begins with a hyphen AND any parameter is equal to -- |
75 |
|
76 |
Hmm, that's not exactly correct. All parameters preceding -- would have |
77 |
to begin with a hyphen. So maybe... |
78 |
|
79 |
IF any parameter is equal to -- AND all parameters preceding it |
80 |
being with a hyphen |
81 |
|
82 |
> collect all parameters before the first -- in the options array |
83 |
> collect all parameters after the first -- in the files array |
84 |
> ELSIF any parameter beginning with a hyphen follows one without a hyphen |
85 |
> return an error |
86 |
|
87 |
Not sure if we should really specify error handling here. The idea is |
88 |
that this is incorrect syntax, so it is unconditional fatal error. |
89 |
|
90 |
> ELSE |
91 |
> collect all parameters starting with a hyphen in the options array |
92 |
> collect all parameters without a hyphen in the files array |
93 |
> ENDIF |
94 |
> |
95 |
> FOR x in files |
96 |
> ... |
97 |
> |
98 |
> > + \IF{\$x is a directory} |
99 |
> > + \FOR{\$f in all files matching \$x/*.diff and \$x/*.patch} |
100 |
> > + \STATE call \t{patch -p1 -f -s "\$\{options[@]\}" "\$f"} |
101 |
> |
102 |
> Options "-p1 -g0 -E --no-backup-if-mismatch" are field-proven in |
103 |
> eutils.eclass. This doesn't mean that we have to adhere to it |
104 |
> slavishly, but I would suggest that we keep both the -g0 and the |
105 |
> --no-backup-if-mismatch options (but drop -E). Also I would omit |
106 |
> the -s; it is up to the PM if it wants to suppress or filter output. |
107 |
> So in summary, that is: |
108 |
> |
109 |
> patch -p1 -f -g0 --no-backup-if-mismatch |
110 |
|
111 |
Ok. |
112 |
|
113 |
> |
114 |
> > + \ENDFOR |
115 |
> > + \ELSE |
116 |
> > + \STATE call \t{patch -p1 -f -s "\$\{options[@]\}" "\$x"} |
117 |
> > + \ENDIF |
118 |
> > + \ENDIF |
119 |
> > +\ENDFOR |
120 |
> > \end{algorithmic} |
121 |
> > \end{algorithm} |
122 |
> |
123 |
> We should say something about error handling. For example, does the |
124 |
> function return when it encounters the first error of a called |
125 |
> patch(1)? |
126 |
|
127 |
Where should I say it? Put in the algorithm? |
128 |
|
129 |
-- |
130 |
Best regards, |
131 |
Michał Górny |
132 |
<http://dev.gentoo.org/~mgorny/> |