From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id EC0681381F3 for ; Fri, 13 Sep 2013 15:10:46 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7765CE0BD3; Fri, 13 Sep 2013 15:10:46 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id ED373E0BBE for ; Fri, 13 Sep 2013 15:10:45 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id CCACC33E341 for ; Fri, 13 Sep 2013 15:10:44 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 64396E468F for ; Fri, 13 Sep 2013 15:10:43 +0000 (UTC) From: "André Erdmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "André Erdmann" Message-ID: <1379084260.0138be482b63df9c34df6e0495fdeb39fef0b7f9.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/config/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/config/defconfig.py X-VCS-Directories: roverlay/config/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: 0138be482b63df9c34df6e0495fdeb39fef0b7f9 X-VCS-Branch: master Date: Fri, 13 Sep 2013 15:10:43 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 589e234a-0d70-4971-b88e-2b9010c8173b X-Archives-Hash: c5d73acc351b0610e497d6f3dffb5ef8 commit: 0138be482b63df9c34df6e0495fdeb39fef0b7f9 Author: André Erdmann mailerd de> AuthorDate: Fri Sep 13 14:57:40 2013 +0000 Commit: André Erdmann mailerd de> CommitDate: Fri Sep 13 14:57:40 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=0138be48 defconfig: generate config files for standalone roverlay --- roverlay/config/defconfig.py | 152 ++++++++++++++++++++++++++----------------- 1 file changed, 92 insertions(+), 60 deletions(-) diff --git a/roverlay/config/defconfig.py b/roverlay/config/defconfig.py index 3654fb8..40d6830 100644 --- a/roverlay/config/defconfig.py +++ b/roverlay/config/defconfig.py @@ -40,6 +40,19 @@ wrap_comment_lines = lambda e: '\n'.join ( map ( wrap_comment, do_iterate ( e ) ) ) +def _fspath_prefix_func ( *prefix ): + _PREFIX = os.path.join ( *prefix ) + def wrapped ( *p ): + if p: + return os.path.join ( _PREFIX, *p ).rstrip ( os.path.sep ) + else: + return _PREFIX + # --- end of wrapped (...) --- + + return wrapped +# --- end of _fspath_prefix_func (...) --- + + class ConfigOptionMissing ( KeyError ): def __init__ ( self, key ): super ( ConfigOptionMissing, self ).__init__ ( @@ -129,50 +142,36 @@ class ConfigOption ( object ): def __str__ ( self ): return '\n'.join ( self.gen_str() ) + # --- end of __str__ (...) --- - - - -def CommentedConfigOption ( - name, default=None, required=False, - use_default_desc=False, append_newline=False, **kw -): - return ConfigOption ( - name, default=default, comment_default=True, required=required, - use_default_desc=use_default_desc, append_newline=append_newline, **kw - ) - - +# --- end of ConfigOption --- class RoverlayConfigCreation ( object ): def __init__ ( self, is_installed, - work_root = '~/roverlay', - data_root = '/usr/share/roverlay', - conf_root = '/etc/roverlay', + work_root = '~/roverlay', + data_root = '/usr/share/roverlay', + conf_root = '/etc/roverlay', + additions_dir = '/etc/roverlay/files', ): - self.work_root = work_root - self.data_root = data_root - self.conf_root = conf_root - - self._ctree = tree.ConfigTree() - self._cloader = self._ctree.get_loader() - self._verify_value = self._cloader._make_and_verify_value - + self.work_root = work_root + self.data_root = data_root + self.conf_root = conf_root + self.additions_dir = additions_dir + + self.get_workdir = _fspath_prefix_func ( self.work_root ) + self.get_datadir = _fspath_prefix_func ( self.data_root ) + self.get_confdir = _fspath_prefix_func ( self.conf_root ) + self.get_additions_dir = _fspath_prefix_func ( self.additions_dir ) + + self._ctree = tree.ConfigTree() + self._cloader = self._ctree.get_loader() + self._verify_value = self._cloader._make_and_verify_value self.reset ( is_installed=is_installed ) # --- end of __init__ (...) --- - def get_workdir ( self, p ): - return os.path.join ( self.work_root, p ).rstrip ( os.path.sep ) - - def get_datadir ( self, p ): - return os.path.join ( self.data_root, p ).rstrip ( os.path.sep ) - - def get_confdir ( self, p ): - return os.path.join ( self.conf_root, p ).rstrip ( os.path.sep ) - def iter_options ( self ): for item in self.config: if isinstance ( item, ConfigOption ): @@ -219,12 +218,22 @@ class RoverlayConfigCreation ( object ): raise ConfigOptionMissing ( key ) def reset ( self, is_installed ): - workdir = self.get_workdir - datadir = self.get_datadir - confdir = self.get_confdir + workdir = self.get_workdir + datadir = self.get_datadir + confdir = self.get_confdir + additions_dir = self.get_additions_dir + + cachedir = _fspath_prefix_func ( self.work_root, 'cache' ) + - cachedir = lambda p=None: ( - workdir ( os.path.join ( 'cache', p ) if p else 'cache' ) + UNLESS_INSTALLED = lambda *a, **b: ( + None if is_installed else ConfigOption ( *a, **b ) + ) + IF_INSTALLED = lambda *a, **b: ( + ConfigOption ( *a, **b ) if is_installed else None + ) + get_val = lambda v_inst, v_standalone: ( + v_inst if is_installed else v_standalone ) @@ -253,31 +262,49 @@ class RoverlayConfigCreation ( object ): '', '# --- Logging Configuration (optional) ---', '', - CommentedConfigOption ( 'LOG_LEVEL', 'WARNING', - use_default_desc=True, append_newline=True, + ConfigOption ( + 'LOG_LEVEL', get_val ( 'WARNING', 'INFO' ), required=False, + comment_default=is_installed, + ), + ConfigOption ( + 'LOG_LEVEL_CONSOLE', get_val ( 'INFO', 'WARNING' ), + required=False, comment_default=is_installed, + use_default_desc=False, append_newline=False, + ), + ConfigOption ( + 'LOG_LEVEL_FILE', get_val ( 'ERROR', 'WARNING' ), + required=False, comment_default=is_installed, + use_default_desc=False, append_newline=False, ), - CommentedConfigOption ( 'LOG_LEVEL_CONSOLE', 'INFO' ), - CommentedConfigOption ( 'LOG_LEVEL_FILE', 'ERROR' ), '', - CommentedConfigOption ( 'LOG_FILE_ROTATE', 'yes', + ConfigOption ( + 'LOG_FILE_ROTATE', 'yes', required=False, + comment_default=is_installed, use_default_desc=False, description='this enables per-run log files', - append_newline=True, # defaults_to="no", + # defaults_to="no" ), - CommentedConfigOption ( 'LOG_FILE_ROTATE_COUNT', '5', + ConfigOption ( + 'LOG_FILE_ROTATE_COUNT', '5', required=False, + comment_default=True, use_default_desc=False, description='number of backup log files to keep', - append_newline=True, + defaults_to="3" + ), + ConfigOption ( + 'LOG_FILE_UNRESOLVABLE', + workdir ( 'log', 'dep_unresolvable.log' ), required=False, + comment_default=is_installed, ), '', '# --- Other Configuration Options ---', '', # ADDITIONS_DIR: confdir or workdir? - ConfigOption ( 'ADDITIONS_DIR', confdir ( 'files' ), ), + ConfigOption ( 'ADDITIONS_DIR', additions_dir() ), ConfigOption ( - 'USE_EXPAND_RENAME', confdir ( 'files/use_expand.rename' ), + 'USE_EXPAND_RENAME', additions_dir ( 'use_expand.rename' ), comment_default=True, required=False, ), ConfigOption ( - 'USE_EXPAND_DESC', confdir ( 'file/use_expand.desc' ), + 'USE_EXPAND_DESC', additions_dir ( 'use_expand.desc' ), comment_default=True, required=False, ), ConfigOption ( @@ -310,6 +337,7 @@ class RoverlayConfigCreation ( object ): comment_default=False, required=False, defaults_to=( "*", "allow all" ), ), + UNLESS_INSTALLED ( 'TEMPLATE_ROOT', datadir ( 'mako_templates' ) ), ConfigOption ( 'LICENSE_MAP', confdir ( 'license.map' ) ), @@ -336,7 +364,11 @@ class RoverlayConfigCreation ( object ): use_default_desc=False, description='using the default field definition file', ), - + UNLESS_INSTALLED ( + 'DESCRIPTION_DIR', cachedir ( 'desc-files' ), + comment_default=True, required=False, + description='Note that this slows overlay creation down.', + ), ConfigOption ( 'DISTDIR_STRATEGY', 'hardlink symlink', use_default_desc=False, @@ -345,18 +377,17 @@ class RoverlayConfigCreation ( object ): ' try hard links first, then fall back to symbolic ones' ), ), - CommentedConfigOption ( - 'DISTDIR_VERIFY', 'no', use_default_desc=True, + ConfigOption ( + 'DISTDIR_VERIFY', 'no', required=False, comment_default=True, description=' usually not needed', - append_newline=True, ), - CommentedConfigOption ( - 'DISTMAP_COMPRESSION', 'bzip2', use_default_desc=True, - append_newline=True, defaults_to=True, + ConfigOption ( + 'DISTMAP_COMPRESSION', 'bzip2', required=False, + comment_default=True, defaults_to=True, ), - CommentedConfigOption ( - 'DISTMAP_FILE', '', use_default_desc=True, append_newline=True, - defaults_to="/distmap.db" + ConfigOption ( + 'DISTMAP_FILE', '', required=False, comment_default=True, + defaults_to="/distmap.db", ), ConfigOption ( 'USE_PORTAGE_LICENSES', 'no', required=False, @@ -388,7 +419,8 @@ class RoverlayConfigCreation ( object ): def gen_lines ( self ): for item in self.config: - yield str ( item ) + if item is not None: + yield str ( item ) # --- end of gen_lines (...) --- def get_lines ( self ):