コード例 #1
0
        public static bool InstallRpmPackage(SDBDeviceInfo device, string rpmFileName, out string errorMessage,
                                             TimeSpan?timeout = null)
        {
            string command          = $"rpm -U --force {rpmFileName}";
            string lastNonEmptyLine = "";
            bool   success          = SDBLib.RunSdbShellCommandAndCheckExitStatus(device, command,
                                                                                  (bool isStdOut, string line) =>
            {
                if (line != "")
                {
                    lastNonEmptyLine = line;
                }
                return(false);    // continue processing
            },
                                                                                  out errorMessage, timeout);

            if (!success)
            {
                if (!(errorMessage.Contains(rpmFileName) || lastNonEmptyLine.Contains(rpmFileName)))
                {
                    errorMessage = StringHelper.CombineMessages(errorMessage, $"Package: \"{rpmFileName}\"");
                }
                errorMessage = StringHelper.CombineMessages(errorMessage, lastNonEmptyLine);
            }
            return(success);
        }
コード例 #2
0
        private bool InstallPackage(string packageName, string packageFileName)
        {
            string errorMessage;
            bool   success;

            if (packageFileName.EndsWith(".rpm"))
            {
                success = DeployHelper.InstallRpmPackage(_device, packageFileName, out errorMessage);
            }
            else
            {
                if (_isSecureProtocol)
                {
                    // TODO!! try to remove special handling of "lldb-tv"
                    if (packageName == LldbTvPackage)
                    {
                        // TODO!! do need to uninstall?
                        string outputLine;
                        success = DeployHelperSecure.RunCommand(_device, "shell 0 vs_lldbinstall", out outputLine, out errorMessage);
                    }
                    else
                    {
                        // TODO!! do need to uninstall?
                        if (DeployHelperSecure.GetInstalledPackageVersion(_device, packageName, out errorMessage) != null)
                        {
                            DeployHelperSecure.UninstallPackage(_device, packageName, out errorMessage);
                        }
                        success = DeployHelperSecure.InstallPackage(_device, packageName, out errorMessage);
                    }
                    if (!success)
                    {
                        errorMessage = StringHelper.CombineMessages($"Cannot install package \"{packageName}\"", errorMessage);
                    }
                }
                else
                {
                    // remove old files (if any)
                    if (!SDBLib.RunSdbShellCommandAndCheckExitStatus(_device, $"rm -rf {_sdkToolPath}/{packageName}", null,
                                                                     out errorMessage))
                    {
                        DebugPrint(StringHelper.CombineMessages("Cannot remove old files", errorMessage));
                    }
                    success = DeployHelper.ExtractTarGzip(_device, packageFileName, _sdkToolPath, out errorMessage);
                }
            }
            if (success)
            {
                Print($"Successfully installed \"{packageFileName}\"");
            }
            else
            {
                Print(errorMessage);
            }
            return(success);
        }
コード例 #3
0
ファイル: PreviewerTool.cs プロジェクト: sung-su/vs-tools-cps
        private bool RunTpk(EmulatorPlatformType platformType)
        {
            string errorMessage;
            bool   result = SDBLib.RunSdbShellCommandAndCheckExitStatus(_selectedDevice,
                                                                        $"launch_app {((platformType == EmulatorPlatformType.TV) ? AppIdTV : AppIdMobile)} " +
                                                                        "__AUL_SDK__ dotnet-launcher", null, out errorMessage);

            if (!result)
            {
                ShowError(errorMessage);
            }
            return(result);
        }
コード例 #4
0
        public static bool IsRmpPackageInstalled(SDBDeviceInfo device, string packageName,
                                                 out string installedPackageName, out string errorMessage, TimeSpan?timeout = null)
        {
            string command = $"rpm -q {packageName}";

            installedPackageName = "";
            string lastNonEmptyLine = "";
            bool   success          = SDBLib.RunSdbShellCommandAndCheckExitStatus(device, command,
                                                                                  (bool isStdOut, string line) =>
            {
                if (line != "")
                {
                    lastNonEmptyLine = line;
                }
                return(false);    // continue processing
            },
                                                                                  out errorMessage, timeout);

            if (success)
            {
                if (!String.IsNullOrEmpty(lastNonEmptyLine))
                {
                    installedPackageName = lastNonEmptyLine;
                }
                else
                {
                    errorMessage = $"Cannot check RPM package \"{packageName}\"";
                    success      = false;
                }
            }
            else
            {
                if (lastNonEmptyLine.EndsWith("is not installed"))
                {
                    errorMessage = ""; // no error, package just not installed
                }
                else
                {
                    if (!(errorMessage.Contains(packageName) || lastNonEmptyLine.Contains(packageName)))
                    {
                        errorMessage = StringHelper.CombineMessages(errorMessage, $"Package: \"{packageName}\"");
                    }
                    errorMessage = StringHelper.CombineMessages(errorMessage, lastNonEmptyLine);
                }
            }
            return(success);
        }
コード例 #5
0
        public static bool ListAndGetFirstLine(SDBDeviceInfo device, string pathName, out string firstLine, out string errorMessage)
        {
            string s      = null;
            bool   result = (SDBLib.RunSdbShellCommandAndCheckExitStatus(device, $"ls -U {pathName}", // "-U" is for speed
                                                                         (bool isStdOut, string line) =>
            {
                if ((s == null) && isStdOut && (line != ""))
                {
                    s = line;
                }
                return(false);    // we want to get the exit status so nether return true
            },
                                                                         out errorMessage));

            firstLine = s;
            return(result && (firstLine != null));
        }
コード例 #6
0
        public static bool ExtractTarGzip(SDBDeviceInfo device, string tarGzipFileName, string destinationPath,
                                          out string errorMessage, TimeSpan?timeout = null)
        {
            string command          = $"mkdir -p {destinationPath} && tar -xvf \"{tarGzipFileName}\" -C {destinationPath}";
            string tarError         = null;
            string lastNonEmptyLine = "";
            bool   success          = SDBLib.RunSdbShellCommandAndCheckExitStatus(device, command,
                                                                                  (bool isStdOut, string line) =>
            {
                if ((tarError == null) && line.StartsWith("tar: ") && line.Contains("Cannot"))
                {
                    tarError = line;
                }
                if (line != "")
                {
                    lastNonEmptyLine = line;
                }
                return(false);    // continue processing
            },
                                                                                  out errorMessage, timeout);

            if (!success)
            {
                if (String.IsNullOrEmpty(tarError))
                {
                    tarError = lastNonEmptyLine;
                }
                if (!String.IsNullOrEmpty(tarError))
                {
                    if (!(errorMessage.Contains(tarGzipFileName) || tarError.Contains(tarGzipFileName)))
                    {
                        errorMessage = StringHelper.CombineMessages(errorMessage, $"Package: \"{tarGzipFileName}\"");
                    }
                    errorMessage = StringHelper.CombineMessages(errorMessage, tarError);
                }
                if (String.IsNullOrEmpty(errorMessage))
                {
                    errorMessage = $"Cannot extract \"{tarGzipFileName}\" to {destinationPath}";
                }
            }
            return(success);
        }