* Refactored so that TFPCustomPackagesStructure has access to the (compiler-)options

git-svn-id: trunk@35427 -
This commit is contained in:
joost 2017-02-12 14:18:20 +00:00
parent 015f034904
commit 09f415dc81
7 changed files with 205 additions and 113 deletions

View File

@ -20,7 +20,8 @@ uses
classes,sysutils,
contnrs,
fpmkunit,
streamcoll;
streamcoll,
pkgoptions;
Const
StreamVersion : Integer = 1;
@ -28,19 +29,29 @@ Const
type
TFPRepositoryType = (fprtUnknown, fprtInstalled, fprtAvailable);
TFPInstallationNeeded = (fpinInstallationNeeded, fpinNoInstallationNeeded, fpinInstallationImpossible);
TFPRepository = class;
TFPPackage = class;
{ TFPCustomPackagesStructure }
TFPCustomPackagesStructureClass = class of TFPCustomPackagesStructure;
TFPCustomPackagesStructure = Class(TComponent)
private class var
FRegisteredPackagesStructureClasses: TFPObjectList;
private
FInstallRepositoryName: string;
function GetInstallRepositoryName: string;
procedure SetInstallRepositoryName(AValue: string);
protected
FCompilerOptions: TCompilerOptions;
FOptions: TFppkgOptions;
public
class procedure RegisterPackagesStructureClass(APackagesStructureClass: TFPCustomPackagesStructureClass);
class function GetPackagesStructureForRepositoryOptionSection(ARepositoryOptionSection: TFppkgRepositoryOptionSection): TFPCustomPackagesStructureClass;
class destructor Destroy;
class function GetRepositoryOptionSectionClass: TFppkgRepositoryOptionSectionClass; virtual;
procedure InitializeWithOptions(ARepoOptionSection: TFppkgRepositoryOptionSection; AnOptions: TFppkgOptions; ACompilerOptions: TCompilerOptions); virtual;
function AddPackagesToRepository(ARepository: TFPRepository): Boolean; virtual; abstract;
function GetUnitDirectory(APackage: TFPPackage): string; virtual;
function GetBuildPathDirectory(APackage: TFPPackage): string; virtual;
@ -202,6 +213,9 @@ type
Public
Constructor Create(AOwner : TComponent); override;
Destructor Destroy; override;
// Initialize the repository based onto an section in the ini-file
procedure InitializeWithOptions(ARepoOptionSection: TFppkgRepositoryOptionSection;
AnOptions: TFppkgOptions; ACompilerOptions: TCompilerOptions);
// Loading and Saving repository. Own format.
Procedure LoadFromStream(Stream : TStream); Virtual;
Procedure SaveToStream(Stream : TStream); Virtual;
@ -367,7 +381,7 @@ end;
function TFPCustomPackagesStructure.GetConfigFileForPackage(APackage: TFPPackage): string;
begin
Result := IncludeTrailingPathDelimiter(GetBaseInstallDir)+
'fpmkinst'+PathDelim+GFPpkg.CompilerOptions.CompilerTarget+PathDelim+APackage.Name+FpmkExt;
'fpmkinst'+PathDelim+FCompilerOptions.CompilerTarget+PathDelim+APackage.Name+FpmkExt;
end;
function TFPCustomPackagesStructure.UnzipBeforeUse: Boolean;
@ -390,6 +404,55 @@ begin
FInstallRepositoryName := AValue;
end;
class procedure TFPCustomPackagesStructure.RegisterPackagesStructureClass(
APackagesStructureClass: TFPCustomPackagesStructureClass);
begin
if not Assigned(FRegisteredPackagesStructureClasses) then
FRegisteredPackagesStructureClasses := TFPObjectList.Create(False);
if FRegisteredPackagesStructureClasses.IndexOf(TObject(APackagesStructureClass)) = -1 then
FRegisteredPackagesStructureClasses.Add(TObject(APackagesStructureClass));
end;
class function TFPCustomPackagesStructure.GetPackagesStructureForRepositoryOptionSection(
ARepositoryOptionSection: TFppkgRepositoryOptionSection): TFPCustomPackagesStructureClass;
var
PackageStructureClass: TFPCustomPackagesStructureClass;
i: Integer;
begin
Result := nil;
if Assigned(FRegisteredPackagesStructureClasses) then
begin
for i := 0 to FRegisteredPackagesStructureClasses.Count -1 do
begin
PackageStructureClass := TFPCustomPackagesStructureClass(FRegisteredPackagesStructureClasses.Items[I]);
if PackageStructureClass.GetRepositoryOptionSectionClass = ARepositoryOptionSection.ClassType then
begin
Result := PackageStructureClass;
end;
end;
end;
end;
class destructor TFPCustomPackagesStructure.Destroy;
begin
FRegisteredPackagesStructureClasses.Free;
end;
class function TFPCustomPackagesStructure.GetRepositoryOptionSectionClass: TFppkgRepositoryOptionSectionClass;
begin
result := nil;
end;
procedure TFPCustomPackagesStructure.InitializeWithOptions(
ARepoOptionSection: TFppkgRepositoryOptionSection; AnOptions: TFppkgOptions;
ACompilerOptions: TCompilerOptions);
begin
if Assigned(ARepoOptionSection) then
InstallRepositoryName := ARepoOptionSection.InstallRepositoryName;
FCompilerOptions := ACompilerOptions;
FOptions := AnOptions;
end;
{ TFPPackage }
procedure TFPPackage.SetVersion(const AValue: TFPVersion);
@ -820,6 +883,23 @@ begin
inherited Destroy;
end;
procedure TFPRepository.InitializeWithOptions(ARepoOptionSection: TFppkgRepositoryOptionSection;
AnOptions: TFppkgOptions; ACompilerOptions: TCompilerOptions);
var
PackStructureClass: TFPCustomPackagesStructureClass;
begin
RepositoryType := ARepoOptionSection.GetRepositoryType;
RepositoryName := ARepoOptionSection.RepositoryName;
Description := ARepoOptionSection.Description;
PackStructureClass := TFPCustomPackagesStructureClass.GetPackagesStructureForRepositoryOptionSection(ARepoOptionSection);
if Assigned(PackStructureClass) then
begin
DefaultPackagesStructure := PackStructureClass.Create(Owner);
DefaultPackagesStructure.InitializeWithOptions(ARepoOptionSection, AnOptions, ACompilerOptions);
end;
end;
procedure TFPRepository.LoadFromStream(Stream: TStream);
Var

View File

@ -30,6 +30,8 @@ type
function IncludeRepositoryTypeForPackageKind(ARepositoryType: TFPRepositoryType;
APackageKind: TpkgPackageKind): Boolean;
procedure ScanPackagesOnDisk(ACompilerOptions: TCompilerOptions; APackageKind: TpkgPackageKind; ARepositoryList: TComponentList);
function CreateRepository(ARepoOptionSection: TFppkgRepositoryOptionSection;
AnOptions: TFppkgOptions; ACompilerOptions: TCompilerOptions): TFPRepository;
function FindPackage(ARepositoryList: TComponentList; APackageName: string; APackageKind: TpkgPackageKind): TFPPackage;
function SelectRemoteMirror:string;
@ -121,17 +123,25 @@ begin
RepoOption := TFppkgRepositoryOptionSection(FOptions.SectionList[i]);
if IncludeRepositoryTypeForPackageKind(RepoOption.GetRepositoryType, APackageKind) then
begin
Repo := RepoOption.InitRepository(Self, ACompilerOptions);
Repo := CreateRepository(RepoOption, FOptions, ACompilerOptions);
if Assigned(Repo) then
begin
ARepositoryList.Add(Repo);
Repo.DefaultPackagesStructure.AddPackagesToRepository(Repo);
if Assigned(Repo.DefaultPackagesStructure) then
Repo.DefaultPackagesStructure.AddPackagesToRepository(Repo);
end;
end;
end;
end;
end;
function TpkgFPpkg.CreateRepository(ARepoOptionSection: TFppkgRepositoryOptionSection;
AnOptions: TFppkgOptions; ACompilerOptions: TCompilerOptions): TFPRepository;
begin
Result := TFPRepository.Create(Self);
Result.InitializeWithOptions(ARepoOptionSection, AnOptions, ACompilerOptions);
end;
procedure TpkgFPpkg.InitializeGlobalOptions(CfgFile: string);
var
GeneratedConfig: boolean;
@ -251,7 +261,8 @@ begin
Repo.RepositoryName := 'Available';
Repo.Description := 'Packages available for download';
Repo.RepositoryType := fprtAvailable;
InstPackages := TFPRemotePackagesStructure.Create(Self, FOptions);
InstPackages := TFPRemotePackagesStructure.Create(Self);
InstPackages.InitializeWithOptions(Nil, FOptions, FCompilerOptions);
InstPackages.AddPackagesToRepository(Repo);
Repo.DefaultPackagesStructure := InstPackages;
end;
@ -478,6 +489,7 @@ begin
AvailableRepo.RepositoryName := Repo.RepositoryName + '_source';
AvailableRepo.Description := Repo.Description + ' (original sources)';
AvailStruc := TFPOriginalSourcePackagesStructure.Create(Self, Repo);
AvailStruc.InitializeWithOptions(nil, FOptions, FCompilerOptions);
AvailStruc.AddPackagesToRepository(AvailableRepo);
AvailableRepo.DefaultPackagesStructure := AvailStruc;
end;

View File

@ -10,8 +10,7 @@ uses
{$endif}
SysUtils,
Classes,
fpmkunit,
fprepos;
fpmkunit;
Const
{$ifdef unix}

View File

@ -17,7 +17,7 @@ unit pkgoptions;
interface
// pkgglobals must be AFTER fpmkunit
uses Classes, Sysutils, Inifiles, fprepos, fpTemplate, fpmkunit, pkgglobals, fgl;
uses Classes, Sysutils, Inifiles, fpTemplate, fpmkunit, pkgglobals, fgl;
Const
UnitConfigFileName = 'fpunits.cfg';
@ -28,6 +28,7 @@ Const
CurrentConfigVersion = 5;
Type
TFPRepositoryType = (fprtUnknown, fprtInstalled, fprtAvailable);
{ TFppkgOptionSection }
@ -131,14 +132,13 @@ Type
function AllowDuplicate: Boolean; override;
function GetRepositoryType: TFPRepositoryType; virtual;
function InitRepository(AParent: TComponent; ACompilerOptions: TCompilerOptions): TFPRepository; virtual;
property RepositoryName: string read FRepositoryName write SetRepositoryName;
property Description: string read FDescription write SetDescription;
property Path: string read GetPath write SetPath;
property Prefix: string read GetPrefix write SetPrefix;
property InstallRepositoryName: string read FInstallRepositoryName write FInstallRepositoryName;
end;
TFppkgRepositoryOptionSectionClass = class of TFppkgRepositoryOptionSection;
{ TFppkgIncludeFilesOptionSection }
@ -470,24 +470,6 @@ begin
result := fprtInstalled;
end;
function TFppkgRepositoryOptionSection.InitRepository(AParent: TComponent;
ACompilerOptions: TCompilerOptions): TFPRepository;
var
InstPackages: TFPInstalledPackagesStructure;
begin
if Path <> '' then
begin
Result := TFPRepository.Create(AParent);
Result.RepositoryType := GetRepositoryType;
Result.RepositoryName := RepositoryName;
Result.Description := Description;
InstPackages := TFPInstalledPackagesStructure.Create(AParent, Path, ACompilerOptions);
InstPackages.InstallRepositoryName := InstallRepositoryName;
Result.DefaultPackagesStructure := InstPackages;
InstPackages.Prefix:=Prefix;
end;
end;
{ TFppkgCommandLineOptionSection }
constructor TFppkgCommandLineOptionSection.Create(AnOptionParser: TTemplateParser);

View File

@ -16,10 +16,8 @@ type
{ TFPRemotePackagesStructure }
TFPRemotePackagesStructure = class(TFPCustomPackagesStructure)
protected
FOptions: TFppkgOptions;
public
constructor Create(AOwner: TComponent; AnOptions: TFppkgOptions);
class function GetRepositoryOptionSectionClass: TFppkgRepositoryOptionSectionClass; override;
function UnzipBeforeUse: Boolean; override;
function AddPackagesToRepository(ARepository: TFPRepository): Boolean; override;
@ -28,11 +26,13 @@ type
{ TFPCustomFileSystemPackagesStructure }
TFPCustomFileSystemPackagesStructure = class(TFPCustomPackagesStructure)
protected
private
FPath: string;
FCompilerOptions: TCompilerOptions;
protected
function GetPath: string; virtual;
procedure SetPath(AValue: string); virtual;
public
constructor Create(AOwner: TComponent; APath: string; ACompilerOptions: TCompilerOptions); virtual;
property Path: string read GetPath write SetPath;
end;
{ TFPInstalledPackagesStructure }
@ -41,6 +41,8 @@ type
private
FPrefix: string;
public
class function GetRepositoryOptionSectionClass: TFppkgRepositoryOptionSectionClass; override;
procedure InitializeWithOptions(ARepoOptionSection: TFppkgRepositoryOptionSection; AnOptions: TFppkgOptions; ACompilerOptions: TCompilerOptions); override;
function AddPackagesToRepository(ARepository: TFPRepository): Boolean; override;
function GetUnitDirectory(APackage: TFPPackage): string; override;
function GetPrefix: string; override;
@ -52,8 +54,9 @@ type
{ TFPCurrentDirectoryPackagesStructure }
TFPCurrentDirectoryPackagesStructure = class(TFPCustomFileSystemPackagesStructure)
protected
procedure SetPath(AValue: string); override;
public
constructor Create(AOwner: TComponent; APath: string; ACompilerOptions: TCompilerOptions); override;
function AddPackagesToRepository(ARepository: TFPRepository): Boolean; override;
function GetBuildPathDirectory(APackage: TFPPackage): string; override;
end;
@ -91,6 +94,18 @@ uses
pkgrepos,
pkgglobals;
{ TFPCustomFileSystemPackagesStructure }
function TFPCustomFileSystemPackagesStructure.GetPath: string;
begin
Result := FPath;
end;
procedure TFPCustomFileSystemPackagesStructure.SetPath(AValue: string);
begin
FPath := AValue;
end;
{ TFPTemporaryDirectoryPackagesStructure }
function TFPTemporaryDirectoryPackagesStructure.GetTempPackageName: string;
@ -157,12 +172,11 @@ end;
{ TFPCurrentDirectoryPackagesStructure }
constructor TFPCurrentDirectoryPackagesStructure.Create(AOwner: TComponent; APath: string;
ACompilerOptions: TCompilerOptions);
procedure TFPCurrentDirectoryPackagesStructure.SetPath(AValue: string);
begin
if APath = '' then
APath := GetCurrentDir;
inherited Create(AOwner, APath, ACompilerOptions);
if AValue = '' then
AValue := GetCurrentDir;
inherited SetPath(AValue);
end;
function TFPCurrentDirectoryPackagesStructure.AddPackagesToRepository(
@ -182,10 +196,9 @@ end;
{ TFPRemotePackagesStructure }
constructor TFPRemotePackagesStructure.Create(AOwner: TComponent; AnOptions: TFppkgOptions);
class function TFPRemotePackagesStructure.GetRepositoryOptionSectionClass: TFppkgRepositoryOptionSectionClass;
begin
inherited Create(AOwner);
FOptions := AnOptions;
Result := nil;
end;
function TFPRemotePackagesStructure.UnzipBeforeUse: Boolean;
@ -226,6 +239,24 @@ end;
{ TFPInstalledPackagesStructure }
class function TFPInstalledPackagesStructure.GetRepositoryOptionSectionClass: TFppkgRepositoryOptionSectionClass;
begin
Result := TFppkgRepositoryOptionSection;
end;
procedure TFPInstalledPackagesStructure.InitializeWithOptions(
ARepoOptionSection: TFppkgRepositoryOptionSection; AnOptions: TFppkgOptions;
ACompilerOptions: TCompilerOptions);
var
RepoOptSection: TFppkgRepositoryOptionSection;
begin
inherited InitializeWithOptions(ARepoOptionSection, AnOptions, ACompilerOptions);
RepoOptSection := ARepoOptionSection as TFppkgRepositoryOptionSection;
Prefix := RepoOptSection.Prefix;
InstallRepositoryName := RepoOptSection.InstallRepositoryName;
Path := RepoOptSection.Path;
end;
function TFPInstalledPackagesStructure.AddPackagesToRepository(ARepository: TFPRepository): Boolean;
procedure LoadPackagefpcFromFile(APackage:TFPPackage;const AFileName: String);
@ -329,16 +360,8 @@ begin
Result:=FPath;
end;
{ TFPCustomFileSystemPackagesStructure }
constructor TFPCustomFileSystemPackagesStructure.Create(AOwner: TComponent; APath: string;
ACompilerOptions: TCompilerOptions);
begin
Inherited Create(AOwner);
FPath := IncludeTrailingPathDelimiter(APath);
FCompilerOptions := ACompilerOptions;
end;
initialization
TFPCustomPackagesStructure.RegisterPackagesStructureClass(TFPRemotePackagesStructure);
TFPCustomPackagesStructure.RegisterPackagesStructureClass(TFPInstalledPackagesStructure);
end.

View File

@ -23,9 +23,6 @@ type
TFppkgUninstalledSourceRepositoryOptionSection = class(TFppkgRepositoryOptionSection)
public
constructor Create(AnOptionParser: TTemplateParser); override;
function InitRepository(AParent: TComponent; ACompilerOptions: TCompilerOptions): TFPRepository; override;
function GetRepositoryType: TFPRepositoryType; override;
end;
@ -33,6 +30,9 @@ type
TFPUninstalledSourcesAvailablePackagesStructure = class(TFPCustomFileSystemPackagesStructure)
public
class function GetRepositoryOptionSectionClass: TFppkgRepositoryOptionSectionClass; override;
procedure InitializeWithOptions(ARepoOptionSection: TFppkgRepositoryOptionSection; AnOptions: TFppkgOptions; ACompilerOptions: TCompilerOptions); override;
function AddPackagesToRepository(ARepository: TFPRepository): Boolean; override;
function GetBuildPathDirectory(APackage: TFPPackage): string; override;
end;
@ -44,8 +44,6 @@ type
private
FSourceRepositoryName: string;
public
function InitRepository(AParent: TComponent; ACompilerOptions: TCompilerOptions): TFPRepository; override;
procedure AddKeyValue(const AKey, AValue: string); override;
procedure LogValues(ALogLevel: TLogLevel); override;
function GetRepositoryType: TFPRepositoryType; override;
@ -58,6 +56,9 @@ type
private
FSourceRepositoryName: string;
public
class function GetRepositoryOptionSectionClass: TFppkgRepositoryOptionSectionClass; override;
procedure InitializeWithOptions(ARepoOptionSection: TFppkgRepositoryOptionSection; AnOptions: TFppkgOptions; ACompilerOptions: TCompilerOptions); override;
function AddPackagesToRepository(ARepository: TFPRepository): Boolean; override;
function IsInstallationNeeded(APackage: TFPPackage): TFPInstallationNeeded; override;
function GetBaseInstallDir: string; override;
@ -77,6 +78,23 @@ const
{ TFPUninstalledSourcesPackagesStructure }
class function TFPUninstalledSourcesPackagesStructure.GetRepositoryOptionSectionClass: TFppkgRepositoryOptionSectionClass;
begin
Result := TFppkgUninstalledRepositoryOptionSection;
end;
procedure TFPUninstalledSourcesPackagesStructure.InitializeWithOptions(
ARepoOptionSection: TFppkgRepositoryOptionSection; AnOptions: TFppkgOptions;
ACompilerOptions: TCompilerOptions);
var
RepoOptionSection: TFppkgUninstalledRepositoryOptionSection;
begin
inherited InitializeWithOptions(ARepoOptionSection, AnOptions, ACompilerOptions);
RepoOptionSection := ARepoOptionSection as TFppkgUninstalledRepositoryOptionSection;
path := RepoOptionSection.Path;
SourceRepositoryName := RepoOptionSection.SourceRepositoryName;
end;
function TFPUninstalledSourcesPackagesStructure.AddPackagesToRepository(ARepository: TFPRepository): Boolean;
procedure LoadPackagefpcFromFile(APackage:TFPPackage;const AFileName: String);
@ -101,12 +119,12 @@ var
UF,UD : String;
begin
Result:=false;
log(llDebug,SLogFindInstalledPackages,[FPath]);
if FindFirst(FPath+AllFiles,faDirectory,SRD)=0 then
log(llDebug,SLogFindInstalledPackages,[Path]);
if FindFirst(Path+AllFiles,faDirectory,SRD)=0 then
begin
repeat
// Try new .fpm-file
UD:=FPath+SRD.Name+PathDelim;
UD:=Path+SRD.Name+PathDelim;
if FindFirst(UD+'*'+FpmkExt,faAnyFile,SRF)=0 then
begin
@ -137,7 +155,7 @@ end;
function TFPUninstalledSourcesPackagesStructure.GetBaseInstallDir: string;
begin
Result := FPath;
Result := Path;
end;
function TFPUninstalledSourcesPackagesStructure.GetConfigFileForPackage(APackage: TFPPackage): string;
@ -152,24 +170,6 @@ end;
{ TFppkgUninstalledRepositoryOptionSection }
function TFppkgUninstalledRepositoryOptionSection.InitRepository(AParent: TComponent;
ACompilerOptions: TCompilerOptions): TFPRepository;
var
InstPackages: TFPUninstalledSourcesPackagesStructure;
begin
if Path <> '' then
begin
Result := TFPRepository.Create(AParent);
Result.RepositoryType := GetRepositoryType;
Result.RepositoryName := RepositoryName;
Result.Description := Description;
InstPackages := TFPUninstalledSourcesPackagesStructure.Create(AParent, Path, ACompilerOptions);
InstPackages.InstallRepositoryName := InstallRepositoryName;
InstPackages.SourceRepositoryName := SourceRepositoryName;
Result.DefaultPackagesStructure := InstPackages;
end;
end;
procedure TFppkgUninstalledRepositoryOptionSection.AddKeyValue(const AKey, AValue: string);
begin
if SameText(AKey,KeySourceRepository) then
@ -191,28 +191,6 @@ end;
{ TFppkgUninstalledSourceRepositoryOptionSection }
constructor TFppkgUninstalledSourceRepositoryOptionSection.Create(AnOptionParser: TTemplateParser);
begin
inherited Create(AnOptionParser);
end;
function TFppkgUninstalledSourceRepositoryOptionSection.InitRepository(AParent: TComponent;
ACompilerOptions: TCompilerOptions): TFPRepository;
var
InstPackages: TFPUninstalledSourcesAvailablePackagesStructure;
begin
if Path <> '' then
begin
Result := TFPRepository.Create(AParent);
Result.RepositoryType := GetRepositoryType;
Result.RepositoryName := RepositoryName;
Result.Description := Description;
InstPackages := TFPUninstalledSourcesAvailablePackagesStructure.Create(AParent, Path, ACompilerOptions);
InstPackages.InstallRepositoryName := InstallRepositoryName;
Result.DefaultPackagesStructure := InstPackages;
end;
end;
function TFppkgUninstalledSourceRepositoryOptionSection.GetRepositoryType: TFPRepositoryType;
begin
Result := fprtAvailable;
@ -220,6 +198,19 @@ end;
{ TFPUninstalledSourcesPackagesStructure }
class function TFPUninstalledSourcesAvailablePackagesStructure.GetRepositoryOptionSectionClass: TFppkgRepositoryOptionSectionClass;
begin
Result := TFppkgUninstalledSourceRepositoryOptionSection;
end;
procedure TFPUninstalledSourcesAvailablePackagesStructure.InitializeWithOptions(
ARepoOptionSection: TFppkgRepositoryOptionSection; AnOptions: TFppkgOptions;
ACompilerOptions: TCompilerOptions);
begin
inherited InitializeWithOptions(ARepoOptionSection, AnOptions, ACompilerOptions);
path := TFppkgUninstalledSourceRepositoryOptionSection(ARepoOptionSection).Path;
end;
function TFPUninstalledSourcesAvailablePackagesStructure.AddPackagesToRepository(ARepository: TFPRepository): Boolean;
var
@ -232,7 +223,8 @@ var
begin
Result:=false;
TempPackagesStructure := TFPTemporaryDirectoryPackagesStructure.Create(Owner, '', FCompilerOptions);
TempPackagesStructure := TFPTemporaryDirectoryPackagesStructure.Create(Owner);
TempPackagesStructure.InitializeWithOptions(nil, FOptions, FCompilerOptions);
TempRepo := TFPRepository.Create(Owner);
TempRepo.RepositoryName := 'TempScanUninstPackages';
TempRepo.Description := 'Temp list of packages during scanning of source-packages';
@ -242,21 +234,21 @@ begin
GFPpkg.RepositoryList.Add(TempRepo);
try
log(llDebug,SLogFindInstalledPackages,[FPath]);
if FindFirst(FPath+AllFiles,faDirectory,SR)=0 then
log(llDebug,SLogFindInstalledPackages,[Path]);
if FindFirst(Path+AllFiles,faDirectory,SR)=0 then
begin
repeat
if ((SR.Attr and faDirectory)=faDirectory) and (SR.Name<>'.') and (SR.Name<>'..') then
begin
AFPMakeFile := FPath+SR.Name+PathDelim+FPMakePPFile;
AFPMakeFile := Path+SR.Name+PathDelim+FPMakePPFile;
if FileExistsLog(AFPMakeFile) then
begin
AManifestFile := FPath+SR.Name+PathDelim+ManifestFile;
AManifestFile := Path+SR.Name+PathDelim+ManifestFile;
if not FileExists(AManifestFile) or (FileAge(AManifestFile) < FileAge(AFPMakeFile)) then
begin
// (Re-)create manifest
try
TempPackagesStructure.SetTempPath(FPath+SR.Name);
TempPackagesStructure.SetTempPath(Path+SR.Name);
PackageName := SR.Name + '_create_manifest';
TempPackagesStructure.TempPackageName := PackageName;
pkghandler.ExecuteAction(PackageName,'fpmakemanifest',GFPpkg);
@ -291,10 +283,12 @@ end;
function TFPUninstalledSourcesAvailablePackagesStructure.GetBuildPathDirectory(APackage: TFPPackage): string;
begin
if APackage.SourcePath<>'' then
Result := FPath+APackage.SourcePath
Result := Path+APackage.SourcePath
else
Result := FPath+APackage.Name
Result := Path+APackage.Name
end;
initialization
TFPCustomPackagesStructure.RegisterPackagesStructureClass(TFPUninstalledSourcesAvailablePackagesStructure);
end.

View File

@ -370,7 +370,9 @@ begin
Repo.RepositoryType := fprtAvailable;
Repo.RepositoryName := 'CurrentDirectory';
Repo.Description := 'Package in current directory';
InstPackages := TFPCurrentDirectoryPackagesStructure.Create(GFPpkg, OldCurrDir, GFPpkg.CompilerOptions);
InstPackages := TFPCurrentDirectoryPackagesStructure.Create(GFPpkg);
InstPackages.InitializeWithOptions(nil, GFPpkg.Options, GFPpkg.CompilerOptions);
InstPackages.Path := OldCurrDir;
InstPackages.AddPackagesToRepository(Repo);
Repo.DefaultPackagesStructure := InstPackages;
end;