Ejemplo n.º 1
0
func (n *NDK) Install(args ...string) {
	if len(args) < 4 {
		fmt.Println("wrong args input")
		return
	}
	n.ComponentId = args[0]
	n.Version = args[1]
	n.ExecFile = args[2]
	n.InstallLocation = args[3]

	os.Chmod(n.ExecFile, 0777)
	_, e := exec.Command(n.ExecFile, "-y", "-o"+n.InstallLocation).Output()
	myutils.CheckError(e)

	//Add enviroment variables
	//1. add platform-tools,build-tools,tools to PATH

	ndk_path := filepath.Join(args[3], "android-ndk-r"+n.Version)
	//os.Mkdir(ndk_path, os.ModePerm)
	myutils.Set_Environment("PATH", ndk_path)

	//2. add ANDROID_NDK_HOME, NDKROOT,NDK_ROOT
	myutils.Set_Environment("ANDROID_NDK_ROOT", ndk_path)
	myutils.Set_Environment("NDK_ROOT", ndk_path)
	myutils.Set_Environment("NDKROOT", ndk_path)
	myutils.Set_Environment("NVPACK_NDK_VERSION", "android-ndk-r"+n.Version)
	//3. generate standalone toolchain

	if myutils.Global_OS == "linux" && runtime.GOARCH == "amd64" {
		genscript := filepath.Join(ndk_path, "build", "tools", "make-standalone-toolchain.sh")

		//generate 32 bit standalone toolchain
		s_path := filepath.Join(ndk_path, "toolchains", "arm-linux-androideabi-4.6", "gen_standalone", "linux-x86_64")
		gencmd := "bash " + genscript + " --platform=android-14 --system=linux-x86_64 --arch=arm --install-dir=" + s_path

		_, e1 := exec.Command("bash", "-c", gencmd).Output()
		myutils.CheckError(e1)
		myutils.Set_Environment("NDK_STANDALONE_46_ANDROID9_32", s_path)

		//generate 64 bit standalone toolchain
		s_path_64 := filepath.Join(ndk_path, "toolchains", "aarch64-linux-android-4.9", "gen_standalone", "linux-x86_64")
		gencmd_64 := "bash " + genscript + " --platform=android-21 --system=linux-x86_64 --arch=arm64 --install-dir=" + s_path_64 + " --toolchain=aarch64-linux-android-4.9"

		_, e2 := exec.Command("bash", "-c", gencmd_64).Output()
		myutils.CheckError(e2)
		myutils.Set_Environment("NDK_STANDALONE_46_ANDROID9_64", s_path_64)
	}
	fmt.Println(ndk_path)
}
Ejemplo n.º 2
0
func (ns *NsightTegra) Uninstall(args ...string) {

	ns.ComponentId = args[0]
	ns.Version = args[1]
	path := `Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall`
	//uninstall the bundle exe
	//uninstall_exe_string := myutils.QueryRegister("Nsight", "QuietUninstallString")
	uninstall_exe_string := myutils.RegQuery(path, "Nsight Tegra", "QuietUninstallString")
	sysroot := os.Getenv("SystemRoot")
	uninstall_exe_string = strings.Replace(strings.Replace(uninstall_exe_string, "\"", "", -1), "/uninstall /quiet", "", 1)
	//fmt.Println("uninstall_exe_string is :", strings.Replace(uninstall_exe_string, "/uninstall /quiet", "", 1))

	if uninstall_exe_string != "" {

		_, e := exec.Command("cmd", "/c", uninstall_exe_string, "/uninstall", "/quiet").Output()
		myutils.CheckError(e)
	}

	//uninstall the msi if still exist

	//uninstall_msi_string := myutils.QueryRegister("NVIDIA*nsight*Tegra", "UninstallString")
	uninstall_msi_string := myutils.RegQuery(path, "Nsight Tegra", "UninstallString")

	if uninstall_msi_string != "" {

		uninstall_msi_string = strings.Replace(uninstall_msi_string, "MsiExec.exe ", "", 1)
		//fmt.Println(sysroot+"/System32/msiexec.exe", "/passive", uninstall_msi_string)
		_, e1 := exec.Command(sysroot+"/System32/msiexec.exe", "/passive", uninstall_msi_string).Output()
		if e1 != nil {
			fmt.Println(e1)
		}

		//fmt.Println("end")
	}
}
Ejemplo n.º 3
0
func (ns *NsightTegra) Install(args ...string) {

	ns.ComponentId = args[0]
	ns.Version = args[1]
	ns.ExecFile = args[2]
	ns.InstallLocation = args[3]

	//check visual studio installed or not
	var node string
	reglist := []string{"Microsoft\\VisualStudio\\10.0\\Setup\\VS", "Microsoft\\VisualStudio\\11.0\\Setup\\VS", "Microsoft\\VisualStudio\\12.0\\Setup\\VS"}
	if runtime.GOARCH == "amd64" {
		node = "HKLM\\Software\\Wow6432Node\\"
	} else {
		node = "HKLM\\Software\\"
	}
	var value string
	flag := false
	for i := 0; i < len(reglist); i++ {
		value = myutils.Get_val_reg(node+reglist[i], "ProductDir")
		if value == "" {
			flag = false
		} else {
			flag = true
			break
		}
	}

	if flag == false {
		fmt.Println("Cannot detect Visual Studio(2010|2012|2013) on your system. Please install Visual Studio first to support install Nsight Tegra")
		os.Exit(2)
	}
	_, e := exec.Command(ns.ExecFile, "/passive").Output()
	myutils.CheckError(e)
	fmt.Println("Nsight Tegra has integrated into Visual Studio")
}
Ejemplo n.º 4
0
func (u *USB) Uninstall(args ...string) {
	u.ComponentId = args[0]
	u.Version = args[1]
	u.InstallLocation = filepath.Join(args[2], "Drivers", "Devkits")
	e := os.RemoveAll(u.InstallLocation)
	myutils.CheckError(e)
	os.Remove(filepath.Join(args[2], "Drivers"))
	fmt.Println(u.InstallLocation)
}
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)
}
Ejemplo n.º 6
0
func (adt *ADT) Install(args ...string) {
	adt.ComponentId = args[0]
	adt.Version = args[1]
	adt.ExecFile = args[2]
	adt.InstallLocation = args[3]

	var elocation, nvpref string
	elocation = filepath.Join(args[3], "eclipse")
	if myutils.Global_OS == "windows" {
		elocation = filepath.Join(elocation, "eclipsec.exe")
		adt.ExecFile = "\"" + adt.ExecFile + "\""
	} else {
		elocation = filepath.Join(elocation, "eclipse")
		adt.ExecFile = strings.Replace(strings.Replace(strings.Replace(strings.Replace(adt.ExecFile, "\\", "\\\\", -1), "\"", "\\\"", -1), "'", "\\'", -1), " ", "\\ ", -1)
	}

	if myutils.Global_OS == "macosx" {
		nvpref = filepath.Join(args[3], "eclipse", "Eclipse.app", "Contents", "MacOS", "nvpref.ini")
	} else {
		nvpref = filepath.Join(args[3], "eclipse", "nvpref.ini")
	}

	//installing adt
	eargs := elocation + " -nosplash -application org.eclipse.equinox.p2.director -repository jar:file:" + adt.ExecFile + "!/, -installIU com.android.ide.eclipse.ddms.feature.feature.group,com.android.ide.eclipse.traceview.feature.feature.group,com.android.ide.eclipse.hierarchyviewer.feature.feature.group,com.android.ide.eclipse.adt.feature.feature.group,com.android.ide.eclipse.ndk.feature.feature.group,com.android.ide.eclipse.gldebugger.feature.feature.group"

	//fmt.Println(eargs)
	if myutils.Global_OS == "windows" {
		_, e := exec.Command("cmd", "/c", eargs).Output()
		myutils.CheckError(e)
	} else {
		_, e := exec.Command("bash", "-c", eargs).Output()
		myutils.CheckError(e)
	}

	//write to nvpref.ini
	sdk_path := filepath.Join(args[3], "android-sdk-"+myutils.Global_OS)
	config_str := `com.android.ide.eclipse.adt/com.android.ide.eclipse.adt.sdk=` + strings.Replace(sdk_path, "\\", "\\\\", -1) + `
org.eclipse.jdt.core/org.eclipse.jdt.core.classpathVariable.ANDROID_JAR=` + strings.Replace(sdk_path, "\\", "/", -1) + `/platforms/android-8/android.jar
com.android.ide.eclipse.adt/com.android.ide.eclipse.adt.skipPostCompileOnFileSave=false
org.eclipse.cdt.debug.mi.core/org.eclipse.cdt.debug.mi.core.SharedLibraries.auto_refresh=false
org.eclipse.cdt.codan.core/org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>;{RUN_ON_FULL_BUILD\=>;false,RUN_ON_INC_BUILD\=>;false,RUN_AS_YOU_TYPE\=>;true,RUN_ON_DEMAND\=>;true}}
Ejemplo n.º 7
0
func (e *Eclipse) Uninstall(args ...string) {
	if len(args) < 3 {
		fmt.Println("wrong args input")
		return
	}

	e.ComponentId = args[0]
	e.Version = args[1]
	e.InstallLocation = filepath.Join(args[2], "eclipse")
	err := os.RemoveAll(e.InstallLocation)
	myutils.CheckError(err)
	fmt.Println(e.InstallLocation)
}
Ejemplo n.º 8
0
func (ib *IncrediBuild) Install(args ...string) {

	ib.ComponentId = args[0]
	ib.Version = args[1]
	ib.ExecFile = args[2]
	ib.InstallLocation = filepath.Join(os.Getenv("ProgramFiles(x86)"), "Xoreax", "IncrediBuild")

	_, e := exec.Command("cmd", "/c", ib.ExecFile+` /install /Components=Coordinator,Agent /tadp_bundle`).Output()

	myutils.CheckError(e)

	fmt.Println(ib.InstallLocation)
}
Ejemplo n.º 9
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)
}
Ejemplo n.º 10
0
func (ib *IncrediBuild) Uninstall(args ...string) {
	//InstallUtil uninstall incredibuild 1606 [installdir] -p [exefile]
	ib.ComponentId = args[0]
	ib.Version = args[1]
	//ib.ExecFile = args[2] //IBSetupConsole1606.exe
	ib.InstallLocation = filepath.Join(os.Getenv("ProgramFiles(x86)"), "Xoreax", "IncrediBuild")

	if len(args) > 4 && args[3] == "-p" {
		ib.ExecFile = args[4]
	}

	_, e := exec.Command(ib.ExecFile, "/uninstall").Output()
	myutils.CheckError(e)
	fmt.Println(ib.InstallLocation)

}
Ejemplo n.º 11
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)

}
Ejemplo n.º 12
0
func (pk *Perfkit) Uninstall(args ...string) {
	if len(args) < 3 {
		fmt.Println("wrong args input")
		return
	}

	pk.ComponentId = args[0]
	pk.Version = args[1]
	pk.InstallLocation = filepath.Join(args[2], "PerfKit")

	if myutils.Global_OS == "windows" {
		exec.Command("C:\\Windows\\system32\\cmd.exe", "/c", "del", "/f", "/s", "/q", pk.InstallLocation).Output()
	}
	err := os.RemoveAll(pk.InstallLocation)
	myutils.CheckError(err)
	//fmt.Println(componentId, "uninstalling ", version, "using execute file : ", execFile)
}
func (q *Quadd) Uninstall(args ...string) {

	q.ComponentId = args[0]
	q.Version = args[1]
	q.InstallLocation = filepath.Join(args[2], "Tegra_System_Profiler")

	if myutils.Global_OS == "windows" {
		q.InstallLocation = filepath.Join(os.Getenv("ProgramFiles"), "NVIDIA Corporation")
		//uninstall_string := myutils.QueryRegister("tegra*system", "UninstallString")
		uninstall_string := myutils.RegQuery(`Software\Microsoft\Windows\CurrentVersion\Uninstall`, "Tegra System Profiler", "UninstallString")

		uninstall_string = strings.Replace(uninstall_string, "MsiExec.exe ", "", 1)
		sysroot := os.Getenv("SystemRoot")
		_, e := exec.Command(sysroot+"/System32/msiexec.exe", "/passive", uninstall_string).Output()
		myutils.CheckError(e)
	} else {
		if myutils.Global_OS == "linux" {
			os.Remove(os.Getenv("HOME") + "/.local/share/applications/tegrasystemprofiler.desktop")
		}
		os.RemoveAll(q.InstallLocation)
	}
	fmt.Println(q.InstallLocation)
}
Ejemplo n.º 14
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")
}
Ejemplo n.º 15
0
func (b *Battle) Install(args ...string) {

	b.ComponentId = args[0]
	b.Version = args[1]
	b.ExecFile = args[2]
	b.InstallLocation = filepath.Join(args[3], "Tegra_Graphics_Debugger")

	var e error
	if _, err := os.Stat(filepath.Join(args[3], "_installer")); err != nil {
		os.MkdirAll(filepath.Join(args[3], "_installer"), 0777)
	}
	if myutils.Global_OS == "windows" {
		b.InstallLocation = filepath.Join(os.Getenv("ProgramFiles(x86)"), "NVIDIA Corporation")
		sysroot := os.Getenv("SystemRoot")
		//_, e = exec.Command(sysroot+"/System32/msiexec.exe", "/i", b.ExecFile, "/q", "/l*vx", "_installer/battle.log", "INSTALLDIR="+b.InstallLocation).Output()
		_, e = exec.Command(sysroot+"/System32/msiexec.exe", "/i", b.ExecFile, "/q", "/l*vx", "_installer/battle.log").Output()
	} else if myutils.Global_OS == "linux" {
		os.Chmod(b.ExecFile, 0777)
		//_, e = exec.Command("xterm", "-e", b.ExecFile+" -targetpath="+b.InstallLocation+" -noprompt").Output()
		_, e = exec.Command(b.ExecFile, " -targetpath="+b.InstallLocation, " -noprompt", "--nox11").Output()

		//add to desktop entry
		battle_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(b.InstallLocation, "nvidia-gfx-debugger") + `
TryExec=` + filepath.Join(b.InstallLocation, "nvidia-gfx-debugger") + `
Keywords=tegra;graphics;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+"/tegragraphicsdebugger.desktop", os.O_CREATE|os.O_RDWR, 0600)
		if fe != nil {
			fmt.Println(fe)
		}
		fp.WriteString(battle_entry)
	} else if myutils.Global_OS == "macosx" {
		if _, exist := os.Stat(b.InstallLocation); exist != nil {
			os.Mkdir(b.InstallLocation, 0777)
		}
		_, e1 := exec.Command("hdiutil", "attach", b.ExecFile).Output()

		_, e2 := exec.Command("cp", "-r", "/Volumes/NVIDIA Tegra Graphics Debugger/NVIDIA Tegra Graphics Debugger.app", b.InstallLocation).Output()
		exec.Command("cp", "/Volumes/NVIDIA Tegra Graphics Debugger/EULA.txt", b.InstallLocation).Output()

		_, e = exec.Command("hdiutil", "detach", "/Volumes/NVIDIA Tegra Graphics Debugger").Output()

		myutils.CheckError(e1)
		myutils.CheckError(e2)
	} else {
		fmt.Println("unknow platforms, only support Windows ,Linux and Mac")
		os.Exit(2)
	}

	myutils.CheckError(e)
	fmt.Println(b.InstallLocation)
}
Ejemplo n.º 16
0
func main() {
	if len(os.Args) == 3 {
		if os.Args[1] == "run" {
			//run the Poller.exe
			poller_dir := os.Args[2]
			e := exec.Command(poller_dir).Start()
			fmt.Println("Done", e)
			os.Exit(0)

		} else if os.Args[1] == "rusb" {
			var pnpu string
			if runtime.GOARCH == "amd64" {
				pnpu = "C:\\windows\\system32\\pnputil.exe"
			} else {
				pnpu = "C:\\windows\\system\\pnputil.exe"
			}
			fmt.Println(pnpu)
			_, e := exec.Command(pnpu, "-a", os.Args[2]).Output()
			if e != nil {
				fmt.Println(e)
				os.Exit(2)
			}
			os.Exit(0)
		}
	}
	if len(os.Args) < 4 {
		fmt.Println("Please supply a command and component id!\nUsage: InstallUtil [Install] [compName] [version] [exefile] [install_location]")
		fmt.Println("      		   [uninstall] [compName] [version] [install_location]")
		fmt.Println("      		   [query] [compName] [location]")
		fmt.Println("      		   [deploy] [location] [version]")
		fmt.Println("      		   [preInstall] [compName] [version] [task] [target] {-c}")
		fmt.Println("      		   [reg_uninstaller] [-i|-u] [installdir]")
		os.Exit(-1)
	} else {
		var pkgname string
		if os.Args[1] == "deploy" {
			c := &myutils.CompileCommand{}
			c.Run(os.Args[1], os.Args[2], os.Args[3])
			os.Exit(0)
		} else if os.Args[1] == "env_add" {

			envadd := &myutils.EnvaddCommand{}
			envadd.Run(os.Args[2], os.Args[3])
			os.Exit(0)
		} else if os.Args[1] == "reg_uninstaller" {
			//add uninstaller to windows registery
			// [Key Name]
			// HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\NVIDIA Tegra Android Development Pack
			//[Name]                    [Value]
			//DisplayIcon               C:\NVPACK\_installer\TegraDeveloperKit.ico
			//NoModify                  0
			//ModifyPath                C:\NVPACK\Chooser.exe
			//UninstallString           C:\NVPACK\tadp_uninstaller.exe
			regName := `HKLM\Software\Wow6432Node\microsoft\windows\CurrentVersion\Uninstall\NVIDIA Tegra Android Development Pack`
			cmdExe := "C:\\Windows\\system32\\cmd.exe"
			option := os.Args[2]
			if option == "-i" {
				path_chooser := filepath.Join(os.Args[3], "Chooser.exe")

				exec.Command(cmdExe, "/c", `reg add "`+regName+`" /v NoModify /d 0 /f`).Output()
				exec.Command(cmdExe, "/c", `reg add "`+regName+`" /v DisplayIcon /d `+path_chooser+` /f`).Output()
				exec.Command(cmdExe, "/c", `reg add "`+regName+`" /v Publisher /d "NVIDIA Corporation" /f`).Output()
				exec.Command(cmdExe, "/c", `reg add "`+regName+`" /v DisplayName /d "NVIDIA Tegra Android Development Pack" /f`).Output()
				exec.Command(cmdExe, "/c", `reg add "`+regName+`" /v UninstallString /d "`+path_chooser+` -u" /f`).Output()
				exec.Command(cmdExe, "/c", `reg add "`+regName+`" /v ModifyPath /d `+path_chooser+` /f`).Output()
			} else if option == "-u" {
				_, e := exec.Command(cmdExe, "/c", `reg delete `+regName+` /f`).Output()
				myutils.CheckError(e)
			}
		}
		if strings.Contains(os.Args[2], "api") {
			pkgname = "api"
		} else {
			pkgname = os.Args[2]
		}
		if comp, ok := comps[pkgname]; ok {
			if os.Args[1] == "install" {
				if len(os.Args) < 6 {
					fmt.Println("Wrong args input. Usage: InstallUtil install compName version exefile install_location")
					os.Exit(-1)
					return
				}
				comp.Install(os.Args[2:]...)
			} else if os.Args[1] == "uninstall" {
				if len(os.Args) < 5 {
					fmt.Println("Wrong args input. Usage: InstallUtil uninstall compName version install_location")
					os.Exit(-1)
					return
				}
				comps[pkgname].Uninstall(os.Args[2:]...)
			} else if os.Args[1] == "query" {
				if len(os.Args) < 4 {
					fmt.Println("Wrong args input. Usage: InstallUtil uninstall compName version install_location")
					os.Exit(-1)
					return
				}
				if autocomp, q := autoComps[pkgname]; q && os.Args[2] != "api" {
					revision := autocomp.Query(os.Args[2], os.Args[3])
					fmt.Println(revision)
					//fmt.Println(myutils.Get_revision(os.Args[2], os.Args[3]))
				} else {
					//fmt.Println(os.Args[2])
					os.Exit(-1)
				}
			} else if os.Args[1] == "preInstall" {
				if len(os.Args) < 6 {
					fmt.Println("Wrong args input. Usage: InstallUtil uninstall compName version install_location")
					os.Exit(-1)
					return
				}
				if pacomp, q := preActionComps[pkgname]; q {
					os.Exit(pacomp.PreInstall(os.Args[2:]...))
				}
			} else {
				panic(os.Args[1] + " command is not defined!")
			}
		} else {
			fmt.Println(os.Args[2] + " component is not defined!")
			os.Exit(-1)
		}
	}
}