1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
|
# R overlay -- config package, entrymap
# -*- coding: utf-8 -*-
# Copyright (C) 2012 André Erdmann <dywi@mailerd.de>
# Distributed under the terms of the GNU General Public License;
# either version 2 of the License, or (at your option) any later version.
"""
config entry map
This module mainly consists of a map that defines all config entries.
Config entry map format:
<config_entry> = None|''|str|dict(...), where
* config_entry is the config entry name in lowercase (e.g. 'log_level')
* None means that config_entry is known but ignored,
* str means that config_entry is an alias for another config entry,
* '' means that config_entry uses defaults,
* dict() means that config_entry has options that divert from the defaults.
known dict keys are 'path', 'description'/'desc' and 'value_type':
* path (string or list of strings) -- path of this entry in the config tree
* description (string) -- describes the entry
* value_type can be any of:
-> list -- value is a whitespace-separated list
-> int -- integer
-> str -- [explicit string conversion]
-> yesno -- value must evaluate to 'yes' or 'no' (on,off,y,n,1,0...)
-> fs_path -- "~" will be expanded
-> fs_abs -- fs_path and path will be converted into an absolute one
(pwd + path)
-> fs_dir -- fs_abs and value must be a dir if it exists
-> fs_file -- fs_abs and value must be a file if it exists
-> regex -- value is a regex and will be compiled (re.compile(..))
-> a type (str,int,...)
-> a callable that accepts one arg and returns the converted value or None,
where None means "not valid"
Multiple types are generally not supported ('this is an int or a str'),
but subtypes are ('list of yesno'), which can be specified by either
using a list of types ['list', 'yesno'] or by separating the types
with a colon 'list:yesno', which is parsed in a left-to-right order.
Nested subtypes such as list:int:fs_file:list may lead to errors.
"""
__all__ = [ 'CONFIG_ENTRY_MAP', 'prune_description', ]
import roverlay.util.compression
fs_file = 'fs_file'
fs_abslist = 'list:fs_abs'
yesno = 'yesno'
list_of_choices = "list:str"
# often (>1) used entry dicts (it's ok to share a ref to those dicts
# 'cause CONFIG_ENTRY_MAP won't be modified)
is_fs_file = { 'value_type' : fs_file }
#is_str = { 'value_type' : 'str' }
is_yesno = { 'value_type' : 'yesno' }
CAPSLOCK = ( 'CAPSLOCK', )
LOG_LEVEL = ( "DEBUG", "INFO", "WARN", "WARNING", "ERROR", "CRITICAL" )
COMP_FORMATS = [ "default", "none" ] + sorted (
roverlay.util.compression.get_all_compression_formats()
##roverlay.util.compression.get_supported_compression_formats()
)
is_log_level = { 'choices' : LOG_LEVEL, 'flags' : CAPSLOCK }
only_vtype = lambda x : { 'value_type': x }
# mask for want_create_dir
WANT_PRIVATE = 1
WANT_FILEDIR = 2
WANT_USERDIR = 4
WANT_PUBLIC_DIR = 0
WANT_PUBLIC_FILEDIR = WANT_FILEDIR
WANT_PRIVATE_DIR = WANT_PRIVATE
WANT_PRIVATE_FILEDIR = WANT_PRIVATE | WANT_FILEDIR
def _verify_distdir_strategy ( strategy, logger ):
methods = set ( strategy )
if not strategy:
logger.error (
'strategy must not be empty.'
)
return False
elif len ( methods ) != len ( strategy ):
logger.error (
'specifying a method more than once makes no sense.'
)
return False
elif 'tmpdir' in methods and len ( strategy ) > 1:
logger.error (
"the 'tmpdir' strategy does not accept any fallback methods!"
)
return False
else:
return True
# --- end of _verify_distdir_strategy (...) ---
CONFIG_ENTRY_MAP = dict (
# == logging ==
log_enabled = dict (
value_type = yesno,
description = "enable/disable logging",
),
log_level = dict (
desc = "global log level, choices are {}.".format (
', '.join ( LOG_LEVEL )
),
**is_log_level
),
#log_format = None, # there's no global log format
log_date_format = dict (
desc = "date format, example: '%F %H:%M:%S'.",
),
# used in depres listener modules
log_file_resolved = dict (
value_type = fs_file,
description = '''NOT IN USE.
file where resolved dep strings will be written to.
''',
want_dir_create = WANT_PRIVATE_FILEDIR | WANT_USERDIR,
),
log_file_unresolvable = dict (
value_type = fs_file,
description = '''file where unresolved dependency strings
will be written to
''',
want_dir_create = WANT_PRIVATE_FILEDIR | WANT_USERDIR,
),
# === logging to console ===
log_console_enabled = dict (
value_type = yesno,
description = "enable/disable logging to stdout/stderr",
),
log_console = 'log_console_enabled',
log_console_level = dict (
desc = "log level for console logging.",
**is_log_level
),
log_level_console = 'log_console_level',
log_console_stream = None, # option not configurable
log_console_format = dict (
desc = '''console logging format,
example: '%(levelname)-7s [%(name)s] %(message)s'
''',
),
log_format_console = 'log_console_format',
# === logging to file ===
log_file_enabled = dict (
value_type = yesno,
description = "enable/disable logging to file",
),
log_file = dict (
# setting path to LOG.FILE.file to avoid collision with LOG.FILE.*
path = [ 'LOG', 'FILE', 'file' ],
value_type = fs_file,
description = "log file to write",
want_dir_create = WANT_PRIVATE_FILEDIR | WANT_USERDIR,
),
log_file_level = dict (
desc = "log level for file logging",
**is_log_level
),
log_level_file = 'log_file_level',
log_file_rotate = dict (
value_type = yesno,
description = "enable/disable log file rotating (per script run)",
),
log_file_rotate_count = dict (
path = [ 'LOG', 'FILE', 'rotate_count' ],
value_type = 'int',
description = "number of rotated log files to keep",
),
log_file_format = dict (
desc = '''file logging format,
example: '%(asctime)s %(levelname)-8s %(name)-10s: %(message)s'
'''
),
log_format_file = 'log_file_format',
log_file_buffered = dict (
value_type = yesno,
description = "buffer log entries before writing them to file",
),
log_file_buffer_count = 'log_file_buffer_capacity',
log_file_buffer_capacity = dict (
path = [ 'LOG', 'FILE', 'buffer_capacity' ],
value_type = 'int',
description = "max number of log entries to buffer",
),
# # === syslog ===
#
# log_syslog_enabled = is_yesno,
# log_syslog = 'log_syslog_enabled',
#
# log_syslog_level = is_log_level,
# log_level_syslog = 'log_syslog_level',
#
# --- logging
# == overlay ==
# COULDFIX key is not in use
ebuild_header = dict (
value_type = fs_file,
description = '''NOT IN USE.
ebuild header file that will be included in every created ebuild.
''',
),
overlay_backup_desc = dict (
path = [ 'OVERLAY', 'backup_desc' ],
value_type = yesno,
description = 'back up files in/from profiles/desc',
),
overlay_category = dict (
desc = "overlay category to use for created ebuilds, e.g. 'sci-R'.",
),
overlay_dir = dict (
value_type = 'fs_abs:fs_dir',
description = (
'this is the directory of the overlay to be created/maintained'
),
want_dir_create = WANT_PUBLIC_DIR | WANT_USERDIR,
),
overlay_additions_dir = dict (
path = [ 'OVERLAY', 'additions_dir', ],
value_type = 'fs_abs:fs_dir',
description = 'directory containing ebuilds and ebuild patches',
# FIXME: WANT_USERDIR or not?
want_dir_create = WANT_PRIVATE_DIR,
),
overlay_eclass = dict (
path = [ 'OVERLAY', 'eclass_files' ],
value_type = fs_abslist,
description = '''eclass files to import into the overlay.
Automatically inherited in ebuilds.
''',
),
overlay_name = dict (
desc = "overlay name, e.g. 'R-Overlay'.",
),
overlay_manifest_implementation = dict (
desc = "manifest implementation to be used",
path = [ 'OVERLAY', 'manifest_implementation' ],
choices = frozenset ((
'none',
'default',
'ebuild',
'next',
# 'e',
)),
),
# ebuild is used to create Manifest files
ebuild_prog = dict (
path = [ 'TOOLS', 'EBUILD', 'exe' ],
value_type = 'fs_path',
description = "name of/path to the ebuild executable",
),
overlay_keep_nth_latest = dict (
path = [ 'OVERLAY', 'keep_nth_latest' ],
value_type = 'int',
description = 'number of ebuilds per R package to keep (if > 0)',
),
overlay_distdir_root = dict (
value_type = 'fs_dir',
description = (
'this is the directory where hard/symbolic links '
'to all package files will be created '
'(during Manifest file creation)'
),
want_dir_create = WANT_PUBLIC_DIR | WANT_USERDIR,
),
overlay_distdir_strategy = dict (
description = "list of DISTDIR creation methods",
value_type = list_of_choices,
choices = frozenset ((
"symlink",
"hardlink",
"copy",
"tmpdir",
)),
f_verify = _verify_distdir_strategy,
),
overlay_distdir_flat = dict (
description = (
"whether to use per-package distdirs (False) or not (True)"
),
value_type = yesno,
),
overlay_distdir_verify = dict (
description = 'check integrity of distdir files on startup',
value_type = yesno,
),
overlay_distmap_compression = dict (
description = 'distmap compression format ({})'.format (
', '.join ( COMP_FORMATS )
),
choices = COMP_FORMATS,
),
overlay_distmap_file = dict (
path = [ 'OVERLAY', 'DISTMAP', 'dbfile', ],
value_type = 'fs_file',
description = 'distmap file',
want_dir_create = WANT_PRIVATE_FILEDIR | WANT_USERDIR,
),
overlay_masters = dict (
path = [ 'OVERLAY', 'masters', ],
value_type = 'list:str',
description = 'masters attribute for metadata/layout.conf',
),
# * alias
backup_desc = 'overlay_backup_desc',
eclass = 'overlay_eclass',
keep_nth_latest = 'overlay_keep_nth_latest',
manifest_implementation = 'overlay_manifest_implementation',
additions_dir = 'overlay_additions_dir',
distdir = 'overlay_distdir_root',
distdir_strategy = 'overlay_distdir_strategy',
distdir_flat = 'overlay_distdir_flat',
distdir_verify = 'overlay_distdir_verify',
distmap_compression = 'overlay_distmap_compression',
distmap_file = 'overlay_distmap_file',
# --- overlay
# == ebuild ==
ebuild_eapi = dict (
description = "EAPI of the created ebuilds",
value_type = str,
),
ebuild_use_expand_desc = dict (
path = [ 'EBUILD', 'USE_EXPAND', 'desc_file', ],
description = "USE_EXPAND flag description file",
value_type = 'fs_file',
want_dir_create = WANT_PRIVATE_FILEDIR,
),
ebuild_use_expand_name = dict (
path = [ 'EBUILD', 'USE_EXPAND', 'name', ],
description = (
'name of the USE_EXPAND variable for suggested dependencies'
)
),
ebuild_use_expand_rename = dict (
path = [ 'EBUILD', 'USE_EXPAND', 'rename_file', ],
description = 'file for renaming USE_EXPAND flags',
value_type = 'fs_file',
want_dir_create = WANT_PRIVATE_FILEDIR,
),
# * alias
eapi = 'ebuild_eapi',
use_expand_desc = 'ebuild_use_expand_desc',
use_expand_name = 'ebuild_use_expand_name',
use_expand_rename = 'ebuild_use_expand_rename',
# --- ebuild
# == remote ==
# the distfiles root directory
# this is where repos create their own DISTDIR as sub directory unless
# they specify another location
distfiles_root = dict (
value_type = 'fs_dir',
description = (
'this is the directory where per-repo package directories '
'will be created'
),
want_dir_create = WANT_PRIVATE_DIR | WANT_USERDIR,
),
# the repo config file(s)
repo_config_files = dict (
path = [ 'REPO', 'config_files' ],
value_type = fs_abslist,
description = 'list of repo config files',
want_dir_create = WANT_PRIVATE_FILEDIR,
),
# this option is used to limit bandwidth usage while running rsync
rsync_bwlimit = dict (
path = [ 'REPO', 'rsync_bwlimit' ],
value_type = 'int',
description = "max average rsync bandwidth usage (in kilobytes/second)"
),
websync_timeout = dict (
path = [ 'REPO', 'websync_timeout' ],
value_type = 'int',
description = "timeout for websync repo connections (in seconds)"
),
# * alias
distfiles = 'distfiles_root',
repo_config = 'repo_config_files',
repo_config_file = 'repo_config_files',
# --- remote
# == dependency resolution ==
# the list of simple dep rule files
simple_rules_files = dict (
path = [ 'DEPRES', 'SIMPLE_RULES', 'files' ],
value_type = fs_abslist,
description = "list of dependency rule files",
want_dir_create = WANT_PRIVATE_FILEDIR,
),
# * alias
simple_rules_file = 'simple_rules_files',
# --- dependency resolution
# == description reader ==
field_definition_file = dict (
path = [ 'DESCRIPTION', 'field_definition_file' ],
value_type = fs_file,
description = "config file that controls DESCRIPTION file reading",
want_dir_create = WANT_PRIVATE_FILEDIR,
),
# * for debugging
# if set: write _all_ description files to dir/<package_filename>
description_descfiles_dir = dict (
path = [ 'DESCRIPTION', 'descfiles_dir' ],
value_type = 'fs_abs:fs_dir',
description = '''if set: write description files (read from tarballs)
into this directory. Leave blank / comment out to disable.
''',
want_dir_create = WANT_PRIVATE_FILEDIR | WANT_USERDIR,
),
# * alias
description_dir = 'description_descfiles_dir',
field_definition = 'field_definition_file',
# --- description reader
# == package rules ==
package_rule_files = dict (
path = [ 'PACKAGE_RULES', 'files' ],
value_type = fs_abslist,
description = 'list of package rule files/dirs',
want_dir_create = WANT_PRIVATE_FILEDIR,
),
# * alias
package_rules = 'package_rule_files',
# --- package rules
# == hooks / scripts ==
filter_shell_env = dict (
path = [ 'SHELL_ENV', 'filter_env', ],
value_type = yesno,
description = 'filter shell env',
),
shell = dict (
path = [ 'SHELL_ENV', 'shell', ],
description = "default command interpreter (for roverlay-sh etc.)",
),
event_hook = dict (
path = [ 'EVENT_HOOK', 'exe', ],
value_type = 'fs_file',
description = 'script that is run on certain events, e.g. overlay_success',
),
event_hook_rc = dict (
path = [ 'EVENT_HOOK', 'config_file', ],
value_type = 'fs_abs',
description = 'hook (shell) config file',
),
event_hook_restrict = dict (
path = [ 'EVENT_HOOK', 'restrict', ],
value_type = 'list:str',
description = 'mask for running hooks',
),
# * alias
hook = 'event_hook',
hook_rc = 'event_hook_rc',
hook_restrict = 'event_hook_restrict',
# == license map ==
license_map = dict (
path = [ 'LICENSEMAP', 'file', ],
value_type = 'fs_file',
description = 'dictionary file for translating license strings',
),
use_portage_licenses = dict (
path = [ 'LICENSEMAP', 'use_portdir', ],
value_type = 'yesno',
description = 'try to read licenses from PORTDIR/licenses',
),
licenses_file = dict (
path = [ 'LICENSEMAP', 'licenses_file', ],
value_type = 'fs_file',
description = (
'licenses file (used as fallback if PORTDIR not available)'
),
),
create_licenses_file = dict (
path = [ 'LICENSEMAP', 'create_licenses_file', ],
value_type = 'yesno',
description = 'create a licenses file after reading portage licenses',
),
# hidden option (always using bzip2)
licenses_file_compression = None,
# * alias
license_file = 'licenses_file',
create_license_file = 'create_licenses_file',
license_file_compression = 'licenses_file_compression',
# --- license map
# == stats / status report generation ==
template_root = dict (
path = [ 'STATS', 'TEMPLATE', 'root', ],
value_type = 'list:fs_dir',
description = 'directories with templates for status reports',
),
template_module_dir = dict (
path = [ 'STATS', 'TEMPLATE', 'module_dir', ],
value_type = 'fs_dir',
description = 'directory for caching templates',
),
stats_db = dict (
path = [ 'STATS', 'dbfile', ],
value_type = 'fs_file',
description = 'stats database file',
),
stats_interval = dict (
path = [ 'RRD_DB', 'step', ],
value_type = 'int',
description = (
'database update interval (only used for creating new database files)'
),
),
# --- stats / status report generation
# == other ==
cachedir = dict (
path = [ 'CACHEDIR', 'root', ],
value_type = 'fs_dir',
description = 'directory for cache data',
want_dir_create = WANT_PRIVATE_DIR | WANT_USERDIR,
),
nosync = dict (
value_type = yesno,
description = 'forbid/allow syncing with remotes',
),
portdir = dict (
value_type = 'fs_dir',
description = 'path to the portage directory (usually /usr/portage)',
),
# --- other
)
del fs_file, fs_abslist, is_fs_file, is_yesno, is_log_level, \
CAPSLOCK, only_vtype
def prune_description():
"""Removes the description strings from all config entries."""
for entry in CONFIG_ENTRY_MAP.values():
if isinstance ( entry, dict ):
if 'description' in entry:
del entry ['description']
elif 'desc' in entry:
del entry ['desc']
|