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 (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() }