#At file:///D:/Work/MySQL/installer/ based on revid:mike.lischke@stripped
467 Mike Lischke 2011-05-17
- ConfigurationContoller: added ability to take config values as string (key, value pair).
- Command line interface: made parsing config values and product configuration work.
modified:
StandardPlugins/Examples/ConfigurationController.cs
StandardPlugins/Server/ConfigurationController.cs
WexInstaller.Core/ProductConfigurationController.cs
WexInstaller.Core/ServerProductConfigurationController.cs
WexInstaller/WexCmd.cs
=== modified file 'StandardPlugins/Examples/ConfigurationController.cs'
=== modified file 'StandardPlugins/Examples/ConfigurationController.cs'
--- a/StandardPlugins/Examples/ConfigurationController.cs 2011-04-07 14:04:55 +0000
+++ b/StandardPlugins/Examples/ConfigurationController.cs 2011-05-17 15:40:12 +0000
@@ -34,8 +34,13 @@
get { return null; }
}
- public override void Initialize(bool afterInstallation)
- {
+ public override void Initialize(bool afterInstallation)
+ {
+ }
+
+ public override void SetConfigurationValue(string[] pair)
+ {
+
}
protected override void BackgroundConfigure(object sender, DoWorkEventArgs e)
@@ -235,7 +240,6 @@
return true;
}
-
private void GetOwningCatalogs()
{
if (owningCatalogs != null)
=== modified file 'StandardPlugins/Server/ConfigurationController.cs'
--- a/StandardPlugins/Server/ConfigurationController.cs 2011-05-10 10:02:42 +0000
+++ b/StandardPlugins/Server/ConfigurationController.cs 2011-05-17 15:40:12 +0000
@@ -543,5 +543,33 @@
Template.DataDir = dataDirectory;
}
}
+
+ public override void SetConfigurationValue(string[] pair)
+ {
+ base.SetConfigurationValue(pair);
+
+ if (pair.Length > 0)
+ {
+ string value = pair.Length < 2 ? "" : pair[1];
+ switch (pair[0].ToLowerInvariant())
+ {
+ case "createservice":
+ bool enabled = true;
+ if (bool.TryParse(value, out enabled))
+ CreateService = enabled;
+ break;
+
+ case "servicename":
+ ServiceName = value;
+ CreateService = true; // Let giving a service name be an implicit agreement to create a service.
+ break;
+
+ case "existingrootpassword":
+ case "existingpassword":
+ ExistingRootPassword = value;
+ break;
+ }
+ }
+ }
}
}
=== modified file 'WexInstaller.Core/ProductConfigurationController.cs'
--- a/WexInstaller.Core/ProductConfigurationController.cs 2011-03-29 16:10:30 +0000
+++ b/WexInstaller.Core/ProductConfigurationController.cs 2011-05-17 15:40:12 +0000
@@ -37,6 +37,8 @@
bgw.RunWorkerAsync();
}
+ public abstract void SetConfigurationValue(string[] pair);
+
protected virtual void ReportProgress(int percent, ConfigurationEventArgs args)
{
if (bgw != null)
=== modified file 'WexInstaller.Core/ServerProductConfigurationController.cs'
--- a/WexInstaller.Core/ServerProductConfigurationController.cs 2011-03-25 17:32:28 +0000
+++ b/WexInstaller.Core/ServerProductConfigurationController.cs 2011-05-17 15:40:12 +0000
@@ -37,5 +37,36 @@
connStr += String.Format(";port={0}", Port);
return connStr;
}
+
+ public override void SetConfigurationValue(string[] pair)
+ {
+ if (pair.Length > 0)
+ {
+ string value = pair.Length < 2 ? "" : pair[1];
+ switch (pair[0].ToLowerInvariant())
+ {
+ case "enabletcpip":
+ bool enabled = true;
+ if (bool.TryParse(value, out enabled))
+ EnableTCPIP = enabled;
+ break;
+
+ case "port":
+ int port = 0;
+ if (Int32.TryParse(value, out port))
+ Port = port;
+ break;
+
+ case "rootpassword":
+ case "password":
+ RootPassword = value;
+ break;
+
+ case "datadir":
+ DataDir = value;
+ break;
+ }
+ }
+ }
}
}
=== modified file 'WexInstaller/WexCmd.cs'
--- a/WexInstaller/WexCmd.cs 2011-05-17 09:27:10 +0000
+++ b/WexInstaller/WexCmd.cs 2011-05-17 15:40:12 +0000
@@ -21,34 +21,29 @@
ConfigurationSettings = new List<string>();
if (features == String.Empty)
- {
Features.Add("*");
- }
else
{
if (features.Contains(","))
{
- string[] feature_list = features.Split(',');
- foreach (string feature in feature_list)
- {
+ string[] featureList = features.Split(',');
+ foreach (string feature in featureList)
Features.Add(feature);
- }
}
else
Features.Add(features);
}
- if (config.Contains(","))
+ if (config != null)
{
- string[] config_options = config.Split(',');
- foreach (string config_option in config_options)
+ if (config.Contains(","))
{
- ConfigurationSettings.Add(config_option);
+ string[] configOptions = config.Split(',');
+ foreach (string configOption in configOptions)
+ ConfigurationSettings.Add(configOption);
}
- }
- else
- {
- ConfigurationSettings.Add(config);
+ else
+ ConfigurationSettings.Add(config);
}
}
}
@@ -127,7 +122,7 @@
if (consoleOutput.WaitOne(1000))
{
consoleOutput.Reset();
- Console.SetCursorPosition(0, currentIndex);
+ //Console.SetCursorPosition(0, currentIndex);
Console.WriteLine(String.Format("{0} - {1} : Installing {2} % Complete.", currentIndex + 1, p.Name, pe.ProgressPercentage));
consoleOutput.Set();
}
@@ -151,6 +146,9 @@
p.MakeChanges();
msiDBLock.WaitOne();
+
+ if (p.Controller != null)
+ p.Controller.PostAction();
}
// Wait for the installs to finish.
@@ -164,8 +162,11 @@
#endregion
#region Configure Product.
- static void ProductConfigurationChanged(object sender, ConfigurationEventArgs cea)
+ static void ProductConfigurationChanged(object sender, ConfigurationEventArgs args)
{
+ Console.WriteLine(args.Details);
+ if (args.Type == ConfigurationEventType.Finished)
+ msiDBLock.Set(); // Allow advancing to next task.
}
static void ProductConfigure(Dictionary<string, ProductOptions> products)
@@ -175,10 +176,12 @@
msiDBLock.Reset();
Product p = ProductManager.GetProductById(installProduct);
-
- if (p.Controller != null)
+ if (p.Controller != null && products.ContainsKey(installProduct))
{
- // TODO: Change configuration object to accept and parse a string with user specified values for it's parameters.
+ foreach (string pair in products[installProduct].ConfigurationSettings)
+ p.Controller.SetConfigurationValue(pair.Split('='));
+ p.Controller.Configured +=new ConfigurationEventHandler(ProductConfigurationChanged);
+ p.Controller.Configure();
}
msiDBLock.WaitOne();
@@ -188,7 +191,7 @@
if (consoleOutput.WaitOne())
{
consoleOutput.Reset();
- Console.WriteLine("Finished all installations");
+ Console.WriteLine("Finished all configurations");
consoleOutput.Set();
}
}
@@ -340,7 +343,7 @@
if (type == "Custom")
{
if (products == null || products.Count == 0)
- throw new OptionException("Custom setup type requies at least one product argument.", "product");
+ throw new OptionException("Custom setup type requires at least one product argument.", "product");
}
// Convert text setup type.
@@ -480,23 +483,29 @@
//{"v|verbose", "Enables verbose output", option => verbose = option != null},
{"u|updates", "Check for new products before performing action. Skipped by default.", option => check_for_updates = option != null},
{"a|action=", "Action to be performed.", option => action = option},
- {"p|product:", String.Format("Product/Feature list element.{0}VALUE1 = Product Name.{0}VALUE2 = Feature/Config string.", Environment.NewLine),
- (name, options) => {
- if (name == null)
- throw new OptionException("Missing product name", "product");
- string features = String.Empty;
- string config = String.Empty;
-
- if (options.Contains("="))
- {
- features = options.Substring(0, options.IndexOf("="));
- config = options.Substring(options.IndexOf("=") + 1);
- }
- else
- features = options;
-
- products.Add(name, new ProductOptions(features, config));
- }
+ {"p|product:{;}", String.Format("Product/Feature list element.{0}VALUE1 = Product Name.{0}VALUE2 = Feature/Config string.", Environment.NewLine),
+ (product, options) =>
+ {
+ // A typical line can look so:
+ // -product:mysql-server-5.5-winx64-gpl.*;"EnableTCIP=true,Port=3306,RootPassword=bob,datadir=C:\ProgramData\MySQL\MySQL Server 5.5\\"
+ // Features and config values are separated by semicolon.
+ // Mind the quoting and escaping by backslashes. Quotes are automatically removed.
+ if (product == null)
+ throw new OptionException("Missing product name", "product");
+
+ string features = string.Empty;
+ string name;
+ int dotPosition = product.LastIndexOf('.');
+ if (dotPosition > -1)
+ {
+ name = product.Substring(0, dotPosition);
+ features = product.Substring(dotPosition + 1);
+ }
+ else
+ name = product;
+
+ products.Add(name, new ProductOptions(features, options));
+ }
},
{"c|catalog:", "Set default catalog.", option => catalog = option},
{"t|type:", "Set default install type.", option => type = option},
@@ -513,15 +522,14 @@
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.
if (catalog != null)
InstallerConfiguration.ActiveCatalog = catalog;
- InstallerConfiguration.Load();
ProductManager.Load();
- // Old check is no longer required ?
- if (ProductManager.ActiveCatalog == null)
- ProductManager.ActiveCatalog = ProductManager.Catalogs[0];
// Update the manifest.
if (check_for_updates)
@@ -533,7 +541,7 @@
// Default installation directory
//InstallerConfiguration.ProposedInstallationPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
- // Complete arugment parsing.
+ // Complete argument parsing.
ProcessInstallArguments(type, products);
// Download any missing products.
@@ -541,6 +549,9 @@
// Do actual installation.
ProductInstall();
+
+ // Finally do configuration.
+ ProductConfigure(products);
break;
case "remove":
// Complete argument parsing.
Attachment: [text/bzr-bundle] bzr/mike.lischke@oracle.com-20110517154012-p8rsxpun5dwoo76t.bundle
| Thread |
|---|
| • bzr commit into wex-installer-1.0 branch (mike.lischke:467) | Mike Lischke | 19 May |