Ejemplo n.º 1
0
#pragma warning restore 8776
    protected override void Solve()
    {
        base.Solve();

        if (_includeZeroInstall)
        {
            try
            {
                var selfSelections = Solver.Solve(new FeedUri(Config.DefaultSelfUpdateUri));

                Selections.Implementations.Add(selfSelections.Implementations);
                UncachedImplementations.Add(SelectionsManager.GetUncachedImplementations(selfSelections));
            }
            #region Error handling
            catch
            {
                // Suppress any left-over errors if the user canceled anyway
                Handler.CancellationToken.ThrowIfCancellationRequested();
                throw;
            }
            #endregion

            Handler.CancellationToken.ThrowIfCancellationRequested();
        }
    }
Ejemplo n.º 2
0
        private void Install(Requirements requirements)
        {
            if (MachineWide && !WindowsUtils.IsAdministrator)
            {
                throw new NotAdminException(Resources.MustBeAdminForMachineWide);
            }
            if (MachineWide && ZeroInstallInstance.IsRunningFromPerUserDir)
            {
                throw new UnsuitableInstallBaseException(Resources.NoMachineWideIntegrationFromPerUser, MachineWide);
            }
            if (ZeroInstallInstance.IsRunningFromCache)
            {
                throw new UnsuitableInstallBaseException(Resources.NoIntegrationFromCache, MachineWide);
            }

            FeedManager.Refresh = Refresh || !DeferDownload;

            var selections = Solve(requirements);

            ApplyIntegration(requirements);
            ApplyVersionRestrictions(requirements, selections);
            if (!DeferDownload)
            {
                Fetcher.Fetch(SelectionsManager.GetUncachedImplementations(selections));
            }
            Yield(requirements);
        }
Ejemplo n.º 3
0
    private void Run(Requirements requirements)
    {
        var selections = Solver.Solve(requirements);
        var missing    = SelectionsManager.GetUncachedImplementations(selections);

        Fetcher.Fetch(missing);
        Executor.Start(selections);
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Trys to generate <see cref="Selections"/> for running the specified <paramref name="command"/> without downloading anything.
    /// </summary>
    private Selections?SolveOffline(string?command)
    {
        Config.NetworkUse = NetworkLevel.Offline;
        try
        {
            var selections = Solver.Solve(new(InterfaceUri, command));
            return(SelectionsManager.GetUncachedImplementations(selections).Any() ? null : selections);
        }
        catch (Exception ex) when(ex is SolverException or WebException)
        {
            Log.Debug("Failed to solve dependencies without downloading anything", ex);
            return(null);
        }
    }
}
Ejemplo n.º 5
0
    protected override void Solve()
    {
        base.Solve();

        try
        {
            UncachedImplementations = SelectionsManager.GetUncachedImplementations(Selections);
        }
        #region Error handling
        catch (Exception ex) when(ex is KeyNotFoundException or InvalidDataException)
        {
            // Wrap exception since only certain exception types are allowed
            throw new SolverException(ex.Message, ex);
        }
        #endregion
    }
Ejemplo n.º 6
0
        public void InstallPackage([NotNull] string fastPackageReference)
        {
            FeedManager.Refresh = Refresh;

            var requirements = ParseReference(fastPackageReference);
            var selections   = Solve(requirements);

            if (Config.NetworkUse == NetworkLevel.Full && !DownloadLater)
            {
                Fetcher.Fetch(SelectionsManager.GetUncachedImplementations(selections));
            }
            ApplyIntegration(requirements);
            ApplyVersionRestrictions(requirements, selections);

            SelfUpdateCheck();
        }
Ejemplo n.º 7
0
        public void DownloadPackage([NotNull] string fastPackageReference, [NotNull] string location)
        {
            Directory.CreateDirectory(location);
            typeof(OneGetCommand).WriteEmbeddedFile("import.bat", Path.Combine(location, "import.bat"));

            FeedCache           = new DiskFeedCache(Path.Combine(location, "interfaces"), OpenPgp);
            Store               = new DirectoryStore(Path.Combine(location, "implementations"), useWriteProtection: false);
            FeedManager.Refresh = true;

            var requirements = ParseReference(fastPackageReference);
            var selections   = Solve(requirements);

            Fetcher.Fetch(SelectionsManager.GetUncachedImplementations(selections));

            SelfUpdateCheck();
        }
Ejemplo n.º 8
0
        public void DownloadPackage(string fastPackageReference, string location)
        {
            var requirements = ParseReference(fastPackageReference);
            var selections   = Solve(requirements);

            Fetcher.Fetch(SelectionsManager.GetUncachedImplementations(selections));

            var exporter = new Exporter(selections, requirements, location);

            exporter.ExportFeeds(FeedCache, OpenPgp);
            exporter.ExportImplementations(ImplementationStore, Handler);
            exporter.DeployImportScript();
            exporter.DeployBootstrapIntegrate(Handler);

            Yield(requirements);

            SelfUpdateCheck();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Downloads any implementations selected by the Solver that are not in the cache yet.
        /// </summary>
        private void Fetch()
        {
            var uncached = SelectionsManager.GetUncachedImplementations(_selections);

            Fetcher.Fetch(uncached);
        }