From 6a7cf195966b9d809a9fe005ef3547503c02776b Mon Sep 17 00:00:00 2001 From: dol-sen Date: Wed, 24 Aug 2011 06:48:33 -0700 Subject: rename local_list to installed, create an update function to migrate the change. --- etc/layman.cfg | 4 ++++ layman/argsparser.py | 4 ++-- layman/config.py | 5 +++-- layman/db.py | 44 +++++++++++++++++++++++++++++++++++--------- layman/makeconf.py | 10 +++++----- 5 files changed, 49 insertions(+), 18 deletions(-) diff --git a/etc/layman.cfg b/etc/layman.cfg index 7b8128f..2bb275a 100644 --- a/etc/layman.cfg +++ b/etc/layman.cfg @@ -13,6 +13,10 @@ cache : %(storage)s/cache #----------------------------------------------------------- # The list of locally installed overlays +installed: %(storage)s/installed.xml + +# old variable and value use it for updating to new one above + local_list: %(storage)s/overlays.xml #----------------------------------------------------------- diff --git a/layman/argsparser.py b/layman/argsparser.py index 8f0b45b..1cb71b3 100644 --- a/layman/argsparser.py +++ b/layman/argsparser.py @@ -62,8 +62,8 @@ class ArgsParser(BareConfig): >>> a['overlays'] '\\nhttp://www.gentoo.org/proj/en/overlays/repositories.xml' >>> sorted(a.keys()) - ['bzr_addopts', 'bzr_command', 'bzr_postsync', 'bzr_syncopts', 'cache', 'config', 'configdir', 'cvs_addopts', 'cvs_command', 'cvs_postsync', 'cvs_syncopts', 'darcs_addopts', 'darcs_command', 'darcs_postsync', 'darcs_syncopts', 'g-common_command', 'g-common_generateopts', 'g-common_postsync', 'g-common_syncopts', 'git_addopts', 'git_command', 'git_postsync', 'git_syncopts', 'local_list', 'make_conf', 'mercurial_addopts', 'mercurial_command', 'mercurial_postsync', 'mercurial_syncopts', 'nocheck', 'overlay_defs', 'overlays', 'proxy', 'quietness', 'rsync_command', 'rsync_postsync', 'rsync_syncopts', 'storage', 'svn_addopts', 'svn_command', 'svn_postsync', 'svn_syncopts', 't/f_options', 'tar_command', 'tar_postsync', 'umask', 'width'] - ''' + ['bzr_addopts', 'bzr_command', 'bzr_postsync', 'bzr_syncopts', 'cache', 'config', 'configdir', 'cvs_addopts', 'cvs_command', 'cvs_postsync', 'cvs_syncopts', 'darcs_addopts', 'darcs_command', 'darcs_postsync', 'darcs_syncopts', 'g-common_command', 'g-common_generateopts', 'g-common_postsync', 'g-common_syncopts', 'git_addopts', 'git_command', 'git_postsync', 'git_syncopts', 'installed', 'local_list', 'make_conf', 'mercurial_addopts', 'mercurial_command', 'mercurial_postsync', 'mercurial_syncopts', 'nocheck', 'overlay_defs', 'overlays', 'proxy', 'quietness', 'rsync_command', 'rsync_postsync', 'rsync_syncopts', 'storage', 'svn_addopts', 'svn_command', 'svn_postsync', 'svn_syncopts', 't/f_options', 'tar_command', 'tar_postsync', 'umask', 'width'] + ''' BareConfig.__init__(self, stdout=stdout, stderr=stderr, stdin=stdin) if args == None: diff --git a/layman/config.py b/layman/config.py index ff4bdd2..2af4069 100644 --- a/layman/config.py +++ b/layman/config.py @@ -79,7 +79,7 @@ class BareConfig(object): >>> a['overlays'] 'http://www.gentoo.org/proj/en/overlays/repositories.xml' >>> sorted(a.keys()) - ['bzr_addopts', 'bzr_command', 'bzr_postsync', 'bzr_syncopts', 'cache', 'config', 'configdir', 'cvs_addopts', 'cvs_command', 'cvs_postsync', 'cvs_syncopts', 'darcs_addopts', 'darcs_command', 'darcs_postsync', 'darcs_syncopts', 'g-common_command', 'g-common_generateopts', 'g-common_postsync', 'g-common_syncopts', 'git_addopts', 'git_command', 'git_postsync', 'git_syncopts', 'local_list', 'make_conf', 'mercurial_addopts', 'mercurial_command', 'mercurial_postsync', 'mercurial_syncopts', 'nocheck', 'nocolor', 'output', 'overlay_defs', 'overlays', 'proxy', 'quiet', 'quietness', 'rsync_command', 'rsync_postsync', 'rsync_syncopts', 'stderr', 'stdin', 'stdout', 'storage', 'svn_addopts', 'svn_command', 'svn_postsync', 'svn_syncopts', 't/f_options', 'tar_command', 'tar_postsync', 'umask', 'verbose', 'width'] + ['bzr_addopts', 'bzr_command', 'bzr_postsync', 'bzr_syncopts', 'cache', 'config', 'configdir', 'cvs_addopts', 'cvs_command', 'cvs_postsync', 'cvs_syncopts', 'darcs_addopts', 'darcs_command', 'darcs_postsync', 'darcs_syncopts', 'g-common_command', 'g-common_generateopts', 'g-common_postsync', 'g-common_syncopts', 'git_addopts', 'git_command', 'git_postsync', 'git_syncopts', 'installed', 'local_list', 'make_conf', 'mercurial_addopts', 'mercurial_command', 'mercurial_postsync', 'mercurial_syncopts', 'nocheck', 'nocolor', 'output', 'overlay_defs', 'overlays', 'proxy', 'quiet', 'quietness', 'rsync_command', 'rsync_postsync', 'rsync_syncopts', 'stderr', 'stdin', 'stdout', 'storage', 'svn_addopts', 'svn_command', 'svn_postsync', 'svn_syncopts', 't/f_options', 'tar_command', 'tar_postsync', 'umask', 'verbose', 'width'] >>> a.get_option('nocheck') True ''' @@ -90,6 +90,7 @@ class BareConfig(object): 'storage' : EPREFIX + '/var/lib/layman', 'cache' : '%(storage)s/cache', 'local_list': '%(storage)s/overlays.xml', + 'installed': '%(storage)s/installed.xml', 'make_conf' : '%(storage)s/make.conf', 'nocheck' : 'yes', 'proxy' : '', @@ -258,7 +259,7 @@ class OptionConfig(BareConfig): >>> a["configdir"] '/etc/test-dir' >>> sorted(a.keys()) - ['bzr_addopts', 'bzr_command', 'bzr_postsync', 'bzr_syncopts', 'cache', 'config', 'configdir', 'cvs_addopts', 'cvs_command', 'cvs_postsync', 'cvs_syncopts', 'darcs_addopts', 'darcs_command', 'darcs_postsync', 'darcs_syncopts', 'g-common_command', 'g-common_generateopts', 'g-common_postsync', 'g-common_syncopts', 'git_addopts', 'git_command', 'git_postsync', 'git_syncopts', 'local_list', 'make_conf', 'mercurial_addopts', 'mercurial_command', 'mercurial_postsync', 'mercurial_syncopts', 'nocheck', 'nocolor', 'output', 'overlay_defs', 'overlays', 'proxy', 'quiet', 'quietness', 'rsync_command', 'rsync_postsync', 'rsync_syncopts', 'stderr', 'stdin', 'stdout', 'storage', 'svn_addopts', 'svn_command', 'svn_postsync', 'svn_syncopts', 't/f_options', 'tar_command', 'tar_postsync', 'umask', 'verbose', 'width'] + ['bzr_addopts', 'bzr_command', 'bzr_postsync', 'bzr_syncopts', 'cache', 'config', 'configdir', 'cvs_addopts', 'cvs_command', 'cvs_postsync', 'cvs_syncopts', 'darcs_addopts', 'darcs_command', 'darcs_postsync', 'darcs_syncopts', 'g-common_command', 'g-common_generateopts', 'g-common_postsync', 'g-common_syncopts', 'git_addopts', 'git_command', 'git_postsync', 'git_syncopts', 'installed', 'local_list', 'make_conf', 'mercurial_addopts', 'mercurial_command', 'mercurial_postsync', 'mercurial_syncopts', 'nocheck', 'nocolor', 'output', 'overlay_defs', 'overlays', 'proxy', 'quiet', 'quietness', 'rsync_command', 'rsync_postsync', 'rsync_syncopts', 'stderr', 'stdin', 'stdout', 'storage', 'svn_addopts', 'svn_command', 'svn_postsync', 'svn_syncopts', 't/f_options', 'tar_command', 'tar_postsync', 'umask', 'verbose', 'width'] """ BareConfig.__init__(self) diff --git a/layman/db.py b/layman/db.py index 17453b8..49069b7 100644 --- a/layman/db.py +++ b/layman/db.py @@ -44,31 +44,57 @@ from layman.version import VERSION #------------------------------------------------------------------------------- class DB(DbBase): - ''' Handle the list of local overlays.''' + ''' Handle the list of installed overlays.''' def __init__(self, config): self.config = config self.output = config['output'] - self.path = config['local_list'] - self.output.debug("DB.__init__(): config['local_list'] = %s" % self.path, 3) + self.path = config['installed'] + self.output.debug("DB.__init__(): config['installed'] = %s" % self.path, 3) if config['nocheck']: ignore = 2 else: ignore = 1 - #quiet = int(config['quietness']) < 3 + # check and handle the name change + #if not os.access(self.path, os.F_OK): + # self.rename_db() DbBase.__init__(self, config, - paths=[config['local_list'], ], + paths=[config['installed'], ], ignore=ignore, ) self.output.debug('DB handler initiated', 6) + + def rename_db(self): + """small upgarde function to handle the name change + for the installed xml file""" + if os.access(self.config['local_list'], os.F_OK): + self.output.info("Automatic db rename, old name was: %s" + % self.config['local_list'],2) + try: + os.rename(self.config['local_list'], self.path) + self.output.info("Automatic db rename, new installed db " + "name is: %s" %self.path, 2) + self.output.notice('') + return + except OSError, err: + self.output.error("Automatic db rename failed:\n%s" %str(err)) + else: + self.output.info("Automatic db rename, failed access to: %s" + % self.config['local_list'],2) + self.output.die("Please check that /etc/layman.cfg is up" + " to date\nThen try running layman again.\n" + "You may need to rename the old 'local_list' config setting" + " to\nthe new 'installed' config setting's filename.\n") + + # overrider def _broken_catalog_hint(self): return '' @@ -82,7 +108,7 @@ class DB(DbBase): >>> write3 = os.tmpnam() >>> here = os.path.dirname(os.path.realpath(__file__)) >>> from layman.config import OptionConfig - >>> myoptions = {'local_list' : + >>> myoptions = {'installed' : ... here + '/tests/testfiles/global-overlays.xml', ... 'make_conf' : write2, ... 'nocheck' : 'yes', @@ -91,7 +117,7 @@ class DB(DbBase): >>> config = OptionConfig(myoptions) >>> config.set_option('quietness', 3) >>> a = DB(config) - >>> config.set_option('local_list', write) + >>> config.set_option('installed', write) >>> b = DB(config) >>> config['output'].set_colorize(False) @@ -161,7 +187,7 @@ class DB(DbBase): >>> write3 = os.tmpnam() >>> here = os.path.dirname(os.path.realpath(__file__)) >>> from layman.config import OptionConfig - >>> myoptions = {'local_list' : + >>> myoptions = {'installed' : ... here + '/tests/testfiles/global-overlays.xml', ... 'make_conf' : write2, ... 'nocheck' : 'yes', @@ -170,7 +196,7 @@ class DB(DbBase): >>> config = OptionConfig(myoptions) >>> config.set_option('quietness', 3) >>> a = DB(config) - >>> config.set_option('local_list', write) + >>> config.set_option('installed', write) >>> b = DB(config) >>> config['output'].set_colorize(False) diff --git a/layman/makeconf.py b/layman/makeconf.py index b6f5d90..9836a1a 100644 --- a/layman/makeconf.py +++ b/layman/makeconf.py @@ -36,7 +36,7 @@ class MakeConf: >>> import hashlib >>> write = os.tmpnam() >>> here = os.path.dirname(os.path.realpath(__file__)) - >>> config = {'local_list' : + >>> config = {'installed' : ... here + '/tests/testfiles/global-overlays.xml', ... 'make_conf' : here + '/tests/testfiles/make.conf', ... 'nocheck' : True, @@ -86,7 +86,7 @@ class MakeConf: >>> write = os.tmpnam() >>> here = os.path.dirname(os.path.realpath(__file__)) - >>> config = {'local_list' : + >>> config = {'installed' : ... here + '/tests/testfiles/global-overlays.xml', ... 'make_conf' : here + '/tests/testfiles/make.conf', ... 'nocheck' : True, @@ -114,7 +114,7 @@ class MakeConf: >>> write = os.tmpnam() >>> here = os.path.dirname(os.path.realpath(__file__)) - >>> config = {'local_list' : + >>> config = {'installed' : ... here + '/tests/testfiles/global-overlays.xml', ... 'make_conf' : here + '/tests/testfiles/make.conf', ... 'nocheck' : True, @@ -143,7 +143,7 @@ class MakeConf: Read the list of registered overlays from /etc/make.conf. >>> here = os.path.dirname(os.path.realpath(__file__)) - >>> config = {'local_list' : + >>> config = {'installed' : ... here + '/tests/testfiles/global-overlays.xml', ... 'make_conf' : here + '/tests/testfiles/make.conf', ... 'nocheck' : True, @@ -203,7 +203,7 @@ class MakeConf: >>> write = os.tmpnam() >>> here = os.path.dirname(os.path.realpath(__file__)) - >>> config = {'local_list' : + >>> config = {'installed' : ... here + '/tests/testfiles/global-overlays.xml', ... 'make_conf' : here + '/tests/testfiles/make.conf', ... 'nocheck' : True, -- cgit v1.2.3-1-g7c22