示例#1
0
	def execute(self):
		if self._cmakeGenerator=="":
			self.reportError("Missing valid generator option")
			return False
		if self._projectPath=="":
			self.reportError("Missing required project path option")
			return False
			
		if self._cmakeGenerator!="" and self._projectPath!="":
			self._projectPath = os.path.abspath(self._projectPath)
			projectName = os.path.basename(self._projectPath)
			if self._projectGenerationPath=="":
				self._projectGenerationPath=os.path.abspath(os.path.join(self._projectPath,"BMCMake"))
			if self._installPath=="":
				self._installPath=os.path.abspath(self._projectPath+os.path.sep+".."+os.path.sep+projectName+"-install")
			if self._buildType=="":
				self._buildType="Release"
				
		bmutil = BMUtil()
		print " * Creating Project Generation Path: "+self._projectGenerationPath
		bmutil.mkdir(self._projectGenerationPath)
		olddir = os.getcwd()
		os.chdir(self._projectGenerationPath)
		if os.path.exists("CMakeCache.txt"):
			os.remove("CMakeCache.txt")
		cmakeCommand = "cmake "+self._cmakeOtherOptions+" -G\""+self._cmakeGenerator+"\" -DCMAKE_BUILD_TYPE="+self._buildType+" -DCMAKE_INSTALL_PREFIX="+self._installPath+" "+self._projectPath 
		print " * Running CMAKE: " + cmakeCommand
		os.system(cmakeCommand)
		os.chdir(olddir)
		return True
示例#2
0
	def execute(self):
		util = BMUtil()
		bmpath = util.buildmanPlugInPath()
		try:
			util.mkdir(bmpath)		
			#shutil.copy(sys.path[0]+os.path.sep+"bmplugins"+os.path.sep+"TestPlugIn.py_",util.buildmanPlugInPath()+os.path.sep+"TestPlugIn.py")
		except:
			self.reportError("Error creating buildman directory or copying test plugin")
			return False
		return True
示例#3
0
	def create(self):
		
		self._dmplugin = PlugInManager().getPlugInInstance("DepManPlugIn")
		if self._dmplugin == None:
			self.reportError("PlugIn `depman` not found")
			return False
		
		#user questions
		if self._is_Interactive:
			self._group=raw_input("Group: ")
			
			self._artifact=raw_input("Artifact: ")
			
			self._version=raw_input("Version: ")
			
			tmpstr=""
			for p in self._dmplugin.getSupportedPlatforms():
				tmpstr=tmpstr+p+" "
			print "( ",tmpstr,")"
			tmstr="Platform [*]:"
			self._platform=raw_input(string.replace(tmstr,"*",self._dmplugin.getOSPlatform()))
			if len(self._platform)==0:
				self._platform=self._dmplugin.getOSPlatform()
			
			tmpstr=""
			for p in self._dmplugin.getSupportedCompilers():
				tmpstr=tmpstr+p+" "
			print "( ",tmpstr,")"
			tmstr="Compiler [*]:"
			self._compiler=raw_input(string.replace(tmstr,"*",self._dmplugin.getOSCompiler()))
			if len(self._compiler)==0:
				self._compiler=self._dmplugin.getOSCompiler()
				
			tmpstr=""
			for p in self._dmplugin.getSupportedArchs():
				tmpstr=tmpstr+p+" "
			print "( ",tmpstr,")"
			tmstr="Architecture [*]:"
			self._arch=raw_input(string.replace(tmstr,"*",self._dmplugin.getOSArch()))
			if len(self._arch)==0:
				self._arch=self._dmplugin.getOSArch()
			
			tmpstr=""
			for p in self._dmplugin.getSupportedLibraryTypes():
				tmpstr=tmpstr+p+" "
			print "( ",tmpstr,")"
			self._ltype=raw_input("Library Type: ")
			
			upload_response = raw_input("Upload to server? (y/n): ")
			if upload_response == "y" or upload_response == "yes":
				self._upload=True
		
		if self._packageNode != None:
			for n in self._packageNode.childNodes:
				if n.localName=="package":
					processPackage = True
					if n.hasAttributes():
						if n.attributes.has_key("platform"):
							values = n.attributes.get("platform").value.split(",")
							if self._dmplugin.getOSPlatform() in values:
								processPackage = True
							else:
								processPackage = False
					if processPackage:
						print "Processing for platform..."
						for p in n.childNodes:
							if p.localName=="group":
								self._group=p.childNodes[0].nodeValue
							if p.localName=="artifact":
								self._artifact=p.childNodes[0].nodeValue
							if p.localName=="version":
								self._version=p.childNodes[0].nodeValue
							if p.localName=="platform":
								self._platform=p.childNodes[0].nodeValue
							if p.localName=="compiler":
								self._compiler=p.childNodes[0].nodeValue
							if p.localName=="arch":
								self._arch=p.childNodes[0].nodeValue
							if p.localName=="libraryType":
								self._ltype=p.childNodes[0].nodeValue
							
							if p.localName =="upload":
								#TODO: Maybe upload should be an external plugin
								for k in p.childNodes:
									if k.localName == "sshserver":
										self._default_ssh = k.childNodes[0].nodeValue
									if k.localName == "destdir":
										self._default_destdir = k.childNodes[0].nodeValue
									if k.localName == "username":
										self._default_login = k.childNodes[0].nodeValue
						
		if self._group == "":
			self.reportError("Group cannot be empty")
			return False
		if self._artifact == "":
			self.reportError("Artifact cannot be empty")
			return False
		if self._version == "":
			self.reportError("Version cannog be empty")
			return 
		self._group=self._group.replace(".","/")
		if self._platform=="default":
			self._platform=self._dmplugin.getOSPlatform()
		if self._compiler=="default":
			self._compiler=self._dmplugin.getOSCompiler()
		if self._arch=="default":
			self._arch=self._dmplugin.getOSArch()
			
		
		#let's check user input consistency
		
		if self._platform not in self._dmplugin.getSupportedPlatforms():
			self.reportError("Platform not supported: " + self._platform + ". Supported platforms:" + str(self._dmplugin.getSupportedPlatforms()))
			return False
		
		if self._compiler not in self._dmplugin.getSupportedCompilers():
			self.reportError("Compiler not supported: " + self._compiler + ". Supported compilers:" +str(self._dmplugin.getSupportedCompilers()))
			return False
		
		if self._arch not in self._dmplugin.getSupportedArchs():
			self.reportError("Architecture not supported: " + self._arch + ". Supported archs:" +str(self._dmplugin.getSupportedArchs()))
			return False
		
		if self._ltype not in self._dmplugin.getSupportedLibraryTypes():
			self.reportError("Library type not supported: " + self._ltype + ". Supported libraries:" +str(self._dmplugin.getSupportedLibraryTypes()))
			return False
		
		#artifact and md5 generation
		
		file_name=self._artifact+"-"+self._version+"-"+self._platform+"-"+self._compiler+"-"+self._arch+"-"+self._ltype
		
		
		tarname=file_name+".tar.gz"
		md5name=tarname+".md5"
		dmfile=file_name+".xml"
		
		dmutil = BMUtil()
		
		tmpdir=self._dmplugin.getDepManPath()+os.path.sep+".cache"+os.path.sep+self._group+os.path.sep+self._artifact+os.path.sep+self._version+os.path.sep+self._platform+os.path.sep+self._compiler+os.path.sep+self._arch+os.path.sep+self._ltype
		
		dmutil.mkdir(tmpdir)
		print tmpdir+os.path.sep+tarname,self._path
		dmutil.targz(os.path.join(tmpdir,tarname),self._path)
		#print "targz ",tmpdir+os.path.sep+tarname
		dmutil.createMD5(tmpdir+os.path.sep+tarname,tmpdir+os.path.sep+md5name)
		if self._xmlfile != "":
			shutil.copyfile(self._xmlfile,tmpdir+os.path.sep+dmfile)	
		print "Artifact " + tarname + " created in:\n" + tmpdir
		
		if self._upload:
			dmutil.rmdir(".dmn_tmp") # Prevent for uploading bad previous compilations!
			sshtmpdir=".dmn_tmp"+os.path.sep+self._group+os.path.sep+self._artifact+os.path.sep+self._version+os.path.sep+self._platform+os.path.sep+self._compiler+os.path.sep+self._arch+os.path.sep+self._ltype
			dmutil.mkdir(sshtmpdir)
			shutil.copyfile(tmpdir+os.path.sep+tarname,sshtmpdir+os.path.sep+tarname)
			shutil.copyfile(tmpdir+os.path.sep+md5name,sshtmpdir+os.path.sep+md5name)
			if self._xmlfile != "":
				shutil.copyfile(tmpdir+os.path.sep+dmfile,sshtmpdir+os.path.sep+dmfile)	
			url = self._default_ssh;
			destdir = self._default_destdir
			login = self._default_login
			
			if self._is_Interactive:
				tmstr="SSH Server [*]:"
				url=raw_input(string.replace(tmstr,"*",self._default_ssh))
				if len(url)==0:
					url=self._default_ssh
				
				tmstr="Destination Directory [*]:"
				destdir=raw_input(string.replace(tmstr,"*",self._default_destdir))
				if len(destdir)==0:
					destdir=self._default_destdir
			
				tmstr="Login [*]:"
				login=raw_input(string.replace(tmstr,"*",self._default_login))
				if len(login)==0:
					login=self._default_login
			
			download_dir = self._group+"/"+self._artifact+"/"+self._version+"/"+self._platform+"/"+self._compiler+"/"+self._arch+"/"+self._ltype
			
			print "* Uploading ",tarname
			print "* Uploading ",md5name
			
			#scp
			base_ssh=destdir
			url_ssh=url
			scpcommand = "scp"
			pscppath = ""
			if sys.platform == "win32":
				scpcommand=self._dmplugin.getDepManDataPath()+os.path.sep+"win32"+os.path.sep+"pscp.exe"
				scpcommand  = '"'+os.path.normpath(scpcommand)+'"'
			cmdstr=scpcommand +" -r "+".dmn_tmp"+os.path.sep+"*"+" "+login+"@"+url_ssh+":"+base_ssh
			
			print cmdstr
			os.system(cmdstr)
			
			#scp
			
			dmutil.rmdir(".dmn_tmp")
示例#4
0
	def get(self, unPackList = None):
		#transform namespaces org.foo to org/foo
		group=self._group.replace(".","/")
	
		print "[",self._artifact,"]"

		file_name=self._artifact+"-"+self._version+"-"+self._platform+"-"+self._compiler+"-"+self._arch+"-"+self._ltype
		tarname=file_name+".tar.gz"
		md5name=tarname+".md5"
	
		download_path = group+os.path.sep+self._artifact+os.path.sep+self._version+os.path.sep+self._platform+os.path.sep+self._compiler+os.path.sep+self._arch+os.path.sep+self._ltype
		download_dir = group+"/"+self._artifact+"/"+self._version+"/"+self._platform+"/"+self._compiler+"/"+self._arch+"/"+self._ltype
		cache_path = self._default_repository+os.path.sep+".cache"+os.path.sep+download_path
	
	
		tstr=self._version.lower()
		if tstr.find("snapshot")!=-1:
			is_snapshot=True
		else:
			is_snapshot=False
	
		dmutil = BMUtil()

		is_tar=True
		is_md5=True
		if not dmutil.checkUrl(self._url+"/"+download_dir+"/"+md5name):
			#print "Error: File ",baseurl+"/"+download_dir+"/"+md5name, " not found in the repository"
			is_md5=False
	
		if not dmutil.checkUrl(self._url+"/"+download_dir+"/"+tarname):
			#print "Error: File ",baseurl+"/"+download_dir+"/"+tarname, " not found in the repository"
			is_tar=False
	
		dmutil.mkdir(cache_path)
		
	
		if not os.path.isfile(cache_path+os.path.sep+md5name):
			is_cache=False
		else:
			is_cache=True

		#Once all variables have been collected, lets decide what to do with the artifact
		must_download=False
	
		if (not is_md5 or not is_tar) and not is_cache:
			print "Error: Artifact ",tarname," not found"
			return False
	
		if not is_md5 and not is_tar and is_cache:
			print "* file not found in repository, using cache..."
			must_download=False
	
		if is_md5 and is_tar  and not is_cache:
			print "* file is not in cache, downloading..."
			must_download=True
	
		if is_md5 and is_tar and is_cache:
			if is_snapshot:
				if self._isInteractive:
					repo=raw_input("What snapshot do you want to use? (cache/remote): ")
				else:
					if self._forceCache:
						repo="cache"
					else:
						repo="remote"
					
				must_download=False
			
				#in case of misspeling, using cache by default
				if repo!="cache" and repo!="remote":
					repo="cache"
			else:
				repo="remote"
		
			if repo=="remote":
				print "* file cached, checking md5..."
				dmutil.download(self._url+"/"+download_dir+"/"+md5name,cache_path+os.path.sep+md5name+".new")
			
				if dmutil.diff(cache_path+os.path.sep+md5name,cache_path+os.path.sep+md5name+".new"):
					print "* no md5 matching, re-downloading..."
					must_download=True
				else:
					print "* md5 matching succesful"
					must_download=False
				os.remove(cache_path+os.path.sep+md5name+".new")
	
		if must_download==True:
			print "URL :", self._url
			dmutil.download(self._url+"/"+download_dir+"/"+md5name,cache_path+os.path.sep+md5name)
			#print "* downloaded [",md5name,"]"
			dmutil.download(self._url+"/"+download_dir+"/"+tarname,cache_path+os.path.sep+tarname)
			#print "* downloaded[",tarname,"]"
		if unPackList != None:
			if (cache_path+os.path.sep+tarname) not in unPackList:
				unPackList.append(cache_path+os.path.sep+tarname)
		
		return True
示例#5
0
    def create(self):

        self._dmplugin = PlugInManager().getPlugInInstance("DepManPlugIn")
        if self._dmplugin == None:
            self.reportError("PlugIn `depman` not found")
            return False

        #user questions
        if self._is_Interactive:
            self._group = raw_input("Group: ")

            self._artifact = raw_input("Artifact: ")

            self._version = raw_input("Version: ")

            tmpstr = ""
            for p in self._dmplugin.getSupportedPlatforms():
                tmpstr = tmpstr + p + " "
            print "( ", tmpstr, ")"
            tmstr = "Platform [*]:"
            self._platform = raw_input(
                string.replace(tmstr, "*", self._dmplugin.getOSPlatform()))
            if len(self._platform) == 0:
                self._platform = self._dmplugin.getOSPlatform()

            tmpstr = ""
            for p in self._dmplugin.getSupportedCompilers():
                tmpstr = tmpstr + p + " "
            print "( ", tmpstr, ")"
            tmstr = "Compiler [*]:"
            self._compiler = raw_input(
                string.replace(tmstr, "*", self._dmplugin.getOSCompiler()))
            if len(self._compiler) == 0:
                self._compiler = self._dmplugin.getOSCompiler()

            tmpstr = ""
            for p in self._dmplugin.getSupportedArchs():
                tmpstr = tmpstr + p + " "
            print "( ", tmpstr, ")"
            tmstr = "Architecture [*]:"
            self._arch = raw_input(
                string.replace(tmstr, "*", self._dmplugin.getOSArch()))
            if len(self._arch) == 0:
                self._arch = self._dmplugin.getOSArch()

            tmpstr = ""
            for p in self._dmplugin.getSupportedLibraryTypes():
                tmpstr = tmpstr + p + " "
            print "( ", tmpstr, ")"
            self._ltype = raw_input("Library Type: ")

            upload_response = raw_input("Upload to server? (y/n): ")
            if upload_response == "y" or upload_response == "yes":
                self._upload = True

        if self._packageNode != None:
            for n in self._packageNode.childNodes:
                if n.localName == "package":
                    processPackage = True
                    if n.hasAttributes():
                        if n.attributes.has_key("platform"):
                            values = n.attributes.get("platform").value.split(
                                ",")
                            if self._dmplugin.getOSPlatform() in values:
                                processPackage = True
                            else:
                                processPackage = False
                    if processPackage:
                        print "Processing for platform..."
                        for p in n.childNodes:
                            if p.localName == "group":
                                self._group = p.childNodes[0].nodeValue
                            if p.localName == "artifact":
                                self._artifact = p.childNodes[0].nodeValue
                            if p.localName == "version":
                                self._version = p.childNodes[0].nodeValue
                            if p.localName == "platform":
                                self._platform = p.childNodes[0].nodeValue
                            if p.localName == "compiler":
                                self._compiler = p.childNodes[0].nodeValue
                            if p.localName == "arch":
                                self._arch = p.childNodes[0].nodeValue
                            if p.localName == "libraryType":
                                self._ltype = p.childNodes[0].nodeValue

                            if p.localName == "upload":
                                #TODO: Maybe upload should be an external plugin
                                for k in p.childNodes:
                                    if k.localName == "sshserver":
                                        self._default_ssh = k.childNodes[
                                            0].nodeValue
                                    if k.localName == "destdir":
                                        self._default_destdir = k.childNodes[
                                            0].nodeValue
                                    if k.localName == "username":
                                        self._default_login = k.childNodes[
                                            0].nodeValue

        if self._group == "":
            self.reportError("Group cannot be empty")
            return False
        if self._artifact == "":
            self.reportError("Artifact cannot be empty")
            return False
        if self._version == "":
            self.reportError("Version cannog be empty")
            return
        self._group = self._group.replace(".", "/")
        if self._platform == "default":
            self._platform = self._dmplugin.getOSPlatform()
        if self._compiler == "default":
            self._compiler = self._dmplugin.getOSCompiler()
        if self._arch == "default":
            self._arch = self._dmplugin.getOSArch()

        #let's check user input consistency

        if self._platform not in self._dmplugin.getSupportedPlatforms():
            self.reportError("Platform not supported: " + self._platform +
                             ". Supported platforms:" +
                             str(self._dmplugin.getSupportedPlatforms()))
            return False

        if self._compiler not in self._dmplugin.getSupportedCompilers():
            self.reportError("Compiler not supported: " + self._compiler +
                             ". Supported compilers:" +
                             str(self._dmplugin.getSupportedCompilers()))
            return False

        if self._arch not in self._dmplugin.getSupportedArchs():
            self.reportError("Architecture not supported: " + self._arch +
                             ". Supported archs:" +
                             str(self._dmplugin.getSupportedArchs()))
            return False

        if self._ltype not in self._dmplugin.getSupportedLibraryTypes():
            self.reportError("Library type not supported: " + self._ltype +
                             ". Supported libraries:" +
                             str(self._dmplugin.getSupportedLibraryTypes()))
            return False

        #artifact and md5 generation

        file_name = self._artifact + "-" + self._version + "-" + self._platform + "-" + self._compiler + "-" + self._arch + "-" + self._ltype

        tarname = file_name + ".tar.gz"
        md5name = tarname + ".md5"
        dmfile = file_name + ".xml"

        dmutil = BMUtil()

        tmpdir = self._dmplugin.getDepManPath(
        ) + os.path.sep + ".cache" + os.path.sep + self._group + os.path.sep + self._artifact + os.path.sep + self._version + os.path.sep + self._platform + os.path.sep + self._compiler + os.path.sep + self._arch + os.path.sep + self._ltype

        dmutil.mkdir(tmpdir)
        print tmpdir + os.path.sep + tarname, self._path
        dmutil.targz(os.path.join(tmpdir, tarname), self._path)
        #print "targz ",tmpdir+os.path.sep+tarname
        dmutil.createMD5(tmpdir + os.path.sep + tarname,
                         tmpdir + os.path.sep + md5name)
        if self._xmlfile != "":
            shutil.copyfile(self._xmlfile, tmpdir + os.path.sep + dmfile)
        print "Artifact " + tarname + " created in:\n" + tmpdir

        if self._upload:
            dmutil.rmdir(
                ".dmn_tmp")  # Prevent for uploading bad previous compilations!
            sshtmpdir = ".dmn_tmp" + os.path.sep + self._group + os.path.sep + self._artifact + os.path.sep + self._version + os.path.sep + self._platform + os.path.sep + self._compiler + os.path.sep + self._arch + os.path.sep + self._ltype
            dmutil.mkdir(sshtmpdir)
            shutil.copyfile(tmpdir + os.path.sep + tarname,
                            sshtmpdir + os.path.sep + tarname)
            shutil.copyfile(tmpdir + os.path.sep + md5name,
                            sshtmpdir + os.path.sep + md5name)
            if self._xmlfile != "":
                shutil.copyfile(tmpdir + os.path.sep + dmfile,
                                sshtmpdir + os.path.sep + dmfile)
            url = self._default_ssh
            destdir = self._default_destdir
            login = self._default_login

            if self._is_Interactive:
                tmstr = "SSH Server [*]:"
                url = raw_input(string.replace(tmstr, "*", self._default_ssh))
                if len(url) == 0:
                    url = self._default_ssh

                tmstr = "Destination Directory [*]:"
                destdir = raw_input(
                    string.replace(tmstr, "*", self._default_destdir))
                if len(destdir) == 0:
                    destdir = self._default_destdir

                tmstr = "Login [*]:"
                login = raw_input(
                    string.replace(tmstr, "*", self._default_login))
                if len(login) == 0:
                    login = self._default_login

            download_dir = self._group + "/" + self._artifact + "/" + self._version + "/" + self._platform + "/" + self._compiler + "/" + self._arch + "/" + self._ltype

            print "* Uploading ", tarname
            print "* Uploading ", md5name

            #scp
            base_ssh = destdir
            url_ssh = url
            scpcommand = "scp"
            pscppath = ""
            if sys.platform == "win32":
                scpcommand = self._dmplugin.getDepManDataPath(
                ) + os.path.sep + "win32" + os.path.sep + "pscp.exe"
                scpcommand = '"' + os.path.normpath(scpcommand) + '"'
            cmdstr = scpcommand + " -r " + ".dmn_tmp" + os.path.sep + "*" + " " + login + "@" + url_ssh + ":" + base_ssh

            print cmdstr
            os.system(cmdstr)

            #scp

            dmutil.rmdir(".dmn_tmp")