Skip to content

Commit

Permalink
Allow metapackages in changesets
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Sep 23, 2024
1 parent 749e4de commit cdf09d0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
44 changes: 24 additions & 20 deletions Core/ModuleInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ public void InstallList(ICollection<CkanModule> modules,
foreach (var module in modsToInstall)
{
User.RaiseMessage(" * {0}", Cache.DescribeAvailability(module));
if (!Cache.IsMaybeCachedZip(module))
// Alert about attempts to install DLC before downloading or installing anything
CheckKindInstallationKraken(module);
if (!module.IsMetapackage && !Cache.IsMaybeCachedZip(module))
{
downloads.Add(module);
}
Expand Down Expand Up @@ -242,8 +244,7 @@ private void Install(CkanModule module,
bool autoInstalled,
Registry registry,
ref HashSet<string>? possibleConfigOnlyDirs,
IProgress<int>? progress,
string? filename = null)
IProgress<int>? progress)
{
CheckKindInstallationKraken(module);
var version = registry.InstalledVersion(module.identifier);
Expand All @@ -256,15 +257,19 @@ private void Install(CkanModule module,
return;
}

// Find ZIP in the cache if we don't already have it.
filename ??= Cache.GetCachedFilename(module);

// If we *still* don't have a file, then kraken bitterly.
if (filename == null)
string? filename = null;
if (!module.IsMetapackage)
{
throw new FileNotFoundKraken(null,
string.Format(Properties.Resources.ModuleInstallerZIPNotInCache,
module));
// Find ZIP in the cache if we don't already have it.
filename ??= Cache.GetCachedFilename(module);

// If we *still* don't have a file, then kraken bitterly.
if (filename == null)
{
throw new FileNotFoundKraken(null,
string.Format(Properties.Resources.ModuleInstallerZIPNotInCache,
module));
}
}

using (var transaction = CkanTransaction.CreateTransactionScope())
Expand All @@ -285,19 +290,14 @@ private void Install(CkanModule module,

// Fire our callback that we've installed a module, if we have one.
onReportModInstalled?.Invoke(module);

}

/// <summary>
/// Check if the given module is a metapackage:
/// Check if the given module is a DLC:
/// if it is, throws a BadCommandKraken.
/// </summary>
private static void CheckKindInstallationKraken(CkanModule module)
{
if (module.IsMetapackage)
{
throw new BadCommandKraken(Properties.Resources.ModuleInstallerMetapackage);
}
if (module.IsDLC)
{
throw new BadCommandKraken(Properties.Resources.ModuleInstallerDLC);
Expand All @@ -313,14 +313,18 @@ private static void CheckKindInstallationKraken(CkanModule module)
/// Propagates a FileExistsKraken if we were going to overwrite a file.
/// </summary>
private List<string> InstallModule(CkanModule module,
string zip_filename,
string? zip_filename,
Registry registry,
ref HashSet<string>? possibleConfigOnlyDirs,
IProgress<int>? moduleProgress)
{
CheckKindInstallationKraken(module);
var createdPaths = new List<string>();

if (module.IsMetapackage || zip_filename == null)
{
// It's OK to include metapackages in changesets,
// but there's no work to do for them
return createdPaths;
}
using (ZipFile zipfile = new ZipFile(zip_filename))
{
var filters = ServiceLocator.Container.Resolve<IConfiguration>().GlobalInstallFilters
Expand Down
5 changes: 0 additions & 5 deletions Core/Relationships/RelationshipResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,6 @@ private string conflictingModDescription(CkanModule? mod, CkanModule? parent)
/// </summary>
private void Add(CkanModule module, SelectionReason reason)
{
if (module.IsMetapackage)
{
AddReason(module, reason);
return;
}
if (module.IsDLC)
{
throw new ModuleIsDLCKraken(module);
Expand Down
2 changes: 1 addition & 1 deletion GUI/Main/MainChangeset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private void Changeset_OnConfirmChanges(List<ModChange> changeset)
{
Wait.StartWaiting(InstallMods, PostInstallMods, true,
new InstallArgument(
// Only pass along user requested mods, so auto-installed can be determined
// Only pass along user requested mods, so auto-installed can be determined
changeset.Where(ch => ch.Reasons.Any(r => r is SelectionReason.UserRequested)
// Include all removes and upgrades
|| ch.ChangeType != GUIModChangeType.Install)
Expand Down
1 change: 0 additions & 1 deletion GUI/Model/ModList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ public Tuple<IEnumerable<ModChange>, Dictionary<CkanModule, string>, List<string
.Union(resolver.ModList()
// Changeset already contains changes for these
.Except(extraInstalls)
.Where(m => !m.IsMetapackage)
.Select(m => new ModChange(m, GUIModChangeType.Install, resolver.ReasonsFor(m)))),
resolver.ConflictList,
resolver.ConflictDescriptions.ToList());
Expand Down

0 comments on commit cdf09d0

Please sign in to comment.