public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/R_overlay:gsoc13/next commit in: roverlay/config/, roverlay/
  2013-06-22 15:24 [gentoo-commits] proj/R_overlay:master commit in: roverlay/config/, roverlay/ André Erdmann
@ 2013-06-20 23:40 ` André Erdmann
  0 siblings, 0 replies; 4+ messages in thread
From: André Erdmann @ 2013-06-20 23:40 UTC (permalink / raw
  To: gentoo-commits

commit:     63c1d92092acfb064e6306d51fb6d5cd99c3afac
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Thu Jun 20 22:16:29 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Thu Jun 20 22:16:29 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=63c1d920

roverlay, config: nosync/hooks, fixup

---
 roverlay/argutil.py         | 13 ++++++++++---
 roverlay/config/const.py    |  6 +++++-
 roverlay/config/entrymap.py | 16 +++++++++++++++-
 3 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/roverlay/argutil.py b/roverlay/argutil.py
index 99842fd..fe541ac 100644
--- a/roverlay/argutil.py
+++ b/roverlay/argutil.py
@@ -277,9 +277,9 @@ def get_parser ( command_map, default_config_file, default_command='create' ):
    )
 
    arg (
-      '--nosync', '--no-sync',
+      '--nosync', '--no-sync', default=argparse.SUPPRESS,
       help="disable syncing with remotes (offline mode).",
-      **opt_in
+      action='store_true',
    )
 
    arg (
@@ -398,7 +398,8 @@ def parse_argv ( command_map, **kw ):
    commands = ( p.commands, ) if isinstance ( p.commands, str ) else p.commands
    conf  = dict()
    extra = dict (
-      nosync                  = p.nosync,
+# TODO: remove nosync entirely from extra
+#      nosync                  = p.nosync,
 #      debug                   = p.debug,
       show_overlay            = p.show_overlay,
       write_overlay           = p.write_overlay,
@@ -445,6 +446,11 @@ def parse_argv ( command_map, **kw ):
       extra ['nosync']   = True
       if 'create' in command_map:
          commands.append ( "create" )
+   elif given ( 'nosync' ):
+      extra ['nosync'] = True
+
+   if extra.get ( 'nosync', False ):
+      doconf ( True, 'nosync' )
 
    if given ( 'deprule_file' ):
       doconf ( p.deprule_file, 'DEPRES.SIMPLE_RULES.files' )
@@ -452,5 +458,6 @@ def parse_argv ( command_map, **kw ):
    if given ( 'manifest_implementation' ):
       doconf ( p.manifest_implementation, 'OVERLAY.manifest_implementation' )
 
+
    return ( commands, p.config, conf, extra )
 # --- end of parse_argv (...) ---

diff --git a/roverlay/config/const.py b/roverlay/config/const.py
index 3d330ba..4ee9d45 100644
--- a/roverlay/config/const.py
+++ b/roverlay/config/const.py
@@ -12,7 +12,11 @@ import time
 __all__ = [ 'clone', 'lookup' ]
 
 _CONSTANTS = dict (
-   DEBUG = False,
+   # FIXME: capslock? ;)
+   DEBUG  = False,
+   debug  = False,
+
+   nosync = False,
 
    # logging defaults are in recipe/easylogger
 

diff --git a/roverlay/config/entrymap.py b/roverlay/config/entrymap.py
index 65f2df5..5ae7b78 100644
--- a/roverlay/config/entrymap.py
+++ b/roverlay/config/entrymap.py
@@ -230,6 +230,7 @@ CONFIG_ENTRY_MAP = dict (
    ),
 
    overlay_additions_dir = dict (
+      path        = [ 'OVERLAY', 'additions_dir', ],
       value_type  = 'fs_abs:fs_dir',
       description = 'directory containing ebuilds and ebuild patches',
    ),
@@ -260,7 +261,7 @@ CONFIG_ENTRY_MAP = dict (
    ),
    # ebuild is used to create Manifest files
    ebuild_prog = dict (
-      path        = [ 'TOOLS', 'ebuild_exe' ],
+      path        = [ 'TOOLS', 'EBUILD', 'exe' ],
       value_type  = 'fs_path',
       description = "name of/path to the ebuild executable",
    ),
@@ -434,6 +435,14 @@ CONFIG_ENTRY_MAP = dict (
 
    # --- package rules
 
+   # == hooks / scripts ==
+
+   hook_overlay_success = dict (
+      path        = [ 'HOOK', 'OVERLAY', 'success', ],
+      value_type  = 'fs_file',
+      description = "script that is run just before exiting normally",
+   ),
+
    # == other ==
 
    cachedir = dict (
@@ -448,6 +457,11 @@ CONFIG_ENTRY_MAP = dict (
       description = 'directory for temporary data',
    ),
 
+   nosync = dict (
+      value_type  = yesno,
+      description = 'forbid/allow syncing with remotes',
+   )
+
    # --- other
 
 )


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-commits] proj/R_overlay:gsoc13/next commit in: roverlay/config/, roverlay/
@ 2013-06-22 15:14 André Erdmann
  0 siblings, 0 replies; 4+ messages in thread
From: André Erdmann @ 2013-06-22 15:14 UTC (permalink / raw
  To: gentoo-commits

commit:     aeaedce89d9a55c4f1bff62bd694eecd08b1f547
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Sat Jun 22 15:05:28 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Sat Jun 22 15:05:28 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=aeaedce8

config, argutil: verify distmap

---
 roverlay/argutil.py         | 12 +++++++++++-
 roverlay/config/entrymap.py |  6 ++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/roverlay/argutil.py b/roverlay/argutil.py
index fe541ac..34147d7 100644
--- a/roverlay/argutil.py
+++ b/roverlay/argutil.py
@@ -262,6 +262,13 @@ def get_parser ( command_map, default_config_file, default_command='create' ):
    )
 
    arg (
+      '--distmap-verify', default=argparse.SUPPRESS,
+      help   = 'check integrity of files in OVERLAY_DISTDIR_ROOT',
+      dest   = 'distmap_verify',
+      action = 'store_true',
+   )
+
+   arg (
       '--stats',
       help="print some stats",
       dest="stats",
@@ -439,7 +446,7 @@ def parse_argv ( command_map, **kw ):
 
    if given ( 'distdirs' ):
       if given ( 'distroot' ):
-         raise Exception ( "--distdir and --disroot are mutually exclusive!" )
+         raise Exception ( "--distdir and --distroot are mutually exclusive!" )
 
       doconf ( (), 'REPO.config_files' )
       extra ['distdirs'] = frozenset ( p.distdirs )
@@ -458,6 +465,9 @@ def parse_argv ( command_map, **kw ):
    if given ( 'manifest_implementation' ):
       doconf ( p.manifest_implementation, 'OVERLAY.manifest_implementation' )
 
+   if given ( 'distmap_verify' ):
+      doconf ( p.distmap_verify, 'OVERLAY.DISTDIR.verify' )
+
 
    return ( commands, p.config, conf, extra )
 # --- end of parse_argv (...) ---

diff --git a/roverlay/config/entrymap.py b/roverlay/config/entrymap.py
index 0176964..136b4b5 100644
--- a/roverlay/config/entrymap.py
+++ b/roverlay/config/entrymap.py
@@ -301,6 +301,11 @@ CONFIG_ENTRY_MAP = dict (
       value_type  = yesno,
    ),
 
+   overlay_distdir_verify = dict (
+      description = 'check integrity of distdir files on startup',
+      value_type  = yesno,
+   ),
+
    # * alias
    backup_desc               = 'overlay_backup_desc',
    eclass                    = 'overlay_eclass',
@@ -310,6 +315,7 @@ CONFIG_ENTRY_MAP = dict (
    distdir                   = 'overlay_distdir_root',
    distdir_strategy          = 'overlay_distdir_strategy',
    distdir_flat              = 'overlay_distdir_flat',
+   distdir_verify            = 'overlay_distdir_verify',
 
    # --- overlay
 


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-commits] proj/R_overlay:master commit in: roverlay/config/, roverlay/
@ 2013-06-22 15:24 André Erdmann
  2013-06-20 23:40 ` [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann
  0 siblings, 1 reply; 4+ messages in thread
From: André Erdmann @ 2013-06-22 15:24 UTC (permalink / raw
  To: gentoo-commits

commit:     63c1d92092acfb064e6306d51fb6d5cd99c3afac
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Thu Jun 20 22:16:29 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Thu Jun 20 22:16:29 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=63c1d920

roverlay, config: nosync/hooks, fixup

---
 roverlay/argutil.py         | 13 ++++++++++---
 roverlay/config/const.py    |  6 +++++-
 roverlay/config/entrymap.py | 16 +++++++++++++++-
 3 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/roverlay/argutil.py b/roverlay/argutil.py
index 99842fd..fe541ac 100644
--- a/roverlay/argutil.py
+++ b/roverlay/argutil.py
@@ -277,9 +277,9 @@ def get_parser ( command_map, default_config_file, default_command='create' ):
    )
 
    arg (
-      '--nosync', '--no-sync',
+      '--nosync', '--no-sync', default=argparse.SUPPRESS,
       help="disable syncing with remotes (offline mode).",
-      **opt_in
+      action='store_true',
    )
 
    arg (
@@ -398,7 +398,8 @@ def parse_argv ( command_map, **kw ):
    commands = ( p.commands, ) if isinstance ( p.commands, str ) else p.commands
    conf  = dict()
    extra = dict (
-      nosync                  = p.nosync,
+# TODO: remove nosync entirely from extra
+#      nosync                  = p.nosync,
 #      debug                   = p.debug,
       show_overlay            = p.show_overlay,
       write_overlay           = p.write_overlay,
@@ -445,6 +446,11 @@ def parse_argv ( command_map, **kw ):
       extra ['nosync']   = True
       if 'create' in command_map:
          commands.append ( "create" )
+   elif given ( 'nosync' ):
+      extra ['nosync'] = True
+
+   if extra.get ( 'nosync', False ):
+      doconf ( True, 'nosync' )
 
    if given ( 'deprule_file' ):
       doconf ( p.deprule_file, 'DEPRES.SIMPLE_RULES.files' )
@@ -452,5 +458,6 @@ def parse_argv ( command_map, **kw ):
    if given ( 'manifest_implementation' ):
       doconf ( p.manifest_implementation, 'OVERLAY.manifest_implementation' )
 
+
    return ( commands, p.config, conf, extra )
 # --- end of parse_argv (...) ---

diff --git a/roverlay/config/const.py b/roverlay/config/const.py
index 3d330ba..4ee9d45 100644
--- a/roverlay/config/const.py
+++ b/roverlay/config/const.py
@@ -12,7 +12,11 @@ import time
 __all__ = [ 'clone', 'lookup' ]
 
 _CONSTANTS = dict (
-   DEBUG = False,
+   # FIXME: capslock? ;)
+   DEBUG  = False,
+   debug  = False,
+
+   nosync = False,
 
    # logging defaults are in recipe/easylogger
 

diff --git a/roverlay/config/entrymap.py b/roverlay/config/entrymap.py
index 65f2df5..5ae7b78 100644
--- a/roverlay/config/entrymap.py
+++ b/roverlay/config/entrymap.py
@@ -230,6 +230,7 @@ CONFIG_ENTRY_MAP = dict (
    ),
 
    overlay_additions_dir = dict (
+      path        = [ 'OVERLAY', 'additions_dir', ],
       value_type  = 'fs_abs:fs_dir',
       description = 'directory containing ebuilds and ebuild patches',
    ),
@@ -260,7 +261,7 @@ CONFIG_ENTRY_MAP = dict (
    ),
    # ebuild is used to create Manifest files
    ebuild_prog = dict (
-      path        = [ 'TOOLS', 'ebuild_exe' ],
+      path        = [ 'TOOLS', 'EBUILD', 'exe' ],
       value_type  = 'fs_path',
       description = "name of/path to the ebuild executable",
    ),
@@ -434,6 +435,14 @@ CONFIG_ENTRY_MAP = dict (
 
    # --- package rules
 
+   # == hooks / scripts ==
+
+   hook_overlay_success = dict (
+      path        = [ 'HOOK', 'OVERLAY', 'success', ],
+      value_type  = 'fs_file',
+      description = "script that is run just before exiting normally",
+   ),
+
    # == other ==
 
    cachedir = dict (
@@ -448,6 +457,11 @@ CONFIG_ENTRY_MAP = dict (
       description = 'directory for temporary data',
    ),
 
+   nosync = dict (
+      value_type  = yesno,
+      description = 'forbid/allow syncing with remotes',
+   )
+
    # --- other
 
 )


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-commits] proj/R_overlay:gsoc13/next commit in: roverlay/config/, roverlay/
@ 2013-07-12 12:36 André Erdmann
  0 siblings, 0 replies; 4+ messages in thread
From: André Erdmann @ 2013-07-12 12:36 UTC (permalink / raw
  To: gentoo-commits

commit:     98ec4275cb1d98a114b8b95ecfc5643ddaa7d04c
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Fri Jul 12 12:32:36 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Fri Jul 12 12:32:36 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=98ec4275

roverlay: setupdirs command

The 'setupdirs' creates roverlay's filesystem layout (based on what has been
configured).

---
 roverlay/argutil.py         | 58 ++++++++++++++++++++++++++++++++++++++-
 roverlay/config/entrymap.py | 32 ++++++++++++++++++++--
 roverlay/main.py            | 67 ++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 153 insertions(+), 4 deletions(-)

diff --git a/roverlay/argutil.py b/roverlay/argutil.py
index c6fc0db..120132c 100644
--- a/roverlay/argutil.py
+++ b/roverlay/argutil.py
@@ -8,10 +8,30 @@
 
 __all__ = [ 'parse_argv', ]
 
-import os.path
+import os
 import argparse
+import pwd
+import grp
+
 import roverlay
 
+def get_uid ( user ):
+   try:
+      return int ( user )
+      #pwd.getpwuid(^).pw_uid
+   except ValueError:
+      pass
+   return pwd.getpwnam ( user ).pw_uid
+
+def get_gid ( group ):
+   try:
+      return int ( group )
+      #grp.getgrgid(^).gr_gid
+   except ValueError:
+      pass
+   return grp.getgrnam ( group ).gr_gid
+
+
 def get_parser ( command_map, default_config_file, default_command='create' ):
    """Returns an arg parsers.
 
@@ -21,6 +41,24 @@ def get_parser ( command_map, default_config_file, default_command='create' ):
    * default_command     -- the default command
    """
 
+   def is_uid ( value ):
+      try:
+         return get_uid ( value )
+      except:
+         pass
+      raise argparse.ArgumentTypeError (
+         "no such user/uid: {}".format ( value )
+      )
+
+   def is_gid ( value ):
+      try:
+         return get_gid ( value )
+      except:
+         pass
+      raise argparse.ArgumentTypeError (
+         "no such group/gid: {}".format ( value )
+      )
+
    def is_fs_file ( value ):
       f = os.path.abspath ( value )
       if not os.path.isfile ( f ):
@@ -353,6 +391,22 @@ def get_parser ( command_map, default_config_file, default_command='create' ):
       type=couldbe_stdout_or_file,
    )
 
+   arg (
+      '--target-uid',
+      metavar="<uid>",
+      help="setupdirs command: uid of the user that will run roverlay",
+      default=os.getuid(),
+      type=is_uid,
+   )
+
+   arg (
+      '--target-gid',
+      metavar="<gid>",
+      help="setupdirs command: gid of the user that will run roverlay",
+      default=os.getgid(),
+      type=is_gid,
+   )
+
 #   # TODO
 #   arg (
 #      '--debug',
@@ -421,6 +475,8 @@ def parse_argv ( command_map, **kw ):
       dump_file               = p.dump_file,
       fixup_category_move     = p.fixup_category_move,
       fixup_category_move_rev = p.fixup_category_move_rev,
+      target_uid              = p.target_uid,
+      target_gid              = p.target_gid,
    )
 
    if given ( 'overlay' ):

diff --git a/roverlay/config/entrymap.py b/roverlay/config/entrymap.py
index de29ca7..86c17da 100644
--- a/roverlay/config/entrymap.py
+++ b/roverlay/config/entrymap.py
@@ -65,6 +65,17 @@ 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:
@@ -111,12 +122,14 @@ CONFIG_ENTRY_MAP = dict (
       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 ===
@@ -154,6 +167,7 @@ CONFIG_ENTRY_MAP = dict (
       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 (
@@ -227,12 +241,15 @@ CONFIG_ENTRY_MAP = dict (
       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 (
@@ -279,6 +296,7 @@ CONFIG_ENTRY_MAP = dict (
          'to all package files will be created '
          '(during Manifest file creation)'
       ),
+      want_dir_create = WANT_PUBLIC_DIR | WANT_USERDIR,
    ),
 
    overlay_distdir_strategy = dict (
@@ -316,6 +334,7 @@ CONFIG_ENTRY_MAP = dict (
       path        = [ 'OVERLAY', 'DISTMAP', 'dbfile', ],
       value_type  = 'fs_file',
       description = 'distmap file',
+      want_dir_create = WANT_PRIVATE_FILEDIR | WANT_USERDIR,
    ),
 
    # * alias
@@ -345,6 +364,7 @@ CONFIG_ENTRY_MAP = 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 (
@@ -358,6 +378,7 @@ CONFIG_ENTRY_MAP = 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
@@ -380,6 +401,7 @@ CONFIG_ENTRY_MAP = dict (
          'this is the directory where per-repo package directories '
          'will be created'
       ),
+      want_dir_create = WANT_PRIVATE_FILEDIR | WANT_USERDIR,
    ),
 
    # the repo config file(s)
@@ -387,6 +409,7 @@ CONFIG_ENTRY_MAP = 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
@@ -411,6 +434,7 @@ CONFIG_ENTRY_MAP = dict (
       path        = [ 'DEPRES', 'SIMPLE_RULES', 'files' ],
       value_type  = fs_abslist,
       description = "list of dependency rule files",
+      want_dir_create = WANT_PRIVATE_FILEDIR,
    ),
 
    # * alias
@@ -425,6 +449,7 @@ CONFIG_ENTRY_MAP = 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
@@ -434,7 +459,8 @@ CONFIG_ENTRY_MAP = dict (
       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
@@ -449,6 +475,7 @@ CONFIG_ENTRY_MAP = dict (
       path        = [ 'PACKAGE_RULES', 'files' ],
       value_type  = fs_abslist,
       description = 'list of package rule files/dirs',
+      want_dir_create = WANT_PRIVATE_FILEDIR,
    ),
 
    # * alias
@@ -488,6 +515,7 @@ CONFIG_ENTRY_MAP = dict (
       path        = [ 'CACHEDIR', 'root', ],
       value_type  = 'fs_dir',
       description = 'directory for cache data',
+      want_dir_create = WANT_PRIVATE_DIR | WANT_USERDIR,
    ),
 
    nosync = dict (

diff --git a/roverlay/main.py b/roverlay/main.py
index 1513b1d..75d1e2f 100644
--- a/roverlay/main.py
+++ b/roverlay/main.py
@@ -63,6 +63,55 @@ class DIE ( object ):
 # --- DIE: exit codes ---
 die = DIE.die
 
+def run_setupdirs ( config, target_uid, target_gid ):
+   import stat
+   import roverlay.util
+   import roverlay.config.entrymap
+   import roverlay.config.entryutil
+
+   dodir            = roverlay.util.dodir
+   find_config_path = roverlay.config.entryutil.find_config_path
+
+   dirmode_private  = stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP
+   #clear_mode = ~(stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
+   #get_mode = lambda old, want_mode: ( old & clear_mode ) | want_mode
+
+   WANT_USERDIR = roverlay.config.entrymap.WANT_USERDIR
+   WANT_PRIVATE = roverlay.config.entrymap.WANT_PRIVATE
+   WANT_FILEDIR = roverlay.config.entrymap.WANT_FILEDIR
+
+   listlike    = lambda a: hasattr(a, '__iter__') and not isinstance(a, str)
+   iter_values = lambda b: () if b is None else (b if listlike(b) else ( b, ))
+
+   my_uid = os.getuid()
+   my_gid = os.getgid()
+   should_chown = my_uid != target_uid or my_gid != target_gid
+
+   # it's not necessary to create all of the listed dirs because some of
+   # them are automatically created at runtime, but doing so results in
+   # a (mostly) complete filesystem layout
+   #
+   for config_key, entry in roverlay.config.entrymap.CONFIG_ENTRY_MAP.items():
+      if isinstance ( entry, dict ) and 'want_dir_create' in entry:
+         for value in iter_values (
+            config.get ( find_config_path ( config_key ), None )
+         ):
+            dirmask = entry ['want_dir_create']
+            dirpath = (
+               os.path.dirname ( value.rstrip ( os.sep ) )
+               if dirmask & WANT_FILEDIR else value.rstrip ( os.sep )
+            )
+            if dirpath:
+               dodir ( dirpath )
+               if dirmask & WANT_PRIVATE:
+                  os.chmod ( dirpath, dirmode_private )
+               if dirmask & WANT_USERDIR and should_chown:
+                  os.chown ( dirpath, target_uid, target_gid )
+
+
+   return os.EX_OK
+# --- end of run_setupdirs (...) ---
+
 def main_installed():
    return main ( ROVERLAY_INSTALLED=True )
 
@@ -332,6 +381,7 @@ def main (
       'depres'         : 'this is an alias to \'depres_console\'',
       'nop'            : 'does nothing',
       'apply_rules'    : 'apply package rules verbosely and exit afterwards',
+      'setupdirs'      : 'create configured directories etc.',
    }
 
 
@@ -372,8 +422,16 @@ def main (
    actions_done = set()
    set_action_done = actions_done.add
 
+   want_logging = True
+   do_setupdirs = False
+
    if 'sync' in actions and OPTION ( 'nosync' ):
       die ( "sync command blocked by --nosync opt.", DIE.ARG )
+   elif 'setupdirs' in actions:
+      do_setupdirs = True
+      want_logging = False
+      if len ( actions ) > 1:
+         die ( "setupdirs cannot be run with other commands!", DIE.USAGE )
 
    del commands
 
@@ -399,7 +457,8 @@ def main (
 
       conf = roverlay.load_config_file (
          config_file,
-         extraconf=additional_config
+         extraconf=additional_config,
+         setup_logger=want_logging,
       )
       del config_file, additional_config
    except:
@@ -413,6 +472,12 @@ def main (
       else:
          raise
 
+
+   if do_setupdirs:
+      sys.exit ( run_setupdirs (
+         conf, extra_opts['target_uid'], extra_opts['target_gid']
+      ) )
+
    if OPTION ( 'list_config' ):
       try:
          from roverlay.config.entryutil import list_entries


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-07-12 12:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-22 15:24 [gentoo-commits] proj/R_overlay:master commit in: roverlay/config/, roverlay/ André Erdmann
2013-06-20 23:40 ` [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann
  -- strict thread matches above, loose matches on Subject: below --
2013-07-12 12:36 André Erdmann
2013-06-22 15:14 André Erdmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox