1import config.base 2import os 3import re 4 5def noCheck(command, status, output, error): 6 ''' Do no check result''' 7 return 8 9class Configure(config.base.Configure): 10 def __init__(self, framework): 11 config.base.Configure.__init__(self, framework) 12 self.isClone = 0 13 return 14 15 def setupDependencies(self, framework): 16 self.sourceControl = framework.require('config.sourceControl',self) 17 self.petscdir = framework.require('PETSc.options.petscdir', self) 18 return 19 20 def configureInstallationMethod(self): 21 if os.path.exists(os.path.join(self.petscdir.dir,'bin','maint')): 22 self.logPrint('bin/maint exists. This appears to be a repository clone') 23 self.isClone = 1 24 if os.path.exists(os.path.join(self.petscdir.dir, '.git')): 25 self.logPrint('.git directory exists') 26 if hasattr(self.sourceControl,'git'): 27 (o1, e1, s1) = self.executeShellCommand("cd "+self.petscdir.dir+" && "+self.sourceControl.git+" describe",checkCommand = noCheck) 28 (o2, e2, s2) = self.executeShellCommand("cd "+self.petscdir.dir+" && "+self.sourceControl.git+" log -1 --pretty=format:%H",checkCommand = noCheck) 29 (o3, e3, s3) = self.executeShellCommand("cd "+self.petscdir.dir+" && "+self.sourceControl.git+" log -1 --pretty=format:%ci",checkCommand = noCheck) 30 (o4, e4, s4) = self.executeShellCommand('cd '+self.petscdir.dir+' && '+self.sourceControl.git+' branch',checkCommand = noCheck) 31 if s2 or s3 or s4: 32 self.logPrintBox('***** WARNING: Git branch check is giving errors! Checking the repo with "git status"') 33 (o5, e5, s5) = self.executeShellCommand('cd '+self.petscdir.dir+' && '+self.sourceControl.git+' status',checkCommand = noCheck) 34 self.logPrint(e5) 35 else: 36 if not o1: o1 = o2 37 self.addDefine('VERSION_GIT','"'+o1+'"') 38 self.addDefine('VERSION_DATE_GIT','"'+o3+'"') 39 try: 40 self.addDefine('VERSION_BRANCH_GIT','"'+re.compile('\* (.*)').search(o4).group(1)+'"') 41 except: 42 self.addDefine('VERSION_BRANCH_GIT','undetermined') 43 else: 44 self.logPrintBox('\n*****WARNING: PETSC_DIR appears to be a Git clone - but git is not found in PATH********\n') 45 else: 46 self.logPrint('This repository clone is obtained as a tarball as no .git dirs exist') 47 else: 48 if os.path.exists(os.path.join(self.petscdir.dir, '.git')): 49 raise RuntimeError('Your petsc source tree is broken. Use "git status" to check, or remove the entire directory and start all over again') 50 else: 51 self.logPrint('This is a tarball installation') 52 return 53 54 def configure(self): 55 self.executeTest(self.configureInstallationMethod) 56 return 57