* Fixed the ability to build packages in .source.zip files

from the command-line. +test

git-svn-id: trunk@36715 -
This commit is contained in:
joost 2017-07-09 20:30:28 +00:00
parent 13e76ccc01
commit 19b60c0cf3
3 changed files with 63 additions and 0 deletions

View File

@ -62,6 +62,17 @@ type
function GetBuildPathDirectory(APackage: TFPPackage): string; override;
end;
{ TFPArchiveFilenamePackagesStructure }
TFPArchiveFilenamePackagesStructure = class(TFPCustomPackagesStructure)
private
FArchiveFileName: string;
public
function AddPackagesToRepository(ARepository: TFPRepository): Boolean; override;
function UnzipBeforeUse: Boolean; override;
property ArchiveFileName: string read FArchiveFileName write FArchiveFileName;
end;
{ TFPOriginalSourcePackagesStructure }
TFPOriginalSourcePackagesStructure = class(TFPCustomPackagesStructure)
@ -95,6 +106,23 @@ uses
pkgrepos,
pkgglobals;
{ TFPArchiveFilenamePackagesStructure }
function TFPArchiveFilenamePackagesStructure.AddPackagesToRepository(ARepository: TFPRepository): Boolean;
var
Package: TFPPackage;
begin
Result := True;
Package := ARepository.AddPackage(CmdLinePackageName);
Package.LocalFileName := FArchiveFileName;
Package.PackagesStructure := Self;
end;
function TFPArchiveFilenamePackagesStructure.UnzipBeforeUse: Boolean;
begin
Result := True;
end;
{ TFPCustomFileSystemPackagesStructure }
function TFPCustomFileSystemPackagesStructure.GetPath: string;

View File

@ -50,6 +50,7 @@ type
procedure TestUninstalledRepository;
procedure TestBrokenPackagesBetweenRepos;
procedure TestPackageDependenciesBetweenRepos;
procedure TestBuildOfArchiveFile;
end;
{ TFullFPCInstallationSetup }
@ -582,6 +583,27 @@ begin
Check(pos('(B)',s) = 0, 'There are no broken packages, fppkg should report so.');
end;
procedure TFullFPCInstallationTests.TestBuildOfArchiveFile;
var
ArchiveFileName, s: String;
begin
TFullFPCInstallationSetup.SyncPackageIntoCurrentTest('packagea');
// Build and install package
RunFppkgIndir(TFullFPCInstallationSetup.GetCurrentTestBasePackagesPath + 'packagea', ['archive'], 'Create archive for PackageA');
ArchiveFileName := ConcatPaths([TFullFPCInstallationSetup.GetCurrentTestBasePackagesPath, 'packagea', 'packagea-1.2.3.source.zip']);
Check(FileExists(ArchiveFileName), 'Archive packagea-1.2.3.source.zip does exist');
RunFppkgIndir(TFullFPCInstallationSetup.GetCurrentTestPath, ['build', ArchiveFileName], 'Build packagea-1.2.3.source.zip');
RunFppkgIndir(TFullFPCInstallationSetup.GetCurrentTestPath, ['install', ArchiveFileName], 'install packagea-1.2.3.source.zip');
// Test installation
s := RunFppkgIndir(TFullFPCInstallationSetup.GetCurrentTestPath, ['list'], 'list packages');
Check(pos('packagea', s) > 0, 'Just installed PackageA is not in package-list');
Check(FileExists(ConcatPaths([TFullFPCInstallationSetup.GetCurrentTestPath,'user','lib','fpc', TFullFPCInstallationSetup.GetCompilerVersion, 'units',TFullFPCInstallationSetup.GetTargetString,'packagea','PackageAUnitA.ppu'])), 'PackageAUnitA.ppu not found');
Check(FileExists(ConcatPaths([TFullFPCInstallationSetup.GetCurrentTestPath,'user','lib','fpc', TFullFPCInstallationSetup.GetCompilerVersion, 'units',TFullFPCInstallationSetup.GetTargetString,'packagea','PackageAUnitA.o'])), 'PackageAUnitA.o not found');
Check(FileExists(ConcatPaths([TFullFPCInstallationSetup.GetCurrentTestPath,'user','lib','fpc', TFullFPCInstallationSetup.GetCompilerVersion, 'fpmkinst',TFullFPCInstallationSetup.GetTargetString,'packagea.fpm'])), 'PackageAUnitA.fpm not found');
end;
procedure TFullFPCInstallationTests.TestCleanupOfTemporaryBuildpath;
var
SR: TSearchRec;

View File

@ -288,6 +288,7 @@ var
SL : TStringList;
Repo: TFPRepository;
InstPackages: TFPCurrentDirectoryPackagesStructure;
ArchivePackages: TFPArchiveFilenamePackagesStructure;
begin
OldCurrDir:=GetCurrentDir;
Try
@ -386,6 +387,18 @@ begin
begin
if sametext(ExtractFileExt(ParaPackages[i]),'.zip') and FileExists(ParaPackages[i]) then
begin
Repo := TFPRepository.Create(GFPpkg);
GFPpkg.RepositoryList.Add(Repo);
Repo.RepositoryType := fprtAvailable;
Repo.RepositoryName := 'ArchiveFile';
Repo.Description := 'Package in archive-file';
ArchivePackages := TFPArchiveFilenamePackagesStructure.Create(GFPpkg);
ArchivePackages.InitializeWithOptions(nil, GFPpkg.Options, GFPpkg.CompilerOptions);
ArchivePackages.ArchiveFileName := ParaPackages[i];
ArchivePackages.AddPackagesToRepository(Repo);
Repo.DefaultPackagesStructure := ArchivePackages;
pkgglobals.Log(llDebug,SLogCommandLineAction,['['+CmdLinePackageName+']',ParaAction]);
pkghandler.ExecuteAction(CmdLinePackageName,ParaAction,GFPpkg);
end
else