From 9762b1b9268bda395c2a0effb37c7a3b1bf51b6c Mon Sep 17 00:00:00 2001 From: Vincent Pelletier <vincent@nexedi.com> Date: Fri, 3 Dec 2010 14:09:49 +0000 Subject: [PATCH] Add a before-configure hook for kumo. Objective: disable kumo build on hosts with broken gcc, as we don't want to build our own gcc (yet ?). This is not used yet, but should be within a few hours. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41093 20353a03-c40f-0410-a6d1-a30d3c3de9de --- buildout/hooks/kumo-hooks.py | 76 ++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 buildout/hooks/kumo-hooks.py diff --git a/buildout/hooks/kumo-hooks.py b/buildout/hooks/kumo-hooks.py new file mode 100644 index 0000000000..963e6680be --- /dev/null +++ b/buildout/hooks/kumo-hooks.py @@ -0,0 +1,76 @@ +import os +import sys +import traceback +from shutil import copy +from subprocess import Popen, PIPE + +CONFIGURE_PATH = os.path.join('configure') +CONFIGURE_BACKUP_PATH = CONFIGURE_PATH + '_disabled' +# Fake configure, generating a fake Makefile which will create a marker file +# instead of actually installing anything. +# This is needed (?) to fetch --prefix from configure parameters, so we know +# where to tell Makefile to put the dummy file. +FAKE_CONFIGURE = '''#!%(python)s -S +import os +import sys +print 'Configuration is disabled on this host because %%s' +print 'Original configure file available at %(backup)s' +prefix = None +next = False +for arg in sys.argv: + if next: + prefix = arg + break + if arg.startswith('--prefix'): + if arg.startswith('--prefix='): + _, prefix = arg.split('=', 1) + break + next = True +if prefix is None: + raise '--prefix parameter not found' +# Generate Makefile with proper prefix +open('Makefile', 'w').write("""all: +\techo 'make disabled, see configure' + +install: +\ttouch %%%%s""" %%%% ( + os.path.join(prefix, 'BUILD_DISABLED_BY_BUILDOUT'), +)) +sys.exit(0) +''' % { + 'backup': CONFIGURE_BACKUP_PATH, + 'python': sys.executable, +} + +def pre_configure_hook(options, buildout): + gcc_executable = os.getenv('CC', 'gcc') + try: + gcc = Popen([gcc_executable, '-v'], stdout=PIPE, stderr=PIPE, + close_fds=True) + except OSError, (errno, _): + if errno == 2: + # No gcc installed, nothing to check + pass + else: + print 'Unexpected failure trying to detect gcc version' + traceback.print_exc() + else: + gcc.wait() + # Considered innocent until proven guilty. + error = None + for line in '\n'.join((gcc.stdout.read(), gcc.stderr.read())).splitlines(): + if line.startswith('gcc version'): + if '4.1.1' in line and 'prerelease' in line: + # There is a bug in 4.1.1 prerelease (ie, as of mandriva + # 2007.0) g++ preventing kumo compilation from succeeding. + error = 'broken GCC version: %s' % (line, ) + break + else: + print >>sys.stderr, 'GCC version could not be detected, ' \ + 'building anyway' + if error is not None: + print 'Disabling build, with reason:', error + # Copy to preserver permission + copy(CONFIGURE_PATH, CONFIGURE_BACKUP_PATH) + open(CONFIGURE_PATH, 'w').write(FAKE_CONFIGURE % (error, )) + -- 2.30.9