--- config-manager-0.3.orig/TODO +++ config-manager-0.3/TODO @@ -1,6 +1,5 @@ This is the TODO list for the python rewrite -build from string build from file build from http dont allow abspaths @@ -15,3 +14,12 @@ implement a front end ConfigEntry eq with bad types, or with different values add svn, cvs, tarball support back in. +map urls to other urls to allow local overrides; + requires a syntax for mapping files + and a ui to select one - all the other machinery is done. +map urls and try all variations in some order - giving us search paths. +map a full url to different url +map a prefix url to a result with the tail preserved. +adding a non-'str' mapping -> assertion (urls are all plain strings) +adding an empty length mapping -> assertion. +the longest matching prefix is chosen. --- config-manager-0.3.orig/bootstrap.sh +++ config-manager-0.3/bootstrap.sh @@ -11,8 +11,8 @@ # Autotool versions preferred. To override either edit the script # to match the versions you want to use, or set the variables on # the command line like "env acver=.. amver=... ./bootstrap.sh" -acversions="${acver:-2.58 2.57 2.53 2.52}" -amversions="${amver:-1.8 1.7 1.6 1.5}" +acversions="${acver:-2.59 2.58 2.57 2.53 2.52}" +amversions="${amver:-1.9 1.8 1.7 1.6 1.5}" check_version() { @@ -81,9 +81,9 @@ if grep m4_regex aclocal.m4 >/dev/null; then perl -i.bak -p -e 's/m4_patsubst/m4_bpatsubst/g; s/m4_regexp/m4_bregexp/g;' aclocal.m4 fi - bootstrap autoheader$acver - bootstrap libtoolize --automake - bootstrap automake$amver --foreign --add-missing + bootstrap autoheader$acver + bootstrap libtoolize --automake -c + bootstrap automake$amver --foreign --add-missing -c bootstrap autoconf$acver ); then : # OK else --- config-manager-0.3.orig/cm.py +++ config-manager-0.3/cm.py @@ -18,6 +18,12 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import sys + +import os.path +my_lib = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib') +if os.path.exists(os.path.join(my_lib, 'config_manager')): + sys.path.insert(0, my_lib) + from config_manager import main if __name__ == '__main__': --- config-manager-0.3.orig/lib/config_manager/__init__.py +++ config-manager-0.3/lib/config_manager/__init__.py @@ -21,27 +21,40 @@ from shutil import rmtree import sys import urllib +import config_manager.implementations from config_manager.optparse import (OptionParser, Sequence, StringArgument, TerminalElement, ArgumentValueError, Optional) -fake_builds = [] fake_updates = [] +class UnsupportedScheme(KeyError): + """A specific URL scheme is not supported.""" + +def test_suite(): + import config_manager.tests + result = config_manager.tests.tests.TestSuite() + result.addTest(config_manager.implementations.test_suite()) + result.addTest(config_manager.tests.test_suite()) + return result + class Config(object): """A configurationof recipe.""" _re_config_line = re.compile("^(#.*)|(([^\s]+)\s+([^\s]+)|\s*)$") # comment is 0, path 2, source 3 - def __init__(self, fromStream=None): + def __init__(self, fromStream=None, override_mapper=None): self._entries = {} + self._override_mapper = override_mapper if fromStream is not None: # parsing might be better in a factory ? for line in fromStream.readlines(): groups = self._re_config_line.match(line).groups() if groups[2] and groups[3]: - self.add_entry(ConfigEntry(groups[2], groups[3])) + self.add_entry(ConfigEntry(groups[2], + groups[3], + self._override_mapper)) def add_entry(self, entry): assert (entry.path not in self._entries) @@ -83,11 +96,124 @@ except AttributeError: return False - def __init__(self, relative_path, url): - """Construct a ConfigEntry for the provided path and url.""" + def __init__(self, relative_path, url, override_mapper=None): + """Construct a ConfigEntry for the provided path and url. + + If an override_mapper is provided, it should be a URLMapper and is + used to establish local overrides for url. + """ self.path = relative_path self.url = url + if override_mapper is not None: + self.url = override_mapper.map(url) + + def _build_arch_url(self, path): + import pybaz + pybaz.get(self.url[7:], os.path.join(path, self.path)) + + def _build_cvs_url(self, path): + if self.url.startswith("pserver://"): + scheme=":pserver:" + url=self.url[10:] + elif self.url.startswith("ext://"): + scheme=":ext:" + url=self.url[6:] + else: + raise ValueError, "CVS scheme not recognised: '%s'" % self.url + module=os.path.basename(url) + repo=os.path.dirname(url) + print "cvs -d %s%s checkout -d %s %s" % (scheme, repo, self.path, module) + os.system("cvs -d %s%s checkout -d %s %s" % (scheme, repo, self.path, module)) + + def _build_svn_url(self, path): + if self.url.startswith("svn://") or self.url.startswith("svn+ssh://"): + url = self.url + else: + url = self.url[4:] + print "svn checkout %s %s" % (url, os.path.normpath(os.path.join(path, self.path))) + os.system("svn checkout %s %s" % (url, os.path.normpath(os.path.join(path, self.path)))) + + def _build_pybaz_name(self, path): + import pybaz + try: + # try as registered name + pybaz.get(self.url, os.path.join(path, self.path)) + return True + except pybaz.errors.ExecProblem, e: + rmtree(os.path.join(path, self.path), ignore_errors=True) + except pybaz.errors.NamespaceError: + return False + + def _build_pybaz_url(self, path): + import pybaz + try: + lastslash = self.url.rfind('/') + url = self.url[:lastslash] + version = self.url[lastslash:] + archive = str(pybaz.register_archive(None, url)) + pybaz.get(archive + version, os.path.join(path, self.path)) + return True + except pybaz.errors.ExecProblem: + rmtree(os.path.join(path, self.path), ignore_errors=True) + + def _build_bzr_url(self, path): + try: + import errno + from bzrlib.merge import merge + from bzrlib.branch import (Branch, + DivergedBranches, + NotBranchError, + NoSuchRevision) + from bzrlib.clone import copy_branch + + revision = [None] + from_location = self.url + to_location = os.path.join(path, self.path) + + #if from_location.startswith("file://"): + # from_location = from_location[7:] + + try: + br_from = Branch.open(from_location) +# we should catch all and report this type as not supported on that url. + except NotBranchError: + return False + + os.mkdir(to_location) + copy_branch(br_from, to_location, None, None) + return True + except Exception, e: + print "%r" % e, e +# bare except because I havn't tested a bad url yet. + return False + + def get_implementations(self): + """Get the implementations represented by the url in this entry.""" + for scheme, implementations in \ + config_manager.implementations.schemes.items(): + if self.url.startswith(scheme): + return implementations + raise UnsupportedScheme + + def _update_bzr(self, path): + from bzrlib.branch import Branch + from bzrlib.errors import DivergedBranches, NotBranchError + path = os.path.join(path, self.path) + try: + br_to = Branch.open(path) + except NotBranchError: + return False + br_from = Branch.open(self.url) + try: + br_to.working_tree().pull(br_from) + return True + except DivergedBranches: + print "Branch %s has diverged from %s - you need to merge." % ( + path, self.url) + raise RuntimeError("Failed to update.") + return False + def build(self, path): """Build this element from root path.""" ## FIXME: the C++ version uses a ConfigSource to abstract out @@ -99,64 +225,39 @@ ", its parent does not exists" % target) # protocol specific urls if self.url.startswith("arch://"): - import pybaz - pybaz.get(self.url[7:], os.path.join(path, self.path)) + self._build_arch_url(path) elif self.url.startswith("fake://"): - os.mkdir(os.path.join(path, self.path)) - fake_builds.append((self.url, os.path.join(path, self.path))) + implementations = self.get_implementations() + for implementation in implementations: + if implementation.checkout(self.url, target): + return + elif self.url.startswith("svn"): + self._build_svn_url(path) + elif self.url.startswith("pserver://"): + self._build_cvs_url(path) + elif self.url.startswith("ext://"): + self._build_cvs_url(path) else: # autodetect urls # - try: - import pybaz - lastslash = self.url.rfind('/') - url = self.url[:lastslash] - version = self.url[lastslash:] - archive = str(pybaz.register_archive(None, url)) - pybaz.get(archive + version, os.path.join(path, self.path)) - except pybaz.errors.ExecProblem: - rmtree(os.path.join(path, self.path), ignore_errors=True) - try: - import errno - from bzrlib.merge import merge - from bzrlib.branch import DivergedBranches, NoSuchRevision, \ - find_cached_branch, Branch - from bzrlib.meta_store import CachedStore - import tempfile - cache_root = tempfile.mkdtemp() - - revision = [None] - from_location = self.url - to_location = os.path.join(path, self.path) - - if from_location.startswith("file://"): - from_location = from_location[7:] - - try: - try: - br_from = find_cached_branch(from_location, cache_root) -# we should catch all and report this type as not supported on that url. - except OSError, e: - if e.errno == errno.ENOENT: - raise BzrCommandError('Source location "%s" does not' - ' exist.' % from_location) - else: - raise + if self._build_pybaz_name(path): + return + elif self._build_pybaz_url(path): + return + elif self._build_bzr_url(path): + return + else: + raise ValueError("unknown url type '%s'" % self.url) - os.mkdir(to_location) - br_to = Branch(to_location, init=True) - br_to.set_root_id(br_from.get_root_id()) - br_to.update_revisions(br_from, stop_revision=br_from.revno()) - merge((to_location, -1), (to_location, 0), this_dir=to_location, - check_clean=False, ignore_zero=False) - from_location = pull_loc(br_from) - br_to.controlfile("x-pull", "wb").write(from_location + "\n") - finally: - rmtree(cache_root) - except Exception, e: - print "%r" % e, e -# bare except because I havn't tested a bad url yet. - raise ValueError("unknown url type '%s'" % self.url) + def _update_pybaz(self, path): + import pybaz + try: + tree = pybaz.WorkingTree(os.path.join(path, self.path)) + # if not tree.version == self.url[7:] ... wrong version + tree.update() + except pybaz.errors.SourceTreeError: + return False + return True def update(self, path): """Update this entry (from root path).""" @@ -177,6 +278,30 @@ tree.update() elif self.url.startswith("fake://"): fake_updates.append((self.url, os.path.join(path, self.path))) + elif self.url.startswith("svn"): + print "svn update %s" % (os.path.normpath(os.path.join(path, self.path)),) + os.system("svn update %s" % (os.path.normpath(os.path.join(path, self.path)),)) + elif self.url.startswith("pserver://") or self.url.startswith("ext://"): + # XXX: duplicated from build() above. Remove when refactored + # into separate classes. + if self.url.startswith("pserver://"): + scheme=":pserver:" + url=self.url[10:] + elif self.url.startswith("ext://"): + scheme=":ext:" + url=self.url[6:] + else: + raise ValueError, "CVS scheme not recognised: '%s'" % self.url + + module=os.path.basename(url) + repo=os.path.dirname(url) + print "cd %s && cvs -d %s%s update -Pd" % (self.path, scheme, repo) + os.system("cd %s && cvs -d %s%s update -Pd" % (self.path, scheme, repo)) + # autodetection + elif self._update_pybaz(path): + return + elif self._update_bzr(path): + return else: raise ValueError("unknown url type '%s'" % self.url) @@ -184,7 +309,8 @@ class CommandArgument(StringArgument): def rule(self): - return "COMMAND" + return "build|show|update" + class UrlArgument(StringArgument): @@ -221,3 +347,32 @@ return 0 +class URLMapper(object): + """A mapping between urls that works with prefixes.""" + + def add_map(self, from_url, to_url): + """Add a mapping rule from from_url to to_url. + + Note that URLs are by definition non-empty ascii strings. + """ + self._rules[from_url] = to_url + + def __eq__(self, other): + return self._rules == other._rules + + def __init__(self): + self._rules = {} + + def map(self, url): + """Map url to produce a new url. + + If no mapping is defined, url is returned. + """ + rules = self._rules.items() + for prefix, replacement in rules: + if url == prefix: + return replacement + if url.startswith(prefix) and url[len(prefix)] == '/': + # valid prefix + return replacement + url[len(prefix):] + return url --- config-manager-0.3.orig/lib/config_manager/tests/__init__.py +++ config-manager-0.3/lib/config_manager/tests/__init__.py @@ -47,25 +47,31 @@ os.mkdir(self.bzr_tree) print >>open(os.path.join(self.bzr_tree, "broom"), "w"), "stick" from bzrlib.branch import Branch - from bzrlib.add import smart_add + from bzrlib.add import smart_add_tree branch = Branch.initialize(self.bzr_tree) - smart_add([self.bzr_tree], False) - branch.commit("a message", verbose=False) + smart_add_tree(branch.working_tree(), [self.bzr_tree], True) + branch.working_tree().commit("a message", verbose=False) os.mkdir(os.path.join(self.tempdir, "build1")) + from config_manager.implementations.fake_vcs import fake_builds + del fake_builds[:] def tearDown(self): - from config_manager import fake_builds, fake_updates + from config_manager import fake_updates + from config_manager.implementations.fake_vcs import fake_builds shutil.rmtree(self.tempdir, ignore_errors=True) - while fake_builds: fake_builds.pop() + del fake_builds[:] while fake_updates: fake_updates.pop() + def test_suite(): import test_config import test_config_entry import test_main + import test_url_mapping result = tests.TestSuite() result.addTest(test_config.test_suite()) result.addTest(test_config_entry.test_suite()) result.addTest(test_main.test_suite()) + result.addTest(test_url_mapping.test_suite()) return result --- config-manager-0.3.orig/lib/config_manager/tests/test_config.py +++ config-manager-0.3/lib/config_manager/tests/test_config.py @@ -62,16 +62,28 @@ config = config_manager.Config(fromStream=stream) self.assertEqual(config.get_entries(), {"./project/lib": entry}) + def test_new_from_stream_with_mapper(self): + mapper = config_manager.URLMapper() + mapper.add_map("arch://foo", "file:///foo") + stream = StringIO("./project arch://foo\n" + "./project/lib file:///foo/bar\n") + entry1 = config_manager.ConfigEntry("./project", "file:///foo") + entry2 = config_manager.ConfigEntry("./project/lib", "file:///foo/bar") + config = config_manager.Config(fromStream=stream, override_mapper=mapper) + self.assertEqual(config.get_entries(), {"./project": entry1, + "./project/lib": entry2}) + + class FunctionalTestConfig(FunctionalTestCase): def test_build_fake(self): """Test that doing a build works.""" + from config_manager.implementations.fake_vcs import fake_builds config = config_manager.Config() config.add_entry (config_manager.ConfigEntry("nested", "fake://anarchive@example.com/foo--0")) config.build(self.tempdir) - from config_manager import fake_builds self.assertEqual(fake_builds, [("fake://anarchive@example.com/foo--0", os.path.join( self.tempdir, @@ -85,7 +97,7 @@ config.build(self.tempdir) config.update(self.tempdir) - from config_manager import fake_builds, fake_updates + from config_manager import fake_updates self.assertEqual(fake_updates, [("fake://anarchive@example.com/foo--0", os.path.join( self.tempdir, --- config-manager-0.3.orig/lib/config_manager/tests/test_config_entry.py +++ config-manager-0.3/lib/config_manager/tests/test_config_entry.py @@ -22,6 +22,7 @@ # if this fails to import, then the config_manager module is bust # and this test script will never be reached to be imported import config_manager +import config_manager.implementations as implementations from config_manager.tests import FunctionalTestCase import os @@ -45,10 +46,38 @@ entry2 = config_manager.ConfigEntry("./foo", "svn:///bar") self.assertEqual(entry1, entry2) + def test_get_implementations_fake(self): + # fake:// is always available + entry1 = config_manager.ConfigEntry("./foo", "fake:///bar") + expected_implementations = implementations.schemes["fake"] + self.assertEqual(expected_implementations, entry1.get_implementations()) + + def test_unknown_scheme(self): + self.failIf("unknownscheme" in implementations.schemes) + entry1 = config_manager.ConfigEntry("./foo", "unknownscheme:///bar") + self.assertRaises(config_manager.UnsupportedScheme, + entry1.get_implementations) + + def test_mapped_creation(self): + mapper = config_manager.URLMapper() + mapper.add_map("svn:///bar", "fake://for-real") + entry = config_manager.ConfigEntry("./foo", "svn:///bar/gam", mapper) + self.assertEqual(entry.path, "./foo") + self.assertEqual(entry.url, "fake://for-real/gam") + + class FunctionalConfigEntryTest(FunctionalTestCase): + def test_build_arch_from_name(self): + """Test that doing an arch name version based build works.""" + entry = config_manager.ConfigEntry("nested", "anarchive@example.com/foo--0") + entry.build(os.path.join(self.tempdir, "build1")) + self.assertEqual(open( + os.path.join(self.tempdir, "build1", "nested", "proof"), "r").read(), + "yo\n") + def test_build_arch_version(self): - """Test that doing an arch version based build works.""" + """Test that doing an arch url version based build works.""" entry = config_manager.ConfigEntry("nested", "arch://anarchive@example.com/foo--0") entry.build(os.path.join(self.tempdir, "build1")) self.assertEqual(open( @@ -62,6 +91,14 @@ self.failIf(os.path.exists( os.path.join(self.tempdir, "build1", "nested", "proof"))) + def test_update_arch_from_name(self): + entry = config_manager.ConfigEntry("nested", + "arch://anarchive@example.com/foo--0--base-0") + entry.build(os.path.join(self.tempdir, "build1")) + entry = config_manager.ConfigEntry("nested", + "anarchive@example.com/foo--0") + entry.update(os.path.join(self.tempdir, "build1")) + def test_update_arch_version(self): entry = config_manager.ConfigEntry("nested", "arch://anarchive@example.com/foo--0--base-0") @@ -72,10 +109,10 @@ def test_build_fake_version(self): """Test doing a fake:// based build works.""" + from config_manager.implementations.fake_vcs import fake_builds entry = config_manager.ConfigEntry("nested", "fake://anarchive@example.com") entry.build(os.path.join(self.tempdir, "build1")) - from config_manager import fake_builds self.assertEqual(fake_builds, [("fake://anarchive@example.com", os.path.join(self.tempdir, "build1", "nested"))]) @@ -93,10 +130,11 @@ def test_update_fake_missing_dir(self): """Test doing a fake:// based update falls back to a build.""" + from config_manager import fake_updates + from config_manager.implementations.fake_vcs import fake_builds entry = config_manager.ConfigEntry("nested", "fake://anarchive@example.com") entry.update(os.path.join(self.tempdir, "build1")) - from config_manager import fake_builds, fake_updates self.assertEqual(fake_builds, [("fake://anarchive@example.com", os.path.join(self.tempdir, "build1", "nested"))]) @@ -112,7 +150,7 @@ os.path.join(self.tempdir, "build1", "nested", "proof"), "r").read(), "yo\n") - def disabled_test_file_url_with_baz2(self): + def test_file_url_with_baz2(self): """Test building a file url that is actually a baz2 branch.""" basepath = self.tempdir.replace('\\', '/') entry = config_manager.ConfigEntry("nested", @@ -122,6 +160,17 @@ os.path.join(self.tempdir, "build1", "nested", "broom"), "r").read(), "stick\n") + def test_file_url_update_with_baz2(self): + basepath = self.tempdir.replace('\\', '/') + entry = config_manager.ConfigEntry("nested", + "file://" + basepath + "/bzr") + entry.build(os.path.join(self.tempdir, "build1")) + # FIXME: should update against something else for completeness + entry.update(os.path.join(self.tempdir, "build1")) + self.assertEqual(open( + os.path.join(self.tempdir, "build1", "nested", "broom"), "r").read(), + "stick\n") + def test_build_absent_path(self): """Test that building fails when a path component is missing.""" entry = config_manager.ConfigEntry("missing/nested", @@ -132,7 +181,6 @@ def test_suite(): - result = tests loader = tests.TestLoader() result = loader.loadTestsFromName(__name__) return result --- config-manager-0.3.orig/lib/config_manager/tests/test_main.py +++ config-manager-0.3/lib/config_manager/tests/test_main.py @@ -39,7 +39,7 @@ def test_rule(self): from config_manager import CommandArgument - self.assertEqual("COMMAND", CommandArgument().rule()) + self.assertEqual("build|show|update", CommandArgument().rule()) class TestUrlArgument(unittest.TestCase): @@ -80,7 +80,7 @@ def test_help(self): result = self.run_config_manager(["cm.py", "--help"]) self.assertEqual(result, 0) - self.assertEqual("usage: cm [options] COMMAND [url]\n" + self.assertEqual("usage: cm [options] build|show|update [url]\n" "\n" "options:\n" " -h, --help show this help message and exit\n", @@ -90,7 +90,7 @@ """If no options or arguments are given, print usage.""" result = self.run_config_manager(["cm.py"]) self.assertEqual(result, 0) - self.assertEqual("usage: cm [options] COMMAND [url]\n\n", + self.assertEqual("usage: cm [options] build|show|update [url]\n\n", self.captured_out.getvalue()) def test_show_config(self): @@ -116,22 +116,22 @@ def test_build_config(self): import shutil - shutil.rmtree("foo") - shutil.rmtree("bar") + from config_manager.implementations.fake_vcs import fake_builds + shutil.rmtree("foo", ignore_errors=True) + shutil.rmtree("bar", ignore_errors=True) result = self.run_config_manager(["cm.py", "build"], "./foo fake://foo@example.com/bar--gam--0\n" "./bar fake://host.example.com/something\n") self.assertEqual(result, 0) self.assertEqual("", self.captured_out.getvalue()) - from config_manager import fake_builds self.assertEqual(fake_builds, [("fake://host.example.com/something", os.path.join( os.path.abspath(os.curdir), - "./bar")), + "bar")), ("fake://foo@example.com/bar--gam--0", os.path.join( os.path.abspath(os.curdir), - "./foo"))]) + "foo"))]) def test_update_config(self): import shutil --- config-manager-0.3.orig/setup.py +++ config-manager-0.3/setup.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#!/usr/bin/python2.4 # This is an installation script for cm. Run it with # './setup.py install', or --- config-manager-0.3.orig/test_all.py +++ config-manager-0.3/test_all.py @@ -78,8 +78,8 @@ def test_suite(): result = TestSuite() - import config_manager.tests - result.addTest(config_manager.tests.test_suite()) + import config_manager + result.addTest(config_manager.test_suite()) return result --- config-manager-0.3.orig/libgetopt/COPYING +++ config-manager-0.3/libgetopt/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. --- config-manager-0.3.orig/libgetopt/ChangeLog +++ config-manager-0.3/libgetopt/ChangeLog @@ -0,0 +1,382 @@ +2003-12-10 20:45:32 GMT Robert Collins patch-17 + + Summary: + bump library version + Revision: + libgetoptplusplus--own-getopt--1.0--patch-17 + + + modified files: + Makefile.am src/OptionSet.cc + + +2003-12-10 13:14:39 GMT Robert Collins patch-16 + + Summary: + extract argumentless parsing logic + Revision: + libgetoptplusplus--own-getopt--1.0--patch-16 + + + modified files: + include/getopt++/OptionSet.h src/OptionSet.cc + + +2003-12-10 12:25:55 GMT Robert Collins patch-15 + + Summary: + simplify logic by consolidating Process calls in OptionSet::doOption + Revision: + libgetoptplusplus--own-getopt--1.0--patch-15 + + + modified files: + src/OptionSet.cc + + +2003-12-10 12:24:22 GMT Robert Collins patch-14 + + Summary: + move option value passing out of the direct path of option processing + Revision: + libgetoptplusplus--own-getopt--1.0--patch-14 + + + modified files: + src/OptionSet.cc + + +2003-12-10 12:21:32 GMT Robert Collins patch-13 + + Summary: + return actual Option results + Revision: + libgetoptplusplus--own-getopt--1.0--patch-13 + + + modified files: + src/OptionSet.cc + + +2003-12-10 12:19:39 GMT Robert Collins patch-12 + + Summary: + extract OptionSet::findOption + Revision: + libgetoptplusplus--own-getopt--1.0--patch-12 + + + modified files: + include/getopt++/OptionSet.h src/OptionSet.cc + + +2003-12-10 12:14:36 GMT Robert Collins patch-11 + + Summary: + make OptionSet::processOne() return void + Revision: + libgetoptplusplus--own-getopt--1.0--patch-11 + + + modified files: + include/getopt++/OptionSet.h src/OptionSet.cc + + +2003-12-10 12:10:42 GMT Robert Collins patch-10 + + Summary: + extract method OptionSet::doOption + Revision: + libgetoptplusplus--own-getopt--1.0--patch-10 + + + modified files: + include/getopt++/OptionSet.h src/OptionSet.cc + + +2003-12-10 11:57:05 GMT Robert Collins patch-9 + + Summary: + extract method OptionSet::isOption + Revision: + libgetoptplusplus--own-getopt--1.0--patch-9 + + + modified files: + include/getopt++/OptionSet.h src/OptionSet.cc + + +2003-12-10 11:48:31 GMT Robert Collins patch-8 + + Summary: + eliminate passed in self reference to OptionSet::processOne + Revision: + libgetoptplusplus--own-getopt--1.0--patch-8 + + + modified files: + include/getopt++/OptionSet.h src/OptionSet.cc + + +2003-12-10 11:36:01 GMT Robert Collins patch-7 + + Summary: + remove OptionState class + Revision: + libgetoptplusplus--own-getopt--1.0--patch-7 + + + modified files: + include/getopt++/OptionSet.h src/OptionSet.cc + + +2003-12-10 11:32:33 GMT Robert Collins patch-6 + + Summary: + remove OptionStateFinder class + Revision: + libgetoptplusplus--own-getopt--1.0--patch-6 + + + modified files: + src/OptionSet.cc + + +2003-12-10 06:52:51 GMT Robert Collins patch-5 + + Summary: + use up option values that are in the next argv slot + Revision: + libgetoptplusplus--own-getopt--1.0--patch-5 + + + modified files: + src/OptionSet.cc + + +2003-12-10 06:47:33 GMT Robert Collins patch-4 + + Summary: + support step by step parsing - using non options to switch 'mode' + Revision: + libgetoptplusplus--own-getopt--1.0--patch-4 + + + modified files: + include/getopt++/OptionSet.h src/OptionSet.cc + tests/OptionSet.cc + + +2003-12-10 04:37:57 GMT Robert Collins patch-3 + + Summary: + deprecate the DefaultOptionSet approach for chaining options + Revision: + libgetoptplusplus--own-getopt--1.0--patch-3 + + + modified files: + include/getopt++/BoolOption.h include/getopt++/Option.h + include/getopt++/OptionSet.h include/getopt++/StringOption.h + src/BoolOption.cc src/OptionSet.cc src/StringOption.cc + tests/BoolOptionTest.cc tests/OptionSet.cc tests/testoption.cc + + +2003-12-10 04:01:28 GMT Robert Collins patch-2 + + Summary: + remove getopt logic + Revision: + libgetoptplusplus--own-getopt--1.0--patch-2 + + + removed files: + include/.arch-ids/cdefs.h.id include/.arch-ids/getopt.h.id + include/cdefs.h include/getopt.h src/.arch-ids/getopt.c.id + src/getopt.c + + modified files: + Makefile.am configure.in include/getopt++/DefaultFormatter.h + include/getopt++/OptionSet.h include/getopt++/StringOption.h + src/BoolOption.cc src/StringOption.cc + + +2003-12-10 03:50:09 GMT Robert Collins patch-1 + + Summary: + add test case, and reimplement getopt from scratch + Revision: + libgetoptplusplus--own-getopt--1.0--patch-1 + + + new files: + tests/.arch-ids/OptionSet.cc.id tests/OptionSet.cc + + modified files: + Makefile.am include/getopt++/BoolOption.h + include/getopt++/DefaultFormatter.h include/getopt++/Option.h + include/getopt++/OptionSet.h include/getopt++/StringOption.h + src/BoolOption.cc src/OptionSet.cc src/StringOption.cc + + +2003-12-09 06:32:21 GMT Robert Collins base-0 + + Summary: + initial import + Revision: + libgetoptplusplus--own-getopt--1.0--base-0 + + + (automatically generated log message) + + new files: + COPYING ChangeLog Makefile.am README bootstrap.sh configure.in + include/cdefs.h include/getopt++/BoolOption.h + include/getopt++/DefaultFormatter.h + include/getopt++/GetOption.h include/getopt++/Option.h + include/getopt++/OptionSet.h include/getopt++/StringOption.h + include/getopt.h src/BoolOption.cc src/GetOption.cc + src/Option.cc src/OptionSet.cc src/StringOption.cc + src/getopt.c tests/BoolOptionTest.cc tests/optioniterator.cc + tests/testoption.cc + + +2003-11-16 Robert Collins + + * src/OptionSet.cc (OptionSet::Process): Call the default optionset + if one is supplied and no options are in the default. + +2003-03-19 Robert Collins + + * configure.in: Bump version number. + * Makefile.am: Add DefaultFormatter.h to installed files. + * src/OptionSet.cc (OptionSet::ParameterUsage): Use new + default DefaultFormatter to format parameters. + * include/getopt++/OptionSet.h: Update copyright. + * include/getopt++/DefaultFormatter.h: Format the help from an Option. + * tests/testoption.cc: Include a -h|--help option to test help + formatting. + Insert copyright statement. + * tests/optioniterator.cc: Insert copyright statement. + +2003-03-18 Robert Collins + + * include/getopt++/OptionSet.h (OptionSet): Convert to use a vector. + * src/OptionSet.cc: Convert array to vector use throughout. + (OptionSet::optionsInSet): Implement external access to the available + options. + +2003-03-10 Max Bowsher + + * Makefile.am: Add foreign to AUTOMAKE_OPTIONS. + +2003-03-09 Max Bowsher + + * bootstrap.sh: Add sanity check of current directory. + +2002-11-29 Max Bowsher + + * .cvsignore: Create, for files generated by bootstrap.sh + * include/.cvsignore: Ditto, for subdir. + +2002-11-10 Robert Collins + + * src/getopt.c: Only use our cdefs.h if the OS doesn't have one. + * Makefile.am: Only compile our getopt.h if the OS doesn't provide + getopt.h. + * configure.in: Ditto. + * tests/testoption.cc: Update for GCC-3. + +2002-11-04 Max Bowsher + + * include/getopt++/BoolOption.h: Add 'std::' where needed. + * include/getopt++/Option.h: Ditto. + * include/getopt++/OptionSet.h: Ditto. + * include/getopt++/StringOption.h: Ditto. + * src/BoolOption.cc: Add 'using namespace std;'. + * src/OptionSet.cc: Ditto. + * src/StringOption.cc: Ditto. + +2002-11-04 Max Bowsher + + * Makefile.am (libgetopt++_la_LDADD): Remove -lstd++, it is only needed + for broken g++ specs on some platforms. + +2002-06-08 Robert Collins + + * Makefile.am: Correct Version requirement syntax. + +2002-04-23 Robert Collins + + * include/cdefs.h: New file, support for getopt.h. + * include/getopt.h: New file, for platforms without getopt.h. + * src/getopt.c: New file, implementation of getopt. + * COPYING: New file, GPL v2 text. + * Makefile.am: Change AM_CXXFLAGS to INCLUDES. + Add getopt.c to the library source. + Add new headers to the source list. + * configure.in: Remove unneeded macro calls. + * include/getopt++/StringOption.h: Change String to string throughout. + * src/StringOption.cc: Ditto. + * include/getopt++/BoolOption.h: Ditto. + * src/BoolOption.cc: Ditto. + * src/OptionSet.cc: Ditto. + * include/getopt++/Option.h: Ditto. + Remove String++ includes, it's not needed anymore. + * include/getopt++/OptionSet.h: Make the destructor virtual. + +2002-04-23 Robert Collins + + * src/OptionSet.cc (OptionSet::ParameterUsage): Line-break long + help text. + +2002-04-20 Robert Collins + + * Makefile.am (libgetopt___la_SOURCES): Add OptionSet.cc and + StringOption.cc for new functionality. + (getoptinclude_HEADERS): Install the new headers. + * include/getopt++/BoolOption.h (BoolOption::shortOption): Change + to align with new Option header. + * include/getopt++/Option.h (Option::shortOption): Change to allow + short options with arguments. + * include/getopt++/OptionSet.h: Implement ParameterUsage to show + program options. + Change Process to include a fallback OptionSet - for picking up + non-option arguments. + * include/getopt++/StringOption.h: New file. + * src/BoolOption.cc (BoolOption::shortOption): Change as per the header. + * src/OptionSet.cc (OptionSet::Process): Pass on umnparameterised + arguments. + (OptionSet::ParameterUsage): Implement. + * src/StringOption.cc: New file. + +2002-04-14 Robert Collins + + * include/BoolOption.h: Move to + * include/getopt++/BoolOption.h: here. + * include/GetOption.h: Implement multiple-sets as per design. + Move to ... + * include/getopt++/GetOption.h: here. + * include/Option.h: Move to + * include/getopt++/Option.h: here. + * include/getopt++/OptionSet.h: New file. + * src/GetOption.cc: Move core functions to OptionSet.cc. + Adjust for new header locations. + * src/OptionSet.cc: New file. + * src/BoolOption.cc: Adjust for new header locations. + * src/Option.cc: Adjust for new header locations. + * tests/testoption.cc: Adjust for new header locations. + +2002-04-14 Robert Collins + + * Makefile.am: New file. + * README: New file. + * bootstrap.sh: New file. + * configure.in: New file. + * include/BoolOption.h: New file. + * include/GetOption.h: New file. + * include/Option.h: New file. + * src/BoolOption.cc: New file. + * src/GetOption.cc: New file. + * src/Option.cc: New file. + * tests/testoption.cc: New file. --- config-manager-0.3.orig/libgetopt/Makefile.am +++ config-manager-0.3/libgetopt/Makefile.am @@ -0,0 +1,46 @@ +## Process this file with automake to produce Makefile.in +# +# $Id: Makefile.am,v 1.12 2003/12/10 20:51:44 rbcollins Exp $ +# + +AUTOMAKE_OPTIONS = dist-bzip2 subdir-objects 1.5 foreign +AM_CXXFLAGS = -Wall -Werror +##DIST_SUBDIRS = src +##SUBDIRS = src + +DISTCLEANFILES = include/stamp-h include/stamp-h[0-9]* + +INCLUDES = -I$(top_srcdir)/include + +getoptincludedir = $(includedir)/getopt++ + +lib_LTLIBRARIES = libgetopt++.la +check_PROGRAMS = tests/OptionSet tests/testoption tests/optioniterator tests/BoolOptionTest + +TESTS = tests/OptionSet tests/optioniterator tests/BoolOptionTest + +libgetopt___la_SOURCES = src/GetOption.cc src/Option.cc src/BoolOption.cc \ + src/OptionSet.cc \ + src/StringOption.cc + +libgetopt___la_LDFLAGS = -version-info 1:1:0 + +getoptinclude_HEADERS = include/getopt++/Option.h \ + include/getopt++/BoolOption.h \ + include/getopt++/DefaultFormatter.h \ + include/getopt++/GetOption.h \ + include/getopt++/OptionSet.h \ + include/getopt++/StringOption.h + +tests_testoption_SOURCES = tests/testoption.cc +tests_testoption_LDADD = libgetopt++.la + +tests_optioniterator_SOURCES = tests/optioniterator.cc +tests_optioniterator_LDADD = libgetopt++.la + +tests_BoolOptionTest_SOURCES = tests/BoolOptionTest.cc +tests_BoolOptionTest_LDADD = libgetopt++.la + +tests_OptionSet_SOURCES = tests/OptionSet.cc +tests_OptionSet_LDADD = libgetopt++.la + --- config-manager-0.3.orig/libgetopt/README +++ config-manager-0.3/libgetopt/README @@ -0,0 +1,72 @@ +This is the README for libgetopt++. Libgetopt++ is a C++ library for command +line parsing. + +It has/allows: + +1) Minimal footprint in main.cc, and no header or source changes outside the + user of an option when the option is altered/a new option added. +2) Multiple option sets can co-exist safely. The default option set is a + singleton, but additional static sets can be created and used. +3) Easy to use. Adding a new option is simply a case of adding a static + variable (can be a class member for instance) for the option, in the scope + that the option needs to be visible - be that class scope or translation + unit scope. +4) There are (will be when feature complete) multiple concrete Option classes + provided (currently BoolOption is the only one implemented). +5) Extensible. Simply create a new subclass of Option to implement a new + Option type, and use it in your program. + +Libgetopt++ is licenced under the GPL. + +The primary mailing list for discussion of libgetopt++ is +cygwin-apps@cygwin.com (unless/until traffic on libgetopt++ becomes worthy +of a dedicated list). Use this list for all bug reports, development discussion +and help requests. + +Getting libgetopt++: +Currently there are no user distributions that I know of. Libgetopt++ source is +available via anonymous cvs from +:pserver:sources.redhat.com:/cvs/cygwin-apps/libgetopt++. + +Building libgetopt++: +For libgetopt++ developers: +You need autoconf 2.52 or better, automake 1.5 or better, and a recent libtool. +Depending on your platform static and or shared libraries will be built by +default. You will also need a C++ compiler, a linker and other such usual tools. + +Once you have the source, and the required tools, run ./bootstrap.sh in the +top of the source tree. This should succeed - if it doesn't check you have all +the tools available and working before seeking help from the mailing list. + +After successfully running the bootstrap.sh script, you can follow the user +building instructions below. As a developer you will likely want to build in +a separate directory to the source code, and to add --enable-maintainer-mode +and --enable-dependency-tracking to the configure line. + +For libgetopt++ users: +You only need a C++ compiler toolchain. The user distributions include a +pregenerated configure script. + +Once you have that, + 1) unpack the source somewhere. + 2) (optional) make a separate build directory - ie $(path to source)/build + 3) cd to wherever you plan to build from - either a dedicated directory + or the top level source directory. + 4) run $(path to source)/configure + 5) run make. + +Installing libgetopt++: +Run make install in the build tree. If you are using shared libraries you need +to ensure that the library load path on your system includes the appropriate +location for the libraries. The default behaviour is to install the libraries +to /usr/local/lib (or for cygwin /usr/local/bin). If you are not sure whether +this has been done, check your system manual for more information. + +Using libgetopt++: + +To be written. Essentially include in main.cc, and + where you need to declare a command line option. + +All options must be static variables or static members. + + --- config-manager-0.3.orig/libgetopt/bootstrap.sh +++ config-manager-0.3/libgetopt/bootstrap.sh @@ -0,0 +1,35 @@ +#! /bin/sh +# Used to setup the configure.in, autoheader and Makefile.in's if configure +# has not been generated. This script is only needed for developers when +# configure has not been run, or if a Makefile.am in a non-configured directory +# has been updated + + +bootstrap() { + if "$@"; then + true # Everything OK + else + echo "$1 failed" + echo "Autotool bootstrapping failed. You will need to investigate and correct" ; + echo "before you can develop on this source tree" + exit 1 + fi +} + +# Make sure we are running in the right directory +if [ ! -f src/GetOption.cc ]; then + echo "You must run this script from the directory containing it" + exit 1 +fi + +# Make sure cfgaux exists +mkdir -p cfgaux + +# Bootstrap the autotool subsystems +bootstrap aclocal +bootstrap autoheader +bootstrap libtoolize --automake +bootstrap automake --foreign --add-missing +bootstrap autoconf + +echo "Autotool bootstrapping complete." --- config-manager-0.3.orig/libgetopt/configure.in +++ config-manager-0.3/libgetopt/configure.in @@ -0,0 +1,47 @@ +dnl +dnl Configuration input file for GetOpt++ +dnl +dnl Robert Collins, rbtcollins@hotmail.com +dnl +dnl $Id: configure.in,v 1.5 2003/12/10 20:51:44 rbcollins Exp $ +dnl +dnl +dnl +AC_INIT(src/GetOption.cc) +AC_PREREQ(2.52) +AC_CONFIG_AUX_DIR(cfgaux) +AM_INIT_AUTOMAKE(GetOpt++, 0.0.2-DEVEL) +AM_CONFIG_HEADER(include/autoconf.h) +AC_REVISION($Revision: 1.5 $)dnl +AC_PREFIX_DEFAULT(/usr/local) +AM_MAINTAINER_MODE + +dnl Check for GNU cc +AC_LANG_CPLUSPLUS +dnl AC_API_WIN32 +AC_PROG_CXX +AM_PROG_CC_C_O +AC_CANONICAL_BUILD +AC_CANONICAL_HOST +AC_PROG_LIBTOOL + +AC_CHECK_HEADERS( \ + unistd.h \ + string \ + string.h +) + +AC_CHECK_HEADER(getopt.h, +[ +AM_CONDITIONAL(INTERNAL_GETOPT, false) +],[ +AM_CONDITIONAL(INTERNAL_GETOPT, true) +]) + + +AC_C_CONST +AC_C_BIGENDIAN + +AC_OUTPUT([\ + Makefile +]) --- config-manager-0.3.orig/libgetopt/include/getopt++/BoolOption.h +++ config-manager-0.3/libgetopt/include/getopt++/BoolOption.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2002 Robert Collins. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * A copy of the GNU General Public License can be found at + * http://www.gnu.org/ + * + * Written by Robert Collins + * + */ + +#ifndef _BOOLOPTION_H_ +#define _BOOLOPTION_H_ + +#include +#include + +// Each registered option must implement this class. +class BoolOption : public Option +{ +public: + BoolOption(bool const defaultvalue, char shortopt, char const *longopt = 0, + std::string const &shorthelp = std::string(), + OptionSet &owner=GetOption::GetInstance()); + virtual ~ BoolOption (); + virtual std::string const shortOption () const; + virtual std::string const longOption () const; + virtual std::string const shortHelp () const; + virtual Result Process (char const *); + virtual Argument argument () const; + operator bool () const; + + +private: + bool _value; + bool _ovalue; + char _shortopt; + char const *_longopt; + std::string _shorthelp; +}; + +#endif // _BOOLOPTION_H_ --- config-manager-0.3.orig/libgetopt/include/getopt++/DefaultFormatter.h +++ config-manager-0.3/libgetopt/include/getopt++/DefaultFormatter.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2003 Robert Collins. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * A copy of the GNU General Public License can be found at + * http://www.gnu.org/ + * + * Written by Robert Collins + * + */ + +#ifndef _GETOPT___DEFAULTFORMATTER_H_ +#define _GETOPT___DEFAULTFORMATTER_H_ + +#include +#include +#include "getopt++/Option.h" + +/* Show the options on the left, the short description on the right. + * descriptions must be < 40 characters in length + */ +class DefaultFormatter { + public: + DefaultFormatter (std::ostream &aStream) : theStream(aStream) {} + void operator () (Option *anOption) { + std::string output = std::string() + " -" + anOption->shortOption ()[0]; + output += " --" ; + output += anOption->longOption (); + output += std::string (40 - output.size(), ' '); + std::string helpmsg = anOption->shortHelp(); + while (helpmsg.size() > 40) + { + // TODO: consider using a line breaking strategy here. + int pos = helpmsg.substr(0,40).find_last_of(" "); + output += helpmsg.substr(0,pos); + helpmsg.erase (0,pos+1); + theStream << output << std::endl; + output = std::string (40, ' '); + } + output += helpmsg; + theStream << output << std::endl; + } + std::ostream &theStream; +}; + + +#endif // _GETOPT___DEFAULTFORMATTER_H_ --- config-manager-0.3.orig/libgetopt/include/getopt++/GetOption.h +++ config-manager-0.3/libgetopt/include/getopt++/GetOption.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2002 Robert Collins. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * A copy of the GNU General Public License can be found at + * http://www.gnu.org/ + * + * Written by Robert Collins + * + */ + +#ifndef _GETOPTION_H_ +#define _GETOPTION_H_ + +#include + +class Option; + +class GetOption : public OptionSet +{ +public: + static GetOption & GetInstance (); +private: + static GetOption Instance; + void Init (); + int inited; //we can't use a bool in case it is + // non zero on startup. +}; + +#endif // _GETOPTION_H_ --- config-manager-0.3.orig/libgetopt/include/getopt++/NumericOption.h +++ config-manager-0.3/libgetopt/include/getopt++/NumericOption.h @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2002 Robert Collins. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * A copy of the GNU General Public License can be found at + * http://www.gnu.org/ + * + * Written by Robert Collins + * + */ + +#ifndef _NUMERICOPTION_H_ +#define _NUMERICOPTION_H_ + +#include +#include +#include + +// Each registered option must implement this class. +template class NumericOption : public Option +{ +public: + NumericOption(N const defaultvalue, char shortopt, char const *longopt = 0, + std::string const &shorthelp = std::string(), bool const optional = true, + OptionSet &owner=GetOption::GetInstance()); + virtual ~ NumericOption (); + virtual std::string const shortOption () const; + virtual std::string const longOption () const; + virtual std::string const shortHelp () const; + virtual Result Process (char const *); + virtual Argument argument () const; + operator N () const; + +private: + Argument _optional; + N _value; + char _shortopt; + char const *_longopt; + std::string _shorthelp; +}; + +template +NumericOption::NumericOption(N const defaultvalue, char shortopt, + char const *longopt, std::string const &shorthelp, + bool const optional, OptionSet &owner) : + _value (defaultvalue) , _shortopt(shortopt), + _longopt (longopt), _shorthelp (shorthelp) +{ + if (!optional) + _optional = Required; + else + _optional = Optional; + owner.Register (this); +}; + +template +NumericOption::~ NumericOption () {}; + +template +std::string const +NumericOption::shortOption () const +{ + return std::string() + _shortopt + ":"; +} + +template +std::string const +NumericOption::longOption () const +{ + return _longopt; +} + +template +std::string const +NumericOption::shortHelp () const +{ + return _shorthelp; +} + +template +Option::Result +NumericOption::Process (char const *optarg) +{ + if (optarg) { + std::istringstream arg(optarg); + arg >> _value; + } + if (optarg || _optional == Optional) + return Ok; + return Failed; +} + +template +NumericOption::operator N () const +{ + return _value; +} + +template +Option::Argument +NumericOption::argument () const +{ + return _optional; +} + +#endif // _NUMERICOPTION_H_ --- config-manager-0.3.orig/libgetopt/include/getopt++/Option.h +++ config-manager-0.3/libgetopt/include/getopt++/Option.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2002 Robert Collins. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * A copy of the GNU General Public License can be found at + * http://www.gnu.org/ + * + * Written by Robert Collins + * + */ + +#ifndef _OPTION_H_ +#define _OPTION_H_ + +#if HAVE_CONFIG_H +#include "autoconf.h" +#endif +#if HAVE_STRING_H +#include +#else +#error " required" +#endif + +// Each registered option must implement this class. +class Option +{ +public: + virtual ~ Option (); + virtual std::string const shortOption () const = 0; + virtual std::string const longOption () const = 0; + virtual std::string const shortHelp () const = 0; + enum Result { + Failed, + Ok, + Stop + }; + virtual Result Process (char const *) = 0; + enum Argument { + None, + Optional, + Required + }; + virtual Argument argument () const = 0; + +protected: + Option (); +}; + +#endif // _OPTION_H_ --- config-manager-0.3.orig/libgetopt/include/getopt++/OptionSet.h +++ config-manager-0.3/libgetopt/include/getopt++/OptionSet.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2002 Robert Collins. + * Copyright (c) 2003 Robert Collins. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * A copy of the GNU General Public License can be found at + * http://www.gnu.org/ + * + * Written by Robert Collins + * + */ + +#ifndef _OPTIONSET_H_ +#define _OPTIONSET_H_ + +#include +#include +#include "getopt++/Option.h" + +class OptionSet +{ +public: + OptionSet(); + virtual ~OptionSet(); + virtual void Register (Option *); + virtual bool Process (int argc, char **argv, Option *nonOptionHandler); + virtual bool Process (std::vector const &parms, Option *nonOptionHandler); + virtual bool process (Option *nonOptionHandler); + virtual void ParameterUsage (std::ostream &); + virtual std::vector