예제 #1
0
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 (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)
}
예제 #3
0
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)
}
예제 #4
0
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)

}
예제 #5
0
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, ""))
}
예제 #6
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")
}