def __init__(self, line): Lister.__init__(self) self.line = line self.name = '' self.args = None infoOut ('processing command: '+ line) self.processCommand()
def __init__ ( self, toDir, rqst, method, baseBom = {} ): """ Defines and builds the internal structure of the DAR distribution. Returns the stub of the environment setup scripts, i.e. relative location in the distribution without shell-specific suffix. """ Lister.__init__(self) # call base class constructor # top installation directory: self.instTop = os.path.join(toDir, rqst.getVersionTag(), rqst.getArchitecture()) # here the global fso image will go: self._SharedTop = os.path.join(self.instTop + '/shared') # top of runtime environment based structure: self._RteTop = os.path.join(self.instTop + '/rte') # link to top of base installation structure: self._BaseTop = os.path.join(self.instTop + '/base') os.makedirs(os.path.join(self.instTop, getDarDirName())) # Stub for templates of environment setup scripts: self._EnvScriptStub = os.path.join(self.instTop, getSetupScriptBasename()) # Create DARball contents: self._BuildDarStructure(rqst, method, baseBom)
def __init__(self): Lister.__init__(self) # The command below must work on linux (UNIX), # other platfroms may need more tweaking. self._Uname = popen2.popen2("uname -a")[0].readlines() self._Hostname = popen2.popen2("hostname")[0].readlines() self._Nisdomainname = popen2.popen2("nisdomainname")[0].readlines() self._Dnsdomainname = popen2.popen2("dnsdomainname")[0].readlines() self._Bintype = ''
def __init__(self, darInput, pltf=None, cnf=None): """ __init__ Initializes DAR Manager apects common to both create and install mode. """ Lister.__init__(self) # Set defaults: self.darballSuffix = '_dar.tar.gz' # and initialize variables: self.baseBomDict = {} # need for incremental darball self.darpool = None # self.dar = None # need for creating darball self.config = cnf infoOut('Validating DAR configuration ...') if getVerbose(): print "CONFIGURATION:", self.config # Check that dar shared pool is set up, exists and has right permissions: # DAR shared pool is to lookup for a base dar distributions and/or # installations . if self.config.has_key("dar_shared_pool"): self.sharedPool = self.config["dar_shared_pool"] else: sys.exit("ERROR:dar shared pool is not defined in the configuration") if self.config.has_key("dar_dist_pool"): self.distPool = self.config["dar_dist_pool"] else: sys.exit("ERROR: dar dist pool is not defined in the configuration") if self.config.has_key("dar_inst_pool"): self.instPool = self.config["dar_inst_pool"] else: sys.exit("ERROR: dar inst pool is not defined in the configuration") # Check that dar tmpdir is set, exists, and has right permissions: if self.config.has_key("dar_tmp_dir"): self.tmpdir = self.config["dar_tmp_dir"] else: sys.exit("ERROR: dar_tmp_dir is not defined in the configuration") if notWritable(self.tmpdir): sys.exit(notWritable(self.tmpdir)) # Each time when dar is called, it creates a new build directory # in tmpdir pool, using a unique datestamp: self.blddir = self.tmpdir+'/'+str(time.time()) # Start logger and pre-set log files: self.logdir = self.blddir + '/logfiles' # one dir for all logfiles self.timingLog = Logger(self.logdir+'/session.timing') self.sessionStdoutLog = self.logdir+'/session.stdout' self.sessionHistoryLog = self.logdir+'/session.history' # Create necessary directories and files: os.makedirs(self.blddir) os.makedirs(self.logdir) for logfile in (self.sessionStdoutLog, self.sessionHistoryLog): infoOut('Creating ' + logfile + ' file') open(logfile, 'w').close() # Get platform info: self.platform = pltf self.timingLog('Completed configuration and setup ') # Create a request self.currentRequest = Request(darInput, self.timingLog) self.timingLog('Created request object') # Initialize dar metadata self.darMeta = Metadata() self.darMeta.setDarVersion(getDarVersion()) # Get release/version metadata from request and # put them into Metadata container: self.darMeta.setDarInput(darInput) self.darMeta.setBaseReleaseName(self.currentRequest.getBaseReleaseName()) self.darMeta.setProjectName(self.currentRequest.getProjectName()) self.darMeta.setVersionTag(self.currentRequest.getVersionTag()) # Architecture self.darMeta.setArchitecture(self.currentRequest.getArchitecture())
def __init__(self, darInput, logger): Lister.__init__(self) # base constructor # Store RTE variables in a dictionary: # no two variables can have same name. self.logger = logger self.rteDict = {} self.cmdList = [] self._ReleaseMetadata = {} self._BaseReleaseName = None self._ProjectName = 'undefined' self._VersionTag = 'undefined' self._DarFile = '' # By default we don't know anything about scram: self.scram = None self.baseDar = None self._Arch = 'arch' ################################## # Fill up rteDict and cmdList ################################## infoOut('Reading lines from dar input:') for line in darInput: # Discard comments and surrounding whitespaces: line = re.sub('\t*#.*', '', line) line = string.strip(line) #################### # Skip blank lines #################### if blankLine.match(line): continue ########################################## # Process variable settings ############################################ result = avariable.match(line) if result: vName, vValue = result.groups() # discard surrounding whitespaces: vName = string.strip(vName) vValue = string.strip(vValue) # Creates a variable object and puts into self.rteDict: self.addVariable(vName, vValue) continue ################################## # Consider the rest as commands: ########################################## cmd = DARcommand(line) self.cmdList.append(cmd) # Execute commands: if cmd.name == "ignore": self.executeIgnore(cmd) continue if cmd.name == "use": self.executeUse(cmd) continue # next line # Check if first command argument is existing variable name. # Commands associated with environment variable # will use corresponding variable method: if self.rteDict.has_key(cmd.args[0]): var = self.rteDict[cmd.args[0]] self.executeVarCommand(cmd, var) continue # next line # Check if first command argument is "ALL", and if it is, # execute corresponding method for all variables. if cmd.args[0] == "ALL": self.executeALLVariables(cmd) ########################################### # Provide hooks to override PATH settings, in order to control # which executables are to be taken into the distribution. if self.scram: # i.e. we deal with a scram managed project # In scram V0 SCRAMRT_PATH contains additions to PATH, so we use it # to override PATH value: if self.scram.program == "scram": if self.rteDict.has_key('SCRAMRT_PATH'): tmp = self.rteDict['SCRAMRT_PATH'].getValue() self.rteDict['PATH'].setValue(tmp) del tmp # Same for LD_LIBRARY_PATH: if self.rteDict.has_key('SCRAMRT_LD_LIBRARY_PATH'): tmp = self.rteDict['SCRAMRT_LD_LIBRARY_PATH'].getValue() self.rteDict['LD_LIBRARY_PATH'].setValue(tmp) del tmp # In scram V1 SCRAMRT_PATH contains default user's PATH settings, # so we strip it from the PATH value: if self.scram.program == "scramv1": tmp = self.rteDict['PATH'].getValue() self.rteDict['PATH'].setValue(tmp.replace(':$SCRAMRT_PATH','')) del tmp # Similar for LD_LIBRARY_PATH: tmp = self.rteDict['LD_LIBRARY_PATH'].getValue() tmp = tmp.replace(':$SCRAMRT_LD_LIBRARY_PATH','') self.rteDict['LD_LIBRARY_PATH'].setValue(tmp) del tmp # DAR_runtime_PATH overrides both PATH and SCRAMRT_PATH # (independent of scram version): if self.rteDict.has_key('DAR_runtime_PATH'): tmp = self.rteDict['DAR_runtime_PATH'].getValue() self.rteDict['PATH'].setValue(tmp) del tmp