Browse Source

* Added fppkg option to gather info on a package

git-svn-id: trunk@32224 -
joost 9 years ago
parent
commit
18b66865ac
3 changed files with 64 additions and 0 deletions
  1. 50 0
      packages/fppkg/src/pkgcommands.pp
  2. 13 0
      packages/fppkg/src/pkgmessages.pp
  3. 1 0
      utils/fppkg/fppkg.pp

+ 50 - 0
packages/fppkg/src/pkgcommands.pp

@@ -125,9 +125,58 @@ type
     Procedure Execute;override;
   end;
 
+  { TCommandInfo }
+
+  TCommandInfo = Class(TPackagehandler)
+  Public
+    Procedure Execute;override;
+  end;
+
 var
   DependenciesDepth: integer;
 
+{ TCommandInfo }
+
+procedure TCommandInfo.Execute;
+var
+  P : TFPPackage;
+  S : string;
+  I : Integer;
+begin
+  if PackageName='' then
+    Error(SErrNoPackageSpecified);
+  P:=AvailableRepository.PackageByName(PackageName);
+
+  log(llProgres,SLogPackageInfoName,[P.Name]);
+  S := P.Email;
+  if S <> '' then
+    S := '<' + S +'>';
+  log(llProgres,SLogPackageInfoAuthor,[P.Author, S]);
+  log(llProgres,SLogPackageInfoVersion,[P.Version.AsString]);
+  log(llProgres,SLogPackageInfoCategory,[P.Category]);
+  log(llProgres,SLogPackageInfoWebsite,[P.HomepageURL]);
+  log(llProgres,SLogPackageInfoLicense,[P.License]);
+
+  log(llProgres,SLogPackageInfoOSes,[OSesToString(P.OSes)]);
+  log(llProgres,SLogPackageInfoCPUs,[CPUSToString(P.CPUs)]);
+
+  log(llProgres,SLogPackageInfoDescription1);
+  log(llProgres,SLogPackageInfoDescription2,[P.Description]);
+
+  if P.Dependencies.Count>0 then
+    begin
+      log(llProgres,SLogPackageInfoDependencies1,[]);
+      for I := 0 to P.Dependencies.Count-1 do
+        begin
+          if not P.Dependencies[I].MinVersion.Empty then
+            S := '('+P.Dependencies[I].MinVersion.AsString+')'
+          else
+            S := '';
+          log(llProgres,SLogPackageInfoDependencies2,[P.Dependencies[I].PackageName,S]);
+        end;
+    end;
+end;
+
 { TCommandUnInstall }
 
 procedure TCommandUnInstall.Execute;
@@ -585,4 +634,5 @@ initialization
   RegisterPkgHandler('installdependencies',TCommandInstallDependencies);
   RegisterPkgHandler('fixbroken',TCommandFixBroken);
   RegisterPkgHandler('listsettings',TCommandListSettings);
+  RegisterPkgHandler('info',TCommandInfo);
 end.

+ 13 - 0
packages/fppkg/src/pkgmessages.pp

@@ -101,6 +101,19 @@ Resourcestring
   SLogCompilerCfgGlobalPrefix     = ' GlobalPrefix:     "%s" -> "%s"';
   SLogCompilerCfgLocalPrefix      = ' LocalPrefix:      "%s" -> "%s"';
 
+  SLogPackageInfoName             = 'Package:        %s';
+  SLogPackageInfoVersion          = 'Version:        %s';
+  SLogPackageInfoAuthor           = 'Author:         %s %s';
+  SLogPackageInfoCategory         = 'Category:       %s';
+  SLogPackageInfoLicense          = 'License:        %s';
+  SLogPackageInfoWebsite          = 'Website:        %s';
+  SLogPackageInfoOSes             = 'Supported OSes: %s';
+  SLogPackageInfoCPUs             = 'Supported CPUs: %s';
+  SLogPackageInfoDescription1     = 'Description:';
+  SLogPackageInfoDescription2     = '%s';
+  SLogPackageInfoDependencies1    = 'Dependencies:';
+  SLogPackageInfoDependencies2    = '  %s %s';
+
   SDbgFound                  = 'Found';
   SDbgNotFound               = 'Not Found';
   SDbgDirectoryExists        = 'Directory "%s" %s';

+ 1 - 0
utils/fppkg/fppkg.pp

@@ -110,6 +110,7 @@ begin
   Writeln('  archive           Create archive of package');
   Writeln('  download          Download package');
   Writeln('  convertmk         Convert Makefile.fpc to fpmake.pp');
+  Writeln('  info              Show more information about a package');
   Writeln('  fixbroken         Recompile all (broken) packages with changed dependencies');
   Writeln('  listsettings      Show the values for all fppkg settings');
 //  Writeln('  addconfig          Add a compiler configuration for the supplied compiler');