summaryrefslogtreecommitdiffstats
path: root/layman
diff options
context:
space:
mode:
authorSebastian Pipping <sebastian@pipping.org>2009-12-29 14:22:06 +0100
committerSebastian Pipping <sebastian@pipping.org>2009-12-29 15:21:35 +0100
commit1fffa93607c68947ae4eea18bf22f95e0d514a66 (patch)
tree8633b54de7cff129e56de3078472e6e7d9f01194 /layman
parent4e5db6241219e5daf79ac20967aef03097d70bb8 (diff)
downloadlayman-1fffa93607c68947ae4eea18bf22f95e0d514a66.tar.gz
layman-1fffa93607c68947ae4eea18bf22f95e0d514a66.tar.bz2
layman-1fffa93607c68947ae4eea18bf22f95e0d514a66.zip
Allow overriding VCS commands
Diffstat (limited to 'layman')
-rw-r--r--layman/action.py12
-rw-r--r--layman/config.py12
-rw-r--r--layman/overlay.py14
-rw-r--r--layman/overlays/bzr.py8
-rw-r--r--layman/overlays/cvs.py10
-rw-r--r--layman/overlays/darcs.py8
-rw-r--r--layman/overlays/git.py8
-rw-r--r--layman/overlays/mercurial.py8
-rw-r--r--layman/overlays/overlay.py3
-rw-r--r--layman/overlays/rsync.py13
-rw-r--r--layman/overlays/svn.py8
-rw-r--r--layman/overlays/tar.py7
12 files changed, 58 insertions, 53 deletions
diff --git a/layman/action.py b/layman/action.py
index b7b36b6..f083ce5 100644
--- a/layman/action.py
+++ b/layman/action.py
@@ -47,7 +47,9 @@ class Fetch:
... 'cache' : cache,
... 'nocheck' : True,
... 'proxy' : None,
- ... 'quietness':3}
+ ... 'quietness':3,
+ ... 'svn_command':'/usr/bin/svn',
+ ... 'rsync_command':'/usr/bin/rsync'}
>>> a = Fetch(config)
>>> a.run()
0
@@ -261,7 +263,9 @@ class Info:
... 'info' : ['wrobel'],
... 'nocheck' : False,
... 'verbose': False,
- ... 'quietness':3}
+ ... 'quietness':3,
+ ... 'svn_command':'/usr/bin/svn',
+ ... 'rsync_command':'/usr/bin/rsync'}
>>> a = Info(config)
>>> a.rdb.cache()
>>> OUT.color_off()
@@ -335,7 +339,9 @@ class List:
... 'nocheck' : False,
... 'verbose': False,
... 'quietness':3,
- ... 'width':80}
+ ... 'width':80,
+ ... 'svn_command':'/usr/bin/svn',
+ ... 'rsync_command':'/usr/bin/rsync'}
>>> a = List(config)
>>> a.rdb.cache()
>>> OUT.color_off()
diff --git a/layman/config.py b/layman/config.py
index d41491e..b00d2ac 100644
--- a/layman/config.py
+++ b/layman/config.py
@@ -54,7 +54,7 @@ class Config(object):
>>> a['overlays']
'\\nhttp://www.gentoo.org/proj/en/overlays/repositories.xml'
>>> sorted(a.keys())
- ['cache', 'config', 'local_list', 'make_conf', 'nocheck', 'overlays', 'proxy', 'quietness', 'storage', 'umask', 'width']
+ ['bzr_command', 'cache', 'config', 'cvs_command', 'darcs_command', 'git_command', 'local_list', 'make_conf', 'mercurial_command', 'nocheck', 'overlays', 'proxy', 'quietness', 'rsync_command', 'storage', 'svn_command', 'tar_command', 'umask', 'width']
'''
self.defaults = {'config' : '/etc/layman/layman.cfg',
@@ -66,7 +66,15 @@ class Config(object):
'proxy' : '',
'umask' : '0022',
'overlays' :
- 'http://www.gentoo.org/proj/en/overlays/repositories.xml',}
+ 'http://www.gentoo.org/proj/en/overlays/repositories.xml',
+ 'bzr_command': '/usr/bin/bzr',
+ 'cvs_command': '/usr/bin/cvs',
+ 'darcs_command': '/usr/bin/darcs',
+ 'git_command': '/usr/bin/git',
+ 'mercurial_command': '/usr/bin/hg',
+ 'rsync_command': '/usr/bin/rsync',
+ 'svn_command': '/usr/bin/svn',
+ 'tar_command': '/bin/tar', }
self.parser = OptionParser(
diff --git a/layman/overlay.py b/layman/overlay.py
index d2126a8..a787b2d 100644
--- a/layman/overlay.py
+++ b/layman/overlay.py
@@ -101,8 +101,8 @@ class Overlays:
Read an xml list of overlays.
>>> here = os.path.dirname(os.path.realpath(__file__))
-
- >>> a = Overlays([here + '/tests/testfiles/global-overlays.xml', ], dict())
+ >>> config = {'svn_command': '/usr/bin/svn', 'rsync_command':'/usr/bin/rsync'}
+ >>> a = Overlays([here + '/tests/testfiles/global-overlays.xml', ], config)
>>> a.overlays.keys()
[u'wrobel', u'wrobel-stable']
@@ -145,8 +145,8 @@ class Overlays:
>>> write = os.tmpnam()
>>> here = os.path.dirname(os.path.realpath(__file__))
-
- >>> a = Overlays([here + '/tests/testfiles/global-overlays.xml', ], dict())
+ >>> config = {'svn_command': '/usr/bin/svn', 'rsync_command':'/usr/bin/rsync'}
+ >>> a = Overlays([here + '/tests/testfiles/global-overlays.xml', ], config)
>>> b = Overlays([write,], dict())
>>> b.overlays['wrobel-stable'] = a.overlays['wrobel-stable']
>>> b.write(write)
@@ -177,7 +177,8 @@ class Overlays:
Select an overlay from the list.
>>> here = os.path.dirname(os.path.realpath(__file__))
- >>> a = Overlays([here + '/tests/testfiles/global-overlays.xml', ], dict())
+ >>> config = {'svn_command': '/usr/bin/svn', 'rsync_command':'/usr/bin/rsync'}
+ >>> a = Overlays([here + '/tests/testfiles/global-overlays.xml', ], config)
>>> a.select('wrobel-stable').src
u'rsync://gunnarwrobel.de/wrobel-stable'
'''
@@ -189,7 +190,8 @@ class Overlays:
List all overlays.
>>> here = os.path.dirname(os.path.realpath(__file__))
- >>> a = Overlays([here + '/tests/testfiles/global-overlays.xml', ], dict())
+ >>> config = {'svn_command': '/usr/bin/svn', 'rsync_command':'/usr/bin/rsync'}
+ >>> a = Overlays([here + '/tests/testfiles/global-overlays.xml', ], config)
>>> for i in a.list(True):
... print i[0]
wrobel
diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py
index 047d944..debf617 100644
--- a/layman/overlays/bzr.py
+++ b/layman/overlays/bzr.py
@@ -41,8 +41,6 @@ class BzrOverlay(Overlay):
type = 'Bzr'
type_key = 'bzr'
- binary_command = '/usr/bin/bzr'
-
def __init__(self, xml, config, ignore = 0, quiet = False):
Overlay.__init__(self, xml, config, ignore)
@@ -52,7 +50,7 @@ class BzrOverlay(Overlay):
self.supported()
- return self.cmd(self.binary_command + ' get "' + self.src + '/" "' +\
+ return self.cmd(self.command() + ' get "' + self.src + '/" "' +\
path([base, self.name]) + '"')
def sync(self, base, quiet = False):
@@ -61,11 +59,11 @@ class BzrOverlay(Overlay):
self.supported()
return self.cmd('cd "' + path([base, self.name]) + '" && ' + \
- self.binary_command + ' pull --overwrite "' + self.src \
+ self.command() + ' pull --overwrite "' + self.src \
+ '"')
def supported(self):
'''Overlay type supported?'''
- return Overlay.supported(self, [(self.binary_command, 'bzr',
+ return Overlay.supported(self, [(self.command(), 'bzr',
'dev-util/bzr'),])
diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py
index fa67871..a4ff74d 100644
--- a/layman/overlays/cvs.py
+++ b/layman/overlays/cvs.py
@@ -39,8 +39,6 @@ class CvsOverlay(Overlay):
type = 'cvs'
type_key = 'cvs'
- binary = '/usr/bin/cvs'
-
def __init__(self, xml, config, ignore = 0, quiet = False):
Overlay.__init__(self, xml, config, ignore, quiet)
@@ -60,8 +58,8 @@ class CvsOverlay(Overlay):
else:
quiet_option = ''
- return self.cmd('cd "' + base + '" && CVSROOT="' + self.src + '" ' +
- self.binary + quiet_option + ' co -d "' + self.name
+ return self.cmd('cd "' + base + '" && CVSROOT="' + self.src + '" ' +
+ self.command() + quiet_option + ' co -d "' + self.name
+ '" "' + self.subpath + '"' )
def sync(self, base, quiet = False):
@@ -75,10 +73,10 @@ class CvsOverlay(Overlay):
quiet_option = ''
return self.cmd('cd "' + path([base, self.name]) + '" && ' +
- self.binary + quiet_option + ' update -d')
+ self.command() + quiet_option + ' update -d')
def supported(self):
'''Overlay type supported?'''
- return Overlay.supported(self, [(self.binary, 'cvs',
+ return Overlay.supported(self, [(self.command(), 'cvs',
'dev-util/cvs'),])
diff --git a/layman/overlays/darcs.py b/layman/overlays/darcs.py
index de23248..9604f6a 100644
--- a/layman/overlays/darcs.py
+++ b/layman/overlays/darcs.py
@@ -40,8 +40,6 @@ class DarcsOverlay(Overlay):
type = 'Darcs'
type_key = 'darcs'
- binary_command = '/usr/bin/darcs'
-
def __init__(self, xml, config, ignore = 0, quiet = False):
Overlay.__init__(self, xml, config, ignore)
@@ -51,7 +49,7 @@ class DarcsOverlay(Overlay):
self.supported()
- return self.cmd(self.binary_command + ' get --partial "' + self.src +
+ return self.cmd(self.command() + ' get --partial "' + self.src +
'/" "' + path([base, self.name]) + '"')
def sync(self, base, quiet = False):
@@ -60,10 +58,10 @@ class DarcsOverlay(Overlay):
self.supported()
return self.cmd('cd "' + path([base, self.name]) + '" && ' +
- self.binary_command + ' pull --all "' + self.src + '"')
+ self.command() + ' pull --all "' + self.src + '"')
def supported(self):
'''Overlay type supported?'''
- return Overlay.supported(self, [(self.binary_command, 'darcs',
+ return Overlay.supported(self, [(self.command(), 'darcs',
'dev-util/darcs'),])
diff --git a/layman/overlays/git.py b/layman/overlays/git.py
index ece0de3..c91938e 100644
--- a/layman/overlays/git.py
+++ b/layman/overlays/git.py
@@ -39,8 +39,6 @@ class GitOverlay(Overlay):
type = 'Git'
type_key = 'git'
- binary_command = '/usr/bin/git'
-
def __init__(self, xml, config, ignore = 0, quiet = False):
Overlay.__init__(self, xml, config, ignore)
@@ -59,7 +57,7 @@ class GitOverlay(Overlay):
slash = ''
if self.src.split(':')[0] == 'http':
slash = '/'
- return self.cmd(self.binary_command + ' clone ' + quiet_option + '"' + self.src + slash
+ return self.cmd(self.command() + ' clone ' + quiet_option + '"' + self.src + slash
+ '" "' + path([base, self.name]) + '"')
def sync(self, base, quiet = False):
@@ -73,10 +71,10 @@ class GitOverlay(Overlay):
quiet_option = ''
return self.cmd('cd "' + path([base, self.name]) + '" && '
- + self.binary_command + ' pull' + quiet_option)
+ + self.command() + ' pull' + quiet_option)
def supported(self):
'''Overlay type supported?'''
- return Overlay.supported(self, [(self.binary_command, 'git',
+ return Overlay.supported(self, [(self.command(), 'git',
'dev-util/git'),])
diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py
index 9e0c5e7..daa686c 100644
--- a/layman/overlays/mercurial.py
+++ b/layman/overlays/mercurial.py
@@ -40,8 +40,6 @@ class MercurialOverlay(Overlay):
type = 'Mercurial'
type_key = 'mercurial'
- binary_command = '/usr/bin/hg'
-
def __init__(self, xml, config, ignore = 0, quiet = False):
Overlay.__init__(self, xml, config, ignore)
@@ -51,7 +49,7 @@ class MercurialOverlay(Overlay):
self.supported()
- return self.cmd(self.binary_command + ' clone "' + self.src + '/" "' +
+ return self.cmd(self.command() + ' clone "' + self.src + '/" "' +
path([base, self.name]) + '"')
def sync(self, base, quiet = False):
@@ -60,10 +58,10 @@ class MercurialOverlay(Overlay):
self.supported()
return self.cmd('cd "' + path([base, self.name]) + '" && ' +
- self.binary_command + ' pull -u "' + self.src + '"')
+ self.command() + ' pull -u "' + self.src + '"')
def supported(self):
'''Overlay type supported?'''
- return Overlay.supported(self, [(self.binary_command, 'mercurial',
+ return Overlay.supported(self, [(self.command(), 'mercurial',
'dev-util/mercurial'),])
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 580ff47..4f245ec 100644
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -349,6 +349,9 @@ class Overlay:
return self.status == 'official'
+ def command(self):
+ return self.config['%s_command' % self.__class__.type_key]
+
#================================================================================
#
# Testing
diff --git a/layman/overlays/rsync.py b/layman/overlays/rsync.py
index 936a15d..f906817 100644
--- a/layman/overlays/rsync.py
+++ b/layman/overlays/rsync.py
@@ -39,11 +39,6 @@ class RsyncOverlay(Overlay):
type = 'Rsync'
type_key = 'rsync'
- binary = '/usr/bin/rsync'
-
- base = binary + ' -rlptDvz --progress --delete --delete-after ' + \
- '--timeout=180 --exclude="distfiles/*" --exclude="local/*" ' + \
- '--exclude="packages/*" '
def __init__(self, xml, config, ignore = 0, quiet = False):
@@ -68,11 +63,15 @@ class RsyncOverlay(Overlay):
else:
quiet_option = ''
- return self.cmd(self.base + quiet_option + '"' + self.src + '/" "' +
+ _command = self.command() + ' -rlptDvz --progress --delete --delete-after ' +\
+ '--timeout=180 --exclude="distfiles/*" --exclude="local/*" ' +\
+ '--exclude="packages/*" '
+
+ return self.cmd(_command + quiet_option + '"' + self.src + '/" "' +
path([base, self.name]) + '"')
def supported(self):
'''Overlay type supported?'''
- return Overlay.supported(self, [(self.binary, 'rsync',
+ return Overlay.supported(self, [(self.command(), 'rsync',
'net-misc/rsync'),])
diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index 6c41569..12a2b0c 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -39,8 +39,6 @@ class SvnOverlay(Overlay):
type = 'Subversion'
type_key = 'svn'
- binary = '/usr/bin/svn'
-
def __init__(self, xml, config, ignore = 0, quiet = False):
Overlay.__init__(self, xml, config, ignore)
@@ -57,7 +55,7 @@ class SvnOverlay(Overlay):
else:
quiet_option = ''
- return self.cmd(self.binary + ' co ' + quiet_option + '"' + self.src + '/" "' +
+ return self.cmd(self.command() + ' co ' + quiet_option + '"' + self.src + '/" "' +
path([base, self.name]) + '"')
def sync(self, base, quiet = False):
@@ -70,11 +68,11 @@ class SvnOverlay(Overlay):
else:
quiet_option = ''
- return self.cmd(self.binary + ' up ' + quiet_option + '"' + path([base, self.name]) +
+ return self.cmd(self.command() + ' up ' + quiet_option + '"' + path([base, self.name]) +
'"')
def supported(self):
'''Overlay type supported?'''
- return Overlay.supported(self, [(self.binary, 'svn',
+ return Overlay.supported(self, [(self.command(), 'svn',
'dev-util/subversion'),])
diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 26010e0..2ef69af 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -50,6 +50,7 @@ class TarOverlay(Overlay):
... self.subpath = 'layman-test'
... self.format = 'bz2'
... self.quiet = False
+ ... self.config = {'tar_command':'/bin/tar'}
>>> testdir = os.tmpnam()
>>> os.mkdir(testdir)
>>> a = DummyTar()
@@ -64,8 +65,6 @@ class TarOverlay(Overlay):
type = 'Tar'
type_key = 'tar'
- binary = u'/bin/tar'
-
def __init__(self, xml, config, ignore = 0, quiet = False):
Overlay.__init__(self, xml, config, ignore)
@@ -139,7 +138,7 @@ class TarOverlay(Overlay):
os.makedirs(target)
- result = self.cmd(self.binary + u' -v -x ' + opt + u' -f "' + pkg
+ result = self.cmd(self.command() + u' -v -x ' + opt + u' -f "' + pkg
+ u'" -C "' + target + u'"')
if self.subpath:
@@ -176,7 +175,7 @@ class TarOverlay(Overlay):
def supported(self):
'''Overlay type supported?'''
- return Overlay.supported(self, [(self.binary, 'tar', 'app-arch/tar'), ])
+ return Overlay.supported(self, [(self.command(), 'tar', 'app-arch/tar'), ])
if __name__ == '__main__':
import doctest