protected void SetImplementationDirs(IEnumerable <string> paths)
 {
     if (MachineWide)
     {
         ImplementationStores.SetMachineWideDirectories(paths);
     }
     else
     {
         ImplementationStores.SetUserDirectories(paths);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Creates the store to provide to clients as a service.
        /// </summary>
        /// <exception cref="IOException">A cache directory could not be created or the underlying filesystem can not store file-changed times accurate to the second.</exception>
        /// <exception cref="UnauthorizedAccessException">Creating a cache directory is not permitted.</exception>
        private static MarshalByRefObject CreateStore()
        {
            var identity = WindowsIdentity.GetCurrent();

            Debug.Assert(identity != null);

            var paths  = ImplementationStores.GetDirectories(serviceMode: true);
            var stores = paths.Select(path => new SecureStore(path, identity)).Cast <IImplementationStore>();

            return(new CompositeImplementationStore(stores));
        }
    /// <summary>
    /// Copies files or directories from another implementation fetched by an external 0install process.
    /// </summary>
    /// <param name="builder">The builder.</param>
    /// <param name="metadata">The path of the source and destination file or directory.</param>
    /// <param name="handler">A callback object used when the the user needs to be informed about IO tasks.</param>
    /// <exception cref="UnauthorizedAccessException">Access to a resource was denied.</exception>
    /// <exception cref="IOException">An IO operation failed.</exception>
    public static void CopyFrom(this IBuilder builder, CopyFromStep metadata, ITaskHandler handler)
    {
        if (metadata.Implementation == null)
        {
            throw new ArgumentException($"Must call {nameof(IRecipeStep.Normalize)}() first.", nameof(metadata));
        }

        handler.RunTask(new SimpleTask(string.Format(Resources.FetchingExternal, metadata.ID),
                                       () => ZeroInstallClient.Detect.FetchAsync(metadata.Implementation).Wait()));

        string path = ImplementationStores.Default().GetPath(metadata.Implementation);

        builder.CopyFrom(metadata, path, handler);
    }
 /// <summary>
 /// Registers a set of scoped services for using Zero Install functionality.
 /// </summary>
 /// <typeparam name="TTaskHandler">A callback object used when the the user needs to be asked questions or informed about download and IO tasks.</typeparam>
 /// <param name="services">The service collection to add the services to.</param>
 public static IServiceCollection AddZeroInstall <TTaskHandler>(this IServiceCollection services)
     where TTaskHandler : class, ITaskHandler
 => services.AddScoped <ITaskHandler, TTaskHandler>()
 .AddScoped(x => Config.Load())
 .AddScoped(x => ImplementationStores.Default())
 .AddScoped(x => OpenPgp.Verifying())
 .AddScoped(x => FeedCaches.Default(x.GetService <IOpenPgp>()))
 .AddScoped(x => TrustDB.LoadSafe())
 .AddScoped <ITrustManager, TrustManager>()
 .AddScoped <IFeedManager, FeedManager>()
 .AddScoped <ICatalogManager, CatalogManager>()
 .AddScoped(x => PackageManagers.Default())
 .AddScoped <ISelectionsManager, SelectionsManager>()
 .AddScoped <ISolver, BacktrackingSolver>()
 .AddScoped <IFetcher, SequentialFetcher>()
 .AddScoped <IExecutor, Executor>()
 .AddScoped <ISelectionCandidateProvider, SelectionCandidateProvider>();
Beispiel #5
0
 /// <summary>
 /// Registers a set of scoped services for using Zero Install functionality.
 /// </summary>
 /// <typeparam name="TTaskHandler">A callback object used when the the user needs to be asked questions or informed about download and IO tasks.</typeparam>
 /// <param name="services">The service collection to add the services to.</param>
 /// <param name="configuration">An optional configuration source for building <see cref="Config"/> instead of the default config files.</param>
 public static IServiceCollection AddZeroInstall <TTaskHandler>(this IServiceCollection services, IConfiguration?configuration = null)
     where TTaskHandler : class, ITaskHandler
 => services.AddScoped <ITaskHandler, TTaskHandler>()
 .AddScoped(_ => (configuration == null) ? Config.Load() : Config.From(configuration))
 .AddScoped(_ => ImplementationStores.Default())
 .AddScoped(_ => OpenPgp.Verifying())
 .AddScoped(provider => FeedCaches.Default(provider.GetRequiredService <IOpenPgp>()))
 .AddScoped(_ => TrustDB.LoadSafe())
 .AddScoped <ITrustManager, TrustManager>()
 .AddScoped <IFeedManager, FeedManager>()
 .AddScoped <ICatalogManager, CatalogManager>()
 .AddScoped(_ => PackageManagers.Default())
 .AddScoped <ISelectionsManager, SelectionsManager>()
 .AddScoped <ISolver, BacktrackingSolver>()
 .AddScoped <IFetcher, Fetcher>()
 .AddScoped <IExecutor, Executor>()
 .AddScoped <ISelectionCandidateProvider, SelectionCandidateProvider>();
Beispiel #6
0
    private static string?GuessAppExePath(Feed feed, EntryPoint?entryPoint)
    {
        if (string.IsNullOrEmpty(entryPoint?.BinaryName))
        {
            return(null);
        }

        string?referenceDigest =
            feed.Implementations
            .OrderByDescending(x => x.Version)
            .FirstOrDefault(x => x.Architecture.RunsOn(Architecture.CurrentSystem))
            ?.ManifestDigest.Best;

        if (referenceDigest == null)
        {
            return(null);
        }

        return(Path.Combine(ImplementationStores.GetDirectories().Last(), referenceDigest, entryPoint.BinaryName + ".exe"));
    }
 protected IEnumerable <string> GetImplementationDirs()
 => MachineWide
         ? ImplementationStores.GetMachineWideDirectories()
         : ImplementationStores.GetUserDirectories();