From: "André Erdmann" <dywi@mailerd.de>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/setupscript/
Date: Fri, 13 Sep 2013 15:10:44 +0000 (UTC) [thread overview]
Message-ID: <1379084627.0a3962d2d7d9f9ede5316058ec9709c825223e26.dywi@gentoo> (raw)
commit: 0a3962d2d7d9f9ede5316058ec9709c825223e26
Author: André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Fri Sep 13 15:03:47 2013 +0000
Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Fri Sep 13 15:03:47 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=0a3962d2
setupscript: support standalone roverlay
This commit adds support for using roverlay-setup with not-installed versions of
roverlay.
For roverlay/setupscript/, this mostly affects the arg parser's defaults, and
allows to make paths in the config file relative to the git repo (IFF a subdir).
Additionally, --import-config gets disabled if roverlay is not installed.
---
roverlay/setupscript/initenv.py | 21 ++++++++++-
roverlay/setupscript/runtime.py | 81 +++++++++++++++++++++++++++++++++--------
2 files changed, 84 insertions(+), 18 deletions(-)
diff --git a/roverlay/setupscript/initenv.py b/roverlay/setupscript/initenv.py
index 5e511f8..2807841 100644
--- a/roverlay/setupscript/initenv.py
+++ b/roverlay/setupscript/initenv.py
@@ -90,15 +90,24 @@ class SetupInitEnvironment (
yield ( "user\'s config root",
get_path_option ( 'private_conf_root', self.setup_env.user_conf_root )
)
+ yield ( "additions dir",
+ get_path_option ( 'additions_dir', self.setup_env.additions_dir )
+ )
import_config = get_option ( 'import_config' )
if import_config == 'disable':
yield ( "import config", "no" )
- else:
+ elif self.setup_env.is_installed():
yield ( "import config",
"yes, "
+ self.IMPORT_CONFIG_DESC [import_config].format ( **fmt_vars )
)
+ else:
+ yield (
+ "import config",
+ 'no, standalone roverlay cannot import config '
+ 'with mode={!r}'.format ( import_config )
+ )
yield ( "enable default hooks", get_option ( 'want_default_hooks' ) )
@@ -147,7 +156,15 @@ class SetupInitEnvironment (
def do_import_config ( self, pretend ):
"""Imports the config."""
- mode = self.setup_env.options ['import_config']
+ mode = self.setup_env.options ['import_config']
+
+ if mode == 'disable':
+ self.info ( "config import: disabled.\n" )
+ return
+ elif not self.setup_env.is_installed():
+ self.error ( "config import: disabled due to standalone mode.\n" )
+ return
+
fs_ops = self.setup_env.private_dir
user_conf_root = self.setup_env.get_user_config_root()
# assert os.path.isdir ( os.path.dirname(user_conf_root) == work_root )
diff --git a/roverlay/setupscript/runtime.py b/roverlay/setupscript/runtime.py
index 5a55515..43733a3 100644
--- a/roverlay/setupscript/runtime.py
+++ b/roverlay/setupscript/runtime.py
@@ -129,6 +129,15 @@ class SetupArgParser ( roverlay.argparser.RoverlayArgumentParser ):
help="additional variables",
)
+ arg (
+ '--prjroot-relpath', dest='prjroot_relpath',
+ flags=self.ARG_WITH_DEFAULT|self.ARG_OPT_IN,
+ help=(
+ 'make --{work,data,conf}-root, --{conf,additions}-dir '
+ 'relative to ROVERLAY_PRJROOT (for distributing config files)'
+ )
+ )
+
return arg
# --- end of setup_config (...) ---
@@ -141,9 +150,9 @@ class SetupArgParser ( roverlay.argparser.RoverlayArgumentParser ):
'\'--variable ADDITIONS_DIR={0}\'.'.format ( val )
)
- self.parsed ['config_vars'].append (
- "ADDITIONS_DIR=" + self.parsed ['additions_dir']
- )
+## self.parsed ['config_vars'].append (
+## "ADDITIONS_DIR=" + self.parsed ['additions_dir']
+## )
# --- end of parse_config (...) ---
def setup_init ( self ):
@@ -274,19 +283,39 @@ class SetupEnvironment ( roverlay.runtime.IndependentRuntimeEnvironment ):
# )
# --- end of __init__ (...) ---
- def create_argparser ( self ):
- instinfo = self.access_constant ( 'INSTALLINFO' )
-
- return SetupArgParser (
- description = 'roverlay setup script',
- defaults = {
+ def get_parser_defaults ( self ):
+ if self.is_installed():
+ instinfo = self.INSTALLINFO
+ return {
'work_root' : instinfo ['workroot'],
'data_root' : instinfo ['libexec'],
'conf_root' : instinfo ['confroot'],
'private_conf_root' : instinfo ['workroot'] + os.sep + 'config',
'import_config' : 'symlink=root',
'additions_dir' : instinfo ['workroot'] + os.sep + 'files',
- },
+ }
+ else:
+ assert self.prjroot
+ prjroot = self.prjroot + os.sep
+ return {
+ 'work_root' : prjroot + 'workdir',
+ 'data_root' : prjroot + 'files',
+ 'conf_root' : prjroot + 'config',
+ 'private_conf_root' : prjroot + 'config',
+ 'import_config' : 'disable',
+ 'additions_dir' : prjroot + 'files',
+ }
+ # --- end of get_parser_defaults (...) ---
+
+ def create_argparser ( self ):
+ return SetupArgParser (
+ description = 'roverlay setup script',
+ defaults = self.get_parser_defaults(),
+ epilog = (
+ 'Environment variables:\n'
+ '* ROVERLAY_PRJROOT - path to roverlay\'s source dir\n'
+ '* ROVERLAY_INSTALLED - mark roverlay as installed (if set and not empty)\n'
+ )
)
# --- end of create_argparser (...) ---
@@ -324,24 +353,44 @@ class SetupEnvironment ( roverlay.runtime.IndependentRuntimeEnvironment ):
# --- end of _expanduser_pwd (...) ---
def create_config_file ( self, expand_user=False ):
+ def _get_prjroot_relpath ( fspath ):
+ p = os.path.relpath ( fspath, self.prjroot )
+ if p and ( p[0] != '.' or p == '.' ):
+ return p
+ else:
+ return fspath
+ # --- end of get_prjroot_relpath (...) ---
+
+ get_prjroot_relpath = (
+ _get_prjroot_relpath
+ if ( self.options ['prjroot_relpath'] and self.prjroot )
+ else (lambda p: p)
+ )
+
conf_creator = roverlay.config.defconfig.RoverlayConfigCreation (
- is_installed = self.is_installed(),
- work_root = (
+ is_installed = self.is_installed(),
+ work_root = get_prjroot_relpath (
self.work_root if expand_user else self.options ['work_root']
),
- data_root = (
+ data_root = get_prjroot_relpath (
self.data_root if expand_user else self.options ['data_root']
),
- conf_root = (
+ conf_root = get_prjroot_relpath (
self.user_conf_root if expand_user
else self.options ['private_conf_root']
),
+ additions_dir = get_prjroot_relpath (
+ self.additions_dir if expand_user
+ else self.options ['additions_dir']
+ )
)
for kv in self.options ['config_vars']:
key, sepa, value = kv.partition ( '=' )
if not sepa:
raise Exception ( "bad variable given: {!r}".format ( kv ) )
+ elif key in { 'ADDITIONS_DIR', 'OVERLAY_ADDITIONS_DIR', }:
+ conf_creator.set_option ( key, get_prjroot_relpath ( value ) )
else:
conf_creator.set_option ( key, value )
@@ -367,8 +416,7 @@ class SetupEnvironment ( roverlay.runtime.IndependentRuntimeEnvironment ):
# --- end of auto_reconfigure (...) ---
def setup ( self ):
- self.PWD_INITIAL = os.getcwd()
- self.setup_common()
+ self.setup_common ( allow_prjroot_missing=False )
# ref
options = self.options
@@ -389,6 +437,7 @@ class SetupEnvironment ( roverlay.runtime.IndependentRuntimeEnvironment ):
self.data_root = expanduser ( options ['data_root'] )
self.conf_root = expanduser ( options ['conf_root'] )
self.user_conf_root = expanduser ( options ['private_conf_root'] )
+ self.additions_dir = expanduser ( options ['additions_dir'] )
self.hook_overwrite = (
roverlay.setupscript.hookenv.HookOverwriteControl.from_str (
options ['hook_overwrite']
next reply other threads:[~2013-09-13 15:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-13 15:10 André Erdmann [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-04-01 16:38 [gentoo-commits] proj/R_overlay:master commit in: roverlay/setupscript/ André Erdmann
2014-02-22 14:56 André Erdmann
2014-02-21 17:36 André Erdmann
2014-02-17 17:22 André Erdmann
2014-02-17 17:10 André Erdmann
2013-09-19 15:00 André Erdmann
2013-09-18 15:24 André Erdmann
2013-09-13 15:20 André Erdmann
2013-09-13 15:10 André Erdmann
2013-09-12 16:36 André Erdmann
2013-09-11 14:50 André Erdmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1379084627.0a3962d2d7d9f9ede5316058ec9709c825223e26.dywi@gentoo \
--to=dywi@mailerd.de \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox