protected override bool DeployDebuggerPackage(string debugger)
        {
            bool    result  = true;
            Process process = SDBLib.CreateSdbProcess(true, true);

            if (process == null)
            {
                ErrorMessage = "Failed to get sdb.exe program";
                return(false);
            }

            string arg       = "shell 0 vs_lldbinstall";
            string arguments = DeviceManager.AdjustSdbArgument(arg);

            process.StartInfo.Arguments = arguments;
            ErrorMessage = String.Empty;

            try
            {
                if (!process.Start())
                {
                    ErrorMessage = "Failed to install lldb.tar.gz";
                    return(false);
                }

                process.WaitForExit(5 * 1000);
            }
            catch (Exception e)
            {
                ErrorMessage = e.Message;
                result       = false;
            }

            return(result);
        }
        protected override bool GetPkgInstalledStatus(out bool isInstalled)
        {
            isInstalled  = false;
            ErrorMessage = string.Empty;

            PkgInstalledStatusWaiter waiter = new PkgInstalledStatusWaiter();
            string  argument = DeviceManager.AdjustSdbArgument("shell 0 vs_lldbversion");
            Process process  = SDBLib.CreateSdbProcess(true, true);
            var     result   = (process == null) ? null : SDBLib.RunSdbProcessAsync(process, argument, true, waiter);

            if (!waiter.Waiter.WaitOne(30000))
            {
                OutputDeviceErrorMsg("GetPkgInstalledStatus failed: Timeout");
                return(false);
            }

            try
            {
                Version installedLldbVersion = new Version(waiter.InstalledStatus);
                Version lldbRpmFileVersion   = new Version(lldbVersion);

                if (installedLldbVersion >= lldbRpmFileVersion)
                {
                    OutputDeviceErrorMsg("GetPkgInstalledStatus (already installed): " + lldbPkgName);
                    isInstalled = true;
                }

                return(true);
            }
            catch (Exception e)
            {
                OutputDeviceErrorMsg("GetPkgInstalledStatus failed: " + e.Message);
                return(false);
            }
        }
        protected virtual bool PushDebuggerPackage(string source, string destination)
        {
            DebuggerInstallWaiter waiter = new DebuggerInstallWaiter(this as IOndemandInstallerEvents);
            Process process = SDBLib.CreateSdbProcess(true, true);

            if (process == null)
            {
                ErrorMessage = "Failed to get sdb.exe program";
                return(false);
            }

            string fmt      = "push \"{0}\" \"{1}\"";
            string arg      = String.Format(fmt, source, destination);
            string argument = DeviceManager.AdjustSdbArgument(arg);
            var    result   = SDBLib.RunSdbProcessAsync(process, argument, true,
                                                        waiter);

            if (waiter.Waiter.WaitOne(300 * 1000)) // 5 minutes will be enough?
            {
                ErrorMessage = waiter.LastErrorMessage;
                return(waiter.PushResult);
            }

            ErrorMessage = "SDB Push Timeout.";
            return(false);
        }
        protected virtual bool GetPkgInstalledStatus(out bool isInstalled)
        {
            isInstalled  = false;
            ErrorMessage = string.Empty;

            PkgInstalledStatusWaiter waiter2 = new PkgInstalledStatusWaiter();
            string argument = DeviceManager.AdjustSdbArgument(
                "shell \"rpm -qa | grep " + lldbPkgName + "\"");
            Process process = SDBLib.CreateSdbProcess(true, true);
            var     result  = (process == null) ? null : SDBLib.RunSdbProcessAsync(process, argument, true, waiter2);

            if (!waiter2.Waiter.WaitOne(30000))
            {
                OutputDeviceErrorMsg("GetPkgInstalledStatus failed: " + lldbPkgName);
                return(false);
            }

            if (!string.IsNullOrEmpty(waiter2.InstalledStatus))
            {
                Version installedLldbVersion = new Version(waiter2.InstalledStatus.Split('-')[1]);
                Version lldbRpmFileVersion   = new Version(lldbVersion);

                if (installedLldbVersion >= lldbRpmFileVersion)
                {
                    OutputDeviceErrorMsg("GetPkgInstalledStatus (already installed): " + lldbPkgName);
                    isInstalled = true;
                }
            }

            return(true);
        }
Exemple #5
0
        private void CheckPackage(string name, ProfilerPackage package)
        {
            InstalledWaiter waiter  = new InstalledWaiter();
            var             proc    = SDBLib.CreateSdbProcess(true, true);
            string          cmdline = DeviceManager.AdjustSdbArgument("shell \"rpm -q " + name + "\"");
            var             result  = SDBLib.RunSdbProcessAsync(proc, cmdline, true, waiter);

            if (!waiter.Waiter.WaitOne(30000))
            {
                Print($"CheckPackage fails for {name}");
                return;
            }

            bool installed = !string.IsNullOrEmpty(waiter.InstalledStatus) &&
                             !waiter.InstalledStatus.EndsWith("not installed");

            Print($"Package {name} installed: {installed}");
            if (installed)
            {
                string[] components = ParsePackageFilename(waiter.InstalledStatus);
                if (components.Length > 2)
                {
                    package.InstalledVersion = components[2];
                }

                if (components.Length > 3)
                {
                    package.InstalledRelease = components[3];
                }
            }

            package.NeedToInstall = !installed;
        }
Exemple #6
0
        private bool RemountRW()
        {
            Print("Remount rootfs RW");
            var    process = SDBLib.CreateSdbProcess();
            string cmdline = DeviceManager.AdjustSdbArgument("shell \"mount / -o remount,rw\"");

            SDBLib.RunSdbProcess(process, cmdline);
            var rc = process.ExitCode;

            process.Close();
            return(rc == 0);
        }
Exemple #7
0
        private bool SwitchToRoot(bool on)
        {
            Print($"Switch to root: {on}");

            var    process = SDBLib.CreateSdbProcess();
            string cmdline = DeviceManager.AdjustSdbArgument($"root {((on) ? "on" : "off")}");

            SDBLib.RunSdbProcess(process, cmdline);
            var rc = process.ExitCode;

            process.Close();
            return(rc == 0);
        }
Exemple #8
0
        private bool InstallPackage(string name, ProfilerPackage p)
        {
            string rpm = name + "-" + p.AvailableVersion + "-" + p.AvailableRelease
                         + "." + ArchToSuffix(GetArch()) + ".rpm";
            string package_path = GetRpmsPath() + "/" + rpm;

            Print($"Installing {package_path}");
            var    process = SDBLib.CreateSdbProcess();
            string cmdline = DeviceManager.AdjustSdbArgument($"shell \"rpm -U --force {package_path}\"");

            SDBLib.RunSdbProcess(process, cmdline, true);
            int rc = process.ExitCode;

            process.Close();
            return(rc == 0);
        }
Exemple #9
0
        private bool PushPackage(string name, ProfilerPackage p)
        {
            string rpm = name + "-" + p.AvailableVersion + "-" + p.AvailableRelease
                         + "." + ArchToSuffix(GetArch()) + ".rpm";
            string src = ToolsPathInfo.OndemandFolderPath + @"\" + rpm;
            string dst = GetRpmsPath() + "/" + rpm;

            Print($"Push {src} -> {dst}");
            var    proc    = SDBLib.CreateSdbProcess(true, true);
            string cmdline = DeviceManager.AdjustSdbArgument($"push \"{src}\" {dst}");

            SDBLib.RunSdbProcess(proc, cmdline, true);
            int rc = proc.ExitCode;

            proc.Close();
            return(rc == 0);
        }
        private bool SetSDBRoot(bool beRoot)
        {
            bool    result  = true;
            Process process = SDBLib.CreateSdbProcess(true, true);

            if (process == null)
            {
                ErrorMessage = "Failed to get sdb.exe program";
                return(false);
            }

            string arguments;

            if (beRoot)
            {
                arguments = DeviceManager.AdjustSdbArgument("root on");
            }
            else
            {
                arguments = DeviceManager.AdjustSdbArgument("root off");
            }

            process.StartInfo.Arguments = arguments;
            ErrorMessage = String.Empty;

            try
            {
                if (!process.Start())
                {
                    ErrorMessage = "Failed to set SDB root";
                    return(false);
                }

                process.WaitForExit(5 * 1000);
            }
            catch (Exception e)
            {
                ErrorMessage = e.Message;
                result       = false;
            }

            return(result);
        }
        private bool InstallDebuggerRPM(string rpm)
        {
            bool    result  = true;
            Process process = SDBLib.CreateSdbProcess(true, true);

            if (process == null)
            {
                ErrorMessage = "Failed to get sdb.exe program";
                return(false);
            }

            string fmt       = "shell rpm -Uvh \"{0}\" --force";
            string arg       = String.Format(fmt, rpm);
            string arguments = DeviceManager.AdjustSdbArgument(arg);

            process.StartInfo.Arguments = arguments;
            ErrorMessage = String.Empty;

            try
            {
                if (!process.Start())
                {
                    ErrorMessage = "Failed to install lldb rpm.";
                    return(false);
                }

                process.WaitForExit(5 * 1000);
            }
            catch (Exception e)
            {
                ErrorMessage = e.Message;
                result       = false;
            }

            return(result);
        }
        private bool RemountRootRW()
        {
            bool    result  = true;
            Process process = SDBLib.CreateSdbProcess(true, true);

            if (process == null)
            {
                ErrorMessage = "Failed to get sdb.exe program";
                return(false);
            }

            string fmt       = "shell mount -o remount, rw /";
            string arguments = DeviceManager.AdjustSdbArgument(fmt);


            process.StartInfo.Arguments = arguments;
            ErrorMessage = String.Empty;

            try
            {
                if (!process.Start())
                {
                    ErrorMessage = "Failed to remount RW";
                    return(false);
                }

                process.WaitForExit(5 * 1000);
            }
            catch (Exception e)
            {
                ErrorMessage = e.Message;
                result       = false;
            }

            return(result);
        }