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 7ea3be8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
18 changes: 10 additions & 8 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 @@ -245,6 +247,12 @@ private void Install(CkanModule module,
IProgress<int>? progress,
string? filename = null)
{
if (module.IsMetapackage)
{
// It's OK to include metapackages in changesets,
// but there's no work to do for them
return;
}
CheckKindInstallationKraken(module);
var version = registry.InstalledVersion(module.identifier);

Expand Down Expand Up @@ -285,19 +293,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 @@ -318,7 +321,6 @@ private List<string> InstallModule(CkanModule module,
ref HashSet<string>? possibleConfigOnlyDirs,
IProgress<int>? moduleProgress)
{
CheckKindInstallationKraken(module);
var createdPaths = new List<string>();

using (ZipFile zipfile = new ZipFile(zip_filename))
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 7ea3be8

Please sign in to comment.