From: W. Trevor King Date: Tue, 1 Jan 2013 14:32:46 +0000 (-0500) Subject: swc-installation-test-2.py: Add MakeDependency class X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ab89f1e35f6da3e81b903a104159effefec96db9;p=swc-workshop.git swc-installation-test-2.py: Add MakeDependency class On the fairly ancient SunOS 5.10 (January 2005), `make` doesn't support `--version`. Looking into the POSIX.2 specs [1], it doesn't have to. On FreeBSD [2] and in GNU Make [3], there is a MAKE_VERSION variable, and the Sun executable has something similar: $ strings make | grep MAKE_VERSION .MAKE_VERSION but it just expands to an empty string. Since reading a makefile from stdin *is* in POSIX [1], we can use that to test `make` if `make --version` fails. If we get something for MAKE_VERSION, use that. If we get something for MAKE (required by POSIX [2]), then call that a valid, but unkown, version. [1]: http://pubs.opengroup.org/onlinepubs/009695399/utilities/make.html#tag_04_84_04 [2]: http://lists.freebsd.org/pipermail/freebsd-questions/2010-October/222214.html [3]: http://www.gnu.org/software/make/manual/html_node/Features.html#index-MAKE_005fVERSION-1021 [4]: http://pubs.opengroup.org/onlinepubs/009695399/utilities/make.html#tag_04_84_13_08 --- diff --git a/swc-installation-test-2.py b/swc-installation-test-2.py index a2d7f01..3de2fdb 100755 --- a/swc-installation-test-2.py +++ b/swc-installation-test-2.py @@ -321,7 +321,6 @@ for command,long_name,minimum_version in [ ('zsh', 'Z Shell', None), ('git', 'Git', (1, 7, 0)), ('hg', 'Mercurial', (2, 0, 0)), - ('make', None, None), ('sqlite3', 'SQLite 3', None), ('nosetests', 'Nose', (1, 0, 0)), ('emacs', 'Emacs', None), @@ -342,6 +341,41 @@ for command,long_name,minimum_version in [ del command, long_name, minimum_version # cleanup namespace +class MakeDependency (CommandDependency): + makefile = '\n'.join([ + 'all:', + '\t@echo "MAKE_VERSION=$(MAKE_VERSION)"', + '\t@echo "MAKE=$(MAKE)"', + '', + ]) + + def _get_version(self): + try: + return super(MakeDependency, self)._get_version() + except DependencyError as e: + version_options = self.version_options + self.version_options = ['-f', '-'] + try: + stream = self._get_version_stream(stdin=self.makefile) + info = {} + for line in stream.splitlines(): + try: + key,value = line.split('=', 1) + except ValueError as ve: + raise e# from NotImplementedError(stream) + info[key] = value + if info.get('MAKE_VERSION', None): + return info['MAKE_VERSION'] + elif info.get('MAKE', None): + return None + raise e + finally: + self.version_options = version_options + + +CHECKER['make'] = MakeDependency(command='make', minimum_version=None) + + class EasyInstallDependency (CommandDependency): def _get_version(self): try: