diff --git a/src/OneGet.Bootstrap/0install.psd1 b/src/OneGet.Bootstrap/0install.psd1
deleted file mode 100644
index 3ed390b41..000000000
--- a/src/OneGet.Bootstrap/0install.psd1
+++ /dev/null
@@ -1,19 +0,0 @@
-@{
- ModuleVersion = '1.0.0'
- GUID = '89e16ee9-f9dd-4efd-b7a2-e0374958f6c0'
- Author = 'Bastian Eicher'
- CompanyName = '0install.net'
- Copyright = 'Copyright Bastian Eicher et al.'
- Description = 'Zero Install is a decentralized cross-platform software-installation system.'
- PowerShellVersion = '3.0'
- FunctionsToExport = @()
- #RequiredModules = @('PackageManagement')
- FileList = @('0install.dll')
- PrivateData = @{
- PackageManagementProviders = '0install.dll'
- PSData = @{
- Tags = @("PackageManagement","Provider")
- ProjectUri = 'https://0install.net'
- }
- }
-}
diff --git a/src/OneGet.Bootstrap/BootstrapPackageProvider.cs b/src/OneGet.Bootstrap/BootstrapPackageProvider.cs
deleted file mode 100644
index 9c06ccc99..000000000
--- a/src/OneGet.Bootstrap/BootstrapPackageProvider.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright Bastian Eicher et al.
-// Licensed under the GNU Lesser Public License
-
-using LinFu.DynamicProxy;
-using PackageManagement.Sdk;
-
-namespace ZeroInstall.OneGet;
-
-///
-/// A OneGet package provider that bootstraps/deploys Zero Install.
-///
-public class BootstrapPackageProvider : PackageProviderBase
-{
- public override string PackageProviderName => "0install";
-
- ///
- protected override IOneGetContext BuildContext(Request request) =>
- new ProxyFactory().CreateProxy(new OneGetContextInterceptor(request));
-}
diff --git a/src/OneGet.Bootstrap/OneGet.Bootstrap.csproj b/src/OneGet.Bootstrap/OneGet.Bootstrap.csproj
deleted file mode 100644
index 67f797477..000000000
--- a/src/OneGet.Bootstrap/OneGet.Bootstrap.csproj
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
- ZeroInstall.OneGet
- ZeroInstall.OneGet.Bootstrap
- Downloads and proxies to the Zero Install OneGet Provider.
- Library
- bin\$(Configuration)\
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- pushd "$(OutDir)"
-"$(ILRepack)" /targetplatform:v4 /ndebug /union /noRepackRes /wildcards /out:"$(TargetDir)0install.dll" "$(TargetPath)" 0install.exe ZeroInstall.*.dll Generator.Equals.Runtime.dll NanoByte.Common.dll System.Buffers.dll System.Memory.dll System.Runtime.*.dll System.Threading.*.dll Microsoft.Bcl.HashCode.dll Newtonsoft.Json.dll INIFileParser.dll BouncyCastle.OpenPgp.dll ICSharpCode.SharpZipLib.dll NDesk.Options.dll LinFu.DynamicProxy.dll
-popd
-
-
-
diff --git a/src/OneGet.Bootstrap/OneGet.Bootstrap.csproj.DotSettings b/src/OneGet.Bootstrap/OneGet.Bootstrap.csproj.DotSettings
deleted file mode 100644
index 392ac44b7..000000000
--- a/src/OneGet.Bootstrap/OneGet.Bootstrap.csproj.DotSettings
+++ /dev/null
@@ -1,2 +0,0 @@
-
- True
\ No newline at end of file
diff --git a/src/OneGet.Bootstrap/OneGetBootstrapHandler.cs b/src/OneGet.Bootstrap/OneGetBootstrapHandler.cs
deleted file mode 100644
index de25bd77a..000000000
--- a/src/OneGet.Bootstrap/OneGetBootstrapHandler.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright Bastian Eicher et al.
-// Licensed under the GNU Lesser Public License
-
-using PackageManagement.Sdk;
-
-namespace ZeroInstall.OneGet;
-
-///
-/// Manages communication between s and a OneGet during the bootstrap process.
-///
-public class OneGetBootstrapHandler(Request request) : OneGetHandler(request), IBootstrapHandler
-{
- ///
- public bool IsGui => false;
-
- ///
- public bool Background { get => false; set {} }
-
- ///
- public string? GetCustomStorePath(bool machineWide, string? currentPath) => currentPath;
-}
diff --git a/src/OneGet.Bootstrap/OneGetContextInterceptor.cs b/src/OneGet.Bootstrap/OneGetContextInterceptor.cs
deleted file mode 100644
index c3ee6b2e0..000000000
--- a/src/OneGet.Bootstrap/OneGetContextInterceptor.cs
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright Bastian Eicher et al.
-// Licensed under the GNU Lesser Public License
-
-using System.Reflection;
-using LinFu.DynamicProxy;
-using PackageManagement.Sdk;
-
-namespace ZeroInstall.OneGet;
-
-///
-/// Forwards requests to an implementation from a deployed or cached Zero Install instance.
-///
-/// The OneGet request interface to pass to the constructor of the target implementation.
-public class OneGetContextInterceptor(Request request) : IInterceptor
-{
- private object? _context;
-
- // NOTE: Static/shared lock, to avoid multiple deployments being started in parallel
- private static readonly object _initLock = new();
-
- public object Intercept(InvocationInfo info)
- {
- #region Sanity checks
- if (info == null) throw new ArgumentNullException(nameof(info));
- #endregion
-
- // Double-checked locking
- if (_context == null)
- {
- lock (_initLock)
- {
- _context ??= InitExternalContext();
- }
- }
-
- request.Debug("Forwarding to other Zero Install instance: {0}", info.TargetMethod.Name);
- return DuckType(_context, info);
- }
-
- ///
- /// Initializes an loaded from an external OneGet provider assembly.
- ///
- private object InitExternalContext()
- {
- string providerDirectory = GetProviderDirectory();
- request.Verbose("Loading Zero Install OneGet provider from {0}", providerDirectory);
-
- var assembly = Assembly.LoadFrom(Path.Combine(providerDirectory, "ZeroInstall.OneGet.dll"));
- var requestType = assembly.GetType("PackageManagement.Sdk.Request", throwOnError: true);
- var requestProxy = new ProxyFactory().CreateProxy(requestType, new RequestInterceptor(request));
- var contextType = assembly.GetType("ZeroInstall.OneGet.OneGetContext", throwOnError: true);
- return Activator.CreateInstance(contextType, requestProxy);
- }
-
- ///
- /// Gets the path of the directory to load the Zero Install OneGet provider assembly from.
- ///
- /// The full path of the directory containing the provider assembly.
- private string GetProviderDirectory()
- {
- using var handler = new OneGetBootstrapHandler(request);
- var bootstrap = new BootstrapProcess(handler);
- var startInfo = bootstrap.ZeroInstallDeployed([]) ?? bootstrap.ZeroInstallCached([]);
- return Path.GetDirectoryName(startInfo.FileName)!;
- }
-
- ///
- /// Duck-types from to an external type with the same method signatures.
- ///
- private class RequestInterceptor : IInterceptor
- {
- private readonly Request _request;
-
- public RequestInterceptor(Request request)
- {
- _request = request;
- }
-
- public object Intercept(InvocationInfo info) => DuckType(_request, info);
- }
-
- ///
- /// Forwards a method invocation to a using duck-typing.
- ///
- private static object DuckType(object target, InvocationInfo info)
- {
- var method = target.GetType().GetMethod(
- info.TargetMethod.Name,
- info.TargetMethod.GetParameters().Select(x => x.ParameterType).ToArray());
- if (method == null) throw new InvalidOperationException("Unable to find suitable method for duck-typing: " + info.TargetMethod.Name);
-
- try
- {
- return method.Invoke(target, info.Arguments);
- }
- catch (TargetInvocationException ex) when (ex.InnerException != null)
- {
- throw ex.InnerException.Rethrow();
- }
- }
-}
diff --git a/src/OneGet.Bootstrap/PowerShell.nuspec b/src/OneGet.Bootstrap/PowerShell.nuspec
deleted file mode 100644
index 0c61f53aa..000000000
--- a/src/OneGet.Bootstrap/PowerShell.nuspec
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
- 0install
- Zero Install OneGet Provider
- $version$
- Bastian Eicher
- bastian.eicher
- false
- LGPL-3.0-or-later
- https://0install.net/
- icon.png
- https://raw.githubusercontent.com/0install/0install-win/master/icon.png
- OneGet Package Provider for Zero Install
- This installs the OneGet Package Provider for Zero Install, a decentralized cross-distribution software installation system.
-
-Zero Install is a decentralized cross-platform software-installation system available under the LGPL. It allows software developers to publish programs directly from their own web-sites, while supporting features familiar from centralized distribution repositories such as shared libraries, automatic updates and digital signatures. It is intended to complement, rather than replace, the operating system’s package management. 0install packages never interfere with those provided by the distribution.
-
-Zero Install does not define a new packaging format; unmodified tarballs or zip archives can be used. Instead, it defines an [XML metadata format](https://docs.0install.net/specifications/feed/) to describe these packages and the dependencies between them. A single metadata file can be used on multiple platforms (e.g. Windows, Ubuntu, Debian, Fedora, FreeBSD and Mac OS X).
-
-Zero Install also has some interesting features not often found in traditional package managers. For example, while it will share libraries whenever possible, it can always install multiple versions of a package in parallel when there are conflicting requirements. Installation is always side-effect-free (each package is unpacked to its own directory and will not touch shared directories), making it ideal for use with sandboxing technologies and virtualization.
- Copyright Bastian Eicher et al.
- PackageManagement Provider PSModule
-
-
-
-
-
-
-
diff --git a/src/OneGet/IOneGetContext.cs b/src/OneGet/IOneGetContext.cs
deleted file mode 100644
index c04d5de28..000000000
--- a/src/OneGet/IOneGetContext.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright Bastian Eicher et al.
-// Licensed under the GNU Lesser Public License
-
-using PackageManagement.Sdk;
-
-namespace ZeroInstall.OneGet;
-
-///
-/// Provides an execution context for handling a single OneGet .
-///
-public interface IOneGetContext : IDisposable
-{
- void AddPackageSource(string uri);
- void RemovePackageSource(string uri);
- void ResolvePackageSources();
- void FindPackage(string? name, string? requiredVersion, string? minimumVersion, string? maximumVersion);
- void FindPackageBy(string identifier);
- void GetInstalledPackages(string? name);
- void DownloadPackage(string fastPackageReference, string location);
- void InstallPackage(string fastPackageReference);
- void UninstallPackage(string fastPackageReference);
- void GetPackageDetails(string fastPackageReference);
-}
diff --git a/src/OneGet/OneGet.csproj b/src/OneGet/OneGet.csproj
deleted file mode 100644
index 7780f83d3..000000000
--- a/src/OneGet/OneGet.csproj
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
- ZeroInstall.OneGet
- ZeroInstall.OneGet
- Implements a OneGet Provider for Zero Install, exposing package installation functionality.
- Library
- ..\..\artifacts\$(Configuration)\
-
-
-
-
-
-
-
diff --git a/src/OneGet/OneGetContext.cs b/src/OneGet/OneGetContext.cs
deleted file mode 100644
index 429714be0..000000000
--- a/src/OneGet/OneGetContext.cs
+++ /dev/null
@@ -1,332 +0,0 @@
-// Copyright Bastian Eicher et al.
-// Licensed under the GNU Lesser Public License
-
-using NanoByte.Common.Native;
-using PackageManagement.Sdk;
-using ZeroInstall.Commands;
-using ZeroInstall.Commands.Basic.Exporters;
-using ZeroInstall.Commands.Desktop;
-using ZeroInstall.Commands.Properties;
-using ZeroInstall.DesktopIntegration;
-using ZeroInstall.Model.Preferences;
-using ZeroInstall.Model.Selection;
-using ZeroInstall.Services;
-using ZeroInstall.Services.Feeds;
-using ZeroInstall.Services.Solvers;
-using ZeroInstall.Store.Feeds;
-
-namespace ZeroInstall.OneGet;
-
-///
-/// Provides an execution context for handling a single OneGet .
-///
-/// The OneGet request callback object.
-public sealed class OneGetContext(Request request) : ScopedOperation(new OneGetHandler(request)), IOneGetContext
-{
- ///
- public void Dispose() => Handler.Dispose();
-
- private bool Refresh => request.OptionKeys.Contains("Refresh");
- private bool AllVersions => request.OptionKeys.Contains("AllVersions");
- private bool GlobalSearch => request.OptionKeys.Contains("GlobalSearch");
- private bool DeferDownload => request.OptionKeys.Contains("DeferDownload");
- private bool MachineWide => StringUtils.EqualsIgnoreCase(request.GetOptionValue("Scope"), "AllUsers");
-
- public void AddPackageSource(string uri)
- {
- var feedUri = new FeedUri(uri);
-
- CatalogManager.DownloadCatalog(feedUri);
-
- if (CatalogManager.AddSource(feedUri))
- CatalogManager.TryGetOnline();
- else
- Log.Warn(string.Format(Resources.CatalogAlreadyRegistered, feedUri.ToStringRfc()));
- }
-
- public void RemovePackageSource(string uri)
- {
- var feedUri = new FeedUri(uri);
-
- if (!CatalogManager.RemoveSource(feedUri))
- Log.Warn(string.Format(Resources.CatalogNotRegistered, feedUri.ToStringRfc()));
- }
-
- public void ResolvePackageSources()
- {
- var registeredSources = CatalogManager.GetSources();
-
- if (request.Sources.Any())
- {
- foreach (var uri in request.Sources.TrySelect(x => new FeedUri(x), (UriFormatException _) => {}))
- {
- bool isRegistered = registeredSources.Contains(uri);
- request.YieldPackageSource(uri.ToStringRfc(), uri.ToStringRfc(), isTrusted: isRegistered, isRegistered: isRegistered, isValidated: false);
- }
- }
- else
- {
- foreach (var uri in registeredSources)
- request.YieldPackageSource(uri.ToStringRfc(), uri.ToStringRfc(), isTrusted: true, isRegistered: true, isValidated: false);
- }
- }
-
- public void FindPackage(string? name, string? requiredVersion, string? minimumVersion, string? maximumVersion)
- {
- FeedManager.Refresh = Refresh;
-
- VersionRange versionRange;
- if (requiredVersion != null) versionRange = new VersionRange(requiredVersion);
- else if (minimumVersion != null || maximumVersion != null)
- {
- var constraint = new Constraint();
- if (minimumVersion != null) constraint.NotBefore = new ImplementationVersion(minimumVersion);
- if (maximumVersion != null) constraint.Before = new ImplementationVersion(maximumVersion);
- versionRange = constraint;
- }
- else versionRange = null;
-
- if (GlobalSearch) MirrorSearch(name, versionRange);
- else CatalogSearch(name, versionRange);
- }
-
- private void MirrorSearch(string? name, VersionRange? versionRange)
- {
- foreach (var result in SearchResults.Query(Config, name))
- {
- var requirements = new Requirements(result.Uri);
- if (versionRange != null) requirements.ExtraRestrictions[requirements.InterfaceUri] = versionRange;
- Yield(requirements, result.ToPseudoFeed());
- }
- }
-
- private void CatalogSearch(string? name, VersionRange? versionRange)
- {
- foreach (var feed in GetCatalogResults(name))
- {
- if (AllVersions)
- {
- foreach (var implementation in FeedManager.GetFresh(feed.Uri).Implementations)
- {
- var requirements = new Requirements(feed.Uri) {ExtraRestrictions = {{feed.Uri, implementation.Version}}};
- Yield(requirements, feed, implementation);
- }
- }
- else
- {
- var requirements = new Requirements(feed.Uri);
- if (versionRange != null) requirements.ExtraRestrictions[requirements.InterfaceUri] = versionRange;
- Yield(requirements, feed);
- }
- }
- }
-
- private IEnumerable GetCatalogResults(string? query)
- {
- if (string.IsNullOrEmpty(query))
- {
- Log.Info("Returning entire catalog");
- return CatalogManager.Get().Feeds;
- }
-
- Log.Info("Searching for short-name match in Catalog: " + query);
- if (FindByShortName(query) is {} feed) return [feed];
-
- Log.Info("Searching for partial match in Catalog: " + query);
- return CatalogManager.Get().Search(query);
- }
-
- public void FindPackageBy(string identifier)
- {
- FeedManager.Refresh = Refresh;
- Yield(new Requirements(GetCanonicalUri(identifier)));
- }
-
- public void GetInstalledPackages(string name)
- {
- var appList = AppList.LoadSafe(MachineWide);
- foreach (var entry in appList.Search(name))
- Yield(entry.EffectiveRequirements);
- }
-
- public void DownloadPackage(string fastPackageReference, string location)
- {
- var requirements = ParseReference(fastPackageReference);
- var selections = Solve(requirements);
- foreach (var implementation in SelectionsManager.GetUncachedImplementations(selections))
- Fetcher.Fetch(implementation);
-
- var exporter = new Exporter(selections, requirements.Architecture, location);
- exporter.ExportFeeds(FeedCache, OpenPgp);
- exporter.ExportImplementations(ImplementationStore, Handler);
- if (FeedCache.GetFeed(requirements.InterfaceUri) is {} feed)
- {
- exporter.ExportIcons(
- [..feed.Icons, ..feed.SplashScreens],
- IconStores.DesktopIntegration(Config, Handler, machineWide: false));
- }
- exporter.DeployImportScript();
-
- Yield(requirements);
-
- BackgroundSelfUpdate();
- }
-
- public void InstallPackage(string fastPackageReference)
- {
- var requirements = ParseReference(fastPackageReference);
- try
- {
- Install(requirements);
- BackgroundSelfUpdate();
- }
- catch (UnsuitableInstallBaseException ex)
- {
- string installLocation = ZeroInstallDeployment.FindOther(ex.NeedsMachineWide)
- ?? DeployInstance(ex.NeedsMachineWide);
-
- // Since we cannot another copy of Zero Install from a different location into the same AppDomain, simply pretend we are running from a different source
- Locations.OverrideInstallBase(installLocation);
- Install(requirements);
- }
- }
-
- private void Install(Requirements requirements)
- {
- if (MachineWide && !WindowsUtils.IsAdministrator) throw new NotAdminException(Resources.MustBeAdminForMachineWide);
- if (MachineWide && !ZeroInstallInstance.IsMachineWide) throw new UnsuitableInstallBaseException(Resources.NoMachineWideIntegrationFromPerUser, MachineWide);
- if (!ZeroInstallInstance.IsDeployed) throw new UnsuitableInstallBaseException(Resources.NoIntegrationDeployRequired, MachineWide);
-
- FeedManager.Refresh = Refresh || !DeferDownload;
-
- var selections = Solve(requirements);
-
- ApplyIntegration(requirements);
- ApplyVersionRestrictions(requirements, selections);
- if (!DeferDownload)
- {
- foreach (var implementation in SelectionsManager.GetUncachedImplementations(selections))
- Fetcher.Fetch(implementation);
- }
- Yield(requirements);
- }
-
- private Selections Solve(Requirements requirements)
- {
- var selections = Solver.Solve(requirements);
-
- if (FeedManager.ShouldRefresh || SelectionsManager.GetUncached(selections.Implementations).Any())
- {
- FeedManager.Stale = false;
- FeedManager.Refresh = true;
- selections = Solver.Solve(requirements);
- FeedManager.Refresh = false;
- }
-
- try
- {
- selections.Name = FeedCache.GetFeed(selections.InterfaceUri).Name;
- }
- #region Error handling
- catch (KeyNotFoundException)
- {
- // Fall back to using feed file name
- selections.Name = selections.InterfaceUri.ToString().GetRightPartAtLastOccurrence('/');
- }
- #endregion
-
- return selections;
- }
-
- private void ApplyIntegration(Requirements requirements)
- {
- Log.Info(Resources.DesktopIntegrationApply);
- var feed = FeedManager[requirements.InterfaceUri];
- using var integrationManager = new CategoryIntegrationManager(Config, Handler, MachineWide);
- var appEntry = integrationManager.AddApp(new(requirements.InterfaceUri, feed));
- integrationManager.AddAccessPointCategories(appEntry, feed, CategoryIntegrationManager.StandardCategories);
- }
-
- private static void ApplyVersionRestrictions(Requirements requirements, Selections selections)
- {
- if (requirements.ExtraRestrictions.Count == 0) return;
-
- // TODO
- Log.Warn($"You have applied a version restriction to this app. Zero Install will continue to apply this restriction to any future updates. You will need to run '0install select --customize {requirements.InterfaceUri}' to undo this.");
-
- foreach (var (feedUri, _) in requirements.ExtraRestrictions)
- {
- var selection = selections.GetImplementation(feedUri);
- if (selection != null)
- {
- var pref = FeedPreferences.LoadForSafe(feedUri);
- pref.Implementations.Clear();
- pref[selection.ID].UserStability = Stability.Preferred;
- pref.SaveFor(feedUri);
- }
- }
- }
-
- ///
- /// Deploys a Zero Install instance to this machine.
- ///
- /// true to deploy to a location for all users; false to deploy to a location for the current user only.
- /// The director Zero Install was deployed to.
- private string DeployInstance(bool machineWide)
- {
- string programFiles = machineWide
- ? WindowsUtils.GetFolderPath(Environment.SpecialFolder.ProgramFiles)
- : Path.Combine(WindowsUtils.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Programs");
- string installLocation = Path.Combine(programFiles, "Zero Install");
-
- Log.Info("Deploying Zero Install to " + installLocation);
- using (var manager = new SelfManager(installLocation, Handler, machineWide))
- manager.Deploy(libraryMode: true);
-
- return installLocation;
- }
-
- public void UninstallPackage(string fastPackageReference)
- {
- if (MachineWide && !WindowsUtils.IsAdministrator) throw new NotAdminException(Resources.MustBeAdminForMachineWide);
-
- var requirements = ParseReference(fastPackageReference);
-
- using var integrationManager = new IntegrationManager(Config, Handler, MachineWide);
- integrationManager.RemoveApp(integrationManager.AppList[requirements.InterfaceUri]);
- }
-
- public void GetPackageDetails(string fastPackageReference)
- {
- FeedManager.Refresh = true;
-
- var requirements = ParseReference(fastPackageReference);
- Yield(requirements);
- }
-
- private static Requirements ParseReference(string fastPackageReference) => JsonStorage.FromJsonString(fastPackageReference);
-
- private void Yield(Requirements requirements, Feed? feed = null, ImplementationBase? implementation = null)
- {
- EnsureAllowed(requirements.InterfaceUri);
-
- if (implementation == null)
- {
- var selections = Solver.TrySolve(requirements);
- if (selections != null) implementation = selections.MainImplementation;
- }
- feed ??= FeedManager[requirements.InterfaceUri];
-
- var sourceUri = feed.CatalogUri ?? feed.Uri;
- request.YieldSoftwareIdentity(
- fastPath: requirements.ToJsonString(),
- name: feed.Name,
- version: implementation?.Version?.ToString(),
- versionScheme: null,
- summary: feed.Summaries.GetBestLanguage(CultureInfo.CurrentUICulture),
- source: sourceUri?.ToStringRfc(),
- searchKey: feed.Name,
- fullPath: null,
- packageFileName: feed.Name);
- }
-}
diff --git a/src/OneGet/OneGetHandler.cs b/src/OneGet/OneGetHandler.cs
deleted file mode 100644
index bb5a280fe..000000000
--- a/src/OneGet/OneGetHandler.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright Bastian Eicher et al.
-// Licensed under the GNU Lesser Public License
-
-using PackageManagement.Sdk;
-
-namespace ZeroInstall.OneGet;
-
-///
-/// Manages communication between s and a OneGet .
-///
-public class OneGetHandler : CliTaskHandler
-{
- private readonly Request _request;
-
- public OneGetHandler(Request request)
- {
- _request = request;
-
- Verbosity = _request.IsInteractive ? Verbosity.Normal : Verbosity.Batch;
- }
-
- ///
- /// Displays entries using the OneGet object.
- ///
- protected override void DisplayLogEntry(LogSeverity severity, string message)
- {
- switch (severity)
- {
- case LogSeverity.Debug:
- _request.Debug(message);
- break;
- case LogSeverity.Info:
- _request.Verbose(message);
- break;
- case LogSeverity.Warn:
- case LogSeverity.Error:
- _request.Warning(message);
- break;
- }
- }
-
- ///
- public override void RunTask(ITask task)
- {
- #region Sanity checks
- if (task == null) throw new ArgumentNullException(nameof(task));
- #endregion
-
- task.Run(CancellationToken, CredentialProvider, new OneGetProgress(task.Name, _request, CancellationTokenSource));
- }
-
- ///
- protected override bool AskInteractive(string question, bool defaultAnswer)
- => _request.OptionKeys.Contains("Force") || _request.ShouldContinue(question, "Zero Install");
-
- ///
- public override void Error(Exception exception) => _request.Warning(exception.Message);
-}
diff --git a/src/OneGet/OneGetProgress.cs b/src/OneGet/OneGetProgress.cs
deleted file mode 100644
index 6a430c7cb..000000000
--- a/src/OneGet/OneGetProgress.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright Bastian Eicher et al.
-// Licensed under the GNU Lesser Public License
-
-using PackageManagement.Sdk;
-
-namespace ZeroInstall.OneGet;
-
-///
-/// Represents a single progress bar provided by OneGet.
-///
-public class OneGetProgress : MarshalByRefObject, IProgress
-{
- private readonly string _name;
- private readonly Request _request;
- private readonly CancellationTokenSource _cancellationTokenSource;
- private readonly int _activityId;
-
- public OneGetProgress(string name, Request request, CancellationTokenSource cancellationTokenSource)
- {
- _name = name ?? throw new ArgumentNullException(nameof(name));
- _request = request ?? throw new ArgumentNullException(nameof(request));
- _cancellationTokenSource = cancellationTokenSource ?? throw new ArgumentNullException(nameof(cancellationTokenSource));
-
- _request.Debug(name);
- _activityId = _request.StartProgress(0, name);
- }
-
- public void Report(TaskSnapshot value)
- {
- if (_request.IsCanceled) _cancellationTokenSource.Cancel();
-
- switch (value.State)
- {
- case TaskState.Canceled:
- case TaskState.IOError:
- case TaskState.WebError:
- _request.CompleteProgress(_activityId, false);
- break;
-
- case TaskState.Header:
- case TaskState.Data:
- _request.Progress(_activityId, (int)(value.Value * 100), _name);
- break;
-
- case TaskState.Complete:
- _request.CompleteProgress(_activityId, true);
- break;
- }
- }
-}
diff --git a/src/OneGet/PackageProvider.cs b/src/OneGet/PackageProvider.cs
deleted file mode 100644
index 0f3555ec6..000000000
--- a/src/OneGet/PackageProvider.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright Bastian Eicher et al.
-// Licensed under the GNU Lesser Public License
-
-using PackageManagement.Sdk;
-
-namespace ZeroInstall.OneGet;
-
-///
-/// A OneGet package provider for Zero Install.
-///
-public class PackageProvider : PackageProviderBase
-{
- public override string PackageProviderName => "0install";
-
- ///
- protected override IOneGetContext BuildContext(Request request) => new OneGetContext(request);
-}
diff --git a/src/OneGet/PackageProviderBase.cs b/src/OneGet/PackageProviderBase.cs
deleted file mode 100644
index a037d8629..000000000
--- a/src/OneGet/PackageProviderBase.cs
+++ /dev/null
@@ -1,198 +0,0 @@
-// Copyright Bastian Eicher et al.
-// Licensed under the GNU Lesser Public License
-
-using System.Security;
-using NanoByte.Common.Info;
-using PackageManagement.Sdk;
-
-namespace ZeroInstall.OneGet;
-
-///
-/// Common base for OneGet package providers. Implements OneGet duck-typing interface.
-///
-public abstract class PackageProviderBase
-{
- public abstract string PackageProviderName { get; }
-
- public string ProviderVersion => AppInfo.CurrentLibrary.Version ?? "1.0.0-pre";
-
- public void OnUnhandledException(string methodName, Exception exception)
- {
- Log.Error($"Unexpected exception thrown in {PackageProviderName}::{methodName}", exception);
- }
-
- public void InitializeProvider(Request request) => request.Debug("Calling '{0}::InitializeProvider'", PackageProviderName);
-
- public void GetFeatures(Request request)
- {
- request.Debug("Calling '{0}::GetFeatures'", PackageProviderName);
- request.Yield(new Dictionary
- {
- [Constants.Features.SupportedExtensions] = ["xml"],
- [Constants.Features.SupportedSchemes] = ["http", "https", "file"]
- });
- }
-
- public void GetDynamicOptions(string? category, Request request)
- {
- request.Debug("Calling '{0}::GetDynamicOptions'", PackageProviderName);
- switch ((category ?? "").ToLowerInvariant())
- {
- case "package":
- request.YieldDynamicOption("Refresh", Constants.OptionType.Switch, isRequired: false);
- request.YieldDynamicOption("AllVersions", Constants.OptionType.Switch, isRequired: false);
- request.YieldDynamicOption("GlobalSearch", Constants.OptionType.Switch, isRequired: false);
- break;
-
- case "install":
- request.YieldDynamicOption("Refresh", Constants.OptionType.Switch, isRequired: false);
- request.YieldDynamicOption("DeferDownload", Constants.OptionType.Switch, isRequired: false);
- request.YieldDynamicOption("Scope", Constants.OptionType.String, isRequired: false, permittedValues: new[] {"CurrentUser", "AllUsers"});
- break;
-
- case "source":
- break;
- }
- }
-
- ///
- /// Creates a instance and executes a delegate on it, handling common exception types.
- ///
- private void Do(Request request, Action action)
- {
- try
- {
- using var context = BuildContext(request);
- action(context);
- }
- #region Error handling
- catch (OperationCanceledException)
- {}
- catch (FormatException ex)
- {
- request.Error(ErrorCategory.InvalidArgument, "", ex.Message);
- }
- catch (WebException ex)
- {
- request.Error(ErrorCategory.ConnectionError, "", ex.Message);
- }
- catch (NotSupportedException ex)
- {
- request.Error(ErrorCategory.NotImplemented, "", ex.Message);
- }
- catch (IOException ex)
- {
- request.Error(ErrorCategory.OpenError, "", ex.Message);
- }
- catch (Exception ex) when (ex is UnauthorizedAccessException or SecurityException)
- {
- request.Error(ErrorCategory.PermissionDenied, "", ex.Message);
- }
- catch (InvalidDataException ex)
- {
- request.Error(ErrorCategory.InvalidData, "", ex.Message);
- }
- catch (Exception ex)
- {
- request.Error(ErrorCategory.MetadataError, "", ex.Message);
- }
- #endregion
- }
-
- ///
- /// Creates a for a given .
- ///
- protected abstract IOneGetContext BuildContext(Request request);
-
- public void ResolvePackageSources(Request request)
- {
- request.Debug("Calling '{0}::ResolvePackageSources'", PackageProviderName);
- Do(request, x => x.ResolvePackageSources());
- }
-
- public void AddPackageSource(string name, string location, bool trusted, Request request)
- {
- request.Debug("Calling '{0}::AddPackageSource'", PackageProviderName);
- if (string.IsNullOrEmpty(location))
- {
- request.Error(ErrorCategory.InvalidArgument, "location", "Location parameter missing");
- return;
- }
- Do(request, x => x.AddPackageSource(location));
- }
-
- public void RemovePackageSource(string name, Request request)
- {
- request.Debug("Calling '{0}::RemovePackageSource'", PackageProviderName);
- if (string.IsNullOrEmpty(name))
- {
- request.Error(ErrorCategory.InvalidArgument, "name", "Name parameter missing");
- return;
- }
-
- Do(request, x => x.RemovePackageSource(name));
- }
-
- public void FindPackage(string name, string requiredVersion, string minimumVersion, string maximumVersion, int id, Request request)
- {
- request.Debug("Calling '{0}::FindPackage'", PackageProviderName);
- Do(request, x => x.FindPackage(name, requiredVersion, minimumVersion, maximumVersion));
- }
-
- public void FindPackageByFile(string file, int id, Request request)
- {
- request.Debug("Calling '{0}::FindPackageByFile'", PackageProviderName);
- if (string.IsNullOrEmpty(file))
- {
- request.Error(ErrorCategory.InvalidArgument, "file", "File parameter missing");
- return;
- }
- Do(request, x => x.FindPackageBy(file));
- }
-
- public void FindPackageByUri(Uri uri, int id, Request request)
- {
- request.Debug("Calling '{0}::FindPackageByUri'", PackageProviderName);
- if (uri == null)
- {
- request.Error(ErrorCategory.InvalidArgument, "uri", "Uri parameter missing");
- return;
- }
- Do(request, x => x.FindPackageBy(uri.OriginalString));
- }
-
- public void DownloadPackage(string fastPackageReference, string location, Request request)
- {
- request.Debug("Calling '{0}::DownloadPackage'", PackageProviderName);
- if (string.IsNullOrEmpty(location))
- {
- request.Error(ErrorCategory.InvalidArgument, "location", "Location parameter missing");
- return;
- }
- Do(request, x => x.DownloadPackage(fastPackageReference, location));
- }
-
- public void InstallPackage(string fastPackageReference, Request request)
- {
- request.Debug("Calling '{0}::InstallPackage'", PackageProviderName);
- Do(request, x => x.InstallPackage(fastPackageReference));
- }
-
- public void UninstallPackage(string fastPackageReference, Request request)
- {
- request.Debug("Calling '{0}::UninstallPackage'", PackageProviderName);
- Do(request, x => x.UninstallPackage(fastPackageReference));
- }
-
- public void GetInstalledPackages(string name, string requiredVersion, string minimumVersion, string maximumVersion, Request request)
- {
- request.Debug("Calling '{0}::GetInstalledPackages'", PackageProviderName);
- Do(request, x => x.GetInstalledPackages(name));
- }
-
- public void GetPackageDetails(string fastPackageReference, Request request)
- {
- request.Debug("Calling '{0}::GetPackageDetails'", PackageProviderName);
- Do(request, x => x.GetPackageDetails(fastPackageReference));
- }
-}
\ No newline at end of file
diff --git a/src/OneGet/Sdk/Constants.cs b/src/OneGet/Sdk/Constants.cs
deleted file mode 100644
index e514f1e5a..000000000
--- a/src/OneGet/Sdk/Constants.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-//
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-namespace PackageManagement.Sdk {
- public static partial class Constants {
- #region copy common-constants-implementation /internal/public
-
- public const string MinVersion = "0.0.0.1";
- public const string MSGPrefix = "MSG:";
- public static string[] FeaturePresent = new string[0];
- public static string[] Empty = new string[0];
-
- public static partial class Features {
- public const string AutomationOnly = "automation-only";
- public const string MagicSignatures = "magic-signatures";
- public const string SupportedExtensions = "file-extensions";
- public const string SupportedSchemes = "uri-schemes";
- public const string SupportsPowerShellModules = "supports-powershell-modules";
- public const string SupportsRegexSearch = "supports-regex-search";
- public const string SupportsSubstringSearch = "supports-substring-search";
- public const string SupportsWildcardSearch = "supports-wildcard-search";
- }
-
- public static partial class Messages {
- public const string CreatefolderFailed = "MSG:CreatefolderFailed";
- public const string DependencyResolutionError = "MSG:UnableToResolveDependency_dependencyPackage";
- public const string DependentPackageFailedInstall = "MSG:DependentPackageFailedInstall_dependency";
- public const string DestinationPathNotSet = "MSG:DestinationPathNotSet";
- public const string FailedProviderBootstrap = "MSG:FailedProviderBootstrap";
- public const string FileFailedVerification = "MSG:FileFailedVerification";
- public const string InvalidFilename = "MSG:InvalidFilename";
- public const string MissingRequiredParameter = "MSG:MissingRequiredParameter";
- public const string PackageFailedInstall = "MSG:UnableToInstallPackage_package_reason";
- public const string PackageSourceExists = "MSG:PackageSourceExists";
- public const string ProtocolNotSupported = "MSG:ProtocolNotSupported";
- public const string ProviderPluginLoadFailure = "MSG:ProviderPluginLoadFailure";
- public const string ProviderSwidtagUnavailable = "MSG:ProviderSwidtagUnavailable";
- public const string RemoveEnvironmentVariableRequiresElevation = "MSG:RemoveEnvironmentVariableRequiresElevation";
- public const string SchemeNotSupported = "MSG:SchemeNotSupported";
- public const string SourceLocationNotValid = "MSG:SourceLocationNotValid_Location";
- public const string UnableToCopyFileTo = "MSG:UnableToCopyFileTo";
- public const string UnableToCreateShortcutTargetDoesNotExist = "MSG:UnableToCreateShortcutTargetDoesNotExist";
- public const string UnableToDownload = "MSG:UnableToDownload";
- public const string UnableToOverwriteExistingFile = "MSG:UnableToOverwriteExistingFile";
- public const string UnableToRemoveFile = "MSG:UnableToRemoveFile";
- public const string UnableToResolvePackage = "MSG:UnableToResolvePackage";
- public const string UnableToResolveSource = "MSG:UnableToResolveSource_NameOrLocation";
- public const string UnableToUninstallPackage = "MSG:UnableToUninstallPackage";
- public const string UnknownFolderId = "MSG:UnknownFolderId";
- public const string UnknownProvider = "MSG:UnknownProvider";
- public const string UnsupportedArchive = "MSG:UnsupportedArchive";
- public const string UnsupportedProviderType = "MSG:UnsupportedProviderType";
- public const string UriSchemeNotSupported = "MSG:UriSchemeNotSupported_Scheme";
- public const string UserDeclinedUntrustedPackageInstall = "MSG:UserDeclinedUntrustedPackageInstall";
- }
-
- public static partial class OptionType {
- public const string String = "String";
- public const string StringArray = "StringArray";
- public const string Int = "Int";
- public const string Switch = "Switch";
- public const string Folder = "Folder";
- public const string File = "File";
- public const string Path = "Path";
- public const string Uri = "Uri";
- public const string SecureString = "SecureString";
- }
-
- public static partial class PackageStatus {
- public const string Available = "Available";
- public const string Dependency = "Dependency";
- public const string Installed = "Installed";
- public const string Uninstalled = "Uninstalled";
- }
-
- public static partial class Parameters {
- public const string IsUpdate = "IsUpdatePackageSource";
- public const string Name = "Name";
- public const string Location = "Location";
- }
-
- public static partial class Signatures {
- public const string Cab = "4D534346";
- public const string OleCompoundDocument = "D0CF11E0A1B11AE1";
- public const string Zip = "504b0304";
- public static string[] ZipVariants = [Zip /* should have EXEs? */];
- }
-
- public static partial class SwidTag {
- public const string SoftwareIdentity = "SoftwareIdentity";
- }
-
- #endregion
- }
-}
diff --git a/src/OneGet/Sdk/ErrorCategory.cs b/src/OneGet/Sdk/ErrorCategory.cs
deleted file mode 100644
index ef0aa7cde..000000000
--- a/src/OneGet/Sdk/ErrorCategory.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-namespace PackageManagement.Sdk
-{
- public enum ErrorCategory
- {
- NotSpecified,
- OpenError,
- CloseError,
- DeviceError,
- DeadlockDetected,
- InvalidArgument,
- InvalidData,
- InvalidOperation,
- InvalidResult,
- InvalidType,
- MetadataError,
- NotImplemented,
- NotInstalled,
- ObjectNotFound,
- OperationStopped,
- OperationTimeout,
- SyntaxError,
- ParserError,
- PermissionDenied,
- ResourceBusy,
- ResourceExists,
- ResourceUnavailable,
- ReadError,
- WriteError,
- FromStdErr,
- SecurityError,
- ProtocolError,
- ConnectionError,
- AuthenticationError,
- LimitsExceeded,
- QuotaExceeded,
- NotEnabled,
- }
-}
diff --git a/src/OneGet/Sdk/Request.cs b/src/OneGet/Sdk/Request.cs
deleted file mode 100644
index 389adee22..000000000
--- a/src/OneGet/Sdk/Request.cs
+++ /dev/null
@@ -1,308 +0,0 @@
-//
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-namespace PackageManagement.Sdk {
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Security;
-
- public abstract class Request {
- private Dictionary _options;
- private string[] _packageSources;
-
- #region PackageMangaement Interfaces
- public interface IProviderServices {
- bool IsElevated { get; }
-
- IEnumerable