* [gentoo-commits] proj/layman:master commit in: layman/overlays/, etc/
@ 2011-02-17 21:53 Brian Dolbec
0 siblings, 0 replies; 2+ messages in thread
From: Brian Dolbec @ 2011-02-17 21:53 UTC (permalink / raw
To: gentoo-commits
commit: af55bea519642b9742135498e5fddaececab7d1f
Author: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Thu Feb 17 21:48:54 2011 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Feb 17 21:48:54 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=af55bea5
add per repo type config options
---
etc/layman.cfg | 43 +++++++++++++++++++++++++++++++++++++++--
layman/overlays/bzr.py | 15 ++++++++++++-
layman/overlays/cvs.py | 8 +++++++
layman/overlays/darcs.py | 17 ++++++++++++++-
layman/overlays/git.py | 8 +++++++
layman/overlays/mercurial.py | 17 ++++++++++++++-
layman/overlays/rsync.py | 5 ++++
layman/overlays/svn.py | 31 ++++++++++++++++++++---------
8 files changed, 125 insertions(+), 19 deletions(-)
diff --git a/etc/layman.cfg b/etc/layman.cfg
index ea68e66..f345fe1 100644
--- a/etc/layman.cfg
+++ b/etc/layman.cfg
@@ -17,13 +17,13 @@ cache : %(storage)s/cache
local_list: %(storage)s/overlays.xml
#-----------------------------------------------------------
-# Path to the make.conf file that should be modified by
+# Path to the make.conf file that should be modified by
# layman
make_conf : %(storage)s/make.conf
#-----------------------------------------------------------
-# URLs of the remote lists of overlays (one per line) or
+# URLs of the remote lists of overlays (one per line) or
# local overlay definitions
#
#overlays : http://www.gentoo.org/proj/en/overlays/repositories.xml
@@ -46,7 +46,7 @@ overlays : http://www.gentoo.org/proj/en/overlays/repositories.xml
# Hopefully this description eases the double negation trouble:
#
# nocheck : yes
-# - Accepts completene overlay entries without warnings
+# - Accepts complete overlay entries without warnings
# - Lists overlays of type foo (say Git) even with no foo installed
#
# nocheck : no
@@ -87,3 +87,40 @@ nocheck : yes
#rsync_command : /usr/bin/rsync
#svn_command : /usr/bin/svn
#tar_command : /bin/tar
+#g-common_command : /usr/bin/g-common
+
+
+#-----------------------------------------------------------
+# Command additional options
+#
+# These commnad options will be added to the above commands
+# when the overlay is added or synced.
+#
+# note: there are some options hardcoded in the backend
+# scripts already. All VCS types listed here are
+# for general consistency. Options may not be available
+# or recommended for all VCS types and/or add/sync operations.
+# Any options defined here are deemed:
+# "Use at your own risk"
+# and are not supported.
+#
+# eg:
+# svn_addopts : --config-option=config:miscellany:use-commit-times=yes
+#
+
+#bzr_addopts :
+#bzr_syncopts :
+#cvs_addopts :
+#cvs_syncopts :
+#darcs_addopts :
+#darcs_syncopts :
+#git_addopts :
+#git_syncopts :
+#mercurial_addopts :
+#mercurial_syncopts :
+#rsync_syncopts :
+#svn_addopts :
+#svn_syncopts :
+#g-common_generateopts :
+#g-common_syncopts :
+
diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py
index e73c2f4..a236210 100644
--- a/layman/overlays/bzr.py
+++ b/layman/overlays/bzr.py
@@ -50,8 +50,14 @@ class BzrOverlay(OverlaySource):
self.supported()
+ cfg_opts = self.config["bzr_addopts"]
+
# bzr get SOURCE TARGET
- args = ['get', self.src + '/', path([base, self.parent.name])]
+ if cfg_opts:
+ args = ['get', cfg_opts,
+ self.src + '/', path([base, self.parent.name])]
+ else:
+ args = ['get', self.src + '/', path([base, self.parent.name])]
return self.run_command(*args)
def sync(self, base, quiet = False):
@@ -59,8 +65,13 @@ class BzrOverlay(OverlaySource):
self.supported()
+ cfg_opts = self.config["bzr_syncopts"]
+
# bzr pull --overwrite SOURCE
- args = ['pull', '--overwrite', self.src]
+ if cfg_opts:
+ args = ['pull', cfg_opts, '--overwrite', self.src]
+ else:
+ args = ['pull', '--overwrite', self.src]
return self.run_command(*args, cwd=path([base, self.parent.name]))
def supported(self):
diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py
index f8fc277..e4ee5eb 100644
--- a/layman/overlays/cvs.py
+++ b/layman/overlays/cvs.py
@@ -74,12 +74,16 @@ class CvsOverlay(OverlaySource):
self.supported()
+ cfg_opts = self.config["cvs_addopts"]
+
# cvs [-q] co -d SOURCE SCOPE
args = []
if quiet:
args.append('-q')
args.append('co')
args.append('-d')
+ if cfg_opts:
+ args.append(cfg_opts)
args.append(self.parent.name)
args.append(self.subpath)
@@ -90,12 +94,16 @@ class CvsOverlay(OverlaySource):
self.supported()
+ cfg_opts = self.config["cvs_syncopts"]
+
# cvs [-q] update -d
args = []
if quiet:
args.append('-q')
args.append('update')
args.append('-d')
+ if cfg_opts:
+ args.append(cfg_opts)
return self.run_command(*args, cwd=path([base, self.parent.name]))
def supported(self):
diff --git a/layman/overlays/darcs.py b/layman/overlays/darcs.py
index 7d89477..cfaba51 100644
--- a/layman/overlays/darcs.py
+++ b/layman/overlays/darcs.py
@@ -49,8 +49,16 @@ class DarcsOverlay(OverlaySource):
self.supported()
+ cfg_opts = self.config["darcs_addopts"]
+
# darcs get --partial SOURCE TARGET
- args = ['get', '--partial', self.src + '/', path([base, self.parent.name])]
+ if cfg_opts:
+ args = ['get', '--partial', cfg_opts,
+ self.src + '/', path([base, self.parent.name])]
+ else:
+ args = ['get', '--partial',
+ self.src + '/', path([base, self.parent.name])]
+
return self.run_command(*args)
def sync(self, base, quiet = False):
@@ -58,8 +66,13 @@ class DarcsOverlay(OverlaySource):
self.supported()
+ cfg_opts = self.config["darcs_addopts"]
+
# darcs pull --all SOURCE
- args = ['pull', '--all', self.src]
+ if cfg_opts:
+ args = ['pull', '--all', cfg_opts, self.src]
+ else:
+ args = ['pull', '--all', self.src]
return self.run_command(*args, cwd=path([base, self.parent.name]))
def supported(self):
diff --git a/layman/overlays/git.py b/layman/overlays/git.py
index caa73f4..9517398 100644
--- a/layman/overlays/git.py
+++ b/layman/overlays/git.py
@@ -54,10 +54,14 @@ class GitOverlay(OverlaySource):
return source + '/'
return source
+ cfg_opts = self.config["git_addopts"]
+
# git clone [-q] SOURCE TARGET
args = ['clone']
if quiet:
args.append('-q')
+ if cfg_opts:
+ args.append(cfg_opts)
args.append(fix_git_source(self.src))
args.append(path([base, self.parent.name]))
return self.run_command(*args)
@@ -67,9 +71,13 @@ class GitOverlay(OverlaySource):
self.supported()
+ cfg_opts = self.config["git_syncopts"]
+
args = ['pull']
if quiet:
args.append('-q')
+ if cfg_opts:
+ args.append(cfg_opts)
return self.run_command(*args, cwd=path([base, self.parent.name]))
def supported(self):
diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py
index 06cf59d..377ad4c 100644
--- a/layman/overlays/mercurial.py
+++ b/layman/overlays/mercurial.py
@@ -49,8 +49,15 @@ class MercurialOverlay(OverlaySource):
self.supported()
+ cfg_opts = self.config["mercurial_addopts"]
+
# hg clone SOURCE TARGET
- args = ['clone', self.src + '/', path([base, self.parent.name])]
+ if cfg_opts:
+ args = ['clone', cfg_opts,
+ self.src + '/', path([base, self.parent.name])]
+ else:
+ args = ['clone', self.src + '/', path([base, self.parent.name])]
+
return self.run_command(*args)
def sync(self, base, quiet = False):
@@ -58,8 +65,14 @@ class MercurialOverlay(OverlaySource):
self.supported()
+ cfg_opts = self.config["mercurial_syncopts"]
+
# hg pull -u SOURCE
- args = ['pull', '-u', self.src]
+ if cfg_opts:
+ args = ['pull', '-u', cfg_opts, self.src]
+ else:
+ args = ['pull', '-u', self.src]
+
return self.run_command(*args, cwd=path([base, self.parent.name]))
def supported(self):
diff --git a/layman/overlays/rsync.py b/layman/overlays/rsync.py
index 3a5a342..d6f3281 100644
--- a/layman/overlays/rsync.py
+++ b/layman/overlays/rsync.py
@@ -61,8 +61,13 @@ class RsyncOverlay(OverlaySource):
# rsync OPTIONS [-q] SOURCE TARGET
args = ['-rlptDvz', '--progress', '--delete', '--delete-after', '--timeout=180',
'--exclude=distfiles/*', '--exclude=local/*', '--exclude=packages/*']
+
+ cfg_opts = self.config["rsync_syncopts"]
+
if quiet:
args.append('-q')
+ if cfg_opts:
+ args.append(cfg_opts)
args.append(self.src + '/')
args.append(path([base, self.parent.name]))
diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index 2a30198..69d7b05 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -1,8 +1,8 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-#################################################################################
+###############################################################################
# LAYMAN SVN OVERLAY HANDLER
-#################################################################################
+###############################################################################
# File: svn.py
#
# Handles subversion overlays
@@ -18,20 +18,20 @@
__version__ = "$Id: svn.py 236 2006-09-05 20:39:37Z wrobel $"
-#===============================================================================
+#==============================================================================
#
# Dependencies
#
-#-------------------------------------------------------------------------------
+#------------------------------------------------------------------------------
from layman.utils import path
from layman.overlays.source import OverlaySource, require_supported
-#===============================================================================
+#==============================================================================
#
# Class SvnOverlay
#
-#-------------------------------------------------------------------------------
+#------------------------------------------------------------------------------
class SvnOverlay(OverlaySource):
''' Handles subversion overlays.'''
@@ -39,9 +39,11 @@ class SvnOverlay(OverlaySource):
type = 'Subversion'
type_key = 'svn'
- def __init__(self, parent, xml, config, _location, ignore = 0, quiet = False):
+ def __init__(self, parent, xml, config, _location,
+ ignore = 0, quiet = False):
- super(SvnOverlay, self).__init__(parent, xml, config, _location, ignore, quiet)
+ super(SvnOverlay, self).__init__(
+ parent, xml,config, _location, ignore, quiet)
def add(self, base, quiet = False):
'''Add overlay.'''
@@ -50,9 +52,13 @@ class SvnOverlay(OverlaySource):
super(SvnOverlay, self).add(base)
+ cfg_opts = self.config["svn_addopts"]
+
args = ['co']
if quiet:
args.append('-q')
+ if cfg_opts:
+ args.append(cfg_opts)
args.append(self.src + '/@')
args.append(path([base, self.parent.name]))
@@ -71,10 +77,14 @@ class SvnOverlay(OverlaySource):
repo_part = repo_part + '@'
return path([base, repo_part])
+ cfg_opts = self.config["svn_syncopts"]
+
# svn up [-q] TARGET
args = ['up']
if quiet:
args.append('-q')
+ if cfg_opts:
+ args.append(cfg_opts)
args.append(checkout_location())
return self.run_command(*args)
@@ -82,5 +92,6 @@ class SvnOverlay(OverlaySource):
def supported(self):
'''Overlay type supported?'''
- return require_supported([(self.command(), 'svn',
- 'dev-vcs/subversion'),])
+ return require_supported(
+ [(self.command(), 'svn','dev-vcs/subversion'),]
+ )
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/overlays/, etc/
@ 2011-02-18 5:19 Brian Dolbec
0 siblings, 0 replies; 2+ messages in thread
From: Brian Dolbec @ 2011-02-18 5:19 UTC (permalink / raw
To: gentoo-commits
commit: 3eaca0340384122c5d83e0aa2d0a8b6dc1165487
Author: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Fri Feb 18 05:19:08 2011 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Feb 18 05:19:08 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=3eaca034
Add per repo type postsync options.
Some minor long lines cleanup.
---
etc/layman.cfg | 23 +++++++++++++++++++++++
layman/overlays/bzr.py | 14 ++++++++++----
layman/overlays/cvs.py | 11 +++++++++--
layman/overlays/darcs.py | 14 ++++++++++----
layman/overlays/g_common.py | 20 +++++++++++++-------
layman/overlays/git.py | 12 +++++++++---
layman/overlays/mercurial.py | 15 ++++++++++-----
layman/overlays/rsync.py | 7 +++++--
layman/overlays/source.py | 28 +++++++++++++++++++++++++---
layman/overlays/svn.py | 14 ++++++++++----
layman/overlays/tar.py | 27 +++++++++++++++++----------
11 files changed, 141 insertions(+), 44 deletions(-)
diff --git a/etc/layman.cfg b/etc/layman.cfg
index f345fe1..741da11 100644
--- a/etc/layman.cfg
+++ b/etc/layman.cfg
@@ -124,3 +124,26 @@ nocheck : yes
#g-common_generateopts :
#g-common_syncopts :
+
+#-----------------------------------------------------------
+# Per VCS Post Sync/Add hooks
+#
+# The listed commands will be run after every add/sync operation.
+# All on one line If the repo path is needed, use a %cwd= in
+# where you want the path substituted in. It will be detected
+# and replaced with the correct path.
+#
+# eg: git_postsync : git-set-file-times
+# eg: git_postsync : git-set-file-times %cwd=
+# eg: git_postsync : git-set-file-times path=%cwd=
+#
+#bzr_postsync :
+#cvs_postsync :
+#darcs_postsync :
+#git_postsync :
+#mercurial_postsync :
+#rsync_postsync :
+#svn_postsync :
+#tar_postsync :
+#g-common_postsync :
+
diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py
index a236210..6f1b560 100644
--- a/layman/overlays/bzr.py
+++ b/layman/overlays/bzr.py
@@ -51,14 +51,17 @@ class BzrOverlay(OverlaySource):
self.supported()
cfg_opts = self.config["bzr_addopts"]
+ target = path([base, self.parent.name])
# bzr get SOURCE TARGET
if cfg_opts:
args = ['get', cfg_opts,
- self.src + '/', path([base, self.parent.name])]
+ self.src + '/', target]
else:
- args = ['get', self.src + '/', path([base, self.parent.name])]
- return self.run_command(*args)
+ args = ['get', self.src + '/', target]
+ return self.postsync(
+ self.run_command(self.command(), *args, cmd=self.type),
+ cwd=target)
def sync(self, base, quiet = False):
'''Sync overlay.'''
@@ -66,13 +69,16 @@ class BzrOverlay(OverlaySource):
self.supported()
cfg_opts = self.config["bzr_syncopts"]
+ target = path([base, self.parent.name])
# bzr pull --overwrite SOURCE
if cfg_opts:
args = ['pull', cfg_opts, '--overwrite', self.src]
else:
args = ['pull', '--overwrite', self.src]
- return self.run_command(*args, cwd=path([base, self.parent.name]))
+ return self.postsync(
+ self.run_command(self.command(), *args, cwd=target, cmd=self.type),
+ cwd=target)
def supported(self):
'''Overlay type supported?'''
diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py
index e4ee5eb..7d3f28f 100644
--- a/layman/overlays/cvs.py
+++ b/layman/overlays/cvs.py
@@ -75,6 +75,7 @@ class CvsOverlay(OverlaySource):
self.supported()
cfg_opts = self.config["cvs_addopts"]
+ target = path([base, self.parent.name])
# cvs [-q] co -d SOURCE SCOPE
args = []
@@ -87,7 +88,10 @@ class CvsOverlay(OverlaySource):
args.append(self.parent.name)
args.append(self.subpath)
- return self.run_command(*args, cwd=base, env=dict(CVSROOT=self.src))
+ return self.postsync(
+ self.run_command(self.command(), *args, cwd=base,
+ env=dict(CVSROOT=self.src), cmd=self.type),
+ cwd=target)
def sync(self, base, quiet = False):
'''Sync overlay.'''
@@ -95,6 +99,7 @@ class CvsOverlay(OverlaySource):
self.supported()
cfg_opts = self.config["cvs_syncopts"]
+ target = path([base, self.parent.name])
# cvs [-q] update -d
args = []
@@ -104,7 +109,9 @@ class CvsOverlay(OverlaySource):
args.append('-d')
if cfg_opts:
args.append(cfg_opts)
- return self.run_command(*args, cwd=path([base, self.parent.name]))
+ return self.postsync(
+ self.run_command(self.command(), *args, cwd=target, cmd=self.type),
+ cwd=target)
def supported(self):
'''Overlay type supported?'''
diff --git a/layman/overlays/darcs.py b/layman/overlays/darcs.py
index cfaba51..d393be7 100644
--- a/layman/overlays/darcs.py
+++ b/layman/overlays/darcs.py
@@ -50,16 +50,19 @@ class DarcsOverlay(OverlaySource):
self.supported()
cfg_opts = self.config["darcs_addopts"]
+ target = path([base, self.parent.name])
# darcs get --partial SOURCE TARGET
if cfg_opts:
args = ['get', '--partial', cfg_opts,
- self.src + '/', path([base, self.parent.name])]
+ self.src + '/', target]
else:
args = ['get', '--partial',
- self.src + '/', path([base, self.parent.name])]
+ self.src + '/', target]
- return self.run_command(*args)
+ return self.postsync(
+ self.run_command(self.command(), *args, cmd=self.type),
+ cwd=target)
def sync(self, base, quiet = False):
'''Sync overlay.'''
@@ -67,13 +70,16 @@ class DarcsOverlay(OverlaySource):
self.supported()
cfg_opts = self.config["darcs_addopts"]
+ target = path([base, self.parent.name])
# darcs pull --all SOURCE
if cfg_opts:
args = ['pull', '--all', cfg_opts, self.src]
else:
args = ['pull', '--all', self.src]
- return self.run_command(*args, cwd=path([base, self.parent.name]))
+ return self.postsync(
+ self.run_command(self.command(), *args, cwd=target, cmd=self.type),
+ cwd=target)
def supported(self):
'''Overlay type supported?'''
diff --git a/layman/overlays/g_common.py b/layman/overlays/g_common.py
index 80d0742..5367c69 100644
--- a/layman/overlays/g_common.py
+++ b/layman/overlays/g_common.py
@@ -40,7 +40,7 @@ class GCommonOverlay(OverlaySource):
def __init__(self, parent, xml, config, _location, ignore = 0, quiet = False):
super(GCommonOverlay, self).__init__(parent, xml, config, _location, ignore, quiet)
- #split source into driver and remote uri.
+ #split source into driver and remote uri.
self.driver=self.src[:self.src.find(' ')]
self.remote_uri=self.src[self.src.find(' ')+1:]
@@ -48,20 +48,26 @@ class GCommonOverlay(OverlaySource):
'''Add overlay.'''
self.supported()
+ target = path([base, self.parent.name])
+
+ os.makedirs(target)
- os.makedirs(os.path.join(base,self.parent.name))
return self.sync(base, quiet)
def sync(self, base, quiet = False):
'''Sync overlay.'''
self.supported()
+ target = path([base, self.parent.name])
- args = [os.path.join(base,self.parent.name), 'sync', self.driver, self.remote_uri]
- returncode=self.run_command(*args,cwd=path([base,self.parent.name]))
- if returncode: return returncode
- args = [os.path.join(base,self.parent.name), 'generate-tree']
- return self.run_command(*args,cwd=path([base,self.parent.name]))
+ args = [target, 'sync', self.driver, self.remote_uri]
+ returncode = self.run_command(self.command(), *args, cwd=target)
+ if returncode:
+ return returncode
+ args = [target, 'generate-tree']
+ return self.postsync(
+ self.run_command(self.command(), *args, cwd=target, cmd=self.type),
+ cwd=target)
def supported(self):
'''Overlay type supported?'''
diff --git a/layman/overlays/git.py b/layman/overlays/git.py
index 9517398..23103f6 100644
--- a/layman/overlays/git.py
+++ b/layman/overlays/git.py
@@ -55,6 +55,7 @@ class GitOverlay(OverlaySource):
return source
cfg_opts = self.config["git_addopts"]
+ target = path([base, self.parent.name])
# git clone [-q] SOURCE TARGET
args = ['clone']
@@ -63,8 +64,10 @@ class GitOverlay(OverlaySource):
if cfg_opts:
args.append(cfg_opts)
args.append(fix_git_source(self.src))
- args.append(path([base, self.parent.name]))
- return self.run_command(*args)
+ args.append(target)
+ return self.postsync(
+ self.run_command(self.command(), *args, cmd=self.type),
+ cwd=target)
def sync(self, base, quiet = False):
'''Sync overlay.'''
@@ -72,13 +75,16 @@ class GitOverlay(OverlaySource):
self.supported()
cfg_opts = self.config["git_syncopts"]
+ target = path([base, self.parent.name])
args = ['pull']
if quiet:
args.append('-q')
if cfg_opts:
args.append(cfg_opts)
- return self.run_command(*args, cwd=path([base, self.parent.name]))
+ return self.postsync(
+ self.run_command(self.command(), *args, cwd=target, cmd=self.type),
+ cwd=target)
def supported(self):
'''Overlay type supported?'''
diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py
index 377ad4c..df4f789 100644
--- a/layman/overlays/mercurial.py
+++ b/layman/overlays/mercurial.py
@@ -50,15 +50,17 @@ class MercurialOverlay(OverlaySource):
self.supported()
cfg_opts = self.config["mercurial_addopts"]
+ target = path([base, self.parent.name])
# hg clone SOURCE TARGET
if cfg_opts:
- args = ['clone', cfg_opts,
- self.src + '/', path([base, self.parent.name])]
+ args = ['clone', cfg_opts, self.src + '/', target]
else:
- args = ['clone', self.src + '/', path([base, self.parent.name])]
+ args = ['clone', self.src + '/', target]
- return self.run_command(*args)
+ return self.postsync(
+ self.run_command(self.command(), *args, cmd=self.type),
+ cwd=target)
def sync(self, base, quiet = False):
'''Sync overlay.'''
@@ -66,6 +68,7 @@ class MercurialOverlay(OverlaySource):
self.supported()
cfg_opts = self.config["mercurial_syncopts"]
+ target = path([base, self.parent.name])
# hg pull -u SOURCE
if cfg_opts:
@@ -73,7 +76,9 @@ class MercurialOverlay(OverlaySource):
else:
args = ['pull', '-u', self.src]
- return self.run_command(*args, cwd=path([base, self.parent.name]))
+ return self.postsync(
+ self.run_command(self.command(), *args, cwd=target, cmd=self.type),
+ cwd=target)
def supported(self):
'''Overlay type supported?'''
diff --git a/layman/overlays/rsync.py b/layman/overlays/rsync.py
index d6f3281..84836dd 100644
--- a/layman/overlays/rsync.py
+++ b/layman/overlays/rsync.py
@@ -63,15 +63,18 @@ class RsyncOverlay(OverlaySource):
'--exclude=distfiles/*', '--exclude=local/*', '--exclude=packages/*']
cfg_opts = self.config["rsync_syncopts"]
+ target = path([base, self.parent.name])
if quiet:
args.append('-q')
if cfg_opts:
args.append(cfg_opts)
args.append(self.src + '/')
- args.append(path([base, self.parent.name]))
+ args.append(target)
- return self.run_command(*args)
+ return self.postsync(
+ self.run_command(self.command(), *args, cmd=self.type),
+ cwd=target)
def supported(self):
'''Overlay type supported?'''
diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index e5cd880..b0bc9a3 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -111,8 +111,8 @@ class OverlaySource(object):
def command(self):
return self.config['%s_command' % self.__class__.type_key]
- def run_command(self, *args, **kwargs):
- file_to_run = _resolve_command(self.command())[1]
+ def run_command(self, command, *args, **kwargs):
+ file_to_run = _resolve_command(command)[1]
args = (file_to_run, ) + args
assert('pwd' not in kwargs) # Bug detector
@@ -132,7 +132,8 @@ class OverlaySource(object):
if cwd:
command_repr = '( cd %s && %s )' % (cwd, command_repr)
- self.output.info('Running... # %s' % command_repr, 2)
+ cmd = kwargs.get('cmd', '')
+ self.output.info('Running %s... # %s' % (cmd, command_repr), 2)
if self.quiet:
input_source = subprocess.PIPE
@@ -162,7 +163,28 @@ class OverlaySource(object):
if self.quiet:
output_target.close()
+ if result:
+ self.output.info('Failure result returned from %s' % cmd , 2)
+
return result
+ def postsync(self, failed_sync, **kwargs):
+ """Runs any repo specific postsync operations
+ """
+ # check if the add/sync operation succeeded
+ if failed_sync:
+ return failed_sync
+ # good to continue
+ postsync_opt = self.config['%s_postsync' % self.__class__.type_key]
+ if postsync_opt:
+ # repalce "%cwd=" while it's still a string'
+ _opt = postsync_opt.replace('%cwd=',
+ kwargs.get('cwd', '')).split()
+ command = _opt[0]
+ args = _opt[1:]
+ return self.run_command(command, *args,
+ cmd='%s_postsync' % self.__class__.type_key)
+ return failed_sync
+
def to_xml_hook(self, repo_elem):
pass
diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index 69d7b05..c237ea4 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -53,6 +53,7 @@ class SvnOverlay(OverlaySource):
super(SvnOverlay, self).add(base)
cfg_opts = self.config["svn_addopts"]
+ target = path([base, self.parent.name])
args = ['co']
if quiet:
@@ -60,9 +61,11 @@ class SvnOverlay(OverlaySource):
if cfg_opts:
args.append(cfg_opts)
args.append(self.src + '/@')
- args.append(path([base, self.parent.name]))
+ args.append(target)
- return self.run_command(*args)
+ return self.postsync(
+ self.run_command(self.command(),*args, cmd=self.type),
+ cwd=target)
def sync(self, base, quiet = False):
'''Sync overlay.'''
@@ -78,6 +81,7 @@ class SvnOverlay(OverlaySource):
return path([base, repo_part])
cfg_opts = self.config["svn_syncopts"]
+ target = checkout_location()
# svn up [-q] TARGET
args = ['up']
@@ -85,9 +89,11 @@ class SvnOverlay(OverlaySource):
args.append('-q')
if cfg_opts:
args.append(cfg_opts)
- args.append(checkout_location())
+ args.append(target)
- return self.run_command(*args)
+ return self.postsync(
+ self.run_command(self.command(),*args, cmd=self.type),
+ cwd=target)
def supported(self):
'''Overlay type supported?'''
diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 4916b77..09ed979 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -130,7 +130,7 @@ class TarOverlay(OverlaySource):
# tar -v -x -f SOURCE -C TARGET
args = ['-v', '-x', '-f', pkg, '-C', dest_dir]
- result = self.run_command(*args)
+ result = self.run_command(self.command(), *args, cmd=self.type)
os.unlink(pkg)
return result
@@ -150,7 +150,8 @@ class TarOverlay(OverlaySource):
final_path = path([base, self.parent.name])
temp_path = tempfile.mkdtemp(dir=base)
try:
- result = self._extract(base=base, tar_url=self.src, dest_dir=temp_path)
+ result = self._extract(base=base, tar_url=self.src,
+ dest_dir=temp_path)
except Exception, error:
try_to_wipe(temp_path)
raise error
@@ -169,8 +170,8 @@ class TarOverlay(OverlaySource):
os.rename(source, final_path)
except Exception, error:
raise Exception('Failed to rename tar subdirectory ' +
- source + ' to ' + final_path + '\nError was:'
- + str(error))
+ source + ' to ' + final_path +
+ '\nError was:' + str(error))
os.chmod(final_path, 0755)
else:
raise Exception('Given subpath "' + source + '" does not exist '
@@ -184,18 +185,24 @@ class TarOverlay(OverlaySource):
self.supported()
- final_path = path([base, self.parent.name])
+ target = path([base, self.parent.name])
- if os.path.exists(final_path):
- raise Exception('Directory ' + final_path + ' already exists. Will not ov'
- 'erwrite its contents!')
+ if os.path.exists(target):
+ raise Exception('Directory ' + target + ' already exists.' +\
+ ' Will not overwrite its contents!')
- return self._add_unchecked(base, quiet)
+ return self.postsync(
+ self._add_unchecked(base, quiet),
+ cwd=target)
def sync(self, base, quiet = False):
'''Sync overlay.'''
self.supported()
- self._add_unchecked(base, quiet)
+ target = path([base, self.parent.name])
+
+ return self.postsync(
+ self._add_unchecked(base, quiet),
+ cwd=target)
def supported(self):
'''Overlay type supported?'''
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-02-18 5:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-18 5:19 [gentoo-commits] proj/layman:master commit in: layman/overlays/, etc/ Brian Dolbec
-- strict thread matches above, loose matches on Subject: below --
2011-02-17 21:53 Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox