public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "André Erdmann" <dywi@mailerd.de>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/tools/, roverlay/config/, roverlay/
Date: Sun, 30 Jun 2013 15:58:12 +0000 (UTC)	[thread overview]
Message-ID: <1372267406.cbde5b6151f882ac7e2f53d57cb65cb1a7333fe8.dywi@gentoo> (raw)
Message-ID: <20130630155812.kxTNiASXXeXfW9jsuL6wPjvqFeJCin5uVkExZSZUVHU@z> (raw)

commit:     cbde5b6151f882ac7e2f53d57cb65cb1a7333fe8
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Wed Jun 26 17:23:26 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Wed Jun 26 17:23:26 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=cbde5b61

roverlay/: misc "distmap"/"run hook" changes

* config
-> added 'installed' and 'INSTALLINFO' to the config tree
-> added OVERLAY_DISTMAP_COMPRESSION to the config entry map

* roverlay.hook
-> allow only one asterisk statement in EVENT_HOOK_RESTRICT
-> catch hook script failure in run() and raise an exception

* roverlay.tools.shenv
-> $SHLIB env var is a list now (see previous commit)

---
 roverlay/config/const.py    | 25 ++++++++++---------
 roverlay/config/entrymap.py | 10 +++++++-
 roverlay/hook.py            | 59 +++++++++++++++++++++++++++++++++++----------
 roverlay/main.py            |  7 +++---
 roverlay/tools/shenv.py     | 46 ++++++++++++++++++++++++++---------
 5 files changed, 106 insertions(+), 41 deletions(-)

diff --git a/roverlay/config/const.py b/roverlay/config/const.py
index f9a2e14..c78e27c 100644
--- a/roverlay/config/const.py
+++ b/roverlay/config/const.py
@@ -12,11 +12,13 @@ import time
 __all__ = [ 'clone', 'lookup' ]
 
 _CONSTANTS = dict (
-   # FIXME: capslock? ;)
-   DEBUG  = False,
-   debug  = False,
+   debug     = False,
+   nosync    = False,
+   #installed = False,
 
-   nosync = False,
+   INSTALLINFO = dict (
+      libexec = '/usr/libexec/roverlay', # ::LIBEXEC::
+   ),
 
    # logging defaults are in recipe/easylogger
 
@@ -33,14 +35,13 @@ _CONSTANTS = dict (
    ),
 
    EBUILD = dict (
-      default_header = '\n'.join ( (
-         '# Copyright 1999-%i Gentoo Foundation' % ( time.gmtime() [0] ),
-         '# Distributed under the terms of the GNU General Public License v2',
-         '# $Header: $',
-         '',
-         # EAPI=N and inherit <eclasses> are no longer part
-         # of the default header
-      ) ),
+      default_header = (
+         '# Copyright 1999-{year:d} Gentoo Foundation\n'
+         '# Distributed under the terms of the GNU General Public License v2\n'
+         '# $Header: $\n'
+         '\n'
+      ).format ( year=time.gmtime()[0] ),
+      # EAPI=N and inherit <eclasses> are no longer part of the default header
       eapi = 4,
 
       # number of workers used by OverlayCreator

diff --git a/roverlay/config/entrymap.py b/roverlay/config/entrymap.py
index 6a282d9..87b4973 100644
--- a/roverlay/config/entrymap.py
+++ b/roverlay/config/entrymap.py
@@ -306,8 +306,15 @@ CONFIG_ENTRY_MAP = dict (
       value_type  = yesno,
    ),
 
+   overlay_distmap_compression = dict (
+      description = 'distmap compression format (none, bzip2 or gzip)',
+      choices     = frozenset ({
+         'none', 'default', 'bz2', 'bzip2', 'gz', 'gzip'
+      }),
+   ),
+
    overlay_distmap_file = dict (
-      path        = [ 'OVERLAY', 'DISTMAP', 'dbfile', ]
+      path        = [ 'OVERLAY', 'DISTMAP', 'dbfile', ],
       value_type  = 'fs_file',
       description = 'distmap file',
    ),
@@ -322,6 +329,7 @@ CONFIG_ENTRY_MAP = dict (
    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

diff --git a/roverlay/hook.py b/roverlay/hook.py
index 3b13315..3392e4e 100644
--- a/roverlay/hook.py
+++ b/roverlay/hook.py
@@ -28,6 +28,10 @@ _EVENT_RESTRICT = None
 #  4: deny all
 _EVENT_POLICY = 0
 
+
+class HookException ( Exception ):
+   pass
+
 def setup():
    global _EVENT_SCRIPT
    global _EVENT_POLICY
@@ -35,14 +39,29 @@ def setup():
 
    _EVENT_SCRIPT = roverlay.config.get ( 'EVENT_HOOK.exe', False )
    if _EVENT_SCRIPT is False:
-      a_dir = roverlay.config.get ( 'OVERLAY.additions_dir', None )
-      if a_dir:
+      if roverlay.config.get_or_fail ( 'installed' ):
          s = os.path.join (
-            a_dir,
+            roverlay.config.get_or_fail ( 'INSTALLINFO.libexec' ),
             *roverlay.config.get_or_fail ( 'EVENT_HOOK.default_exe_relpath' )
          )
          if os.path.isfile ( s ):
             _EVENT_SCRIPT = s
+         else:
+            LOGGER.error (
+               'missing {!r} - '
+               'has roverlay been installed properly?'.format ( s )
+            )
+      else:
+         a_dir = roverlay.config.get ( 'OVERLAY.additions_dir', None )
+         if a_dir:
+            s = os.path.join (
+               a_dir, *roverlay.config.get_or_fail (
+                  'EVENT_HOOK.default_exe_relpath'
+               )
+            )
+            if os.path.isfile ( s ):
+               _EVENT_SCRIPT = s
+      # -- end if installed
    # -- end if _EVENT_SCRIPT
 
    conf_restrict = roverlay.config.get ( 'EVENT_HOOK.restrict', False )
@@ -53,12 +72,16 @@ def setup():
       allow = set()
       deny  = set()
       for p in conf_restrict:
-         if p == '*':
-            # "allow all"
-            is_whitelist = False
-         elif p == '-*':
-            # "deny all"
-            is_whitelist = True
+         if p in { '*', '+*', '-*' }:
+            # "allow all" / "deny all"
+            #  to avoid confusion, only one "[+-]*" statement is allowed
+            if is_whitelist is None:
+               is_whitelist = bool ( p[0] == '-' )
+            else:
+               raise Exception (
+                  'EVENT_HOOK_RESTRICT must not contain more than one '
+                  '"*"/"+*"/"-*" statement'
+               )
          elif p == '-' or p == '+':
             # empty
             pass
@@ -148,19 +171,29 @@ def phase_allowed_nolog ( phase ):
    )
 # --- end of phase_allowed_nolog (...) ---
 
-def run ( phase ):
+def run ( phase, catch_failure=True ):
    if _EVENT_SCRIPT is None:
       LOGGER.warning (
          "hook module not initialized - doing that now (FIXME!)"
       )
       setup()
-
+   # -- end if
 
 
    if _EVENT_SCRIPT and phase_allowed ( phase ):
-      return roverlay.tools.shenv.run_script (
+      if roverlay.tools.shenv.run_script (
          _EVENT_SCRIPT, phase, return_success=True
-      )
+      ):
+         return True
+      elif catch_failure:
+         raise HookException (
+            "hook {h!r} returned non-zero for phase {p!r}".format (
+               h=_EVENT_SCRIPT, p=phase
+            )
+         )
+         #return False
+      else:
+         return False
    else:
       # nop
       return True

diff --git a/roverlay/main.py b/roverlay/main.py
index 4822e21..8bfecf6 100644
--- a/roverlay/main.py
+++ b/roverlay/main.py
@@ -289,8 +289,7 @@ def main (
          #  this hook should be called _after_ verifying the overlay
          #  (verification is not implemented yet)
          #
-         if not roverlay.hook.run ( 'overlay_success' ):
-            die ( "overlay_success hook returned non-zero", DIE.OV_CREATE )
+         roverlay.hook.run ( 'overlay_success' )
 
          set_action_done ( "create" )
 
@@ -348,11 +347,13 @@ def main (
       DEFAULT_CONFIG_FILE = CONFIG_FILE_NAME
 
 
-   commands, config_file, additional_config, extra_opts = \
+   commands, config_file, additional_config, extra_opts = (
       roverlay.argutil.parse_argv (
          command_map=COMMAND_DESCRIPTION,
          default_config_file=DEFAULT_CONFIG_FILE,
       )
+   )
+   additional_config ['installed'] = ROVERLAY_INSTALLED
 
    OPTION = extra_opts.get
 

diff --git a/roverlay/tools/shenv.py b/roverlay/tools/shenv.py
index f0c054b..794ed1e 100644
--- a/roverlay/tools/shenv.py
+++ b/roverlay/tools/shenv.py
@@ -90,6 +90,10 @@ NULL_PHASE = 'null'
 def setup_env():
    """Returns a 'well-defined' env dict for running scripts."""
 
+   ROVERLAY_INSTALLED = roverlay.config.get_or_fail ( 'installed' )
+   SHLIB_DIRNAME      = 'shlib'
+   SHFUNC_FILENAME    = 'functions.sh'
+
    # @typedef shbool is SH_TRUE|SH_FALSE, where:
    SH_TRUE  = 'y'
    SH_FALSE = 'n'
@@ -175,30 +179,48 @@ def setup_env():
    #  shell file with "core" functions
    #
    additions_dir = roverlay.config.get ( 'OVERLAY.additions_dir', None )
+   shlib_path    = []
+
+   if ROVERLAY_INSTALLED:
+      installed_shlib = (
+         roverlay.config.get_or_fail ( 'INSTALLINFO.libexec' )
+         + os.sep + SHLIB_DIRNAME
+      )
+      if os.path.isdir ( installed_shlib ):
+         shlib_path.append ( installed_shlib )
+         shlib_file = installed_shlib + os.sep + SHFUNC_FILENAME
+         if os.path.isfile ( shlib_file ):
+            setup ( 'FUNCTIONS', shlib_file )
+         else:
+            LOGGER.error (
+               "roverlay is installed, but $FUNCTIONS file is missing."
+            )
+      else:
+         LOGGER.error ( "roverlay is installed, but shlib dir is missing." )
+   # -- end if installed~shlib
+
    if additions_dir:
       setup ( 'ADDITIONS_DIR', additions_dir )
       setup_self ( 'FILESDIR', 'ADDITIONS_DIR' )
 
-      shlib_root      = additions_dir + os.sep + 'shlib'
-      shlib_file      = None
-      SHFUNC_FILENAME = 'functions.sh'
+      shlib_root = additions_dir + os.sep + 'shlib'
 
       if os.path.isdir ( shlib_root ):
-         setup ( 'SHLIB', shlib_root )
-         shlib_file = shlib_root + os.sep + SHFUNC_FILENAME
+         shlib_path.append ( shlib_root )
 
+#         if not ROVERLAY_INSTALLED:
+         shlib_file = shlib_root + os.sep + SHFUNC_FILENAME
          if os.path.isfile ( shlib_file ):
             setup ( 'FUNCTIONS', shlib_file )
-         else:
-            shlib_file = None
       # -- end if shlib_root;
-
-      if not shlib_file:
-         shlib_file = additions_dir + os.sep + SHFUNC_FILENAME
-         if os.path.isfile ( shlib_file ):
-            setup ( 'FUNCTIONS', shlib_file )
    # -- end if additions_dir;
 
+   if shlib_path:
+      # reversed shlib_path:
+      #  assuming that user-provided function files are more important
+      #
+      setup ( 'SHLIB', ':'.join ( reversed ( shlib_path ) ) )
+
    # str::exe $EBUILD
    setup_conf ( 'EBUILD', 'TOOLS.EBUILD.exe' )
 


             reply	other threads:[~2013-06-30 15:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-26 17:29 André Erdmann [this message]
2013-06-30 15:58 ` [gentoo-commits] proj/R_overlay:master commit in: roverlay/tools/, roverlay/config/, roverlay/ André Erdmann
  -- strict thread matches above, loose matches on Subject: below --
2013-06-30 15:58 André Erdmann
2013-06-25 21:10 ` [gentoo-commits] proj/R_overlay:gsoc13/next " 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=1372267406.cbde5b6151f882ac7e2f53d57cb65cb1a7333fe8.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