Пример #1
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);
        }
Пример #2
0
        private bool Push(string source, string destination)
        {
            string errorMessage;
            bool   success = DeployHelper.PushFile(_device, source, destination, null, out errorMessage);

            if (success)
            {
                Print($"Pushed \"{source}\" to \"{destination}\"");
            }
            else
            {
                Print(errorMessage);
            }
            return(success);
        }
Пример #3
0
        /// <summary>
        /// Install packages on the target.
        /// </summary>
        /// <param name="packageNames">E.g. "profctl", "heaptrack", "coreprofiler".</param>
        /// <returns>True iff installed successfully</returns>
        public bool Install(params string[] packageNames)
        {
            if ((packageNames == null) || (packageNames.Length == 0))
            {
                throw new ArgumentException(nameof(packageNames));
            }
            ErrorMessage = "";
            var    cap          = new SDBCapability(_device);
            string tizenVersion = cap.GetValueByKey("platform_version");

            if (!DeployHelper.IsTizenVersionSupported(tizenVersion))
            {
                ErrorMessage = $"The target system platform version {tizenVersion} is not supported";
                return(false);
            }
            _sdkOnDemandFolder = ToolsPathInfo.GetOnDemandFolderPath(tizenVersion);
            if (string.IsNullOrEmpty(_sdkOnDemandFolder))
            {
                ErrorMessage = $"Can not find the folder with target packages for version \"{tizenVersion}\"";
                return(false);
            }
            if (!Directory.Exists(_sdkOnDemandFolder))
            {
                ErrorMessage = $"Folder \"{_sdkOnDemandFolder}\" not found";
                return(false);
            }
            _isSecureProtocol = cap.GetAvailabilityByKey("secure_protocol");
            if (_isSecureProtocol)
            {
                if (!_supportTarGz)
                {
                    ErrorMessage = "The target uses secure protocol. Only tar.gz packages are supported for secure targets";
                }
                _supportRpms = false;
            }
            _sdkToolPath = cap.GetValueByKey("sdk_toolpath");
            _cpuArch     = DeployHelper.GetPackageSuffix(cap.GetValueByKey("cpu_arch"));
            var unavailablePackages = new List <string>();

            CheckAvailable(packageNames, unavailablePackages);
            bool result = true;

            try
            {
                if (unavailablePackages != null)
                {
                    foreach (string packageName in unavailablePackages)
                    {
                        Version installedVersion = GetInstalledPackageVersion(packageName);
                        if (installedVersion == null)
                        {
                            ErrorMessage = $"Package \"{packageName}\" not found both in \"{_sdkOnDemandFolder}\" and on the target system";
                            return(false);
                        }
                    }
                }
                CheckInstalled();
                if (_packages.Any(p => p.Value.NeedToInstall))
                {
                    result = InstallPackages(_sdkToolPath + "/on-demand");
                }
            }
            finally
            {
                //
            }
            _packages.Clear();
            return(result);
        }