diff options
| author | Rob Mensching <rob@firegiant.com> | 2020-05-30 14:53:05 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2020-05-30 15:07:21 -0700 |
| commit | d529525a1e331f3ef9ec2707791c99bd78fdd82f (patch) | |
| tree | 1d9fe1f0c0ee9850371c916802eb03ec9dc37a87 /src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs | |
| parent | 9c54d2fce80983bbee5f0f113b5aa30f22bc8a23 (diff) | |
| download | wix-d529525a1e331f3ef9ec2707791c99bd78fdd82f.tar.gz wix-d529525a1e331f3ef9ec2707791c99bd78fdd82f.tar.bz2 wix-d529525a1e331f3ef9ec2707791c99bd78fdd82f.zip | |
Basic patching support
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs | 130 |
1 files changed, 26 insertions, 104 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index 8e901d30..d9d246f5 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs | |||
| @@ -43,7 +43,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 43 | this.DefaultCompressionLevel = context.DefaultCompressionLevel; | 43 | this.DefaultCompressionLevel = context.DefaultCompressionLevel; |
| 44 | this.DelayedFields = context.DelayedFields; | 44 | this.DelayedFields = context.DelayedFields; |
| 45 | this.ExpectedEmbeddedFiles = context.ExpectedEmbeddedFiles; | 45 | this.ExpectedEmbeddedFiles = context.ExpectedEmbeddedFiles; |
| 46 | this.FileSystemExtensions = context.FileSystemExtensions; | 46 | this.FileSystemManager = new FileSystemManager(context.FileSystemExtensions); |
| 47 | this.Intermediate = context.IntermediateRepresentation; | 47 | this.Intermediate = context.IntermediateRepresentation; |
| 48 | this.IntermediateFolder = context.IntermediateFolder; | 48 | this.IntermediateFolder = context.IntermediateFolder; |
| 49 | this.OutputPath = context.OutputPath; | 49 | this.OutputPath = context.OutputPath; |
| @@ -79,7 +79,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 79 | 79 | ||
| 80 | public IEnumerable<IExpectedExtractFile> ExpectedEmbeddedFiles { get; } | 80 | public IEnumerable<IExpectedExtractFile> ExpectedEmbeddedFiles { get; } |
| 81 | 81 | ||
| 82 | public IEnumerable<IFileSystemExtension> FileSystemExtensions { get; } | 82 | public FileSystemManager FileSystemManager { get; } |
| 83 | 83 | ||
| 84 | public bool DeltaBinaryPatch { get; set; } | 84 | public bool DeltaBinaryPatch { get; set; } |
| 85 | 85 | ||
| @@ -116,7 +116,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 116 | var trackedFiles = new List<ITrackedFile>(); | 116 | var trackedFiles = new List<ITrackedFile>(); |
| 117 | 117 | ||
| 118 | var containsMergeModules = false; | 118 | var containsMergeModules = false; |
| 119 | var suppressedTableNames = new HashSet<string>(); | ||
| 120 | 119 | ||
| 121 | // If there are any fields to resolve later, create the cache to populate during bind. | 120 | // If there are any fields to resolve later, create the cache to populate during bind. |
| 122 | var variableCache = this.DelayedFields.Any() ? new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase) : null; | 121 | var variableCache = this.DelayedFields.Any() ? new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase) : null; |
| @@ -226,7 +225,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 226 | return null; | 225 | return null; |
| 227 | } | 226 | } |
| 228 | 227 | ||
| 229 | WindowsInstallerData output; | ||
| 230 | this.Intermediate.UpdateLevel(Data.WindowsInstaller.IntermediateLevels.FullyBound); | 228 | this.Intermediate.UpdateLevel(Data.WindowsInstaller.IntermediateLevels.FullyBound); |
| 231 | this.Messaging.Write(VerboseMessages.UpdatingFileInformation()); | 229 | this.Messaging.Write(VerboseMessages.UpdatingFileInformation()); |
| 232 | 230 | ||
| @@ -268,14 +266,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 268 | } | 266 | } |
| 269 | else if (SectionType.Patch == section.Type) | 267 | else if (SectionType.Patch == section.Type) |
| 270 | { | 268 | { |
| 271 | // Merge transform data into the output object. | 269 | var command = new GetFileFacadesFromTransforms(this.Messaging, this.FileSystemManager, this.SubStorages); |
| 272 | //IEnumerable<FileFacade> filesFromTransform = this.CopyFromTransformData(this.Output); | ||
| 273 | |||
| 274 | //var command = new CopyTransformDataCommand(this.Messaging, /*output*/this.SubStorages, tableDefinitions, copyOutFileRows: true); | ||
| 275 | //command.Output = output; | ||
| 276 | //command.TableDefinitions = this.TableDefinitions; | ||
| 277 | //command.CopyOutFileRows = true; | ||
| 278 | var command = new GetFileFacadesFromTransforms(this.Messaging, this.SubStorages, tableDefinitions); | ||
| 279 | command.Execute(); | 270 | command.Execute(); |
| 280 | var filesFromTransforms = command.FileFacades; | 271 | var filesFromTransforms = command.FileFacades; |
| 281 | 272 | ||
| @@ -338,6 +329,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 338 | command.Execute(); | 329 | command.Execute(); |
| 339 | } | 330 | } |
| 340 | 331 | ||
| 332 | // Update file sequence. | ||
| 333 | { | ||
| 334 | var command = new UpdateMediaSequencesCommand(section, fileFacades); | ||
| 335 | command.Execute(); | ||
| 336 | } | ||
| 337 | |||
| 341 | // stop processing if an error previously occurred | 338 | // stop processing if an error previously occurred |
| 342 | if (this.Messaging.EncounteredError) | 339 | if (this.Messaging.EncounteredError) |
| 343 | { | 340 | { |
| @@ -345,6 +342,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 345 | } | 342 | } |
| 346 | 343 | ||
| 347 | // Time to create the output object. Try to put as much above here as possible, updating the IR is better. | 344 | // Time to create the output object. Try to put as much above here as possible, updating the IR is better. |
| 345 | WindowsInstallerData output; | ||
| 348 | { | 346 | { |
| 349 | var command = new CreateOutputFromIRCommand(this.Messaging, section, tableDefinitions, this.BackendExtensions, this.WindowsInstallerBackendHelper); | 347 | var command = new CreateOutputFromIRCommand(this.Messaging, section, tableDefinitions, this.BackendExtensions, this.WindowsInstallerBackendHelper); |
| 350 | command.Execute(); | 348 | command.Execute(); |
| @@ -352,14 +350,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 352 | output = command.Output; | 350 | output = command.Output; |
| 353 | } | 351 | } |
| 354 | 352 | ||
| 355 | // Update file sequence. | ||
| 356 | { | ||
| 357 | var command = new UpdateMediaSequencesCommand(output, fileFacades); | ||
| 358 | command.Execute(); | ||
| 359 | } | ||
| 360 | |||
| 361 | // Modularize identifiers. | 353 | // Modularize identifiers. |
| 362 | if (OutputType.Module == output.Type) | 354 | if (output.Type == OutputType.Module) |
| 363 | { | 355 | { |
| 364 | var command = new ModularizeCommand(output, modularizationSuffix, section.Tuples.OfType<WixSuppressModularizationTuple>()); | 356 | var command = new ModularizeCommand(output, modularizationSuffix, section.Tuples.OfType<WixSuppressModularizationTuple>()); |
| 365 | command.Execute(); | 357 | command.Execute(); |
| @@ -457,18 +449,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 457 | trackedFiles.AddRange(command.TrackedFiles); | 449 | trackedFiles.AddRange(command.TrackedFiles); |
| 458 | } | 450 | } |
| 459 | 451 | ||
| 460 | #if DELETE | 452 | if (output.Type == OutputType.Patch) |
| 461 | if (OutputType.Patch == output.Type) | 453 | { |
| 462 | { | 454 | // Copy output data back into the transforms. |
| 463 | // Copy output data back into the transforms. | 455 | var command = new UpdateTransformsWithFileFacades(this.Messaging, output, this.SubStorages, tableDefinitions, fileFacades); |
| 464 | #if TODO_PATCHING | 456 | command.Execute(); |
| 465 | var command = new CopyTransformDataCommand(this.Messaging, output, tableDefinitions, copyOutFileRows: false); | 457 | } |
| 466 | command.Execute(); | ||
| 467 | |||
| 468 | this.CopyToTransformData(this.Output); | ||
| 469 | #endif | ||
| 470 | } | ||
| 471 | #endif | ||
| 472 | 458 | ||
| 473 | // stop processing if an error previously occurred | 459 | // stop processing if an error previously occurred |
| 474 | if (this.Messaging.EncounteredError) | 460 | if (this.Messaging.EncounteredError) |
| @@ -483,8 +469,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 483 | var trackMsi = this.BackendHelper.TrackFile(this.OutputPath, TrackedFileType.Final); | 469 | var trackMsi = this.BackendHelper.TrackFile(this.OutputPath, TrackedFileType.Final); |
| 484 | trackedFiles.Add(trackMsi); | 470 | trackedFiles.Add(trackMsi); |
| 485 | 471 | ||
| 486 | var temporaryFiles = this.GenerateDatabase(output, tableDefinitions, trackMsi.Path, false, false); | 472 | var command = new GenerateDatabaseCommand(this.Messaging, this.BackendHelper, this.FileSystemManager, output, trackMsi.Path, tableDefinitions, this.IntermediateFolder, this.Codepage, keepAddedColumns: false, this.SuppressAddingValidationRows, useSubdirectory: false); |
| 487 | trackedFiles.AddRange(temporaryFiles); | 473 | command.Execute(); |
| 474 | |||
| 475 | trackedFiles.AddRange(command.GeneratedTemporaryFiles); | ||
| 488 | } | 476 | } |
| 489 | 477 | ||
| 490 | // Stop processing if an error previously occurred. | 478 | // Stop processing if an error previously occurred. |
| @@ -498,31 +486,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 498 | { | 486 | { |
| 499 | this.Messaging.Write(VerboseMessages.MergingModules()); | 487 | this.Messaging.Write(VerboseMessages.MergingModules()); |
| 500 | 488 | ||
| 501 | // Add back possibly suppressed sequence tables since all sequence tables must be present | ||
| 502 | // for the merge process to work. We'll drop the suppressed sequence tables again as | ||
| 503 | // necessary. | ||
| 504 | foreach (SequenceTable sequence in Enum.GetValues(typeof(SequenceTable))) | ||
| 505 | { | ||
| 506 | var sequenceTableName = (sequence == SequenceTable.AdvertiseExecuteSequence) ? "AdvtExecuteSequence" : sequence.ToString(); | ||
| 507 | var sequenceTable = output.Tables[sequenceTableName]; | ||
| 508 | |||
| 509 | if (null == sequenceTable) | ||
| 510 | { | ||
| 511 | sequenceTable = output.EnsureTable(tableDefinitions[sequenceTableName]); | ||
| 512 | } | ||
| 513 | |||
| 514 | if (0 == sequenceTable.Rows.Count) | ||
| 515 | { | ||
| 516 | suppressedTableNames.Add(sequenceTableName); | ||
| 517 | } | ||
| 518 | } | ||
| 519 | |||
| 520 | var command = new MergeModulesCommand(this.Messaging); | 489 | var command = new MergeModulesCommand(this.Messaging); |
| 521 | command.FileFacades = fileFacades; | 490 | command.FileFacades = fileFacades; |
| 522 | command.IntermediateFolder = this.IntermediateFolder; | 491 | command.IntermediateFolder = this.IntermediateFolder; |
| 523 | command.Output = output; | 492 | command.Output = output; |
| 524 | command.OutputPath = this.OutputPath; | 493 | command.OutputPath = this.OutputPath; |
| 525 | command.SuppressedTableNames = suppressedTableNames; | 494 | command.TableDefinitions = tableDefinitions; |
| 526 | command.Execute(); | 495 | command.Execute(); |
| 527 | } | 496 | } |
| 528 | 497 | ||
| @@ -607,38 +576,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 607 | return wixout; | 576 | return wixout; |
| 608 | } | 577 | } |
| 609 | 578 | ||
| 610 | #if TODO_PATCHING | ||
| 611 | /// <summary> | ||
| 612 | /// Copy file data between transform substorages and the patch output object | ||
| 613 | /// </summary> | ||
| 614 | /// <param name="output">The output to bind.</param> | ||
| 615 | /// <param name="allFileRows">True if copying from transform to patch, false the other way.</param> | ||
| 616 | private IEnumerable<FileFacade> CopyFromTransformData(Output output) | ||
| 617 | { | ||
| 618 | var command = new CopyTransformDataCommand(); | ||
| 619 | command.CopyOutFileRows = true; | ||
| 620 | command.Output = output; | ||
| 621 | command.TableDefinitions = this.TableDefinitions; | ||
| 622 | command.Execute(); | ||
| 623 | |||
| 624 | return command.FileFacades; | ||
| 625 | } | ||
| 626 | |||
| 627 | /// <summary> | ||
| 628 | /// Copy file data between transform substorages and the patch output object | ||
| 629 | /// </summary> | ||
| 630 | /// <param name="output">The output to bind.</param> | ||
| 631 | /// <param name="allFileRows">True if copying from transform to patch, false the other way.</param> | ||
| 632 | private void CopyToTransformData(Output output) | ||
| 633 | { | ||
| 634 | var command = new CopyTransformDataCommand(); | ||
| 635 | command.CopyOutFileRows = false; | ||
| 636 | command.Output = output; | ||
| 637 | command.TableDefinitions = this.TableDefinitions; | ||
| 638 | command.Execute(); | ||
| 639 | } | ||
| 640 | #endif | ||
| 641 | |||
| 642 | /// <summary> | 579 | /// <summary> |
| 643 | /// Validate that there are no duplicate GUIDs in the output. | 580 | /// Validate that there are no duplicate GUIDs in the output. |
| 644 | /// </summary> | 581 | /// </summary> |
| @@ -650,7 +587,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 650 | { | 587 | { |
| 651 | if (output.TryGetTable("Component", out var componentTable)) | 588 | if (output.TryGetTable("Component", out var componentTable)) |
| 652 | { | 589 | { |
| 653 | Dictionary<string, bool> componentGuidConditions = new Dictionary<string, bool>(componentTable.Rows.Count); | 590 | var componentGuidConditions = new Dictionary<string, bool>(componentTable.Rows.Count); |
| 654 | 591 | ||
| 655 | foreach (Data.WindowsInstaller.Rows.ComponentRow row in componentTable.Rows) | 592 | foreach (Data.WindowsInstaller.Rows.ComponentRow row in componentTable.Rows) |
| 656 | { | 593 | { |
| @@ -658,12 +595,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 658 | // there's already an error that prevented it from being replaced with a real GUID. | 595 | // there's already an error that prevented it from being replaced with a real GUID. |
| 659 | if (!String.IsNullOrEmpty(row.Guid) && "*" != row.Guid) | 596 | if (!String.IsNullOrEmpty(row.Guid) && "*" != row.Guid) |
| 660 | { | 597 | { |
| 661 | bool thisComponentHasCondition = !String.IsNullOrEmpty(row.Condition); | 598 | var thisComponentHasCondition = !String.IsNullOrEmpty(row.Condition); |
| 662 | bool allComponentsHaveConditions = thisComponentHasCondition; | 599 | var allComponentsHaveConditions = thisComponentHasCondition; |
| 663 | 600 | ||
| 664 | if (componentGuidConditions.ContainsKey(row.Guid)) | 601 | if (componentGuidConditions.ContainsKey(row.Guid)) |
| 665 | { | 602 | { |
| 666 | allComponentsHaveConditions = componentGuidConditions[row.Guid] && thisComponentHasCondition; | 603 | allComponentsHaveConditions = thisComponentHasCondition && componentGuidConditions[row.Guid]; |
| 667 | 604 | ||
| 668 | if (allComponentsHaveConditions) | 605 | if (allComponentsHaveConditions) |
| 669 | { | 606 | { |
| @@ -728,20 +665,5 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 728 | 665 | ||
| 729 | return layout; | 666 | return layout; |
| 730 | } | 667 | } |
| 731 | |||
| 732 | /// <summary> | ||
| 733 | /// Creates the MSI/MSM/PCP database. | ||
| 734 | /// </summary> | ||
| 735 | /// <param name="output">Output to create database for.</param> | ||
| 736 | /// <param name="databaseFile">The database file to create.</param> | ||
| 737 | /// <param name="keepAddedColumns">Whether to keep columns added in a transform.</param> | ||
| 738 | /// <param name="useSubdirectory">Whether to use a subdirectory based on the <paramref name="databaseFile"/> file name for intermediate files.</param> | ||
| 739 | private IEnumerable<ITrackedFile> GenerateDatabase(WindowsInstallerData output, TableDefinitionCollection tableDefinitions, string databaseFile, bool keepAddedColumns, bool useSubdirectory) | ||
| 740 | { | ||
| 741 | var command = new GenerateDatabaseCommand(this.Messaging, this.BackendHelper, this.FileSystemExtensions, output, databaseFile, tableDefinitions, this.IntermediateFolder, this.Codepage, keepAddedColumns, this.SuppressAddingValidationRows, useSubdirectory); | ||
| 742 | command.Execute(); | ||
| 743 | |||
| 744 | return command.GeneratedTemporaryFiles; | ||
| 745 | } | ||
| 746 | } | 668 | } |
| 747 | } | 669 | } |
