diff --git a/installer/install.iss b/installer/install.iss index b80397455d..46b8b908e6 100644 --- a/installer/install.iss +++ b/installer/install.iss @@ -365,6 +365,10 @@ const GC_OpenSSL = 1; GC_WinSSL = 2; + // Git GPG options. + GG_GPG = 1; + GG_ExternalGPG = 2; + // Git line ending conversion options. GC_LFOnly = 1; GC_CRLFAlways = 2; @@ -476,6 +480,10 @@ var CurlVariantPage:TWizardPage; RdbCurlVariant:array[GC_OpenSSL..GC_WinSSL] of TRadioButton; + // Wizard page and variables for the GPG options. + GPGChoicePage:TWizardPage; + RdbGPG:array[GG_GPG..GG_ExternalGPG] of TRadioButton; + // Wizard page and variables for the line ending conversion options. CRLFPage:TWizardPage; RdbCRLF:array[GC_LFOnly..GC_CRLFCommitAsIs] of TRadioButton; @@ -2211,6 +2219,34 @@ begin RdbCurlVariant[GC_OpenSSL].Checked:=True; end; + (* + * Create a custom page for using self-supplied GPG instead of bundled GPG + * if an GPG binary is found on the PATH. + *) + + if (FileSearch('gpg.exe', GetEnv('PATH')) <> '') then begin + GPGChoicePage:=CreatePage(PrevPageID,'Choosing the GPG executable','Which GnuPG program would you like Git to use?',TabOrder,Top,Left); + + // 1st choice + RdbGPG[GG_GPG]:=CreateRadioButton(GPGChoicePage,'Use bundled GPG','This uses gpg.exe that comes with Git.',TabOrder,Top,Left); + + // 2nd choice + RdbGPG[GG_ExternalGPG]:=CreateRadioButton(GPGChoicePage,'Use external GPG', + 'NEW! This uses an external gpg.exe. Git will not install its own GnuPG'+#13+ + '(and related) binaries but use them as found on the PATH.', + TabOrder,Top,Left); + + // Restore the setting chosen during a previous install. + case ReplayChoice('GPG Option','GPG') of + 'GPG': RdbGPG[GG_GPG].Checked:=True; + 'ExternalGPG': RdbGPG[GG_ExternalGPG].Checked:=True; + else + RdbGPG[GG_GPG].Checked:=True; + end; + end else begin + GPGChoicePage:=NIL; + end; + (* * Create a custom page for the core.autocrlf setting. *) @@ -3385,6 +3421,14 @@ begin end; #endif +#ifdef DELETE_GPG_FILES + if (GPGChoicePage<>NIL) and (RdbGPG[GG_ExternalGPG].Checked) then begin + WizardForm.StatusLabel.Caption:='Removing bundled Git GPG binaries'; + if not DeleteGPGFiles() then + LogError('Failed to remove GPG file(s)'); + end; +#endif + { Set the default Git editor } diff --git a/installer/release.sh b/installer/release.sh index 0fc93f9ea4..d1aa030ef6 100755 --- a/installer/release.sh +++ b/installer/release.sh @@ -296,6 +296,18 @@ openssh_deletes="$(comm -12 sorted-file-list.txt sorted-openssh-file-list.txt | inno_defines="$inno_defines$LF[Code]${LF}function DeleteOpenSSHFiles():Boolean;${LF}var$LF AppDir:String;${LF}begin$LF AppDir:=ExpandConstant('{app}');$LF Result:=True;" inno_defines="$inno_defines$LF$openssh_deletes${LF}end;$LF#define DELETE_OPENSSH_FILES 1" +# 1. Collect all GPG related files from $LIST and pacman, sort each and then return the overlap +# 2. Convert paths to Windows filesystem compatible ones and construct the function body for the DeleteGPGFiles function; one DeleteFile operation per file found +# 3. Construct DeleteGPGFiles function signature to be used in install.iss +# 4. Assemble function body and compile flag to be used as guard in install.iss +echo "$LIST" | sort >sorted-file-list.txt +pacman -Ql gnupg 2>pacman.stderr | sed -n 's|^gnupg /\(.*[^/]\)$|\1|p' | sort >sorted-gnupg-file-list.txt +grep -v 'database file for .* does not exist' &2 +gpg_deletes="$(comm -12 sorted-file-list.txt sorted-gnupg-file-list.txt | + sed -e 'y/\//\\/' -e "s|.*| if not DeleteFile(AppDir+'\\\\&') then\n Result:=False;|")" +inno_defines="$inno_defines$LF[Code]${LF}function DeleteGPGFiles():Boolean;${LF}var$LF AppDir:String;${LF}begin$LF AppDir:=ExpandConstant('{app}');$LF Result:=True;" +inno_defines="$inno_defines$LF$gpg_deletes${LF}end;$LF#define DELETE_GPG_FILES 1" + test -z "$LIST" || echo "$LIST" | sed -e 's|/|\\|g' \