#At file:///D:/Work/MySQL/installer/ based on revid:mike.lischke@stripped
358 Mike Lischke 2011-03-09
- Examples wix projects: changed output path to point to the correct product cache folder.
- IncludeMSIs.wxs: outcommented 5.1 server (only one server per msi please). Adjusted a few version numbers.
- ProductManager: added a version check to the manifest download chain. Update local manifest only if newer.
- manifest-base.xml: increased vesion number (new client-only setup has been added recently).
- ConfigurationController: added new check for existing server data file (physical folder on disk).
- Some code cleanup.
- Added two binaries to bzr ignore path (which are copied by the build process).
- Example wix projects and the net setup project are no longer automatically build when doing a full build of the solution, as they either change almost never or require a significant amount of build time. Can always be build manually.
modified:
.bzrignore
Examples/Examples 5.1.wixproj
Examples/Examples 5.5.wixproj
Setup/IncludeMSIs.wxs
Setup/manifest-base.xml
StandardPlugins/Server/ConfigurationController.cs
StandardPlugins/Server/MysqlSCM.cs
WexInstaller.Core/ProductManager.cs
installer-vs2010.sln
=== modified file '.bzrignore'
=== modified file '.bzrignore'
--- a/.bzrignore 2011-02-25 09:16:00 +0000
+++ b/.bzrignore 2011-03-09 12:44:28 +0000
@@ -6,3 +6,5 @@
**/*.user
ProductCache
Setup/products.xml
+Setup/ManifestUpdater.exe
+Setup/MySQLCA.CA.dll
=== modified file 'Examples/Examples 5.1.wixproj'
--- a/Examples/Examples 5.1.wixproj 2011-02-25 09:16:00 +0000
+++ b/Examples/Examples 5.1.wixproj 2011-03-09 12:44:28 +0000
@@ -13,7 +13,7 @@
<Name>Examples 5.1</Name>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
- <OutputPath>..\ProductCache\</OutputPath>
+ <OutputPath>..\Setup\ProductCache\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
<SuppressPdbOutput>True</SuppressPdbOutput>
=== modified file 'Examples/Examples 5.5.wixproj'
--- a/Examples/Examples 5.5.wixproj 2011-02-25 09:16:00 +0000
+++ b/Examples/Examples 5.5.wixproj 2011-03-09 12:44:28 +0000
@@ -12,7 +12,7 @@
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
- <OutputPath>..\ProductCache\</OutputPath>
+ <OutputPath>..\Setup\ProductCache\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
<SuppressPdbOutput>True</SuppressPdbOutput>
=== modified file 'Setup/IncludeMSIs.wxs'
--- a/Setup/IncludeMSIs.wxs 2011-02-25 21:39:47 +0000
+++ b/Setup/IncludeMSIs.wxs 2011-03-09 12:44:28 +0000
@@ -4,15 +4,15 @@
<DirectoryRef Id="UniversalInstaller">
<Directory Id="ProductCache" Name="Product Cache">
<Component Id="Products" Guid="88D9D419-FCCB-4B4B-881E-FAE4D29C81B9" Permanent="yes">
- <File Id="server51" Name="mysql-5.1.55-win32.msi" Source="ProductCache\mysql-5.1.55-win32.msi"/>
+ <!--File Id="server51" Name="mysql-5.1.55-win32.msi" Source="ProductCache\mysql-5.1.56-win32.msi"/ -->
<File Id="server55" Name="mysql-5.5.9-win32.msi" Source="ProductCache\mysql-5.5.9-win32.msi"/>
- <File Id="connector_cpp_10" Name="mysql-connector-c++-1.0.5-win32.msi" Source="ProductCache\mysql-connector-c++-1.0.5-win32.msi"/>
+ <File Id="connector_cpp_10" Name="mysql-connector-c++-1.1.0-win32.msi" Source="ProductCache\mysql-connector-c++-1.1.0-win32.msi"/>
<File Id="connector_c_60" Name="mysql-connector-c-6.0.2-win32.msi" Source="ProductCache\mysql-connector-c-6.0.2-win32.msi"/>
<File Id="connector_odbc_51" Name="mysql-connector-odbc-5.1.8-win32.msi" Source="ProductCache\mysql-connector-odbc-5.1.8-win32.msi"/>
<File Id="examples_51" Name="mysql-examples-5.1.0.msi" Source="ProductCache\mysql-examples-5.1.0.msi"/>
<File Id="examples_55" Name="mysql-examples-5.5.0.msi" Source="ProductCache\mysql-examples-5.5.0.msi"/>
<File Id="universal_installer_document_bundle_10" Name="mysql-universal-installer-document-bundle-1.0.0.0.msi" Source="ProductCache\mysql-universal-installer-document-bundle-1.0.0.0.msi"/>
- <File Id="workbench_gpl_52" Name="mysql-workbench-gpl-5.2.31-win32.msi" Source="ProductCache\mysql-workbench-gpl-5.2.31-win32.msi"/>
+ <File Id="workbench_gpl_52" Name="mysql-workbench-gpl-5.2.32-win32.msi" Source="ProductCache\mysql-workbench-gpl-5.2.32-win32.msi"/>
</Component>
</Directory>
</DirectoryRef>
=== modified file 'Setup/manifest-base.xml'
--- a/Setup/manifest-base.xml 2011-02-28 18:16:46 +0000
+++ b/Setup/manifest-base.xml 2011-03-09 12:44:28 +0000
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<ProductManifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1" format="1">
+<ProductManifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="2" format="1">
<UpdateURL></UpdateURL>
<UpdateVersion></UpdateVersion>
<UpdateHash></UpdateHash>
=== modified file 'StandardPlugins/Server/ConfigurationController.cs'
--- a/StandardPlugins/Server/ConfigurationController.cs 2011-03-08 11:10:55 +0000
+++ b/StandardPlugins/Server/ConfigurationController.cs 2011-03-09 12:44:28 +0000
@@ -126,6 +126,7 @@
{
string thisServiceName = ScManager.FindServiceName(Template.BaseDir);
+ // TODO: add check if an existing service is marked for deletion.
if (thisServiceName.Length > 0)
//if (it.Reconfiguring)
{
@@ -225,7 +226,7 @@
string baseDirectory = String.Empty;
string dataDirectory = String.Empty;
- string foundDataDir = String.Empty;
+ bool foundDataDir = false;
string version = String.Empty;
if (Owner != null)
@@ -236,7 +237,8 @@
baseDirectory = Owner.GetInstalledProductRegistryKey("Location");
dataDirectory = Owner.GetInstalledProductRegistryKey("DataLocation");
- foundDataDir = Owner.GetInstalledProductRegistryKey("FoundExistingDataDir");
+ string value = Owner.GetInstalledProductRegistryKey("FoundExistingDataDir");
+ foundDataDir = (value == "1");
version = Owner.GetInstalledProductRegistryKey("Version");
if (!String.IsNullOrEmpty(baseDirectory))
@@ -250,6 +252,10 @@
// If no existing service, use default.
this.ServiceName = String.Format("MySQL{0}{1}", version[0], version[2]);
}
+
+ // Don't rely only on a registry key for an existing data folder. Check it on disk.
+ if (!foundDataDir)
+ foundDataDir = Directory.Exists(dataDirectory);
}
Reconfigure = (Owner.IsUpgrade && Owner.Installed);
@@ -277,7 +283,7 @@
Logger.LogInformation("Product configuration controller creating new template instance.");
Template = new IniTemplate(baseDirectory, dataDirectory, InstallerConfiguration.TemplateName, dataDirectory);
- Template.FoundExistingDataDir = (!String.IsNullOrEmpty(foundDataDir) && foundDataDir == "1");
+ Template.FoundExistingDataDir = foundDataDir;
}
else
{
=== modified file 'StandardPlugins/Server/MysqlSCM.cs'
--- a/StandardPlugins/Server/MysqlSCM.cs 2011-03-07 16:27:05 +0000
+++ b/StandardPlugins/Server/MysqlSCM.cs 2011-03-09 12:44:28 +0000
@@ -14,6 +14,8 @@
using System.Threading;
using Microsoft.Win32;
+// XXX: Use the System.ServiceProcess.ServiceInstaller class instead of P/Invoke for service installation!
+// Here's code to get you started: http://stackoverflow.com/questions/255056/install-a-net-windows-service-without-installutil-exe
namespace WexInstaller.Core
{
public class MySQLServiceControlManager
=== modified file 'WexInstaller.Core/ProductManager.cs'
--- a/WexInstaller.Core/ProductManager.cs 2011-03-02 15:58:16 +0000
+++ b/WexInstaller.Core/ProductManager.cs 2011-03-09 12:44:28 +0000
@@ -1,305 +1,310 @@
using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Xml.Serialization;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
using System.IO;
using System.Net;
-using System.ComponentModel;
-using System.Collections.ObjectModel;
-using WexInstaller.Core;
-using System.Reflection;
using System.Threading;
+using System.Xml.Serialization;
namespace WexInstaller.Core
{
- public delegate void DownloadManifestProgressHandler(object sender, DownloadProgressChangedEventArgs de);
- public delegate void DownloadManifestCompleteHandler(object sender, AsyncCompletedEventArgs ae);
-
- public static class ProductManager
- {
- private static ProductManifest manifest;
-
- public static ReadOnlyCollection<ProductCategory> ProductCategories
- {
- get { return manifest.ProductCategories.AsReadOnly(); }
- }
-
- public static ReadOnlyCollection<ProductCatalog> Catalogs
- {
- get { return manifest.ProductCatalogs.AsReadOnly(); }
- }
-
- public static ProductManifest Manifest { get; set; }
- private static bool CatalogProductsInstalled { get; set; }
- private static bool CatalogProductsUpgrade { get; set; }
- public static bool ProductsInstalled { get; private set; }
- public static bool ProductsUpgrade { get; private set; }
- public static ProductCatalog ActiveCatalog { get; set; }
-
- private static ProductManifest ObjectifyManifest(string fileName)
- {
- ProductManifest thisManifest = null;
-
- if (File.Exists(fileName))
- {
- XmlRootAttribute productCategories = new XmlRootAttribute("ProductManifest");
- XmlSerializer s = new XmlSerializer(typeof(ProductManifest));
- TextReader w = new StreamReader(fileName);
- thisManifest = (ProductManifest)s.Deserialize(w);
- w.Close();
- }
-
- return thisManifest;
- }
-
- public static void Load()
- {
- Logger.LogTrace("ProductManager.Load()");
-
- LoadManifestWithCheckForTemp();
-
- //TODO: fix this to handle it better
- if (manifest == null || manifest.ProductCategories == null || manifest.ProductCatalogs == null)
- throw new InvalidOperationException("Manifest failed to load properly");
- Manifest = manifest;
-
- foreach (ProductCategory pc in manifest.ProductCategories)
- {
- pc.Type = (ProductCategoryType)Enum.Parse(typeof(ProductCategoryType), pc.Name);
- foreach (Product p in pc.Products)
- {
- p.PostInitialize(true);
- p.SetParent(pc);
-
- // Initialize the controller if there are any
- if (p.Controller != null)
- p.Controller.Initialize();
- }
- }
-
- // run through all categories and determine if *any* products are
- // installed or have upgrades
- foreach (ProductCategory category in manifest.ProductCategories)
- foreach (Product product in category.Products)
- {
- ProductsInstalled |= product.Installed;
- ProductsUpgrade |= product.IsUpgrade;
- }
-
- // run through all catalogs and de-reference all referenced products
- foreach (ProductCatalog catalog in manifest.ProductCatalogs)
- foreach (CatalogProduct p in catalog.Products)
- {
- p.ReferencedProduct = GetProductById(p.ProductId);
- if (p.ReferencedProduct == null)
- //TODO: handle this better
- throw new InvalidOperationException();
- }
-
- // Default to first catalog and then see if we have a catalog file
- // that gives us a different default
- string defaultCatalog = GetDefaultCatalogIfAny();
- ActiveCatalog = null;
- if (defaultCatalog != null)
- {
- foreach (ProductCatalog cat in manifest.ProductCatalogs)
- if (cat.Id == defaultCatalog)
- {
- ActiveCatalog = cat;
- break;
- }
- }
- if (ActiveCatalog != null)
- {
- // setup the Installed and IsUpgrade global variables based
- // on what from the active catalog is installed.
- foreach (CatalogProduct cp in ActiveCatalog.Products)
- {
- CatalogProductsInstalled |= cp.ReferencedProduct.Installed;
- CatalogProductsUpgrade |= cp.ReferencedProduct.IsUpgrade;
- }
- }
- }
-
- public static bool IsNewSetup()
- {
- if (ActiveCatalog == null)
- {
- if (ProductsInstalled) return false;
- if (ProductsUpgrade) return false;
- return true;
- }
- else
- {
- if (CatalogProductsInstalled) return false;
- if (CatalogProductsUpgrade) return false;
- return true;
- }
- }
-
- private static string GetDefaultCatalogIfAny()
- {
- // if ActiveCatalog != null, then this isn't the the first
- // time we have run so we always use default in that case
- if (ActiveCatalog != null) return null;
- string[] args = Environment.GetCommandLineArgs();
- if (args.Length < 2) return null;
- return args[1]; // this should be the default catalog name
- }
-
- private static void LoadManifestWithCheckForTemp()
- {
- // first we need to see if there is any temp manifest file to check
- ProductManifest tempManifest = ObjectifyManifest(InstallerConfiguration.TempProductsManifest);
- ProductManifest currentManifest = ObjectifyManifest(InstallerConfiguration.ProductsManifest);
-
- if (tempManifest == null)
- manifest = currentManifest;
+ public delegate void DownloadManifestProgressHandler(object sender, DownloadProgressChangedEventArgs de);
+ public delegate void DownloadManifestCompleteHandler(object sender, AsyncCompletedEventArgs ae);
+
+ public static class ProductManager
+ {
+ private static ProductManifest manifest;
+
+ public static ReadOnlyCollection<ProductCategory> ProductCategories
+ {
+ get { return manifest.ProductCategories.AsReadOnly(); }
+ }
+
+ public static ReadOnlyCollection<ProductCatalog> Catalogs
+ {
+ get { return manifest.ProductCatalogs.AsReadOnly(); }
+ }
+
+ public static ProductManifest Manifest { get; set; }
+ private static bool CatalogProductsInstalled { get; set; }
+ private static bool CatalogProductsUpgrade { get; set; }
+ public static bool ProductsInstalled { get; private set; }
+ public static bool ProductsUpgrade { get; private set; }
+ public static ProductCatalog ActiveCatalog { get; set; }
+
+ private static ProductManifest ObjectifyManifest(string fileName)
+ {
+ ProductManifest thisManifest = null;
+
+ if (File.Exists(fileName))
+ {
+ XmlRootAttribute productCategories = new XmlRootAttribute("ProductManifest");
+ XmlSerializer s = new XmlSerializer(typeof(ProductManifest));
+ TextReader w = new StreamReader(fileName);
+ thisManifest = (ProductManifest)s.Deserialize(w);
+ w.Close();
+ }
+
+ return thisManifest;
+ }
+
+ public static void Load()
+ {
+ Logger.LogTrace("ProductManager.Load()");
+
+ LoadManifestWithCheckForTemp();
+
+ //TODO: fix this to handle it better
+ if (manifest == null || manifest.ProductCategories == null || manifest.ProductCatalogs == null)
+ throw new InvalidOperationException("Manifest failed to load properly");
+ Manifest = manifest;
+
+ foreach (ProductCategory pc in manifest.ProductCategories)
+ {
+ pc.Type = (ProductCategoryType)Enum.Parse(typeof(ProductCategoryType), pc.Name);
+ foreach (Product p in pc.Products)
+ {
+ p.PostInitialize(true);
+ p.SetParent(pc);
+
+ // Initialize the controller if there are any
+ if (p.Controller != null)
+ p.Controller.Initialize();
+ }
+ }
+
+ // run through all categories and determine if *any* products are
+ // installed or have upgrades
+ foreach (ProductCategory category in manifest.ProductCategories)
+ foreach (Product product in category.Products)
+ {
+ ProductsInstalled |= product.Installed;
+ ProductsUpgrade |= product.IsUpgrade;
+ }
+
+ // run through all catalogs and de-reference all referenced products
+ foreach (ProductCatalog catalog in manifest.ProductCatalogs)
+ foreach (CatalogProduct p in catalog.Products)
+ {
+ p.ReferencedProduct = GetProductById(p.ProductId);
+ if (p.ReferencedProduct == null)
+ //TODO: handle this better
+ throw new InvalidOperationException();
+ }
+
+ // Default to first catalog and then see if we have a catalog file
+ // that gives us a different default
+ string defaultCatalog = GetDefaultCatalogIfAny();
+ ActiveCatalog = null;
+ if (defaultCatalog != null)
+ {
+ foreach (ProductCatalog cat in manifest.ProductCatalogs)
+ if (cat.Id == defaultCatalog)
+ {
+ ActiveCatalog = cat;
+ break;
+ }
+ }
+ if (ActiveCatalog != null)
+ {
+ // setup the Installed and IsUpgrade global variables based
+ // on what from the active catalog is installed.
+ foreach (CatalogProduct cp in ActiveCatalog.Products)
+ {
+ CatalogProductsInstalled |= cp.ReferencedProduct.Installed;
+ CatalogProductsUpgrade |= cp.ReferencedProduct.IsUpgrade;
+ }
+ }
+ }
+
+ public static bool IsNewSetup()
+ {
+ if (ActiveCatalog == null)
+ {
+ if (ProductsInstalled)
+ return false;
+ if (ProductsUpgrade)
+ return false;
+ return true;
+ }
+ else
+ {
+ if (CatalogProductsInstalled)
+ return false;
+ if (CatalogProductsUpgrade)
+ return false;
+ return true;
+ }
+ }
+
+ private static string GetDefaultCatalogIfAny()
+ {
+ // if ActiveCatalog != null, then this isn't the the first
+ // time we have run so we always use default in that case
+ if (ActiveCatalog != null)
+ return null;
+ string[] args = Environment.GetCommandLineArgs();
+ if (args.Length < 2)
+ return null;
+ return args[1]; // this should be the default catalog name
+ }
+
+ private static void LoadManifestWithCheckForTemp()
+ {
+ // first we need to see if there is any temp manifest file to check
+ ProductManifest tempManifest = ObjectifyManifest(InstallerConfiguration.TempProductsManifest);
+ ProductManifest currentManifest = ObjectifyManifest(InstallerConfiguration.ProductsManifest);
+
+ if (tempManifest == null)
+ manifest = currentManifest;
+ else
+ {
+ if (currentManifest == null || tempManifest.Version > currentManifest.Version)
+ {
+ manifest = tempManifest;
+ currentManifest = null;
+ File.Copy(InstallerConfiguration.TempProductsManifest, InstallerConfiguration.ProductsManifest, true);
+ }
+ else
+ {
+ manifest = currentManifest;
+ tempManifest = null;
+ }
+ File.Delete(InstallerConfiguration.TempProductsManifest);
+ }
+ }
+
+ public static event DownloadManifestProgressHandler DownloadManifestProgressChanged;
+
+ public static event DownloadManifestCompleteHandler DownloadManifestCompleted;
+
+ public static Product GetProductById(string id)
+ {
+ foreach (ProductCategory cat in manifest.ProductCategories)
+ foreach (Product p in cat.Products)
+ if (String.Compare(id, p.Name, true) == 0)
+ return p;
+ return null;
+ }
+
+ public static void CancelDownload()
+ {
+ Logger.LogTrace("ProductManager.CancelDownload().");
+
+ if (wc != null)
+ wc.CancelAsync();
+ }
+
+ private static void DownloadManifestComplete(object sender, AsyncCompletedEventArgs e)
+ {
+ if (e.Cancelled == false && e.Error == null)
+ {
+ Logger.LogInformation(String.Format("Successfully downloaded product manifest from {0}.", (string) e.UserState));
+ try
+ {
+ ProductManifest tempManifest = ObjectifyManifest(InstallerConfiguration.TempManifest);
+ if (tempManifest.Version > manifest.Version)
+ {
+ Logger.LogInformation("New manifest version found. Attempting to update existing product manifest.");
+ File.Delete(InstallerConfiguration.ProductsManifest);
+ File.Move(InstallerConfiguration.TempManifest, InstallerConfiguration.ProductsManifest);
+ Load();
+ }
else
- {
- if (currentManifest == null || tempManifest.Version > currentManifest.Version)
- {
- manifest = tempManifest;
- currentManifest = null;
- File.Copy(InstallerConfiguration.TempProductsManifest, InstallerConfiguration.ProductsManifest, true);
- }
- else
- {
- manifest = currentManifest;
- tempManifest = null;
- }
- File.Delete(InstallerConfiguration.TempProductsManifest);
- }
- }
-
- public static event DownloadManifestProgressHandler DownloadManifestProgressChanged;
-
- public static event DownloadManifestCompleteHandler DownloadManifestCompleted;
-
- public static Product GetProductById(string id)
- {
- foreach (ProductCategory cat in manifest.ProductCategories)
- foreach (Product p in cat.Products)
- if (String.Compare(id, p.Name, true) == 0) return p;
- return null;
- }
-
- public static void CancelDownload()
- {
- Logger.LogTrace("ProductManager.CancelDownload().");
-
- if (wc != null)
- wc.CancelAsync();
- }
-
- private static void DownloadManifestComplete(object sender, AsyncCompletedEventArgs e)
- {
- if (e.Cancelled == false && e.Error == null)
- {
- Logger.LogInformation(String.Format("Successfully downloaded new product manifest from {0}.", (string) e.UserState));
- try
- {
- Logger.LogInformation("Attempting to update existing product manifest.");
- File.Delete(InstallerConfiguration.ProductsManifest);
- File.Move(InstallerConfiguration.TempManifest, InstallerConfiguration.ProductsManifest);
- Load();
- UpdateURLIndex = 0;
- }
- catch (Exception ex)
- {
- Logger.LogException(ex);
- }
-
- if (DownloadManifestCompleted != null)
- {
- DownloadManifestCompleted(sender, e);
- }
- }
- else
- {
- Logger.LogError(String.Format("Failed to download new product manifest from {0}.", (string)e.UserState));
- if (UpdateURLIndex < (InstallerConfiguration.UpdateURLs.Count - 1))
- {
- UpdateURLIndex += 1;
- DownloadManifest();
- }
- else
- {
- if (DownloadManifestCompleted != null)
- {
- DownloadManifestCompleted(sender, e);
- }
- }
- }
-
- return;
- }
-
- private static void DownloadManifestProgress(object sender, DownloadProgressChangedEventArgs e)
- {
- Logger.LogInformation(String.Format("Downloaded {0} of new manifest.", e.ProgressPercentage));
- downloadMonitor.Dispose();
-
- if (DownloadManifestProgressChanged != null)
- {
- DownloadManifestProgressChanged(sender, e);
- }
- return;
- }
-
- private static WebClient wc;
-
- private static int UpdateURLIndex = 0;
-
- private static TimerCallback downloadMonitorCallback = TimedCancel;
-
- private static Timer downloadMonitor;
-
- public static void TimedCancel(Object stateInfo)
- {
- Logger.LogTrace("Download attempt has exceeded it's time limit");
- if (wc != null)
- wc.CancelAsync();
- }
-
- public static bool DownloadManifest()
- {
- Logger.LogTrace("ProductManager.DownloadManifest()");
-
- if (UpdateURLIndex > InstallerConfiguration.UpdateURLs.Count)
- {
- Logger.LogWarning("Invalid update URL index. No download URL defined?");
- return false;
- }
-
- if (File.Exists(InstallerConfiguration.TempManifest))
- {
- File.Delete(InstallerConfiguration.TempManifest);
- Logger.LogInformation("Removed existing temporary product manifest.");
- }
-
- wc = new WebClient();
- downloadMonitor = new Timer(downloadMonitorCallback, null, InstallerConfiguration.UpdateTimeoutMilliseconds, Timeout.Infinite);
-
- string updateUrl = InstallerConfiguration.UpdateURLs[UpdateURLIndex].URL;
- Uri updateUri = new Uri(updateUrl);
-
- try
- {
- Logger.LogInformation(String.Format("Attempting product manifest download from {0}.", updateUrl));
-
- wc.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadManifestComplete);
- wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadManifestProgress);
- wc.DownloadFileAsync(updateUri, InstallerConfiguration.TempManifest, updateUrl);
- }
- catch (Exception e)
- {
- // Unable to begin download due to a malformed request or a busy TempManifest
- Logger.LogException(e);
- }
-
- return wc.IsBusy;
- }
-
- }
+ Logger.LogInformation("Manifest already up-to-date. No action required.");
+ UpdateURLIndex = 0;
+ }
+ catch (Exception ex)
+ {
+ Logger.LogException(ex);
+ }
+
+ if (DownloadManifestCompleted != null)
+ {
+ DownloadManifestCompleted(sender, e);
+ }
+ }
+ else
+ {
+ Logger.LogError(String.Format("Failed to download new product manifest from {0}.", (string)e.UserState));
+ if (UpdateURLIndex < (InstallerConfiguration.UpdateURLs.Count - 1))
+ {
+ UpdateURLIndex += 1;
+ DownloadManifest();
+ }
+ else
+ {
+ if (DownloadManifestCompleted != null)
+ DownloadManifestCompleted(sender, e);
+ }
+ }
+
+ return;
+ }
+
+ private static void DownloadManifestProgress(object sender, DownloadProgressChangedEventArgs e)
+ {
+ Logger.LogInformation(String.Format("Downloaded {0} of new manifest.", e.ProgressPercentage));
+ downloadMonitor.Dispose();
+
+ if (DownloadManifestProgressChanged != null)
+ DownloadManifestProgressChanged(sender, e);
+ return;
+ }
+
+ private static WebClient wc;
+
+ private static int UpdateURLIndex = 0;
+
+ private static TimerCallback downloadMonitorCallback = TimedCancel;
+
+ private static Timer downloadMonitor;
+
+ public static void TimedCancel(Object stateInfo)
+ {
+ Logger.LogTrace("Download attempt has exceeded it's time limit");
+ if (wc != null)
+ wc.CancelAsync();
+ }
+
+ public static bool DownloadManifest()
+ {
+ Logger.LogTrace("ProductManager.DownloadManifest()");
+
+ if (UpdateURLIndex > InstallerConfiguration.UpdateURLs.Count)
+ {
+ Logger.LogWarning("Invalid update URL index. No download URL defined?");
+ return false;
+ }
+
+ if (File.Exists(InstallerConfiguration.TempManifest))
+ {
+ File.Delete(InstallerConfiguration.TempManifest);
+ Logger.LogInformation("Removed existing temporary product manifest.");
+ }
+
+ wc = new WebClient();
+ downloadMonitor = new Timer(downloadMonitorCallback, null, InstallerConfiguration.UpdateTimeoutMilliseconds, Timeout.Infinite);
+
+ string updateUrl = InstallerConfiguration.UpdateURLs[UpdateURLIndex].URL;
+ Uri updateUri = new Uri(updateUrl);
+
+ try
+ {
+ Logger.LogInformation(String.Format("Attempting product manifest download from {0}.", updateUrl));
+
+ wc.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadManifestComplete);
+ wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadManifestProgress);
+ wc.DownloadFileAsync(updateUri, InstallerConfiguration.TempManifest, updateUrl);
+ }
+ catch (Exception e)
+ {
+ // Unable to begin download due to a malformed request or a busy TempManifest
+ Logger.LogException(e);
+ }
+
+ return wc.IsBusy;
+ }
+
+ }
}
=== modified file 'installer-vs2010.sln'
--- a/installer-vs2010.sln 2011-03-02 15:58:16 +0000
+++ b/installer-vs2010.sln 2011-03-09 12:44:28 +0000
@@ -115,7 +115,6 @@
{C471DBDA-2AFA-4EA3-970A-795133F1FE1A}.Release|x86.ActiveCfg = Release|Any CPU
{13190F97-5D72-4949-A77A-500A57DA44BB}.Debug|Any CPU.ActiveCfg = Debug|x86
{13190F97-5D72-4949-A77A-500A57DA44BB}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
- {13190F97-5D72-4949-A77A-500A57DA44BB}.Debug|Mixed Platforms.Build.0 = Debug|x86
{13190F97-5D72-4949-A77A-500A57DA44BB}.Debug|Win32.ActiveCfg = Debug|x86
{13190F97-5D72-4949-A77A-500A57DA44BB}.Debug|x86.ActiveCfg = Debug|x86
{13190F97-5D72-4949-A77A-500A57DA44BB}.Debug|x86.Build.0 = Debug|x86
@@ -140,7 +139,6 @@
{64664A39-D6C5-4842-A879-BDD915DDDCCF}.Release|x86.ActiveCfg = Release|Any CPU
{FBC6C598-EC89-49E6-8FE4-4140141761CC}.Debug|Any CPU.ActiveCfg = Debug|x86
{FBC6C598-EC89-49E6-8FE4-4140141761CC}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
- {FBC6C598-EC89-49E6-8FE4-4140141761CC}.Debug|Mixed Platforms.Build.0 = Debug|x86
{FBC6C598-EC89-49E6-8FE4-4140141761CC}.Debug|Win32.ActiveCfg = Debug|x86
{FBC6C598-EC89-49E6-8FE4-4140141761CC}.Debug|x86.ActiveCfg = Debug|x86
{FBC6C598-EC89-49E6-8FE4-4140141761CC}.Debug|x86.Build.0 = Debug|x86
@@ -189,7 +187,6 @@
{57913AF9-D535-4B13-A088-8DF74FD47A53}.Release|x86.Build.0 = Release|x86
{D2E2842E-20B1-4167-8FE4-32CCD9D63214}.Debug|Any CPU.ActiveCfg = Debug|x86
{D2E2842E-20B1-4167-8FE4-32CCD9D63214}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
- {D2E2842E-20B1-4167-8FE4-32CCD9D63214}.Debug|Mixed Platforms.Build.0 = Debug|x86
{D2E2842E-20B1-4167-8FE4-32CCD9D63214}.Debug|Win32.ActiveCfg = Debug|x86
{D2E2842E-20B1-4167-8FE4-32CCD9D63214}.Debug|x86.ActiveCfg = Debug|x86
{D2E2842E-20B1-4167-8FE4-32CCD9D63214}.Debug|x86.Build.0 = Debug|x86
Attachment: [text/bzr-bundle] bzr/mike.lischke@oracle.com-20110309124428-6eyh44f3i4zgm83q.bundle
| Thread |
|---|
| • bzr commit into wex-installer-1.0 branch (mike.lischke:358) | Mike Lischke | 9 Mar |