func (q *Quadd) Install(args ...string) { q.ComponentId = args[0] q.Version = args[1] q.ExecFile = args[2] q.InstallLocation = filepath.Join(args[3], "Tegra_System_Profiler") if _, err := os.Stat(filepath.Join(args[3], "_installer")); err != nil { os.MkdirAll(filepath.Join(args[3], "_installer"), 0777) } if myutils.Global_OS == "windows" { sysroot := os.Getenv("SystemRoot") //_, e := exec.Command(sysroot+"/System32/msiexec.exe", "/i", q.ExecFile, "/q", "/l*vx", "_installer/profile.log", "INSTALLDIR="+q.InstallLocation).Output() _, e := exec.Command(sysroot+"/System32/msiexec.exe", "/i", q.ExecFile, "/q", "/l*vx", "_installer/profile.log").Output() myutils.CheckError(e) q.InstallLocation = filepath.Join(os.Getenv("ProgramFiles"), "NVIDIA Corporation") } else if myutils.Global_OS == "linux" { myutils.Decompress(q.ExecFile, args[3]) os.RemoveAll(q.InstallLocation) oldname := filepath.Base(strings.Replace(q.ExecFile, ".tar.gz", "", 1)) oldname = filepath.Join(args[3], oldname) //os.Rename(oldname, q.InstallLocation) myutils.CopyFile(oldname, q.InstallLocation) //add to desktop entry quadd_entry := `[Desktop Entry] Type=Application Name=Tegra System Profiler GenericName=Tegra System Profiler Icon=` + args[3] + ` Exec=env PATH=usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:` + filepath.Join(args[3], "android-sdk-linux", "platform-tool") + " " + filepath.Join(q.InstallLocation, "Host-x86_64", "TegraSystemProfiler") + ` TryExec=` + filepath.Join(q.InstallLocation, "Host-x86_64", "TegraSystemProfiler") + ` Keywords=tegra;nvidia; Terminal=No Categories=Development;` entry_folder := os.Getenv("HOME") + "/.local/share/applications" if _, se := os.Stat(entry_folder); se != nil { //fmt.Println("no folder exist") _, ce := exec.Command("mkdir", "-p", entry_folder).Output() if ce != nil { fmt.Println(ce) } } fp, fe := os.OpenFile(entry_folder+"/tegrasystemprofiler.desktop", os.O_CREATE|os.O_RDWR, 0600) if fe != nil { fmt.Println(fe) } fp.WriteString(quadd_entry) } else { myutils.Decompress(q.ExecFile, q.InstallLocation) } fmt.Println(q.InstallLocation) }
func (u *USB) Install(args ...string) { u.ComponentId = args[0] location := filepath.Join(args[3], "Drivers", "Devkits") //if os.IsExist(os.Chdir(location)) == false { // os.Create(location) //} myutils.Decompress(args[2], location) install_location := filepath.Join(location, "Win7+Vista+XP") os.RemoveAll(install_location) //os.Rename(filepath.Join(location, "usb_driver"), install_location) myutils.CopyFile(filepath.Join(location, "usb_driver"), install_location) if myutils.OS_Win() == "win7" { //substitude the file Google.NTx86 fname := filepath.Join(install_location, "android_winusb.inf") oldstr := "[Google.NTx86]" tegra_str := ";NVIDIA Tegra\r\n" + "%SingleAdbInterface%\t= USB_Install,USB\\VID_0955&PID_7000\r\n%CompositeAdbInterface%\t= USB_Install,USB\\VID_0955&PID_7100&MI_01\r\n\r\n" note_str := ";NVIDIA Tegra\r\n%SingleAdbInterface%\t= USB_Install, USB\\VID_0955&PID_CF01\r\n%CompositeAdbInterface%\t= USB_Install, USB\\VID_0955&PID_CF00&MI_01\r\n\r\n" note8_str := ";NVIDIA Tegra\r\n%SingleAdbInterface%\t= USB_Install, USB\\VID_0955&PID_CF05\r\n%CompositeAdbInterface%\t= USB_Install, USB\\VID_0955&PID_CF05&MI_01\r\n\r\n" shield_str := ";NVIDIA Tegra\r\n%SingleAdbInterface%\t= USB_Install, USB\\VID_0955&PID_B400&MI_00\r\n%CompositeAdbInterface%\t= USB_Install, USB\\VID_0955&PID_B400&MI_01\r\n\r\n" shield1_str := ";NVIDIA Tegra\r\n%SingleAdbInterface%\t= USB_Install, USB\\VID_0955&PID_B400\r\n%CompositeAdbInterface%\t= USB_Install, USB\\VID_0955&PID_B401&MI_01\r\n\r\n" newstr := "[Google.NTx86]\r\n\r\n" + tegra_str + note_str + note8_str + shield_str + shield1_str myutils.Substitude(fname, oldstr, newstr) //os.Rename(filepath.Join(install_location, ".tmp_file"), fname) myutils.CopyFile(filepath.Join(install_location, ".tmp_file"), fname) //substitude the Google.NTamd64 oldstr = "[Google.NTamd64]" newstr = "[Google.NTamd64]\r\n\r\n" + tegra_str + note_str + note8_str + shield_str + shield1_str myutils.Substitude(fname, oldstr, newstr) //os.Rename(filepath.Join(install_location, ".tmp_file"), fname) myutils.CopyFile(filepath.Join(install_location, ".tmp_file"), fname) //installing pnpu_path := filepath.Join("C:\\Windows", "system32", "pnputil.exe") _, e := exec.Command(pnpu_path, "-a", fname).Output() //fmt.Println("meet error is", pnpu_path, "-i -a", fname, string(out), e) myutils.CheckError(e) } //win8 action myutils.Decompress(args[2], location) os.RemoveAll(filepath.Join(location, "Win8")) myutils.CopyFile(filepath.Join(location, "usb_driver"), filepath.Join(location, "Win8")) fmt.Println(location) }
func (sr *SupportlibRep) Install(args ...string) { sr.ComponentId = args[0] sr.Version = args[1] sr.ExecFile = args[2] sr.InstallLocation = args[3] myutils.Decompress(args[2], args[3]) fmt.Println(filepath.Join(sr.InstallLocation, "m2repository")) }
func (r *Rebel) Install(args ...string) { fmt.Println(args[0], args[1], args[2], args[3]) r.ComponentId = args[0] r.ExecFile = "TOD.zip" r.InstallLocation = args[3] //if _, e := os.Stat(r.InstallLocation); e != nil { // os.Mkdir(r.InstallLocation, 0777) //} myutils.Decompress(r.ExecFile, r.InstallLocation) }
func (c *Component) Install(args ...string) { if len(args) < 4 { fmt.Println("wrong args input") return } c.Version = args[1] c.ExecFile = args[2] //fmt.Println(c.ComponentId, "installing ", c.Version, "using execute file : ", c.ExecFile) myutils.Decompress(args[2], args[3]) c.InstallLocation = filepath.Join(args[3], "") fmt.Println(c.InstallLocation) }
func (d *Docs_NDA) Install(args ...string) { //fmt.Println(args[0], args[1], args[2], args[3]) d.ComponentId = args[0] d.ExecFile = "docs.zip" d.InstallLocation = args[3] if _, e := os.Open(d.InstallLocation); e == nil { myutils.Rmdir(d.InstallLocation) } myutils.Decompress(d.ExecFile, d.InstallLocation) fmt.Println(filepath.Join(d.InstallLocation, "docs")) }
func (g *GameWorks) Install(args ...string) { g.ComponentId = args[0] g.Version = args[1] g.ExecFile = args[2] g.InstallLocation = args[3] if _, e1 := os.Open(g.InstallLocation); e1 == nil { //destination directory exist myutils.Rmdir(g.InstallLocation) } //fmt.Println(c.ComponentId, "installing ", c.Version, "using execute file : ", c.ExecFile) myutils.Decompress(args[2], args[3]) fmt.Println(filepath.Join(g.InstallLocation, "")) }
func (s *SDK) Install(args ...string) { s.ComponentId = args[0] myutils.Decompress(args[2], args[3]) //Add enviroment variables //1. add platform-tools,build-tools,tools to PATH sdk_path := filepath.Join(args[3], "android-sdk-"+myutils.Global_OS) t_path := filepath.Join(sdk_path, "tools") myutils.Set_Environment("PATH", t_path) //2. add ANDROID_HOME myutils.Set_Environment("ANDROID_HOME", sdk_path) fmt.Println(sdk_path) }
func (a *Ant) Install(args ...string) { a.ComponentId = args[0] myutils.Decompress(args[2], args[3]) //Add enviroment variables //1. add ant/bin to PATH a.Version = args[1] ant_path := filepath.Join(args[3], "apache-ant-"+args[1]) bin_path := filepath.Join(ant_path, "bin") myutils.Set_Environment("PATH", bin_path) //2. add ANT_HOME myutils.Set_Environment("ANT_HOME", ant_path) fmt.Println(ant_path) }
func (s *Samples) Install(args ...string) { s.ComponentId = args[0] s.Version = args[1] s.ExecFile = args[2] s.InstallLocation = filepath.Join(args[3], "TDK_Samples") _, e := os.Stat(s.InstallLocation) if e == nil { os.RemoveAll(s.InstallLocation) } myutils.Decompress(s.ExecFile, args[3]) oldfname := filepath.Join(args[3], "tegra_android_native_samples_"+s.Version) //os.Rename(oldfname, s.InstallLocation) myutils.CopyFile(oldfname, s.InstallLocation) fmt.Println(s.InstallLocation) }
func (g *Gradle) Install(args ...string) { g.ComponentId = args[0] myutils.Decompress(args[2], args[3]) //Add enviroment variables //1. add gradle/bin to PATH g.Version = args[1] gradle_path := filepath.Join(args[3], "gradle-"+args[1]) bin_path := filepath.Join(gradle_path, "bin") myutils.Set_Environment("PATH", bin_path) //2. add ANT_HOME myutils.Set_Environment("GRADLE_HOME", gradle_path) fmt.Println(gradle_path) }
func (ocv *OpenCV) Install(args ...string) { if len(args) < 4 { fmt.Println("wrong args input") return } ocv.Version = args[1] ocv.ExecFile = args[2] ocv.InstallLocation = args[3] if _, e := os.Open(filepath.Join(ocv.InstallLocation, "OpenCV-"+ocv.Version+"-Tegra-sdk")); e == nil { myutils.Rmdir(filepath.Join(ocv.InstallLocation, "OpenCV-"+ocv.Version+"-Tegra-sdk")) } myutils.Decompress(args[2], args[3]) fmt.Println(filepath.Join(ocv.InstallLocation, "OpenCV-"+ocv.Version+"-Tegra-sdk")) }
func (cs *CUDASamples) Install(args ...string) { if len(args) < 4 { fmt.Println("wrong args input") return } cs.Version = args[1] cs.ExecFile = args[2] cs.InstallLocation = args[3] if _, e := os.Open(cs.InstallLocation); e == nil { myutils.Rmdir(cs.InstallLocation) } myutils.Decompress(args[2], args[3]) fmt.Println(filepath.Join(cs.InstallLocation, "CUDA_Samples")) }
func (d *Docs) Install(args ...string) { if len(args) < 4 { fmt.Println("wrong args input") return } d.Version = args[1] d.ExecFile = args[2] d.InstallLocation = args[3] if _, e := os.Open(d.InstallLocation); e == nil { myutils.Rmdir(d.InstallLocation) } myutils.Decompress(args[2], args[3]) fmt.Println(filepath.Join(d.InstallLocation, "docs")) }
func (api *API) Install(args ...string) { api.ComponentId = args[0] api.Version = args[1] if api.ComponentId == "api21" || api.ComponentId == "api22" { api_list[api.ComponentId] = "android-" + api.Version } location := filepath.Join(args[3], api_list[api.ComponentId]) new_location := filepath.Join(args[3], strings.Replace(args[0], "api", "android-", 1)) myutils.Decompress(args[2], args[3]) os.RemoveAll(new_location) //err := os.Rename(location, new_location) _, err := myutils.CopyFile(location, new_location) myutils.CheckError(err) fmt.Println(new_location) }
func (p *PlatformTools) Install(args ...string) { if len(args) < 4 { fmt.Println("wrong args input") return } p.ComponentId = args[0] myutils.Decompress(args[2], args[3]) //Add enviroment variables //add platform-tools to PATH sdk_path := args[3] pt_path := filepath.Join(sdk_path, "platform-tools") myutils.Set_Environment("PATH", pt_path) fmt.Println(pt_path) }
func (b *BuildTools) Install(args ...string) { if len(args) < 4 { fmt.Println("wrong args input") return } b.ComponentId = args[0] b.Version = args[1] bt_path := args[3] myutils.Decompress(args[2], bt_path) flocation := filepath.Join(bt_path, "android-5.1") //os.Rename(flocation, filepath.Join(bt_path, b.Version)) myutils.CopyFile(flocation, filepath.Join(bt_path, b.Version)) //Add enviroment variables //add build-tools to PATH myutils.Set_Environment("PATH", bt_path) fmt.Println(filepath.Join(bt_path, "")) }
func (j *JavaSDK) Install(args ...string) { j.ComponentId = args[0] j.Version = args[1] j.InstallLocation = args[3] if _, e1 := os.Open(filepath.Join(j.InstallLocation, "jdk"+j.Version)); e1 == nil { //destination directory exist myutils.Rmdir(filepath.Join(j.InstallLocation, "jdk"+j.Version)) } myutils.Decompress(args[2], args[3]) //Add enviroment variables //1. add java/bin to PATH j.Version = args[1] java_path := filepath.Join(args[3], "jdk"+args[1]) bin_path := filepath.Join(java_path, "bin") myutils.Set_Environment("PATH", bin_path) //2. add ANT_HOME myutils.Set_Environment("JAVA_HOME", java_path) fmt.Println(java_path) }
func (ca *CUDAAndroid) Install(args ...string) { if len(args) < 4 { fmt.Println("wrong args input") return } ca.Version = args[1] ca.ExecFile = args[2] ca.InstallLocation = args[3] if _, e := os.Open(ca.InstallLocation); e == nil { myutils.Rmdir(ca.InstallLocation) } //fmt.Println(c.ComponentId, "installing ", c.Version, "using execute file : ", c.ExecFile) myutils.Decompress(args[2], args[3]) if strings.Contains(ca.Version, "6.5") { fmt.Println(filepath.Join(ca.InstallLocation, "cuda-android-6.5")) } else if strings.Contains(ca.Version, "7.0") { fmt.Println(filepath.Join(ca.InstallLocation, "cuda-android-7.0")) } }
func (p *PerfHUDES) Install(args ...string) { p.ComponentId = args[0] p.Version = args[1] p.ExecFile = args[2] p.InstallLocation = args[3] var pkg_name, pkg_installer string _, exist := os.Stat(filepath.Join(p.InstallLocation, "perfhudes_tmp", "uninstall.iss")) if exist == nil { os.Chmod(filepath.Join(p.InstallLocation, "perfhudes_tmp", "uninstall.iss"), 0777) os.RemoveAll(filepath.Join(p.InstallLocation, "perfhudes_tmp")) } myutils.Decompress(args[2], args[3]) if myutils.Global_OS == "linux" { //install perfhude on linux if runtime.GOARCH == "386" { pkg_name = "perfhudes_release.x86.deb.tgz" pkg_installer = "perfhudes_" + p.Version + "_i386.deb" } else if runtime.GOARCH == "amd64" { pkg_name = "perfhudes_release.x64.deb.tgz" pkg_installer = "perfhudes_" + p.Version + "_amd64.deb" } else { fmt.Println("unknown os arch") os.Exit(-1) } myutils.Decompress(filepath.Join(args[3], pkg_name), p.InstallLocation) os.Remove(filepath.Join(args[3], pkg_name)) _, e := exec.Command("xterm", "-e", "sudo dpkg -i "+filepath.Join(args[3], pkg_installer)+" && sudo apt-get install -f -y && echo success>>.p.txt").Output() myutils.CheckError(e) os.Remove(filepath.Join(p.InstallLocation, "perfhudes_"+p.Version+"_amd64.deb")) if _, pe := os.Stat(".p.txt"); pe != nil { fmt.Println("Failed to install perfhudes") os.Exit(2) } else { os.Remove(".p.txt") } } else if myutils.Global_OS == "windows" { setup_file := filepath.Join(p.InstallLocation, "perfhudes_tmp", "setup.iss") setup_log := filepath.Join(p.InstallLocation, "perfhudes_tmp", "setup.log") myutils.Substitude(setup_file, "szDir=c:\\perfhud_es", "szDir="+args[3]+"\\perfhud_es") os.Remove(setup_file) //re := os.Rename(filepath.Join(args[3], "perfhudes_tmp", ".tmp_file"), setup_file) _, re := myutils.CopyFile(filepath.Join(args[3], "perfhudes_tmp", ".tmp_file"), setup_file) myutils.CheckError(re) pkg_name = "NVIDIA_PerfHUD_ES_Release.exe" pkg_installer = filepath.Join(p.InstallLocation, "perfhudes_tmp", pkg_name) _, e := exec.Command("cmd", "/c", pkg_installer, "/s", "/f1"+setup_file+"\n/f2"+setup_log).Output() myutils.CheckError(e) dst := filepath.Join(p.InstallLocation, "perfhud_es", "uninstall.iss") org := filepath.Join(p.InstallLocation, "perfhudes_tmp", "uninstall.iss") _, ce := myutils.CopyFile(org, dst) myutils.CheckError(ce) os.Chmod(org, 0777) os.RemoveAll(filepath.Join(p.InstallLocation, "perfhudes_tmp")) } else if myutils.Global_OS == "macosx" { //not finished perfhudes_mac := "perfhudes-" + p.Version pkg_installer = "perfhudes-" + p.Version + ".dmg" _, e1 := exec.Command("hdiutil", "attach", filepath.Join(args[3], "perfhudes_tmp", pkg_installer)).Output() myutils.CheckError(e1) _, e2 := exec.Command("cp", "-rf", "/Volumes/"+perfhudes_mac+"_x86/perfhudes.app", args[3]).Output() myutils.CheckError(e2) //detach _, e3 := exec.Command("hdiutil", "detach", "/Volumes/"+perfhudes_mac+"_x86").Output() myutils.CheckError(e3) } else { fmt.Println("error") } fmt.Println("System") }
func (e *Eclipse) Install(args ...string) { e.ComponentId = args[0] e.Version = args[1] e.ExecFile = args[2] e.InstallLocation = args[3] var cfile, tmp_file string if myutils.Global_OS == "macosx" { //exec.Command("bash", "-c", "java -version 2>a.txt").Output() // java_version, _ := exec.Command("cat", ".java.txt").Output() // os.Remove("a.txt") // fmt.Println(string(java_version)) // if strings.Contains(string(java_version), "1") { // } else { // fmt.Println("installing java 1.6.0_65") // //_, oe1 := exec.Command("hdiutil", "attach", "_installer/JavaForOSX2014-001.dmg").Output() // //_, oe2 := exec.Command("osascript", "-e 'do shell script with administrator privileges'", "installer -pkg /Volumes/Java for OS X 2014-001/JavaForOSX.pkg -target /").Output() // _, oe2 := exec.Command("bash", "installjava.sh").Output() // //fmt.Println("osascript", "-e 'do shell script with administrator privileges'", "installer -pkg /Volumes/Java for OS X 2014-001/JavaForOSX.pkg -target /") // if oe2 != nil { // myutils.CheckError(oe2) // } // //exec.Command("hdiutil", "detach", "/Volumes/Java for OS X 2014-001").Output() // //os.Remove("installjava.sh") // } //exec.Command("bash", "-c", "unzip "+e.ExecFile+" -d "+e.InstallLocation).Output() // myutils.Decompress(e.ExecFile, e.InstallLocation) exec.Command("bash", "-c", "cd "+e.InstallLocation+"&& tar xvf "+e.ExecFile).Output() cfile = filepath.Join(e.InstallLocation, "eclipse", "Eclipse.app", "Contents", "MacOS", ".eclipse.ini") tmp_file = filepath.Join(e.InstallLocation, "eclipse", "Eclipse.app", "Contents", "MacOS", ".tmp_file") } else { myutils.Decompress(e.ExecFile, e.InstallLocation) cfile = filepath.Join(e.InstallLocation, "eclipse", "eclipse.ini") tmp_file = filepath.Join(e.InstallLocation, "eclipse", ".tmp_file") } var oldstr, newstr string if myutils.Global_OS == "windows" { //Get JAVA version java_ver := get_java_version() oldstr = "-vmargs" newstr = "-pluginCustomization\r\n" + e.InstallLocation + "eclipse\\nvpref.ini\r\n-vm\r\n" + java_ver + "\\bin\\javaw.exe\r\n-vmargs" } else if myutils.Global_OS == "linux" { oldstr = "-vmargs" newstr = "-pluginCustomization\n" + e.InstallLocation + "eclipse/nvpref.ini\n-vmargs" } else if myutils.Global_OS == "macosx" { oldstr = "-vmargs" newstr = "-pluginCustomization\n" + e.InstallLocation + "eclipse/Eclipse.app/Contents/Mac" } myutils.Substitude(cfile, oldstr, newstr) err := os.Rename(tmp_file, cfile) //_, err := myutils.CopyFile(tmp_file, cfile) if err != nil { fmt.Println("Copy file error") fmt.Println(err) } os.Remove(tmp_file) fmt.Println(filepath.Join(e.InstallLocation, "eclipse")) // myutils.CopyFile(filepath.Join(e.InstallLocation, "eclipse", ".tmp_file"), cfile) //strings.Replace() }