Преглед изворни кода

Remove the archive stuff from CodeDownloadFiles.iss and add CodeDownloadFiles2.iss instead.

Martijn Laan пре 3 месеци
родитељ
комит
28cd78499f
5 измењених фајлова са 120 додато и 52 уклоњено
  1. 2 50
      Examples/CodeDownloadFiles.iss
  2. 115 0
      Examples/CodeDownloadFiles2.iss
  3. 1 1
      ISHelp/isxfunc.xml
  4. 1 0
      setup.iss
  5. 1 1
      whatsnew.htm

+ 2 - 50
Examples/CodeDownloadFiles.iss

@@ -2,11 +2,10 @@
 ;
 ; This script shows how the CreateDownloadPage support function can be used to
 ; download temporary files while showing the download progress to the user.
-; One of the files is a 7-Zip archive and the script shows how to extract it.
 ;
 ; To verify the downloaded files, this script shows two methods:
-; -For innosetup-latest.exe and MyProg-ExtraReadmes.7z: using the Inno Setup
-;  Signature Tool, the [ISSigKeys] section, and the issigverify flag
+; -For innosetup-latest.exe: using the Inno Setup Signature Tool, the [ISSigKeys]
+;  section, and the issigverify flag
 ; -For iscrypt.dll: using a simple SHA256 check
 ; Using the Inno Setup Signature Tool has the benefit that the script does not
 ; need to be changed when the downloaded file changes, so any installers built
@@ -27,18 +26,7 @@ Name: "mykey"; \
   PublicX: "515dc7d6c16d4a46272ceb3d158c5630a96466ab4d948e72c2029d737c823097"; \
   PublicY: "f3c21f6b5156c52a35f6f28016ee3e31a3ded60c325b81fb7b1f88c221081a61"
 
-// Uncomment the following line to use the 7-Zip library for extraction
-//#define USE7ZDLL
-// Please see the Init7ZipLibrary topic in the help file for more information
-//
-#ifdef USE7ZDLL
-  #define _7ZDLL "7zxa.dll"
-#endif
-//
 [Files]
-#ifdef USE7ZDLL 
-Source: "{#_7ZDLL}"; Flags: dontcopy
-#endif
 ; Place any regular files here
 Source: "MyProg.exe"; DestDir: "{app}";
 Source: "MyProg.chm"; DestDir: "{app}";
@@ -46,7 +34,6 @@ Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme;
 ; These files will be downloaded
 Source: "{tmp}\innosetup-latest.exe"; DestDir: "{app}"; Flags: external ignoreversion issigverify
 Source: "{tmp}\ISCrypt.dll"; DestDir: "{app}"; Flags: external ignoreversion
-Source: "{tmp}\MyProg-ExtraReadmes\*"; Excludes: "*.issig"; DestDir: "{app}"; Flags: external recursesubdirs ignoreversion issigverify
 
 [Icons]
 Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"
@@ -54,13 +41,11 @@ Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"
 [Code]
 var
   DownloadPage: TDownloadWizardPage;
-  ExtractionPage: TExtractionWizardPage;
 
 procedure InitializeWizard;
 begin
   DownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), nil);
   DownloadPage.ShowBaseNameInsteadOfUrl := True;
-  ExtractionPage := CreateExtractionPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), nil);
 end;
 
 function NextButtonClick(CurPageID: Integer): Boolean;
@@ -71,7 +56,6 @@ begin
     DownloadPage.Add('https://jrsoftware.org/download.php/is.exe?dontcount=1', 'innosetup-latest.exe', '');
     DownloadPage.Add('https://jrsoftware.org/download.php/is.exe.issig?dontcount=1', 'innosetup-latest.exe.issig', '');
     DownloadPage.Add('https://jrsoftware.org/download.php/iscrypt.dll?dontcount=1', 'ISCrypt.dll', '2f6294f9aa09f59a574b5dcd33be54e16b39377984f3d5658cda44950fa0f8fc');
-    DownloadPage.Add('https://jrsoftware.org/download.php/myprog-extrareadmes.7z?dontcount=1', 'MyProg-ExtraReadmes.7z', '');
     DownloadPage.Show;
     try
       try
@@ -88,38 +72,6 @@ begin
     finally
       DownloadPage.Hide;
     end;
-
-    if not Result then
-      Exit;
-
-    ExtractionPage.Clear;
-    // Use AddEx to specify a password
-    ExtractionPage.Add(ExpandConstant('{tmp}\MyProg-ExtraReadmes.7z'), ExpandConstant('{tmp}\MyProg-ExtraReadmes'), True);
-    ExtractionPage.Show;
-    try
-      try
-        #ifdef USE7ZDLL
-          // Extract and initialize the 7-Zip library
-          // This which will make the ExtractionPage switch from using Extract7ZipArchive to using ExtractArchive
-          ExtractTemporaryFile('{#_7ZDLL}');
-          Init7ZipLibrary(ExpandConstant('{tmp}\{#_7ZDLL}'));
-        #endif
-        // Extracts the archive to {tmp}\MyProg-ExtraReadmes
-        // Please see the Extract7ZipArchive or ExtractArchive topic in the help file for limitations
-        // Note that each file in the MyProg-ExtraReadmes.7z example archive comes with an .issig signature file
-        // These signature files are used by the [Files] section to verify the archive's content
-        ExtractionPage.Extract;
-        Result := True;
-      except
-        if ExtractionPage.AbortedByUser then
-          Log('Aborted by user.')
-        else
-          SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK);
-        Result := False;
-      end;
-    finally
-      ExtractionPage.Hide;
-    end;
   end else
     Result := True;
 end;

+ 115 - 0
Examples/CodeDownloadFiles2.iss

@@ -0,0 +1,115 @@
+; -- CodeDownloadFiles2.iss --
+; Same as CodeDownloadFiles1.iss but additionally downloads a 7-Zip archive and
+; shows how to verify and extract it.
+
+[Setup]
+AppName=My Program
+AppVersion=1.5
+WizardStyle=modern
+DefaultDirName={autopf}\My Program
+DefaultGroupName=My Program
+UninstallDisplayIcon={app}\MyProg.exe
+OutputDir=userdocs:Inno Setup Examples Output
+
+[ISSigKeys]
+Name: "mykey"; \
+  KeyID:   "def020edee3c4835fd54d85eff8b66d4d899b22a777353ca4a114b652e5e7a28"; \
+  PublicX: "515dc7d6c16d4a46272ceb3d158c5630a96466ab4d948e72c2029d737c823097"; \
+  PublicY: "f3c21f6b5156c52a35f6f28016ee3e31a3ded60c325b81fb7b1f88c221081a61"
+
+// Uncomment the following line to use the 7-Zip library for extraction
+//#define USE7ZDLL
+// Please see the Init7ZipLibrary topic in the help file for more information
+//
+#ifdef USE7ZDLL
+  #define _7ZDLL "7zxa.dll"
+#endif
+//
+[Files]
+#ifdef USE7ZDLL 
+Source: "{#_7ZDLL}"; Flags: dontcopy
+#endif
+; Place any regular files here
+Source: "MyProg.exe"; DestDir: "{app}";
+Source: "MyProg.chm"; DestDir: "{app}";
+Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme;
+; These files will be downloaded
+Source: "{tmp}\innosetup-latest.exe"; DestDir: "{app}"; Flags: external ignoreversion issigverify
+Source: "{tmp}\ISCrypt.dll"; DestDir: "{app}"; Flags: external ignoreversion
+Source: "{tmp}\MyProg-ExtraReadmes\*"; Excludes: "*.issig"; DestDir: "{app}"; Flags: external recursesubdirs ignoreversion issigverify
+
+[Icons]
+Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"
+
+[Code]
+var
+  DownloadPage: TDownloadWizardPage;
+  ExtractionPage: TExtractionWizardPage;
+
+procedure InitializeWizard;
+begin
+  DownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), nil);
+  DownloadPage.ShowBaseNameInsteadOfUrl := True;
+  ExtractionPage := CreateExtractionPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), nil);
+end;
+
+function NextButtonClick(CurPageID: Integer): Boolean;
+begin
+  if CurPageID = wpReady then begin
+    DownloadPage.Clear;
+    // Use AddEx to specify a username and password
+    DownloadPage.Add('https://jrsoftware.org/download.php/is.exe?dontcount=1', 'innosetup-latest.exe', '');
+    DownloadPage.Add('https://jrsoftware.org/download.php/is.exe.issig?dontcount=1', 'innosetup-latest.exe.issig', '');
+    DownloadPage.Add('https://jrsoftware.org/download.php/iscrypt.dll?dontcount=1', 'ISCrypt.dll', '2f6294f9aa09f59a574b5dcd33be54e16b39377984f3d5658cda44950fa0f8fc');
+    DownloadPage.Add('https://jrsoftware.org/download.php/myprog-extrareadmes.7z?dontcount=1', 'MyProg-ExtraReadmes.7z', '');
+    DownloadPage.Show;
+    try
+      try
+        // Downloads the files to {tmp}
+        DownloadPage.Download;
+        Result := True;
+      except
+        if DownloadPage.AbortedByUser then
+          Log('Aborted by user.')
+        else
+          SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK);
+        Result := False;
+      end;
+    finally
+      DownloadPage.Hide;
+    end;
+
+    if not Result then
+      Exit;
+
+    ExtractionPage.Clear;
+    // Use AddEx to specify a password
+    ExtractionPage.Add(ExpandConstant('{tmp}\MyProg-ExtraReadmes.7z'), ExpandConstant('{tmp}\MyProg-ExtraReadmes'), True);
+    ExtractionPage.Show;
+    try
+      try
+        #ifdef USE7ZDLL
+          // Extract and initialize the 7-Zip library
+          // This which will make the ExtractionPage switch from using Extract7ZipArchive to using ExtractArchive
+          ExtractTemporaryFile('{#_7ZDLL}');
+          Init7ZipLibrary(ExpandConstant('{tmp}\{#_7ZDLL}'));
+        #endif
+        // Extracts the archive to {tmp}\MyProg-ExtraReadmes
+        // Please see the Extract7ZipArchive or ExtractArchive topic in the help file for limitations
+        // Note that each file in the MyProg-ExtraReadmes.7z example archive comes with an .issig signature file
+        // These signature files are used by the [Files] section to verify the archive's content
+        ExtractionPage.Extract;
+        Result := True;
+      except
+        if ExtractionPage.AbortedByUser then
+          Log('Aborted by user.')
+        else
+          SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK);
+        Result := False;
+      end;
+    finally
+      ExtractionPage.Hide;
+    end;
+  end else
+    Result := True;
+end;

+ 1 - 1
ISHelp/isxfunc.xml

@@ -2723,7 +2723,7 @@ Page := CreateOutputMsgMemoPage(wpWelcome,
 <p>To start the extraction, call the <tt>Extract</tt> method. An exception will be raised if there was an error. Otherwise, <tt>Extract</tt> returns the number of archives extracted.</p>
 <p>Set the <tt>ShowArchiveInsteadFile</tt> property to <tt>True</tt> to show the name of the archive which is being extracted to the user instead of the names of the files inside the archive.</p>
 <p>See <link topic="isxfunc_Extract7ZipArchive">Extract7ZipArchive</link> for other considerations and the definition of <tt>TOnExtractionProgress</tt>.</p></remarks>
-        <example><p>See <i>CodeDownloadFiles.iss</i> for an example.</p></example>
+        <example><p>See <i>CodeDownloadFiles2.iss</i> for an example.</p></example>
         <seealso><p><link topic="scriptclasses" anchor="TExtractionWizardPage">TExtractionWizardPage</link><br />
 <link topic="isxfunc_Extract7ZipArchive">Extract7ZipArchive</link><br />
 <link topic="isxfunc_CreateOutputProgressPage">CreateOutputProgressPage</link></p></seealso>

+ 1 - 0
setup.iss

@@ -164,6 +164,7 @@ Source: "Examples\CodeClasses.iss"; DestDir: "{app}\Examples"; Flags: ignorevers
 Source: "Examples\CodeDlg.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch
 Source: "Examples\CodeDll.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch
 Source: "Examples\CodeDownloadFiles.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch
+Source: "Examples\CodeDownloadFiles2.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch
 Source: "Examples\CodeExample1.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch
 Source: "Examples\CodePrepareToInstall.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch
 Source: "Examples\Components.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch

+ 1 - 1
whatsnew.htm

@@ -118,7 +118,7 @@ issigtool --key-file="MyKey.ispublickey" verify "MyProg.dll"</pre>
     <li><tt>Extract7ZipArchive</tt> now honors the file system redirection state set by <tt>EnableFsRedirection</tt> or 64-bit install mode.</li>
   </ul>
   </li>
-  <li>Example script <i>CodeDownloadFiles.iss</i> now also demonstrates how to use the <tt>CreateExtractionPage</tt> support function to extract a 7-Zip archive. See the <a href="https://jrsoftware.org/ishelp/index.php?topic=isxfunc_extract7ziparchive">Extract7ZipArchive help topic</a> for information about this function's limitations.</li>
+  <li>Added example script <i>CodeDownloadFiles2.iss</i> to demonstrate how to use the <tt>CreateExtractionPage</tt> support function to verify and extract a downloaded archive.</li>
   <li>Documentation improvements.</li>
 </ul>