2007-11-14 Marcus Brinkmann <marcus@g10code.de>
authorMarcus Brinkmann <mb@g10code.com>
Wed, 14 Nov 2007 17:12:44 +0000 (17:12 +0000)
committerMarcus Brinkmann <mb@g10code.com>
Wed, 14 Nov 2007 17:12:44 +0000 (17:12 +0000)
* src/inst-kleopatra.nsi: Prefix kleopatra.bat by $BUILD_DIR.
* src/make-msi.pl: Add INSTDIR\pub to PATH environment for gnupg.
Handle /oname in File statements.  Handle upgrades.  Register
DLLs.  Register services.
* src/make-msi.guids: Update.

ChangeLog
src/inst-kleopatra.nsi
src/make-msi.guids
src/make-msi.pl

index be1a7ed..abffe51 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-11-14  Marcus Brinkmann  <marcus@g10code.de>
+
+       * src/inst-kleopatra.nsi: Prefix kleopatra.bat by $BUILD_DIR.
+       * src/make-msi.pl: Add INSTDIR\pub to PATH environment for gnupg.
+       Handle /oname in File statements.  Handle upgrades.  Register
+       DLLs.  Register services.
+       * src/make-msi.guids: Update.
+
 2007-11-13  Marcus Brinkmann  <marcus@g10code.de>
 
        * src/make-msi.pl: New file.
index ceaf9bc..37c007d 100644 (file)
@@ -33,7 +33,7 @@ Section "Kleopatra" SEC_kleopatra
   SetOutPath "$INSTDIR\bin"
   File ${prefix}/bin/kleopatra.exe
   SetOutPath "$INSTDIR"
-  File kleopatra.bat
+  File ${BUILD_DIR}/kleopatra.bat
 
   File ${prefix}/bin/libgpgme++-glib.dll
   File ${prefix}/bin/libgpgme++-qt.dll
index 9a22e97..14f2a2c 100644 (file)
@@ -2,6 +2,7 @@
 c98dadcc-b796-41cf-aff2-bfa1706a5a6f /PRODUCT/1.9.0.581
 fb54db39-2456-4fcc-9550-2790db663015 /REGISTRY/HKLM/Software\GNU\GnuPG/Install Directory
 ad23691b-1734-4dec-b91a-d4ff286190ea /REGISTRY/HKLM/Software\GNU\GnuPG/gpgProgram
+e0807a2f-4e70-48f8-b047-c5d3e219c3e7 /UPGRADE/1
 e3b715b2-757f-4908-a3bf-2bbf7d298b4d PTD.dll
 c3ac0e08-d6df-402c-a688-6ed9c1882c09 Qt3Support4.dll
 5dfc6d83-0ac3-4e41-bad9-dd3e1b478357 QtAssistantClient4.dll
@@ -73,6 +74,7 @@ a44e024e-d7be-41af-aef1-a71ac0fa156f intl.dll
 996ad039-3d20-4d59-9738-61b37c935d73 jpegexiforient.exe
 cc503b23-d91a-4a62-b718-d3d8421ab7b4 jpegtran.exe
 02193762-114d-4a94-933f-63fe75eb7cad kcmdwrapper.exe
+92c55686-77ac-4be1-9c11-b4b29ae221ee kleopatra.bat
 cd859306-3fdf-4b82-a658-7311ed8c9ef3 lib\gtk-2.0\2.10.0\engines\libpixmap.dll
 fa4cf290-a03d-4c1b-959f-ff817038ba70 lib\gtk-2.0\2.10.0\engines\libwimp.dll
 9d1e8259-486a-4d68-b4f0-3f872484de74 lib\gtk-2.0\2.10.0\immodules\im-am-et.dll
@@ -146,6 +148,7 @@ c6c25e5d-3c93-4b25-8500-438e6e54edc7 pcregrep.exe
 d2d12f16-ea10-4602-8a11-11c0cd0c532b pcreposix.dll
 61a687c1-323b-4259-9253-cabc98fe5436 pinentry-gtk-2.exe
 def76dfd-df61-475b-b804-28ab536dae1a pinentry-w32.exe
+9b2b5969-951e-4c1e-8314-fbf75ce3cbf8 pinentry.exe
 2f5d42e7-1de0-434b-884b-6f7752438aea plugins\accessible\qtaccessiblecompatwidgets4.dll
 9c507371-c6a9-436e-a392-735bf5cabfbc plugins\accessible\qtaccessiblewidgets4.dll
 6be23045-c2f9-4794-a023-2ec27b0c1883 plugins\codecs\qcncodecs4.dll
@@ -169,6 +172,13 @@ a3323831-3e8f-4fce-a799-a82deb19a65f png2pnm.exe
 4ebf7e3a-b493-4aba-9e85-6e35d7acf82d pngtest.exe
 a6fe5108-2c72-4f79-85d6-26d44fa26bfa pnm2png.exe
 a6244378-a28a-488b-a5a4-ed87f89a1b84 pthreadGC2.dll
+45126bd1-8ede-4997-99b5-1c6cdba3affd pub\gpa.exe
+36b88ab6-3b92-4870-acb8-f3fc8e7aa20b pub\gpg-connect-agent.exe
+c5d41ce6-542e-4509-80cb-6fc805aa4a44 pub\gpg.exe
+5cc63041-4789-4f74-999b-07cc31b32c80 pub\gpg2.exe
+f24f9221-f347-4435-b818-4c3473d8f4ed pub\gpgsm.exe
+0762e4a3-a292-4d69-a0c9-34fc9747adef pub\gpgsplit.exe
+826eb8d2-14f1-44ff-8fd0-29f891fafa0c pub\gpgv.exe
 b5303e90-698c-4823-b982-32bfd2b761b4 rdjpgcom.exe
 22c41f80-e04d-4ad9-a18f-65a74df05b89 rpng-win.exe
 66c7ad35-6e11-40ed-a74d-2a6c4fb502b1 rpng2-win.exe
index 1657e93..d1b29d7 100644 (file)
@@ -39,11 +39,8 @@ use strict;
 
 # TODO:
 #
-# UpgradeCode + table
-# Overwrite try files (gpgol, etc)
-# Register DLLs
-# Register services
-# Menu, shortcut, desktop entries
+# DirMngr config files/cache directory?  service start fails!!!
+# desktop and quick launch entries, but optional (also startmenu optional)
 
 # The list of all enabled packages.
 @::pkgs = ();
@@ -57,6 +54,9 @@ use strict;
 # A hash which maps frobbed package names to a hash of frobbed package
 # names on which they depend.
 %::deps = ();
+# A hash which contains one key for each file that wants a shortcut in the
+# canonical places (start menu, desktop, quick launch).
+%::shortcuts = ();
 
 $::INSTDIR = 'GnuPG';
 $::name = 'GnuPG for Windows';
@@ -197,6 +197,37 @@ sub get_deps
 }
 
 \f
+sub get_shortcuts
+{
+    my %shortcuts = ();
+
+    # Pending line.
+    my $line;
+
+    # FIXME: Check if file exists.
+    open (FILE, "<inst-sections.nsi") or return;
+    while (<FILE>)
+    {
+       # Combine multiple lines connected with backslashes.
+       $line = $line . $_;
+       if ($line =~ m/^(.*)\\\s*\r?\n$/)
+       {
+           $line = $1 . ' ';
+           next;
+       }
+       $_ = $line;
+       $line = '';
+
+       if (m,^\s*CreateShortCut\s+\"\$SMPROGRAMS\\\$STARTMENU_FOLDER\\[^.]+\.lnk\"\s+\"\$INSTDIR\\([^"]+)\",)
+       {
+           $shortcuts{$1} = 1;
+       }
+    }
+    close (FILE);
+    %::shortcuts = %shortcuts;
+}
+
+\f
 sub collect_all
 {
   # Input file is $(top_srcdir)/include/config.nsi
@@ -293,12 +324,39 @@ sub collect_all
          {
              $dir = $1;
          }
-         elsif (m,^\s*File\s+"?\$\{prefix\}(\S+)/([^/"\s]+)"?\s*\r?\n$,)
+         elsif (m,^\s*File\s+"?\$\{(prefix|BUILD_DIR)\}(?:/(\S*))?/([^/"\s]+)"?\s*\r?\n$,)
          {
-             my $source = "${prefix}$1/$2";
+             my $source = $3;
+
+             $source = "$2/$source" if defined $2;
+             $source = "${prefix}/$source" if $1 eq 'prefix';
+
+             push @files, { source => $source, dir => $dir, target => $3 };
+             push @::sources, $source;
+         }
+         elsif (m,^\s*File\s+"?\$\{BUILD_DIR\}(\S+)/([^/"\s]+)"?\s*\r?\n$,)
+         {
+             my $source = $2;
+             $source = "$1/$source" if ($1 ne '');
              push @files, { source => $source, dir => $dir, target => $2 };
              push @::sources, $source;
          }
+         elsif (m,^\s*File\s+/oname=(\S+)\s+"?\$\{(prefix|BUILD_DIR)\}/([^"\s]+)"?\s*\r?\n$,)
+         {
+             my $target = $1;
+             my $source = $3;
+
+             $source = "${prefix}/$source" if $2 eq 'prefix';
+
+             # Temp files are due to overwrite attempts, which are
+             # handled automatically by the Windows Installer.
+             # Ignore them here.
+             next if $target =~ m/\.tmp$/;
+
+             push @files, { source => $source,
+                            dir => $dir, target => $target };
+             push @::sources, $source;
+         }
          elsif (m,^\s*WriteRegStr\s+(\S+)\s+"([^"]+)"\s+"([^"]+)"\s+"?([^"]+)"?\s*\r?\n$,)
          {
              my ($root, $key, $name, $value) = ($1, $2, $3, $4);
@@ -392,7 +450,112 @@ sub dump_all
            print ' ' x $::level
                . "  <File Id='f_$pkg->{frobbed_name}_$fileidx' Name='"
                . $file->{target} . "' Source='" . $file->{source} . "'"
-               . " DefaultLanguage='1033'/>\n";
+               . " DefaultLanguage='1033'>\n";
+
+           # EXCEPTIONS:
+           if ($targetfull eq 'gpgol.dll')
+           {
+               print ' ' x $::level
+                   . "    <Class Id='{42D30988-1A3A-11DA-C687-000D6080E735}' "
+                   . "Context='InprocServer32' Description='GpgOL - The "
+                   . "GnuPG Outlook Plugin' ThreadingModel='neutral'/>\n";
+           }
+           if ($targetfull eq 'gpgex.dll')
+           {
+               print ' ' x $::level
+                   . "    <Class Id='{CCD955E4-5C16-4A33-AFDA-A8947A94946B}' "
+                   . "Context='InprocServer32' Description='GpgEX' "
+                   . "ThreadingModel='apartment'/>\n";
+           }
+           elsif ($targetfull eq 'gpgee.dll')
+           {
+               print STDERR "ERR: run heat.exe on gpgee.dll and add info\n";
+               exit 1;
+           }
+
+           # Create shortcuts.
+           if (defined $::shortcuts{$targetfull})
+           {
+               print ' ' x $::level
+                   . "    <Shortcut Id='sm_$pkg->{frobbed_name}_$fileidx' "
+                   . "Directory='ProgramMenuDir' Name='$file->{target}'/>\n";
+
+#              print ' ' x $::level
+#                   . "    <Shortcut Id='sm_$pkg->{frobbed_name}_$fileidx' "
+#                  . "Directory='DesktopFolder' Name='$file->{target}'/>\n";
+           }
+
+           print ' ' x $::level
+               . "  </File>\n";
+
+           if (defined $::shortcuts{$targetfull})
+           {
+               # http://www.mail-archive.com/wix-users@lists.sourceforge.net/msg02746.html
+               # -sice:ICE64
+               print ' ' x $::level
+                   . "    <RemoveFolder Id='rsm_$pkg->{frobbed_name}_$fileidx' "
+                   . "Directory='ProgramMenuDir' On='uninstall'/>\n";
+           }
+
+           # EXCEPTIONS:
+           # We use $targetfull because there is also a gpg.exe in pub\.
+           if ($targetfull eq 'gpg.exe')
+           {
+               print ' ' x $::level
+                   . "  <Environment Id='env_path' Name='PATH' Action='set' "
+                   . "System='yes' Part='last' Value='[INSTDIR]pub'/>\n";
+           }
+           elsif ($targetfull eq 'gpgol.dll')
+           {
+               print ' ' x $::level
+                   . "  <RegistryValue Root='HKLM' Key='Software\\"
+                   . "Microsoft\\Exchange\\Client\\Extensions' "
+                   . "Name='GpgOL' "
+                   . "Value='4.0;[!gpgol.dll];1;11000111111100;11111101' "
+                   . "Type='string' Action='write'/>\n";
+               print ' ' x $::level
+                   . "  <RegistryValue Root='HKLM' Key='Software\\"
+                   . "Microsoft\\Exchange\\Client\\Extensions' "
+                   . "Name='Outlook Setup Extension' "
+                   . "Value='4.0;Outxxx.dll;7;000000000000000;0000000000;OutXXX' "
+                   . "Type='string' Action='write'/>\n";
+           }
+           elsif ($targetfull eq 'gpgex.dll')
+           {
+               print ' ' x $::level
+                   . "  <ProgId Id='*'/>\n";
+               print ' ' x $::level
+                   . "  <ProgId Id='Directory'/>\n";
+               print ' ' x $::level
+                   . "  <RegistryValue Root='HKCR' "
+                   . "Key='*\\ShellEx\\ContextMenuHandlers\\GpgEX' "
+                   . "Value='{CCD955E4-5C16-4A33-AFDA-A8947A94946B}' "
+                   . "Type='string' Action='write'/>\n";
+               print ' ' x $::level
+                   . "  <RegistryValue Root='HKCR' "
+                   . "Key='Directory\\ShellEx\\ContextMenuHandlers\\GpgEX' "
+                   . "Value='{CCD955E4-5C16-4A33-AFDA-A8947A94946B}' "
+                   . "Type='string' Action='write'/>\n";
+           }
+           elsif ($targetfull eq 'gpgee.dll')
+           {
+               print STDERR "ERR: run heat.exe on gpgee.dll and add info\n";
+               exit 1;
+           }
+           elsif ($targetfull eq 'dirmngr.exe')
+           {
+               print ' ' x $::level
+                   . "  <ServiceInstall Id='s_dirmngr' "
+                   . "DisplayName='Directory Manager' "
+                   . "Name='DirMngr' ErrorControl='normal' Start='auto' "
+                   . "Type='ownProcess' Vital='yes'/>\n";
+
+               print ' ' x $::level
+                   . "  <ServiceControl Id='s_dirmngr_ctrl' "
+                   . "Name='DirMngr' Start='install' Stop='uninstall' "
+                   . "Remove='uninstall'/>\n";
+           }
+
            print ' ' x $::level
                . "</Component>\n";
            $fileidx++;
@@ -410,7 +573,7 @@ sub dump_all
                . "<Component Id='c_$pkg->{frobbed_name}_r_$regidx' Guid='"
                . get_guid ($target) . "'>\n";
            print ' ' x $::level
-               . "  <Registry Id='r_$pkg->{frobbed_name}_$regidx' Root='"
+               . "  <RegistryValue Id='r_$pkg->{frobbed_name}_$regidx' Root='"
                . $reg->{root} . "' Key='" . $reg->{key} . "' Name='"
                . $reg->{name} . "' Action='write' Type='" . $reg->{type}
                . "' Value='" . $reg->{value} . "'/>\n";
@@ -505,15 +668,18 @@ sub dump_all2
 # FIXME: Use Vital for all file attributes?
 fetch_guids ();
 collect_all ();
-get_deps();
+get_deps ();
+get_shortcuts ();
 
 $::product_id = get_guid ("/PRODUCT/$::config{_BUILD_FILEVERSION}");
+$::upgrade_code = get_guid ("/UPGRADE/1");
 
 print <<EOF;
 <?xml version='1.0'?>
 <Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
   <Product Name='Gpg4win'
            Id='$::product_id'
+           UpgradeCode='$::upgrade_code'
            Language='1033'
            Version='$::config{_BUILD_FILEVERSION}'
            Manufacturer='g10 Code GmbH'>
@@ -524,6 +690,16 @@ print <<EOF;
              InstallPrivileges='elevated'
              Manufacturer='g10 Code GmbH'/>
 
+    <Upgrade Id='$::upgrade_code'>
+      <UpgradeVersion Property='UPGRADEPROP'
+                      IncludeMaximum='no'
+                      Maximum='$::config{_BUILD_FILEVERSION}'/>
+    </Upgrade>
+
+    <InstallExecuteSequence>
+      <RemoveExistingProducts After='InstallFinalize' />
+    </InstallExecuteSequence>
+
     <Condition
      Message="You need to be an administrator to install this product.">
       Privileged
@@ -552,14 +728,20 @@ print <<EOF;
       </Directory>
 EOF
 
+if (scalar keys %::shortcuts)
+{
+    print <<EOF;
+      <Directory Id='ProgramMenuFolder' Name='PMenu'>
+        <Directory Id='ProgramMenuDir' Name='$::name'/>
+      </Directory>
+EOF
+}
+
 #print <<EOF;
-#      <Directory Id='ProgramMenuFolder' Name='PMenu'>
-#        <Directory Id='ProgramMenuDir' Name='$::name'/>
-#      </Directory>
-#
 #      <Directory Id="DesktopFolder" Name="Desktop"/>
 #EOF
 
+
 print <<EOF;
     </Directory>