Windows: Backup and restore configuration across installs
[openafs.git] / src / WINNT / install / wix / openafs.wxs
index d2e48c6..e955ea2 100644 (file)
@@ -1,4 +1,4 @@
-\feff<?xml version="1.0" ?>
+<?xml version="1.0" ?>
 <Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>
 
     <!-- See config.wxi for the symbols that it defines/asserts -->
@@ -7,8 +7,14 @@
     <!-- See language_config for localization options. -->
     <?include language_config.wxi?>
 
+    <!--
+      We autogenerate a new product code for each build.  According to MSDN we have
+      to change the product code whenever we change the name of the MSI file.  Each
+      version of OpenAFS has a different MSI name.  Thus, each version needs a
+      unique product code.
+      -->
     <Product 
-        Id="$(var.ProductCode)"
+        Id="????????-????-????-????-????????????"
         Codepage="$(var.Codepage)"
         Language="$(var.LanguageCode)"
         Manufacturer="$(var.Manufacturer)"
                         Id="$(var.PackageCode)"
                -->
         <Package
+                Id="????????-????-????-????-????????????"
          AdminImage="no"
          Comments="$(var.PackageComments)"
          Compressed="yes"
          Description="$(var.ProductName)"
-         InstallerVersion="110"
+         InstallerVersion="$(var.InstallerVersion)"
          Keywords="Installer,OpenAFS,$(var.Manufacturer)"
          Languages="$(var.Languages)"
          Manufacturer="$(var.Manufacturer)"
-         Platforms="Intel"
+         Platforms="$(var.Platform)"
          ShortNames="no"
          SummaryCodepage="1252"
          />
         
         <!-- Launch conditions -->
-        <Condition
-         Message="$(loc.StrLaunchCond)">
+        <Condition Message="$(loc.StrLaunchCond)">
          <![CDATA[VersionNT >= 500]]>
         </Condition>
+        <Condition Message="$(loc.AdminRequired)">Privileged</Condition>
+    <?if $(var.Platform) = "x64" ?>
+        <Condition Message="$(loc.StrPlatform64)">
+         <![CDATA[VersionNT64]]>
+        </Condition>
+    <?else?>
+        <Condition Message="$(loc.StrPlatformNot64)">
+         <![CDATA[NOT VersionNT64]]>
+        </Condition>
+    <?endif?>
         
         <!-- Global Properties -->
         <?include property.wxi?>
         
         <!-- File system and registry settings -->
         <Directory Id="TARGETDIR" Name="SourceDir">
+            <?include platform.wxi?>
             <?include registry.wxi?>
             <?include files.wxi?>
         </Directory>
         <?include lang\$(var.Language)\ui.wxi?>
         
         <!-- Custom actions -->
+    <?ifndef UseDllLoopbackInstaller?>
         <Binary
-         Id="BIN_Instloop"
+         Id="BIN_instloop"
          src="$(var.MediaBinDir)instloop.exe"/>
+    <?else?>
+        <Binary
+         Id="BIN_afsLoopback"
+         src="$(var.MediaBinDir)afsloopback.dll"/>
+    <?endif?>
         <Binary
                 Id="BIN_afsCustom"
-                src="$(var.MediaBinDir)afscustom.dll"/>
+                src="$(var.MediaDllDir)afscustom.dll"/>
+    <Binary
+       Id="BIN_idndl.exe"
+       src="$(var.IDNMRedistDir)\idndl.$(var.Arch).exe" />
+    <CustomAction
+       Id="InstallIDNMRedistributable"
+       BinaryKey="BIN_idndl.exe"
+       ExeCommand="/quiet /norestart"
+       Execute="deferred"
+       Impersonate="no"
+       />
+
+       <?ifdef UseDllLoopbackInstaller?>
         <CustomAction
          Id="InstallLoopback"
-         BinaryKey="BIN_Instloop"
-         ExeCommand="-i"
-         Execute="deferred"
+         BinaryKey="BIN_afsLoopback"
+         DllEntry="installLoopbackMSI"
+         Execute="deferred" 
          Impersonate="no"
          />
        <?ifdef RemoveLoopback?>
         <CustomAction
          Id="RemoveLoopback"
-         BinaryKey="BIN_Instloop"
-         ExeCommand="-u"
-         Execute="deferred"
-         Return="ignore"
+         BinaryKey="BIN_afsLoopback"
+         DllEntry="uninstallLoopbackMSI"
+         Execute="deferred" 
          Impersonate="no"
          />
         <CustomAction
          Id="RollbackLoopback"
-         BinaryKey="BIN_Instloop"
-         ExeCommand="-u"
-         Execute="rollback"
-         Return="ignore"
+         BinaryKey="BIN_afsLoopback"
+         DllEntry="uninstallLoopbackMSI"
+         Execute="deferred" 
          Impersonate="no"
          />
        <?endif?>
+       <?else?>
+               <CustomAction
+                Id="InstallLoopback"
+                BinaryKey="BIN_instloop"
+                ExeCommand="-i"
+                Impersonate="no"
+                Execute="deferred"
+                />
+               <?ifdef RemoveLoopback?>
+                       <CustomAction
+                       Id="RollbackLoopback"
+                       BinaryKey="BIN_instloop"
+                       ExeCommand="-u"
+                       Impersonate="no"
+                       Execute="rollback"
+                       />
+                       <CustomAction
+                       Id="RemoveLoopback"
+                       BinaryKey="BIN_instloop"
+                       ExeCommand="-u"
+                       Impersonate="no"
+                       Execute="deferred"
+                       />
+               <?endif?>
+       <?endif?>
         <CustomAction
          Id="InstallNetProvider" 
          BinaryKey="BIN_afsCustom" 
          DllEntry="InstallNetProvider"
-         Execute="oncePerProcess" />
+         Execute="deferred" 
+         Impersonate="no"
+        />
                <CustomAction 
                 Id="RemoveNetProvider" 
                 BinaryKey="BIN_afsCustom"
                 DllEntry="UninstallNetProvider"
                 Return="ignore"
-                Execute="oncePerProcess" />
+                Execute="deferred" 
+                 Impersonate="no"
+                />
                <CustomAction 
                 Id="RollbackNetProvider" 
                 BinaryKey="BIN_afsCustom"
                 DllEntry="UninstallNsisInstallation"
                 Execute="immediate" />
                <CustomAction
-                Id="AbortInstallation"
+                Id="CreateAFSAdminGroup"
+                BinaryKey="BIN_afsCustom"
+                DllEntry="CreateAFSClientAdminGroup"
+                Impersonate="no"
+                Execute="deferred" />
+               <CustomAction
+                Id="RemoveAFSAdminGroup"
+                BinaryKey="BIN_afsCustom"
+                DllEntry="RemoveAFSClientAdminGroup"
+                Impersonate="no"
+                Execute="deferred" />
+               <CustomAction
+                Id="RollbackAFSAdminGroup"
+                BinaryKey="BIN_afsCustom"
+                DllEntry="RemoveAFSClientAdminGroup"
+                Impersonate="no"
+                Execute="rollback" />
+               <CustomAction
+                Id="AbortInstallationA"
                 BinaryKey="BIN_afsCustom"
                 DllEntry="AbortMsiImmediate"
                 Execute="immediate" />
+               <CustomAction
+                Id="AbortInstallationB"
+                BinaryKey="BIN_afsCustom"
+                DllEntry="AbortMsiImmediate"
+                Execute="immediate" />
+                <CustomAction
+                    Id="BackupAFSClientRegistryKeys"
+                    BinaryKey="BIN_afsCustom"
+                    DllEntry="BackupAFSClientRegistryKeys"
+                    Execute="deferred"
+                    Impersonate="no" />
+                <CustomAction
+                    Id="RestoreAFSClientRegistryKeys"
+                    BinaryKey="BIN_afsCustom"
+                    DllEntry="RestoreAFSClientRegistryKeys"
+                    Execute="deferred"
+                    Impersonate="no" />
+                <CustomAction
+                    Id="RollbackRestoreAFSClientRegistryKeys"
+                    BinaryKey="BIN_afsCustom"
+                    DllEntry="BackupAFSClientRegistryKeys"
+                    Execute="rollback"
+                    Impersonate="no" />
+                <CustomAction
+                    Id="DetectSavedConfiguration"
+                    BinaryKey="BIN_afsCustom"
+                    DllEntry="DetectSavedConfiguration"
+                    Execute="firstSequence" />
+                <CustomAction
+                   Id="SetInstallLocation"
+                   Property="ARPINSTALLLOCATION"
+                   Value="[AFSDIR]" />
 
         <!-- Installation Sequences -->
         <AdvertiseExecuteSequence />
         <AdminExecuteSequence />
         <InstallExecuteSequence>
-                       <RemoveExistingProducts After="InstallValidate">IBMAFS_UPGRADE OR OPENAFS_UPGRADE</RemoveExistingProducts>
-                       <Custom Action="RemoveNsisInstallation" Before="AbortInstallation">NSISUNINSTALL &lt;&gt; "" AND UILevel &gt;= 4</Custom>
-                       <Custom Action="AbortInstallation" Before="CostInitialize">NSISUNINSTALL &lt;&gt; "" AND UILevel &lt; 4</Custom>
+                       <RemoveExistingProducts After="InstallValidate">(Not Installed) And (IBMAFS_UPGRADE OR OPENAFS_UPGRADE OR AFSPLUGIN_UPGRADE)</RemoveExistingProducts>
+                       <Custom Action="RemoveNsisInstallation" Before="AbortInstallationA">NSISUNINSTALL &lt;&gt; "" AND UILevel &gt;= 4</Custom>
+                       <Custom Action="AbortInstallationA" Before="CostInitialize">NSISUNINSTALL &lt;&gt; "" AND UILevel &lt; 4</Custom>
+                       <!-- Assert that if the server is going to be installed locally after this session, control center and client are also local -->
+                       <Custom Action="AbortInstallationB" After="MigrateFeatureStates">
+                               <![CDATA[((&feaServer=3 OR (!feaServer=3 AND &feaServer<1)) AND (&feaClient=2 OR (&feaClient<>3 AND !feaClient<>3) OR &feaControlCenter=2 OR (&feaControlCenter<>3 AND !feaControlCenter<>3) ))]]>
+                       </Custom>
                <?ifdef RemoveLoopback?>
                        <Custom Action="RemoveLoopback" After="SelfRegModules">&amp;feaLoopback=2 OR &amp;feaLoopback=3</Custom>
             <Custom Action="RollbackLoopback" After="RemoveLoopback">&amp;feaLoopback=3</Custom>
             <Custom Action="RollbackNetProvider" After="WriteRegistryValues">&amp;feaClient=3</Custom>
                        <Custom Action="InstallNetProvider" After="RollbackNetProvider">&amp;feaClient=3</Custom>
                        <Custom Action="RemoveNetProvider" After="InstallNetProvider">&amp;feaClient=2</Custom>
+      <Custom Action="InstallIDNMRedistributable" After="WriteRegistryValues">!feaClient=2 And &amp;feaClient=3 And (VersionNT=501 Or VersionNT=502)</Custom>
                        <Custom Action="ConfigureClient" After="InstallServices">&amp;feaClient=3</Custom>
                        <Custom Action="ConfigureServer" After="ConfigureClient">&amp;feaServer=3</Custom>
+                        <Custom Action="RollbackRestoreAFSClientRegistryKeys" After="RemoveNetProvider">!feaClient=2 And &amp;feaClient=3 And RESTORE_CONFIG</Custom>
+                        <Custom Action="RestoreAFSClientRegistryKeys" After="RollbackRestoreAFSClientRegistryKeys">!feaClient=2 And &amp;feaClient=3 And RESTORE_CONFIG</Custom>
+                        <Custom Action="BackupAFSClientRegistryKeys" Before="DeleteServices">!feaClient=3 And &amp;feaClient=2</Custom>
+                       <!-- <Custom Action="RemoveAFSAdminGroup" Before="">&amp;feaClient=2</Custom> -->
+                       <Custom Action="RollbackAFSAdminGroup" Before="CreateAFSAdminGroup">&amp;feaClient=3</Custom>
+                       <Custom Action="CreateAFSAdminGroup" Before="CreateFolders">&amp;feaClient=3</Custom>
+                        <Custom Action="SetInstallLocation" Before="RegisterProduct" />
+                        <Custom Action="DetectSavedConfiguration" Before="CostInitialize" />
             <ScheduleReboot After="PublishProduct">&amp;feaClient=3 OR &amp;feaServer=3 OR &amp;feaClient=2 OR &amp;feaServer=2</ScheduleReboot>
         </InstallExecuteSequence>
 
         <!-- Related producs -->
-        <!-- MIT's OpenAFS MSI installer -->
+        <!-- OpenAFS MSI installer -->
         <Upgrade Id="6823EEDD-84FC-4204-ABB3-A80D25779833">
-            <UpgradeVersion IgnoreRemoveFailure="no" IncludeMaximum="no" Maximum="$(var.NumericVersion)" MigrateFeatures="yes" Property="OPENAFS_UPGRADE" />
+            <UpgradeVersion IgnoreRemoveFailure="no" IncludeMaximum="yes" Maximum="$(var.NumericVersion)" MigrateFeatures="yes" Property="OPENAFS_UPGRADE" />
         </Upgrade>
         
         <!-- MIT's Transarc AFS MSI Installer -->
             <UpgradeVersion IgnoreRemoveFailure="no" IncludeMaximum="yes" Maximum="3.6.2" MigrateFeatures="no" Property="IBMAFS_UPGRADE" />
         </Upgrade>
         
+  <?if $(env.CPU) = "i386" ?>
+        <!-- Secure-Endpoints OpenAFS NetIDMgr plug-in -->
+        <Upgrade Id="646D643A-73E3-4C77-AE4A-EDBE313DD45D">
+            <UpgradeVersion IgnoreRemoveFailure="no" IncludeMaximum="no" Maximum="$(var.NumericVersion)" MigrateFeatures="no" Property="AFSPLUGIN_UPGRADE" />
+        </Upgrade>
+  <?endif?>
+        
         <!-- openafs.org NSIS installer is detected using other means -->
         <!-- Please let us know if you want other Installers to be detected and upgraded/removed -->
 
                <!-- Media -->
-               <Media Id="1" Cabinet="disk1.cab" CompressionLevel="mszip" EmbedCab="yes" />
+               <Media Id="1" Cabinet="disk1.cab" CompressionLevel="high" EmbedCab="yes" />
     </Product>
 </Wix>