* Reading the fppkg-settings should not depend on the global

OnGetApplicationName event

git-svn-id: trunk@35701 -
This commit is contained in:
joost 2017-04-01 10:01:29 +00:00
parent b52d6874d2
commit 3b58c328c7
3 changed files with 44 additions and 9 deletions

View File

@ -169,16 +169,16 @@ begin
else else
begin begin
// Now try if a local config-file exists // Now try if a local config-file exists
cfgfile:=GetAppConfigFile(False,False); cfgfile:=GetFppkgConfigFile(False,False);
if not FileExists(cfgfile) then if not FileExists(cfgfile) then
begin begin
// If not, try to find a global configuration file // If not, try to find a global configuration file
cfgfile:=GetAppConfigFile(True,False); cfgfile:=GetFppkgConfigFile(True,False);
if not FileExists(cfgfile) then if not FileExists(cfgfile) then
begin begin
// Create a new configuration file // Create a new configuration file
if not IsSuperUser then // Make a local, not global, configuration file if not IsSuperUser then // Make a local, not global, configuration file
cfgfile:=GetAppConfigFile(False,False); cfgfile:=GetFppkgConfigFile(False,False);
ForceDirectories(ExtractFilePath(cfgfile)); ForceDirectories(ExtractFilePath(cfgfile));
FOptions.SaveToFile(cfgfile); FOptions.SaveToFile(cfgfile);
GeneratedConfig:=true; GeneratedConfig:=true;

View File

@ -96,6 +96,10 @@ var
LogHandler: TLogProc; LogHandler: TLogProc;
ErrorHandler: TPkgErrorProc; ErrorHandler: TPkgErrorProc;
function GetFppkgConfigFile(Global : Boolean; SubDir : Boolean): string;
function GetFppkgConfigDir(Global : Boolean): string;
Implementation Implementation
// define use_shell to use sysutils.executeprocess // define use_shell to use sysutils.executeprocess
@ -420,11 +424,42 @@ begin
end; end;
end; end;
function GetFppkgConfigFile(Global : Boolean; SubDir : Boolean): string;
var
StoredOnGetApplicationName: TGetAppNameEvent;
StoredOnGetVendorName: TGetVendorNameEvent;
begin
StoredOnGetApplicationName := OnGetApplicationName;
StoredOnGetVendorName := OnGetVendorName;
try
OnGetApplicationName := @FPPkgGetApplicationName;
OnGetVendorName := @FPPkgGetVendorName;
result := GetAppConfigFile(Global, SubDir);
finally
OnGetApplicationName := StoredOnGetApplicationName;
OnGetVendorName := StoredOnGetVendorName;
end;
end;
function GetFppkgConfigDir(Global : Boolean): string;
var
StoredOnGetApplicationName: TGetAppNameEvent;
StoredOnGetVendorName: TGetVendorNameEvent;
begin
StoredOnGetApplicationName := OnGetApplicationName;
StoredOnGetVendorName := OnGetVendorName;
try
OnGetApplicationName := @FPPkgGetApplicationName;
OnGetVendorName := @FPPkgGetVendorName;
result := GetAppConfigDir(Global);
finally
OnGetApplicationName := StoredOnGetApplicationName;
OnGetVendorName := StoredOnGetVendorName;
end;
end;
initialization initialization
OnGetVendorName:=@FPPkgGetVendorName;
OnGetApplicationName:=@FPPkgGetApplicationName;
LogHandler := @LogCmd; LogHandler := @LogCmd;
ErrorHandler := @ErrorCmd; ErrorHandler := @ErrorCmd;
end. end.

View File

@ -614,7 +614,7 @@ begin
LocalRepository:='{UserDir}.fppkg/'; LocalRepository:='{UserDir}.fppkg/';
{$else} {$else}
if IsSuperUser then if IsSuperUser then
LocalRepository:=IncludeTrailingPathDelimiter(GetAppConfigDir(true)) LocalRepository:=IncludeTrailingPathDelimiter(GetFppkgConfigDir(true))
else else
LocalRepository:='{AppConfigDir}'; LocalRepository:='{AppConfigDir}';
{$endif} {$endif}
@ -754,7 +754,7 @@ end;
constructor TFppkgOptions.Create; constructor TFppkgOptions.Create;
begin begin
FOptionParser := TTemplateParser.Create; FOptionParser := TTemplateParser.Create;
FOptionParser.Values['AppConfigDir'] := GetAppConfigDir(false); FOptionParser.Values['AppConfigDir'] := GetFppkgConfigDir(false);
FOptionParser.Values['UserDir'] := GetUserDir; FOptionParser.Values['UserDir'] := GetUserDir;
FSectionList := TFppkgOptionSectionList.Create; FSectionList := TFppkgOptionSectionList.Create;
@ -899,7 +899,7 @@ end;
constructor TCompilerOptions.Create; constructor TCompilerOptions.Create;
begin begin
FOptionParser := TTemplateParser.Create; FOptionParser := TTemplateParser.Create;
FOptionParser.Values['AppConfigDir'] := GetAppConfigDir(false); FOptionParser.Values['AppConfigDir'] := GetFppkgConfigDir(false);
FOptionParser.Values['UserDir'] := GetUserDir; FOptionParser.Values['UserDir'] := GetUserDir;
{$ifdef unix} {$ifdef unix}
FLocalInstallDir:='{LocalPrefix}'+'lib'+PathDelim+'fpc'+PathDelim+'{CompilerVersion}'+PathDelim; FLocalInstallDir:='{LocalPrefix}'+'lib'+PathDelim+'fpc'+PathDelim+'{CompilerVersion}'+PathDelim;