Bladeren bron

* Fixed the ability to build packages in .source.zip files
from the command-line. +test

git-svn-id: trunk@36715 -

joost 8 jaren geleden
bovenliggende
commit
19b60c0cf3

+ 28 - 0
packages/fppkg/src/pkgpackagesstructure.pp

@@ -62,6 +62,17 @@ type
     function GetBuildPathDirectory(APackage: TFPPackage): string; override;
     function GetBuildPathDirectory(APackage: TFPPackage): string; override;
   end;
   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 }
 
 
   TFPOriginalSourcePackagesStructure = class(TFPCustomPackagesStructure)
   TFPOriginalSourcePackagesStructure = class(TFPCustomPackagesStructure)
@@ -95,6 +106,23 @@ uses
   pkgrepos,
   pkgrepos,
   pkgglobals;
   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 }
 { TFPCustomFileSystemPackagesStructure }
 
 
 function TFPCustomFileSystemPackagesStructure.GetPath: string;
 function TFPCustomFileSystemPackagesStructure.GetPath: string;

+ 22 - 0
packages/fppkg/tests/fullfpcinstallationtests.pas

@@ -50,6 +50,7 @@ type
     procedure TestUninstalledRepository;
     procedure TestUninstalledRepository;
     procedure TestBrokenPackagesBetweenRepos;
     procedure TestBrokenPackagesBetweenRepos;
     procedure TestPackageDependenciesBetweenRepos;
     procedure TestPackageDependenciesBetweenRepos;
+    procedure TestBuildOfArchiveFile;
   end;
   end;
 
 
   { TFullFPCInstallationSetup }
   { TFullFPCInstallationSetup }
@@ -582,6 +583,27 @@ begin
   Check(pos('(B)',s) = 0, 'There are no broken packages, fppkg should report so.');
   Check(pos('(B)',s) = 0, 'There are no broken packages, fppkg should report so.');
 end;
 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;
 procedure TFullFPCInstallationTests.TestCleanupOfTemporaryBuildpath;
 var
 var
   SR: TSearchRec;
   SR: TSearchRec;

+ 13 - 0
utils/fppkg/fppkg.pp

@@ -288,6 +288,7 @@ var
   SL     : TStringList;
   SL     : TStringList;
   Repo: TFPRepository;
   Repo: TFPRepository;
   InstPackages: TFPCurrentDirectoryPackagesStructure;
   InstPackages: TFPCurrentDirectoryPackagesStructure;
+  ArchivePackages: TFPArchiveFilenamePackagesStructure;
 begin
 begin
   OldCurrDir:=GetCurrentDir;
   OldCurrDir:=GetCurrentDir;
   Try
   Try
@@ -386,6 +387,18 @@ begin
           begin
           begin
             if sametext(ExtractFileExt(ParaPackages[i]),'.zip') and FileExists(ParaPackages[i]) then
             if sametext(ExtractFileExt(ParaPackages[i]),'.zip') and FileExists(ParaPackages[i]) then
               begin
               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);
                 pkghandler.ExecuteAction(CmdLinePackageName,ParaAction,GFPpkg);
               end
               end
             else
             else