[gimp/gimp-2-8] Installer: allow override of system-wide configuration files with custom versions during install



commit 416dfc458430dc4cd61762c3708e079d7556cac8
Author: Jernej SimonÄiÄ <jernej+s-gnome eternallybored org>
Date:   Wed Jun 20 16:34:53 2012 +0200

    Installer: allow override of system-wide configuration files with custom
    versions during install

 build/windows/installer/configoverride.isi |   36 +++++++++++++++
 build/windows/installer/gimp3264.iss       |   65 +++++++++++++++++++++++++++-
 build/windows/installer/utils.isi          |    9 ++++
 3 files changed, 109 insertions(+), 1 deletions(-)
---
diff --git a/build/windows/installer/configoverride.isi b/build/windows/installer/configoverride.isi
new file mode 100644
index 0000000..f88d6a9
--- /dev/null
+++ b/build/windows/installer/configoverride.isi
@@ -0,0 +1,36 @@
+ï;allow specific configuration files to be overriden by files in a specific directory
+#if 0
+[Files]
+#endif
+
+#define FindHandle
+#define FindResult
+
+#sub ProcessConfigFile
+  #define FileName FindGetFileName(FindHandle)
+Source: "{code:GetExternalConfDir}\{#FileName}"; DestDir: "{app}\{#ConfigDir}"; Flags: external recursesubdirs restartreplace; Check: CheckExternalConf('{#FileName}')
+  #if BaseDir != GIMP_DIR32
+Source: "{code:GetExternalConfDir}\{#FileName}"; DestDir: "{app}\32\{#ConfigDir}"; Components: gimp32on64; Flags: external recursesubdirs restartreplace; Check: CheckExternalConf('{#FileName}')
+  #endif
+#endsub
+
+#sub ProcessConfigDir
+  #emit ';; ' + ConfigDir
+  #emit ';; ' + BaseDir
+  #for {FindHandle = FindResult = FindFirst(AddBackslash(BaseDir) + AddBackSlash(ConfigDir) + "*", 0); \
+      FindResult; FindResult = FindNext(FindHandle)} ProcessConfigFile
+  #if FindHandle
+    #expr FindClose(FindHandle)
+  #endif
+#endsub
+
+#define public BaseDir GIMP_DIR32
+#define public ConfigDir "etc\gimp\2.0"
+#expr ProcessConfigDir
+
+#define public BaseDir DEPS_DIR32
+#define public ConfigDir "etc\gtk-2.0"
+#expr ProcessConfigDir
+
+#define public ConfigDir "etc\fonts"
+#expr ProcessConfigDir
diff --git a/build/windows/installer/gimp3264.iss b/build/windows/installer/gimp3264.iss
index 5f72a3c..b1b7c7f 100644
--- a/build/windows/installer/gimp3264.iss
+++ b/build/windows/installer/gimp3264.iss
@@ -213,7 +213,7 @@ Source: "{#GIMP_DIR32}\etc\*"; DestDir: "{app}\etc"; Components: gimp32 or gimp6
 Source: "{#GIMP_DIR32}\lib\gimp\2.0\environ\*"; DestDir: "{app}\lib\gimp\2.0\environ"; Components: gimp32 or gimp64; Flags: recursesubdirs restartreplace
 Source: "{#GIMP_DIR32}\lib\gimp\2.0\interpreters\*"; DestDir: "{app}\lib\gimp\2.0\interpreters"; Components: gimp32 or gimp64; Flags: recursesubdirs restartreplace
 Source: "{#GIMP_DIR32}\share\gimp\*"; DestDir: "{app}\share\gimp"; Components: gimp32 or gimp64; Flags: recursesubdirs restartreplace
-Source: "{#DEPS_DIR32}\share\enchant\*"; DestDir: "{app}\share\enchant"; Components: deps32 or deps64; Flags: recursesubdirs restartreplace
+;Source: "{#DEPS_DIR32}\share\enchant\*"; DestDir: "{app}\share\enchant"; Components: deps32 or deps64; Flags: recursesubdirs restartreplace
 Source: "{#DEPS_DIR32}\share\libwmf\*"; DestDir: "{app}\share\libwmf"; Components: deps32 or deps64; Flags: recursesubdirs restartreplace
 Source: "{#DEPS_DIR32}\share\themes\*"; DestDir: "{app}\share\themes"; Components: deps32 or deps64; Flags: recursesubdirs restartreplace
 Source: "{#DEPS_DIR32}\share\xml\*"; DestDir: "{app}\share\xml"; Components: deps32 or deps64; Flags: recursesubdirs restartreplace
@@ -262,6 +262,9 @@ Source: "{#DEPS_DIR}-compat\*.dll"; DestDir: "{app}"; Components: deps32\compat;
 Source: "{#DEPS_DIR32}\bin\zlib1.dll"; DestDir: "{sys}"; Components: deps32 or deps64; Flags: restartreplace sharedfile 32bit; Check: BadSysDLL('zlib1.dll',32)
 Source: "{#DEPS_DIR64}\bin\zlib1.dll"; DestDir: "{sys}"; Components: deps64; Flags: restartreplace sharedfile; Check: BadSysDLL('zlib1.dll',64)
 
+;overridden configuration files
+#include "configoverride.isi"
+
 ;python
 Source: "{#PY_DIR}\pythonw.exe"; DestDir: "{app}\Python"; Components: py or gimp32on64\py; Flags: restartreplace
 Source: "{#PY_DIR}\python.exe"; DestDir: "{app}\Python"; Components: py or gimp32on64\py; Flags: restartreplace
@@ -327,6 +330,8 @@ const
 
 	RunOnceName = 'Resume GIMP {#VERSION} install';
 
+	CONFIG_OVERRIDE_PARAM = 'configoverride';
+
 	UNINSTALL_MAX_WAIT_TIME = 10000;
 	UNINSTALL_CHECK_TIME    =   250;
 
@@ -362,6 +367,8 @@ var
 
 	InstallMode: (imNone, imSimple, imCustom, imRebootContinue);
 
+	ConfigOverride: (coUndefined, coOverride, coDontOverride);
+
 	asUninstInf: TArrayOfString; //uninst.inf contents (loaded at start of uninstall, exectued at the end)
 
 
@@ -420,6 +427,60 @@ begin
 end;
 
 
+function DoConfigOverride: Boolean;
+var i: Integer;
+begin
+
+	if ConfigOverride = coUndefined then
+	begin
+
+		DebugMsg('DoConfigOverride', 'First call');
+		
+		Result := False;
+		ConfigOverride := coDontOverride;
+
+		for i := 0 to ParamCount() do //use ParamCount/ParamStr to allow specifying /configoverride without any parameters
+			if LowerCase(Copy(ParamStr(i),1,15)) = '/' + CONFIG_OVERRIDE_PARAM then
+			begin
+				Result := True;
+				ConfigOverride := coOverride;
+				break;
+			end;
+
+	end
+	else if ConfigOverride = coOverride then
+		Result := True
+	else
+		Result := False;
+
+	DebugMsg('DoConfigOverride', BoolToStr(Result));
+end;
+
+function GetExternalConfDir(Unused: String): String;
+begin
+	if ExpandConstant('{param:' + CONFIG_OVERRIDE_PARAM + '|<>}') = '<>' then
+		Result := ExpandConstant('{src}\')
+	else
+		Result := ExpandConstant('{param:' + CONFIG_OVERRIDE_PARAM + '|<>}\');
+	DebugMsg('GetExternalConfDir', Result);
+end;
+
+function CheckExternalConf(const pFile: String): Boolean;
+begin
+
+	if not DoConfigOverride then //no config override
+		Result := False
+	else
+	begin
+		if FileExists(GetExternalConfDir('') + pFile) then //config file override only applies when that file exists
+			Result := True
+		else
+			Result := False;
+	end;
+	DebugMsg('CheckExternalConf', pFile + ': ' + BoolToStr(Result));
+end;
+
+
 #include "associations.isi"
 
 
@@ -1346,6 +1407,8 @@ function InitializeSetup(): Boolean;
 var Message,Buttons: TArrayOfString;
 #endif
 begin
+	ConfigOverride := coUndefined;
+
 	if not IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE) then
 	begin
 		SuppressibleMsgBox(CustomMessage('SSERequired'), mbCriticalError, MB_OK, 0);
diff --git a/build/windows/installer/utils.isi b/build/windows/installer/utils.isi
index dc04c26..4f48a7f 100644
--- a/build/windows/installer/utils.isi
+++ b/build/windows/installer/utils.isi
@@ -146,3 +146,12 @@ begin
 	WizardForm.FilenameLabel.Caption := Status2;
 	WizardForm.Refresh();
 end;
+
+
+function BoolToStr(const Value: Boolean): String;
+begin
+  if Value then
+    Result := 'true'
+  else
+    Result := 'false';
+end;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]