From 2c36f7f69a6070200c4385447e991ed66ebfe548 Mon Sep 17 00:00:00 2001 From: Geoff Evans Date: Sat, 18 May 2019 17:46:38 -0700 Subject: [PATCH] InnoSetup installer --- .gitignore | 3 +- Dependencies/InnoSetup | 2 +- Source/gui/P4Win409/P4Win409.rc | 8 +- Source/gui/P4Win411/P4Win411.rc | 8 +- Source/gui/resource.h | 10 +++ installer.bat | 2 + installer.iss | 150 ++++++++++++++++++++++++++++++++ installer.pl | 68 +++++++++++++++ 8 files changed, 241 insertions(+), 10 deletions(-) create mode 100644 installer.bat create mode 100644 installer.iss create mode 100644 installer.pl diff --git a/.gitignore b/.gitignore index 6d9e74b..d57d774 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ Bin/ -Build/ \ No newline at end of file +Build/ +*.aps \ No newline at end of file diff --git a/Dependencies/InnoSetup b/Dependencies/InnoSetup index 48d0756..3786cc4 160000 --- a/Dependencies/InnoSetup +++ b/Dependencies/InnoSetup @@ -1 +1 @@ -Subproject commit 48d075672f1c575844f9ccedf08522f7d4925937 +Subproject commit 3786cc42fdae8fe80a8f2e6ce1fe7defdac193e9 diff --git a/Source/gui/P4Win409/P4Win409.rc b/Source/gui/P4Win409/P4Win409.rc index 6020f19..7ed0e43 100644 --- a/Source/gui/P4Win409/P4Win409.rc +++ b/Source/gui/P4Win409/P4Win409.rc @@ -3235,8 +3235,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2008,1,17,6239 - PRODUCTVERSION 2008,1,0,0 + FILEVERSION RESOURCE_VERSION + PRODUCTVERSION RESOURCE_VERSION FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -3254,12 +3254,12 @@ BEGIN VALUE "Comments", "Requires Perforce 98.2.7488 or higher server" VALUE "CompanyName", "Perforce Software" VALUE "FileDescription", "Perforce Windows Client, English (U.S.) resource dll" - VALUE "FileVersion", "2008.1 BETA 17.6239" + VALUE "FileVersion", RESOURCE_VERSION_STRING VALUE "InternalName", "P4Win409" VALUE "LegalCopyright", "Copyright © 1997, 2008 Perforce Software" VALUE "OriginalFilename", "P4Win409.DLL" VALUE "ProductName", "Perforce Windows GUI Client " - VALUE "ProductVersion", "2008.1 BETA 17.6239" + VALUE "ProductVersion", RESOURCE_VERSION_STRING END END BLOCK "VarFileInfo" diff --git a/Source/gui/P4Win411/P4Win411.rc b/Source/gui/P4Win411/P4Win411.rc index 392caee..aa8d85e 100644 --- a/Source/gui/P4Win411/P4Win411.rc +++ b/Source/gui/P4Win411/P4Win411.rc @@ -3145,8 +3145,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2008,1,17,6239 - PRODUCTVERSION 2008,1,0,0 + FILEVERSION RESOURCE_VERSION + PRODUCTVERSION RESOURCE_VERSION FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -3164,12 +3164,12 @@ BEGIN VALUE "Comments", "Requires Perforce 98.2.7488 or higher server" VALUE "CompanyName", "Perforce Software" VALUE "FileDescription", "Perforce Windows Client, Japanese resource dll" - VALUE "FileVersion", "2008.1 BETA 17.6239" + VALUE "FileVersion", RESOURCE_VERSION_STRING VALUE "InternalName", "P4Win411" VALUE "LegalCopyright", "Copyright © 1997, 2008 Perforce Software" VALUE "OriginalFilename", "P4Win411.DLL" VALUE "ProductName", "Perforce Windows GUI Client " - VALUE "ProductVersion", "2008.1 BETA 17.6239" + VALUE "ProductVersion", RESOURCE_VERSION_STRING END END BLOCK "VarFileInfo" diff --git a/Source/gui/resource.h b/Source/gui/resource.h index 230c356..4a443f0 100644 --- a/Source/gui/resource.h +++ b/Source/gui/resource.h @@ -2,6 +2,16 @@ // Microsoft Visual C++ generated include file. // Used by c:\workspac\main\p4-win\gui\P4Win409\P4Win409.rc // +#define VERSION_MAJOR 2008 +#define VERSION_MINOR 1 +#define VERSION_PATCH 1 +#define VERSION_STRINGIFY(major, minor, patch) _T(#major) _T(".") _T(#minor) _T(".") _T(#patch) +#define VERSION_TOSTRING(major, minor, patch) VERSION_STRINGIFY(major,minor,patch) +#define VERSION_STRING VERSION_TOSTRING( VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH ) +#define RESOURCE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, 0 +#define RESOURCE_VERSION_STRINGIFY(major, minor, patch) #major "," #minor "," #patch ",0" +#define RESOURCE_VERSION_TOSTRING(major, minor, patch) RESOURCE_VERSION_STRINGIFY(major, minor, patch) +#define RESOURCE_VERSION_STRING RESOURCE_VERSION_TOSTRING( VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH ) #define IDC_NOT_USED 1 #define P4_INT_MINOR 1 #define IDC_NEXT 2 diff --git a/installer.bat b/installer.bat new file mode 100644 index 0000000..addbc60 --- /dev/null +++ b/installer.bat @@ -0,0 +1,2 @@ +@"%~dp0Dependencies\StrawberryPerl\perl\bin\perl.exe" installer.pl %* +@exit /b %ERRORLEVEL% \ No newline at end of file diff --git a/installer.iss b/installer.iss new file mode 100644 index 0000000..d348931 --- /dev/null +++ b/installer.iss @@ -0,0 +1,150 @@ +; This script uses Inno Setup Preprocessor (ISPP) by Alex Yackimoff. +; To download and install ISPP, get the Inno Setup QuickStart Pack from http://www.jrsoftware.org/isdl.php#qsp + +#define _AppName "P4Win" +#define _AppMutex "EShellMenu" +#define _AppPublisher "gorlak" +#define _AppPublisherURL "https://github.com/gorlak/P4Win" + +#ifndef _AppVersionMajor +#define _AppVersionMajor "0" +#endif + +#ifndef _AppVersionMinor +#define _AppVersionMinor "0" +#endif + +#ifndef _AppVersionPatch +#define _AppVersionPatch "0" +#endif + +#define _AppVersion _AppVersionMajor + "." + _AppVersionMinor + "." + _AppVersionPatch + +#ifndef _BuildConfig +#define _BuildConfig "Release" +#endif + +#define _VersionInfoComments "P4Win is a Windows client for Perforce (Helix VCS) built in MFC." +#define _VersionInfoCopyright "Copyright (C) " + _AppPublisher +#define _VersionInfoDescription "EShell Menu" +#define _VersionInfoVersion _AppVersion + +[Setup] +AllowNoIcons=yes +AlwaysShowDirOnReadyPage=yes +; NOTE: The value of AppId uniquely identifies this application. +; Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{1068CD05-61D1-4371-96EC-FD6AA4BC9E27} +AppName={#_AppName} +AppMutex={#_AppMutex} +AppVerName={cm:NameAndVersion,{#_AppName},{#_AppVersion}} +AppPublisher={#_AppPublisher} +AppPublisherURL={#_AppPublisherURL} +AppSupportURL={#_AppPublisherURL} +AppUpdatesURL={#_AppPublisherURL} +ArchitecturesAllowed=x64 +ArchitecturesInstallIn64BitMode=x64 +Compression=lzma +CreateUninstallRegKey=yes +DefaultDirName={pf64}\{#_AppName} +DisableDirPage=no +DefaultGroupName={#_AppName} +OutputDir=.\ +OutputBaseFilename=P4WinSetup +PrivilegesRequired=admin +SetupIconFile=Source\gui\res\P4win.ico +SolidCompression=yes +Uninstallable=yes +UninstallDisplayIcon={uninstallexe} +UsePreviousAppDir=yes +UsePreviousGroup=yes +UsePreviousTasks=yes +VersionInfoCompany={#_AppPublisher} +VersionInfoCopyright={#_AppName} {#_AppVersion} +VersionInfoDescription={#_VersionInfoDescription} +VersionInfoProductName={#_AppName} +VersionInfoProductVersion={#_VersionInfoVersion} +VersionInfoTextVersion={#_VersionInfoVersion} +VersionInfoVersion={#_VersionInfoVersion} + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked +Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked + +[Files] +; NOTE: Don't use "Flags: ignoreversion" on any shared system files +Source: "Bin\{#_BuildConfig}\P4Win.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "Bin\{#_BuildConfig}\P4Win.pdb"; DestDir: "{app}"; Flags: ignoreversion +Source: "Bin\{#_BuildConfig}\P4.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "Bin\{#_BuildConfig}\P4.pdb"; DestDir: "{app}"; Flags: ignoreversion + +[Icons] +Name: "{group}\{#_AppName}"; Filename: "{app}\P4Win.exe"; Comment: {#_VersionInfoComments} +Name: "{group}\{cm:UninstallProgram,{#_AppName}}"; Filename: "{uninstallexe}"; Comment: {#_VersionInfoComments} +Name: "{commondesktop}\{#_AppName}"; Filename: "{app}\P4Win.exe"; Comment: {#_VersionInfoComments}; Tasks: desktopicon +Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#_AppName}"; Filename: "{app}\P4Win.exe"; Comment: {#_VersionInfoComments}; Tasks: quicklaunchicon + +[Run] +Filename: "{app}\P4Win.exe"; Description: "Run {#_AppName}"; Flags: nowait postinstall shellexec + +[Code] +///////////////////////////////////////////////////////////////////// +function GetUninstallString(): String; +var + sUnInstPath: String; + sUnInstallString: String; +begin + sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1'); + sUnInstallString := ''; + if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then + RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString); + Result := sUnInstallString; +end; + +///////////////////////////////////////////////////////////////////// +function IsUpgrade(): Boolean; +begin + Result := (GetUninstallString() <> ''); +end; + +///////////////////////////////////////////////////////////////////// +function UnInstallOldVersion(): Integer; +var + sUnInstallString: String; + iResultCode: Integer; +begin +// Return Values: +// 1 - uninstall string is empty +// 2 - error executing the UnInstallString +// 3 - successfully executed the UnInstallString + + // default return value + Result := 0; + + // get the uninstall string of the old app + sUnInstallString := GetUninstallString(); + if sUnInstallString <> '' then begin + sUnInstallString := RemoveQuotes(sUnInstallString); + if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, iResultCode) then + Result := 3 + else + Result := 2; + end else + Result := 1; +end; + +///////////////////////////////////////////////////////////////////// +procedure CurStepChanged(CurStep: TSetupStep); +begin + if (CurStep=ssInstall) then + begin + if (IsUpgrade()) then + begin + UnInstallOldVersion(); + end; + end; +end; \ No newline at end of file diff --git a/installer.pl b/installer.pl new file mode 100644 index 0000000..39b35fa --- /dev/null +++ b/installer.pl @@ -0,0 +1,68 @@ +#!/usr/bin/perl -w +use strict; +use Data::Dumper; +use File::Basename; +use File::Copy; +use File::Path; +use Getopt::Long; + + +# +# globals +# + +my $g_ISCCFilePath = File::Spec->catfile( 'Dependencies', 'InnoSetup', 'ISCC.exe' ); +my $g_ISSFilePath = 'installer.iss'; +my $g_OutputBaseFilename = 'P4WinSetup'; +my $g_OutputDir = 'Bin\\Release'; +my $g_VersionFilePath = 'Source\\gui\\resource.h'; +my $g_OutputFilePath = File::Spec->catfile( $g_OutputDir, "$g_OutputBaseFilename.exe" ); + + +# +# extract version +# + +my $g_MajorVersion = 0; +my $g_MinorVersion = 0; +my $g_PatchVersion = 0; + +open IN, "<$g_VersionFilePath" or die "could not read $g_VersionFilePath: $!"; +my @VersionFileContent = ; +close IN or die "could not close $g_VersionFilePath: $!"; +chomp @VersionFileContent; + +foreach my $line ( @VersionFileContent ) +{ + if ( $line =~ /VERSION_MAJOR\s+(\d+)/i ) + { + $g_MajorVersion = $1; + } + elsif ( $line =~ /VERSION_MINOR\s+(\d+)/i ) + { + $g_MinorVersion = $1; + } + elsif ( $line =~ /VERSION_PATCH\s+(\d+)/i ) + { + $g_PatchVersion = $1; + } +} +my $g_PrintVersion = "${g_MajorVersion}.${g_MinorVersion}.${g_PatchVersion}"; + + +# +# build installer +# + +print( "\n o Building installer for $g_PrintVersion...\n" ); + +if ( -e $g_OutputFilePath ) +{ + system( "del /Q /F \"$g_OutputFilePath\"" ); +} + +mkpath( $g_OutputDir ); + +system( "\"$g_ISCCFilePath\" \"$g_ISSFilePath\" /q /o\"$g_OutputDir\" /f\"$g_OutputBaseFilename\" /d\"_AppVersionMajor=$g_MajorVersion\" /d\"_AppVersionMinor=$g_MinorVersion\" /d\"_AppVersionPatch=$g_PatchVersion\"" ); + +exit $? >> 8; \ No newline at end of file