diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/export.py | 49 | ||||
-rwxr-xr-x | tools/upgrade/1.3/migrate_configs.py | 1 | ||||
-rwxr-xr-x | tools/upgrade/1.3/migrate_perms_to_mode.py | 20 |
3 files changed, 52 insertions, 18 deletions
diff --git a/tools/export.py b/tools/export.py index 0ea6df2af..bdb85de41 100755 --- a/tools/export.py +++ b/tools/export.py @@ -220,12 +220,12 @@ E.G. 1.2.0pre1 is a valid version. dryrun=options.dryrun) find_and_replace('solaris-ips/MANIFEST.bcfg2.header', 'set name=pkg.fmri value="pkg://bcfg2/bcfg2@', - 'set name=pkg.fmri value="pkg://bcfg2/bcfg2@%s"' % version, + 'set name=pkg.fmri value="pkg://bcfg2/bcfg2@%s"\n' % version, startswith=True, dryrun=options.dryrun) find_and_replace('solaris-ips/MANIFEST.bcfg2-server.header', 'set name=pkg.fmri value="pkg://bcfg2/bcfg2-server@', - 'set name=pkg.fmri value="pkg://bcfg2/bcfg2-server@%s"' % version, + 'set name=pkg.fmri value="pkg://bcfg2/bcfg2-server@%s"\n' % version, startswith=True, dryrun=options.dryrun) find_and_replace('solaris-ips/pkginfo.bcfg2', 'VERSION=', @@ -248,30 +248,49 @@ E.G. 1.2.0pre1 is a valid version. find_and_replace('misc/bcfg2-selinux.spec', 'Version:', 'Version: %s\n' % version_release, dryrun=options.dryrun) - if version_info['build'] == '': - find_and_replace('misc/bcfg2.spec', 'Release: ', - 'Release: 1\n', + if version_info['build'].startswith('rc'): + find_and_replace('misc/bcfg2.spec', 'global _rc ', + '%%global _rc %s\n' % version_info['build'], dryrun=options.dryrun) - find_and_replace('misc/bcfg2-selinux.spec', 'Release: ', - 'Release: 1\n', + find_and_replace('misc/bcfg2-selinux.spec', 'global _rc ', + '%%global _rc %s\n' % version_info['build'], + dryrun=options.dryrun) + elif version_info['build'].startswith('pre'): + find_and_replace('misc/bcfg2.spec', 'global _pre ', + '%%global _pre %s\n' % version_info['build'], + dryrun=options.dryrun) + find_and_replace('misc/bcfg2-selinux.spec', 'global _pre ', + '%%global _pre %s\n' % version_info['build'], dryrun=options.dryrun) else: + # comment out pre/rc + find_and_replace('misc/bcfg2.spec', 'global _pre ', + '#%%global _pre 2\n', + dryrun=options.dryrun) + find_and_replace('misc/bcfg2-selinux.spec', 'global _pre ', + '#%%global _pre 2\n', + dryrun=options.dryrun) + find_and_replace('misc/bcfg2.spec', 'global _rc ', + '#%%global _rc 1\n', + dryrun=options.dryrun) + find_and_replace('misc/bcfg2-selinux.spec', 'global _rc ', + '#%%global _rc 1\n', + dryrun=options.dryrun) + find_and_replace('misc/bcfg2.spec', 'Release: ', - 'Release: 0.%s.%s\n' % - (version_info['build'][-1], version_info['build']), + 'Release: 1%{?_pre_rc}%{?dist}\n', + startswith=True, dryrun=options.dryrun) find_and_replace('misc/bcfg2-selinux.spec', 'Release: ', - 'Release: 0.%s.%s\n' % - (version_info['build'][-1], version_info['build']), + 'Release: 1%{?_pre_rc}%{?dist}\n', + startswith=True, dryrun=options.dryrun) find_and_replace('misc/bcfg2.spec', '%setup', - '%%setup -q -n %%{name}-%%{version}%s\n' % - version_info['build'], + '%setup -q -n %{name}-%{version}%{?_pre_rc}\n', startswith=True, dryrun=options.dryrun) find_and_replace('misc/bcfg2-selinux.spec', '%setup', - '%%setup -q -n %%{name}-%%{version}%s\n' % - version_info['build'], + '%setup -q -n %{name}-%{version}%{?_pre_rc}\n', startswith=True, dryrun=options.dryrun) find_and_replace('misc/bcfg2.spec', 'BuildRoot', diff --git a/tools/upgrade/1.3/migrate_configs.py b/tools/upgrade/1.3/migrate_configs.py index 9fa362acf..547ce61e4 100755 --- a/tools/upgrade/1.3/migrate_configs.py +++ b/tools/upgrade/1.3/migrate_configs.py @@ -5,6 +5,7 @@ import sys from Bcfg2.Compat import ConfigParser import Bcfg2.Options + def copy_section(src_file, tgt_cfg, section, newsection=None): if newsection is None: newsection = section diff --git a/tools/upgrade/1.3/migrate_perms_to_mode.py b/tools/upgrade/1.3/migrate_perms_to_mode.py index 786df0de6..2dfb70388 100755 --- a/tools/upgrade/1.3/migrate_perms_to_mode.py +++ b/tools/upgrade/1.3/migrate_perms_to_mode.py @@ -3,13 +3,15 @@ import lxml.etree import os import sys - +from fnmatch import fnmatch +from Bcfg2.Compat import any # pylint: disable=W0622 +from Bcfg2.Server.FileMonitor import FileMonitor import Bcfg2.Options def setmodeattr(elem): """Set the mode attribute for a given element.""" - if elem.attrib.has_key('perms'): + if 'perms' in elem.attrib: elem.set('mode', elem.get('perms')) del elem.attrib['perms'] return True @@ -53,10 +55,16 @@ def convertstructure(structfile): writefile(structfile, xdata) +def skip_path(path): + return any(fnmatch(path, p) or fnmatch(os.path.basename(path), p) + for p in Bcfg2.Options.setup.ignore_files) + + def main(): parser = Bcfg2.Options.get_parser( description="Migrate from Bcfg2 1.2 'perms' attribute to 1.3 'mode' " - "attribute") + "attribute", + components=FileMonitor) parser.add_options([Bcfg2.Options.Common.repository, Bcfg2.Options.Common.plugins]) parser.parse() @@ -65,11 +73,17 @@ def main(): for plugin in Bcfg2.Options.setup.plugins: if plugin in ['Base', 'Bundler', 'Rules']: for root, _, files in os.walk(os.path.join(repo, plugin)): + if skip_path(root): + continue for fname in files: + if skip_path(fname): + continue convertstructure(os.path.join(root, fname)) if plugin not in ['Cfg', 'TGenshi', 'TCheetah', 'SSHbase', 'SSLCA']: continue for root, dirs, files in os.walk(os.path.join(repo, plugin)): + if skip_path(root): + continue for fname in files: if fname == 'info.xml': convertinfo(os.path.join(root, fname)) |