From e46464de9a37579c89a0a8fab5c561c4fc5e38bd Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Sun, 3 Jan 2010 14:13:34 +0100 Subject: [PATCH] Installer: Move msysGit unspecific helper functions to a separate file Signed-off-by: Sebastian Schuberth --- share/WinGit/helpers.inc.iss | 91 ++++++++++++++++++++++++++++++++++++++++++++ share/WinGit/install.iss | 89 +------------------------------------------ share/WinGit/release.sh | 1 + 3 files changed, 94 insertions(+), 87 deletions(-) create mode 100644 share/WinGit/helpers.inc.iss diff --git a/share/WinGit/helpers.inc.iss b/share/WinGit/helpers.inc.iss new file mode 100644 index 00000000..f4ba63b2 --- /dev/null +++ b/share/WinGit/helpers.inc.iss @@ -0,0 +1,91 @@ +// Returns the path to the common or user shell folder as specified in "Param". +function GetShellFolder(Param:string):string; +begin + if IsAdminLoggedOn then begin + Param:='{common'+Param+'}'; + end else begin + Param:='{user'+Param+'}'; + end; + Result:=ExpandConstant(Param); +end; + +// Returns the value(s) of the environment variable "VarName", which is tokenized +// by ";" into an array of strings. This makes it easy query PATH-like variables +// in addition to normal variables. If "AllUsers" is true, the common variables +// are searched, else the user-specific ones. +function GetEnvStrings(VarName:string;AllUsers:Boolean):TArrayOfString; +var + Path:string; + i:Longint; + p:Integer; +begin + Path:=''; + + // See http://www.jrsoftware.org/isfaq.php#env + if AllUsers then begin + // We ignore errors here. The resulting array of strings will be empty. + RegQueryStringValue(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',VarName,Path); + end else begin + // We ignore errors here. The resulting array of strings will be empty. + RegQueryStringValue(HKEY_CURRENT_USER,'Environment',VarName,Path); + end; + + // Make sure we have at least one semicolon. + Path:=Path+';'; + + // Split the directories in PATH into an array of strings. + i:=0; + SetArrayLength(Result,0); + + p:=Pos(';',Path); + while p>0 do begin + SetArrayLength(Result,i+1); + if p>1 then begin + Result[i]:=Copy(Path,1,p-1); + i:=i+1; + end; + Path:=Copy(Path,p+1,Length(Path)); + p:=Pos(';',Path); + end; +end; + +// Sets the environment variable "VarName" to the concatenation of "DirStrings" +// using ";" as the delimiter. If "AllUsers" is true, a common variable is set, +// else a user-specific one. If "DeleteIfEmpty" is true and "DirStrings" is +// empty, "VarName" is deleted instead of set if it exists. +function SetEnvStrings(VarName:string;AllUsers,DeleteIfEmpty:Boolean;DirStrings:TArrayOfString):Boolean; +var + Path,KeyName:string; + i:Longint; +begin + // Merge all non-empty directory strings into a PATH variable. + Path:=''; + for i:=0 to GetArrayLength(DirStrings)-1 do begin + if Length(DirStrings[i])>0 then begin + if Length(Path)>0 then begin + Path:=Path+';'+DirStrings[i]; + end else begin + Path:=DirStrings[i]; + end; + end; + end; + + // See http://www.jrsoftware.org/isfaq.php#env + if AllUsers then begin + KeyName:='SYSTEM\CurrentControlSet\Control\Session Manager\Environment'; + if DeleteIfEmpty and (Length(Path)=0) then begin + Result:=(not RegValueExists(HKEY_LOCAL_MACHINE,KeyName,VarName)) or + RegDeleteValue(HKEY_LOCAL_MACHINE,KeyName,VarName); + end else begin + Result:=RegWriteStringValue(HKEY_LOCAL_MACHINE,KeyName,VarName,Path); + end; + end else begin + KeyName:='Environment'; + if DeleteIfEmpty and (Length(Path)=0) then begin + Result:=(not RegValueExists(HKEY_CURRENT_USER,KeyName,VarName)) or + RegDeleteValue(HKEY_CURRENT_USER,KeyName,VarName); + end else begin + Result:=RegWriteStringValue(HKEY_CURRENT_USER,KeyName,VarName,Path); + end; + end; +end; diff --git a/share/WinGit/install.iss b/share/WinGit/install.iss index 03326470..94b6ae62 100644 --- a/share/WinGit/install.iss +++ b/share/WinGit/install.iss @@ -39,7 +39,7 @@ Name: guiextension; Description: "Add ""Git &GUI Here"""; GroupDescription: Wind Name: consolefont; Description: Use TrueType font (required for proper character encoding); GroupDescription: Console properties:; Flags: checkedonce [Files] -Source: *; DestDir: {app}; Excludes: \*.bmp, gpl-2.0.rtf, \install.*, \tmp.*, \bin\*install*; Flags: recursesubdirs replacesameversion +Source: *; DestDir: {app}; Excludes: \*.bmp, gpl-2.0.rtf, \*.iss, \tmp.*, \bin\*install*; Flags: recursesubdirs replacesameversion Source: ReleaseNotes.rtf; DestDir: {app}; Flags: isreadme replacesameversion [Icons] @@ -75,96 +75,11 @@ Type: dirifempty; Name: {app}\home\{username} Type: dirifempty; Name: {app}\home [Code] -{ - Helper methods -} - -function GetShellFolder(Param:string):string; -begin - if IsAdminLoggedOn then begin - Param:='{common'+Param+'}'; - end else begin - Param:='{user'+Param+'}'; - end; - Result:=ExpandConstant(Param); -end; +#include "helpers.inc.iss" function CreateHardLink(lpFileName,lpExistingFileName:string;lpSecurityAttributes:Integer):Boolean; external 'CreateHardLinkA@Kernel32.dll'; -function GetEnvStrings(VarName:string;AllUsers:Boolean):TArrayOfString; -var - Path:string; - i:Longint; - p:Integer; -begin - Path:=''; - - // See http://www.jrsoftware.org/isfaq.php#env - if AllUsers then begin - // We ignore errors here. The resulting array of strings will be empty. - RegQueryStringValue(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',VarName,Path); - end else begin - // We ignore errors here. The resulting array of strings will be empty. - RegQueryStringValue(HKEY_CURRENT_USER,'Environment',VarName,Path); - end; - - // Make sure we have at least one semicolon. - Path:=Path+';'; - - // Split the directories in PATH into an array of strings. - i:=0; - SetArrayLength(Result,0); - - p:=Pos(';',Path); - while p>0 do begin - SetArrayLength(Result,i+1); - if p>1 then begin - Result[i]:=Copy(Path,1,p-1); - i:=i+1; - end; - Path:=Copy(Path,p+1,Length(Path)); - p:=Pos(';',Path); - end; -end; - -function SetEnvStrings(VarName:string;AllUsers,DeleteIfEmpty:Boolean;DirStrings:TArrayOfString):Boolean; -var - Path,KeyName:string; - i:Longint; -begin - // Merge all non-empty directory strings into a PATH variable. - Path:=''; - for i:=0 to GetArrayLength(DirStrings)-1 do begin - if Length(DirStrings[i])>0 then begin - if Length(Path)>0 then begin - Path:=Path+';'+DirStrings[i]; - end else begin - Path:=DirStrings[i]; - end; - end; - end; - - // See http://www.jrsoftware.org/isfaq.php#env - if AllUsers then begin - KeyName:='SYSTEM\CurrentControlSet\Control\Session Manager\Environment'; - if DeleteIfEmpty and (Length(Path)=0) then begin - Result:=(not RegValueExists(HKEY_LOCAL_MACHINE,KeyName,VarName)) or - RegDeleteValue(HKEY_LOCAL_MACHINE,KeyName,VarName); - end else begin - Result:=RegWriteStringValue(HKEY_LOCAL_MACHINE,KeyName,VarName,Path); - end; - end else begin - KeyName:='Environment'; - if DeleteIfEmpty and (Length(Path)=0) then begin - Result:=(not RegValueExists(HKEY_CURRENT_USER,KeyName,VarName)) or - RegDeleteValue(HKEY_CURRENT_USER,KeyName,VarName); - end else begin - Result:=RegWriteStringValue(HKEY_CURRENT_USER,KeyName,VarName,Path); - end; - end; -end; - const TortoiseSVNInstallKey='SOFTWARE\TortoiseSVN'; TortoiseCVSUninstallKey='SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\TortoiseCVS_is1'; diff --git a/share/WinGit/release.sh b/share/WinGit/release.sh index 524c82c4..3bd8b30b 100644 --- a/share/WinGit/release.sh +++ b/share/WinGit/release.sh @@ -72,6 +72,7 @@ cp /share/resources/gpl-2.0.rtf /share/resources/git.bmp /share/resources/gitsma homewinpath=$(cd ~ ; pwd -W) && sed -e "s/%APPVERSION%/$version/" -e "s@%OUTPUTDIR%@$homewinpath@" \ < /share/WinGit/install.iss > $TMPDIR/install.iss && +cp /share/WinGit/*.inc.iss $TMPDIR && echo "Lauching Inno Setup compiler ..." && /share/InnoSetup/ISCC.exe "$TMPDIR/install.iss" -q | grep -Ev "\s*Reading|\s*Compressing" && (cd / && git tag -a -m "Git for Windows $1" Git-$1) -- 2.11.4.GIT