Gentoo Archives: gentoo-commits

From: "André Erdmann" <dywi@×××××××.de>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/R_overlay:master commit in: doc/rst/
Date: Sun, 30 Jun 2013 15:58:15
Message-Id: 1372194602.adbe0bb8d1edc7cbff598b4834fbaceb7335fbb3.dywi@gentoo
1 commit: adbe0bb8d1edc7cbff598b4834fbaceb7335fbb3
2 Author: André Erdmann <dywi <AT> mailerd <DOT> de>
3 AuthorDate: Tue Jun 25 21:10:02 2013 +0000
4 Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
5 CommitDate: Tue Jun 25 21:10:02 2013 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=adbe0bb8
7
8 doc/rst: doc for "run hooks" (incomplete)
9
10 ---
11 doc/rst/usage.rst | 354 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
12 1 file changed, 354 insertions(+)
13
14 diff --git a/doc/rst/usage.rst b/doc/rst/usage.rst
15 index 8d06bab..078a7ac 100644
16 --- a/doc/rst/usage.rst
17 +++ b/doc/rst/usage.rst
18 @@ -314,6 +314,12 @@ have reasonable defaults if *roverlay* has been installed using *emerge*:
19
20 Example: USE_EXPAND_RENAME = ~/roverlay/config/useflag_rename
21
22 + CACHEDIR
23 + Directory for generated files that do not belong to the overlay, e.g.
24 + the *distmap* file. This option is **required**.
25 +
26 + Example: CACHEDIR = ~/roverlay/workdir/cache
27 +
28 OVERLAY_ECLASS
29 This option lists eclass files that should be imported into the overlay
30 (into *OVERLAY_DIR*/eclass/) and inherited in all ebuilds.
31 @@ -409,6 +415,10 @@ to know in detail what *roverlay* does before running it.
32 --nosync, --no-sync
33 Disable downloading of R packages.
34
35 +--distmap-verify
36 + Enforce verification of R packages in the package mirror directory.
37 + This also tries to recreate the distmap.
38 +
39 --no-incremental
40 Force recreation of existing ebuilds
41
42 @@ -1834,6 +1844,16 @@ The following sections will list all config entries.
43 misc options
44 --------------
45
46 +.. _CACHEDIR:
47 +
48 +CACHEDIR
49 + Directory for persistent files that don't belong to the overlay, e.g.
50 + the distmap file.
51 +
52 + This option is **required**.
53 +
54 + <<TODO: default value!>>
55 +
56 .. _DISTFILES:
57
58 DISTFILES
59 @@ -1863,6 +1883,14 @@ EBUILD_PROG
60
61 Defaults to *ebuild*, which should be fine in most cases.
62
63 +.. _NOSYNC:
64 +
65 +NOSYNC
66 + A *bool* that controls whether *syncing*, i.e. data transfers from/to
67 + remote machines, is allowed or forbidden.
68 +
69 + Defaults to *no*.
70 +
71 .. _RSYNC_BWLIMIT:
72
73 RSYNC_BWLIMIT
74 @@ -1872,6 +1900,7 @@ RSYNC_BWLIMIT
75 Defaults to <not set>, which disables bandwidth limitation.
76
77
78 +
79 -----------------
80 overlay options
81 -----------------
82 @@ -1901,6 +1930,17 @@ DISTDIR_FLAT
83 DISTDIR_STRATEGY
84 Alias to OVERLAY_DISTDIR_STRATEGY_.
85
86 +
87 +.. _DISTDIR_VERIFY:
88 +
89 +DISTDIR_VERIFY
90 + Alias to OVERLAY_DISTDIR_VERIFY_.
91 +
92 +.. _DISTMAP_FILE:
93 +
94 +DISTMAP_FILE
95 + Alias to OVERLAY_DISTMAP_FILE_.
96 +
97 .. _EBUILD_USE_EXPAND_NAME:
98
99 EBUILD_USE_EXPAND_NAME
100 @@ -2002,6 +2042,23 @@ OVERLAY_DISTDIR_STRATEGY
101 This option is **required**, but has a reasonable value in the default
102 config file, "hardlink symlink".
103
104 +.. _OVERLAY_DISTDIR_VERIFY:
105 +
106 +OVERLAY_DISTDIR_VERIFY
107 + A *bool* that controls whether file integrity of *OVERLAY_DISTDIR_ROOT*
108 + should be checked on startup. This is an expensive operation since each
109 + file have to be read once.
110 +
111 + Defaults to *no* as the verification is normally not needed.
112 +
113 +
114 +.. _OVERLAY_DISTMAP_FILE:
115 +
116 +OVERLAY_DISTMAP_FILE:
117 + File path to the distmap file.
118 +
119 + Defaults to <not set>, which results in CACHEDIR_/distmap.db.
120 +
121 .. _OVERLAY_ECLASS:
122
123 OVERLAY_ECLASS
124 @@ -2148,6 +2205,45 @@ USE_EXPAND_DESC
125 USE_EXPAND_RENAME
126 Alias to EBUILD_USE_EXPAND_RENAME_.
127
128 +---------------------------
129 + shell environment / hooks
130 +---------------------------
131 +
132 +.. _EVENT_HOOK:
133 +
134 +EVENT_HOOK
135 + A script that is called for handling *events* (see Hooks_).
136 +
137 + Defaults to ADDITIONS_DIR_/hooks/mux.sh.
138 +
139 +.. _EVENT_HOOK_RESTRICT:
140 +
141 +EVENT_HOOK_RESTRICT
142 + A list of *events* that are allowed (``<event>``, ``+<event>``) or
143 + forbidden (``-<event>``). The asterisk wildcard character can be used to
144 + set the default policy to *allow unless forbidden* (``*``) or
145 + *deny unless allowed* (``-*``).
146 +
147 + Defaults to <not set>, which is equivalent to *deny all*.
148 +
149 +.. _FILTER_SHELL_ENV:
150 +
151 +FILTER_SHELL_ENV
152 + A *bool* that controls whether the hook environment should be filtered
153 + or not.
154 +
155 + Defaults to *true*.
156 +
157 +.. _HOOK:
158 +
159 +HOOK
160 + Alias to EVENT_HOOK_.
161 +
162 +.. _HOOK_RESTRICT:
163 +
164 +HOOK_RESTRICT
165 + Alias to EVENT_HOOK_RESTRICT_.
166 +
167 ---------
168 logging
169 ---------
170 @@ -3146,3 +3242,261 @@ Its mode of operation of operation is best described in pseudo-code:
171
172 The dependency resolver can be **run as thread**, in which case the while loop
173 becomes "loop until resolver closes".
174 +
175 +
176 +=======
177 + undef
178 +=======
179 +
180 +<<TODO; this section has to merged/moved>>
181 +
182 +---------
183 + distmap
184 +---------
185 +
186 +The distmap is a file that stores information about the files in the package
187 +mirror directory (`OVERLAY_DISTDIR_ROOT`_).
188 +<<TODO>>
189 +
190 +
191 +-------
192 + hooks
193 +-------
194 +
195 +*roverlay* calls a script when certain events occur, e.g. after successful
196 +overlay creation.
197 +
198 +<<TODO>>
199 +
200 +* real work is offloaded to the called script
201 +* roverlay provides some env vars
202 +* roverlay provides a *$FUNCTIONS* file and a way to load other function files
203 +* ``EVENT_HOOK_RESTRICT="this -not_that *"``
204 +
205 +<<^^TODO>>
206 +
207 +.. Note::
208 +
209 + *roverlay* waits until the script terminates.
210 +
211 +
212 +++++++++++++++++++
213 + Hook environment
214 +++++++++++++++++++
215 +
216 +.. table:: environment variables provided by *roverlay*
217 +
218 + +----------------+------------------+-----------------------------------------+
219 + | variable | source | notes / description |
220 + +================+==================+=========================================+
221 + | PATH | os.environ | |
222 + +----------------+------------------+-----------------------------------------+
223 + | LOGNAME | os.environ | |
224 + +----------------+------------------+-----------------------------------------+
225 + | SHLVL | os.environ | |
226 + +----------------+------------------+-----------------------------------------+
227 + | TERM | os.environ | |
228 + +----------------+------------------+-----------------------------------------+
229 + | HOME | os.environ | |
230 + +----------------+------------------+-----------------------------------------+
231 + | ROVERLAY_PHASE | event | event that caused the script to run |
232 + +----------------+------------------+-----------------------------------------+
233 + | OVERLAY | config | overlay directory (`OVERLAY_DIR`_), |
234 + +----------------+------------------+ initial working directory |
235 + | S | *$OVERLAY* | |
236 + +----------------+------------------+ |
237 + | PWD | *$OVERLAY* | |
238 + +----------------+------------------+-----------------------------------------+
239 + | DISTROOT | config | package mirror directory |
240 + | | | (`OVERLAY_DISTDIR_ROOT`_) |
241 + +----------------+------------------+-----------------------------------------+
242 + | TMPDIR | os.environ, | directory for temporary files |
243 + | | *fallback* | |
244 + +----------------+------------------+ |
245 + | T | *$TMPDIR* | |
246 + +----------------+------------------+-----------------------------------------+
247 + | ADDITIONS_DIR | config | directory with supplementary files |
248 + | | | (`OVERLAY_ADDITIONS_DIR`_) |
249 + +----------------+------------------+ |
250 + | FILESDIR | *$ADDITIONS_DIR* | |
251 + +----------------+------------------+-----------------------------------------+
252 + | SHLIB | *$ADDITIONS_DIR* | directory with shell function files |
253 + | | | (optional, only set if it exists) |
254 + +----------------+------------------+-----------------------------------------+
255 + | FUNCTIONS | *$ADDITIONS_DIR* | file with essential shell functions |
256 + | | | (optional, only set if it exists) |
257 + +----------------+------------------+-----------------------------------------+
258 + | DEBUG | log level | *shbool* (``y`` or ``n``) that |
259 + | | | indicates whether debug messages should |
260 + | | | be printed |
261 + +----------------+------------------+-----------------------------------------+
262 + | VERBOSE | log level | *shbool* |
263 + +----------------+------------------+-----------------------------------------+
264 + | QUIET | log level | *shbool* that indicates whether scripts |
265 + | | | should be quiet |
266 + +----------------+------------------+-----------------------------------------+
267 + | NO_COLOR | *n/a* | *shbool*. Always set to *y* since |
268 + | | | colored output should not be produced |
269 + +----------------+------------------+-----------------------------------------+
270 + | NOSYNC | config | *shbool* that indicates whether data |
271 + | | | transfers from/to remote machines is |
272 + | | | allowed (NOSYNC_) |
273 + +----------------+------------------+-----------------------------------------+
274 + | EBUILD | config | the *ebuild* executable |
275 + +----------------+------------------+-----------------------------------------+
276 + | GIT_EDITOR | *n/a* | set to */bin/false* |
277 + +----------------+------------------+ |
278 + | GIT_ASKPASS | *n/a* | |
279 + +----------------+------------------+-----------------------------------------+
280 +
281 +
282 +The default *essential shell functions* file (*$FUNCTIONS*) makes,
283 +when included in the hook script, most of the enviroment variables readonly.
284 +
285 +
286 +.. table:: variables provided by *$FUNCTIONS*
287 +
288 + +-----------------+-------------------------------------------------------+
289 + | variable | description |
290 + +=================+=======================================================+
291 + | IFS_DEFAULT | default *internal field separator* |
292 + +-----------------+-------------------------------------------------------+
293 + | IFS_NEWLINE | *IFS* for iterating over text lines |
294 + +-----------------+-------------------------------------------------------+
295 + | DEVNULL | */dev/null* target (could also be a file) |
296 + +-----------------+-------------------------------------------------------+
297 + | EX_ERR | default error exit code |
298 + +-----------------+-------------------------------------------------------+
299 + | EX_ARG_ERR | default exit code for arg errors |
300 + +-----------------+-------------------------------------------------------+
301 + | SCRIPT_FILENAME | file name of the hook script |
302 + +-----------------+-------------------------------------------------------+
303 + | SCRIPT_NAME | name of the hook script (without file extension) |
304 + +-----------------+-------------------------------------------------------+
305 + | lf | reference to a function that loads additional shell |
306 + | | function files |
307 + +-----------------+-------------------------------------------------------+
308 +
309 +
310 +*$FUNCTIONS* also provides a number of shell functions:
311 +
312 +.. code-block:: sh
313 +
314 + # --- message ---
315 + #
316 + # void veinfo ( message )
317 + # Prints a message to stdout if $DEBUG is set to 'y'.
318 + #
319 + # void einfo ( message )
320 + # Prints a message to stdout if $VERBOSE is set to 'y'.
321 + #
322 + # void ewarn ( message )
323 + # Prints a message to stderr unless $QUIET is set to 'y'.
324 + #
325 + # void eerror ( message )
326 + # Prints a message to stderr.
327 + #
328 + #
329 + # --- core ---
330 + #
331 + # @noreturn die ( [message], [exit_code] ), raises exit()
332 + # Lets the script die with the given message/exit code.
333 + #
334 + # @noreturn OUT_OF_BOUNDS(), raises die()
335 + # Lets the script die due to insufficient arg count.
336 + #
337 + # int run_command ( *cmdv )
338 + # Logs a command and runs it afterwards.
339 + #
340 + # int run_command_logged ( *cmdv )
341 + # Logs a command, runs it and logs the result.
342 + #
343 + # void autodie ( *cmdv ), raises die()
344 + # Runs a command. Lets the script die if the command fails.
345 + #
346 + #
347 + # void load_functions ( *filenames, **SHLIB ), raises die()
348 + # Loads additional shell functions file(s) from $SHLIB.
349 + # (Referenced by $lf.)
350 + #
351 + # void dont_run_as_root(), raises die()
352 + # Lets the script die if it is run as root.
353 + #
354 + # int list_has ( word, *list_items )
355 + # Returns 0 if $word is in the given list.
356 + #
357 + # int qwhich ( *command )
358 + # Returns 0 if all listed commands are found by "which".
359 + #
360 + #
361 + # --- fs ---
362 + #
363 + # int dodir ( *dir )
364 + # Ensures that zero or more directories exist by creating them if
365 + # necessary. Returns the number of directories that could not be created.
366 + #
367 + #
368 + # --- str ---
369 + #
370 + # int yesno ( word, **YESNO_YES=0, **YESNO_NO=1, **YESNO_EMPTY=2 )
371 + # Returns $YESNO_YES if $word means "yes", $YESNO_EMPTY if $word is empty
372 + # and $YESNO_NO otherwise (if $word probably means "no").
373 + #
374 + # ~int str_trim ( *args )
375 + # Removes whitespace at the beginning and end of a string and replaces
376 + # any whitespace sequence within the string with a single space char.
377 + # Passes the return value of the underlying sed command.
378 + #
379 + # ~int str_upper ( *args )
380 + # Echoes the uppercase variant of stdin or *args.
381 + # Passes tr's return value.
382 + #
383 + # ~int str_lower ( *args )
384 + # Echoes the lowercase variant of stdin or *args.
385 + # Passes tr's return value.
386 + #
387 + # ~int str_field ( fieldspec, *args, **FIELD_SEPARATOR=' ' )
388 + # Echoes the requested fields of stdin or *args.
389 + # Passes cut's return value.
390 + #
391 + #
392 + # --- int ---
393 + #
394 + # int is_int ( word )
395 + # Returns 0 if $word is an integer, else 1.
396 + #
397 + # int is_natural ( word )
398 + # Returns 0 if $word is an integer >= 0, else 1.
399 + #
400 + # int is_positive ( word )
401 + # Returns 0 if $word is an integer >= 1, else 1.
402 + #
403 + # int is_negative ( word )
404 + # Returns 0 if $word is an integer < 0, else 1.
405 + #
406 +
407 +
408 ++++++++++++++++++++++
409 + Adding a hook event
410 ++++++++++++++++++++++
411 +
412 +in roverlay
413 +
414 +.. code-block:: python
415 +
416 + # import hook module
417 + import roverlay.hook
418 +
419 + # ...
420 + # then:
421 + roverlay.hook.run ( "<event>" )
422 + # ...
423 + roverlay.hook.run ( "<another event>" )
424 +
425 +
426 +in additions dir (assuming that mux.sh is used)
427 +
428 +.. code-block:: text
429 +
430 + <somehow create> ${ADDITIONS_DIR}/<hook>.<event>
431 + <somehow create> ${ADDITIONS_DIR}/<hook>/<event>.sh