#At file:///C:/src/bzr.mysql/wex/installer/ based on revid:mike.lischke@stripped
468 Iggy Galarza 2011-05-18
Command-Line interface cleanup.
modified:
WexInstaller/Program.cs
WexInstaller/WexCmd.cs
=== modified file 'WexInstaller/Program.cs'
--- a/WexInstaller/Program.cs 2011-05-17 09:27:10 +0000
+++ b/WexInstaller/Program.cs 2011-05-18 18:39:31 +0000
@@ -78,41 +78,5 @@ namespace WexInstaller
if (runningCommandLineOnly)
Win32.ReleaseConsole();
}
-
-/* static bool ProcessCommandLineArguments()
- {
- bool checkForUpdates = false;
- bool showHelp = false;
-
- string[] args = Environment.GetCommandLineArgs();
- OptionSet options = new OptionSet();
- options.Add(Resources.HelpOptions, Resources.HelpDescription, o => showHelp = true);
- options.Add(Resources.CheckForUpdatesOptions, Resources.CheckForUpdatesDescription, o => checkForUpdates = true);
- List<string> extra = options.Parse(Environment.GetCommandLineArgs());
- if (showHelp)
- ShowHelp(options);
- else if (checkForUpdates)
- CheckForUpdates();
- else
- return false;
- return true;
- }
-
- static void ShowHelp(OptionSet options)
- {
- Console.WriteLine(Resources.AppName);
- options.WriteOptionDescriptions(Console.Out);
- }
-
- public static void CheckForUpdates()
- {
- //DialogResult result = MessageBox.Show(Resources.UpdatesAreAvailable, Resources.UpdatesAreAvailableCaption,
- // MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- //if (result == DialogResult.Yes)
- //{
- // // need to jump to the udpate form here
- // Program.FormManager.CurrentForm = new Overview(2);
- //}
- }*/
}
}
=== modified file 'WexInstaller/WexCmd.cs'
--- a/WexInstaller/WexCmd.cs 2011-05-17 15:40:12 +0000
+++ b/WexInstaller/WexCmd.cs 2011-05-18 18:39:31 +0000
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
+using System.Diagnostics;
using System.Net;
using System.Reflection;
using System.Text;
@@ -57,11 +58,30 @@ namespace WexInstaller
static ManualResetEvent msiDBLock = new ManualResetEvent(true);
#endregion
- #region Update Manifest. Needs event handlers.
- static void GetProductUpdates()
+ #region Manifest Update and event handler.
+ static void ManifestUpdateCompleted(object sender, AsyncCompletedEventArgs e)
{
+ msiDBLock.Set();
+ }
+
+ static void ManifestUpdate()
+ {
+ // Perform no MSI actions until the download completes.
+ msiDBLock.Reset();
+
+ ProductManager.DownloadManifestCompleted += new DownloadManifestCompleteHandler(ManifestUpdateCompleted);
ProductManager.DownloadManifest();
- // Wait for downloads to complete
+
+ // Wait for download to complete
+ msiDBLock.WaitOne();
+
+ // Wait for the console handle.
+ if (consoleOutput.WaitOne())
+ {
+ consoleOutput.Reset();
+ Console.WriteLine("Finished downloading new manifest.");
+ consoleOutput.Set();
+ }
}
#endregion
@@ -76,7 +96,6 @@ namespace WexInstaller
if (consoleOutput.WaitOne(1000))
{
consoleOutput.Reset();
- Console.SetCursorPosition(0, currentIndex);
Console.WriteLine(String.Format("{0} - {1} : Download {2}% complete", currentIndex + 1, p.Name, e.ProgressPercentage));
consoleOutput.Set();
}
@@ -122,7 +141,6 @@ namespace WexInstaller
if (consoleOutput.WaitOne(1000))
{
consoleOutput.Reset();
- //Console.SetCursorPosition(0, currentIndex);
Console.WriteLine(String.Format("{0} - {1} : Installing {2} % Complete.", currentIndex + 1, p.Name, pe.ProgressPercentage));
consoleOutput.Set();
}
@@ -303,7 +321,7 @@ namespace WexInstaller
{
Console.Error.WriteLine();
Console.Error.WriteLine(message);
- Console.Error.WriteLine("Usage: WexCmd.exe -action=install");
+ Console.Error.WriteLine(String.Format("Usage: {0} -action=install", Process.GetCurrentProcess().ProcessName));
option_set.WriteOptionDescriptions(Console.Error);
Console.WriteLine("Press Enter to continue.");
@@ -403,25 +421,34 @@ namespace WexInstaller
else
productActionList.Clear();
- if (products == null || products.Count == 0)
+ foreach (CatalogProduct product in ProductManager.ActiveCatalog.Products)
{
- // Remove all installed products in current catalog.
- foreach (CatalogProduct product in ProductManager.ActiveCatalog.Products)
+ // Only remove currently installed products.
+ if (product.ReferencedProduct.Installed == true)
{
- if (product.ReferencedProduct.Installed == true)
+ // Default to Remove All.
+ bool removeThisProduct = products == null || products.Count == 0;
+
+ if (!removeThisProduct)
+ {
+ // Remove the products specified on the command-line.
+ foreach (string listedProduct in products.Keys)
+ {
+ if (listedProduct == product.ReferencedProduct.Name)
+ {
+ removeThisProduct = true;
+ break;
+ }
+ }
+ }
+
+ if (removeThisProduct)
{
productActionList.Add(product.ReferencedProduct.Name);
Console.WriteLine(String.Format("{0} - {1} : ", productActionList.Count, productActionList[productActionList.Count - 1]));
}
}
}
- else
- {
- foreach (string product in products.Keys)
- {
- // Check if product name exists and add to list if it does.
- }
- }
}
static void ProcessUpgradeArguments(Dictionary<string, ProductOptions> products)
@@ -436,12 +463,28 @@ namespace WexInstaller
else
productDownloadList.Clear();
- if (products == null || products.Count == 0)
+ foreach (CatalogProduct product in ProductManager.ActiveCatalog.Products)
{
- // Remove all installed products in current catalog.
- foreach (CatalogProduct product in ProductManager.ActiveCatalog.Products)
+ // Only upgrade currently installed and upgradable products.
+ if (product.ReferencedProduct.Installed == true && product.ReferencedProduct.IsUpgrade)
{
- if (product.ReferencedProduct.Installed == true && product.ReferencedProduct.IsUpgrade)
+ // Default to Upgrade all possible.
+ bool upgradeThisProduct = products == null || products.Count == 0;
+
+ if (!upgradeThisProduct)
+ {
+ // Upgrade the products specified on the command-line.
+ foreach (string listedProduct in products.Keys)
+ {
+ if (listedProduct == product.ReferencedProduct.Name)
+ {
+ upgradeThisProduct = true;
+ break;
+ }
+ }
+ }
+
+ if (upgradeThisProduct)
{
product.ReferencedProduct.ProposedInstalled = true;
@@ -455,13 +498,6 @@ namespace WexInstaller
}
}
}
- else
- {
- foreach (string product in products.Keys)
- {
- // Check if product name exists, is installed and then add to list if it does.
- }
- }
}
#endregion
@@ -522,7 +558,6 @@ namespace WexInstaller
throw new OptionException("Error: No action specified.", "action");
// Begin doing work here.
- InstallerConfiguration.Load();
InstallerConfiguration.CatalogWasSpecified = catalog != null;
// Set the catalog after we loaded the configuration or it might override it.
@@ -533,7 +568,7 @@ namespace WexInstaller
// Update the manifest.
if (check_for_updates)
- GetProductUpdates();
+ ManifestUpdate();
switch (action.ToLower())
{
Attachment: [text/bzr-bundle] bzr/iggy@mysql.com-20110518183931-3sdynhxrfu6k0ne0.bundle
| Thread |
|---|
| • bzr commit into wex-installer-1.0 branch (iggy:468) | Iggy Galarza | 19 May |