[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH] lpt: Filter beim Auflisten



+ Durch Eingabe von lpt list --filter [installed|notinstalled] werden nur
  installierte bzw. nicht installierte Pakete angezeigt
---
 src/modules/pas/lpt/lpt.pas |  119 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 118 insertions(+), 1 deletions(-)

diff --git a/src/modules/pas/lpt/lpt.pas b/src/modules/pas/lpt/lpt.pas
index 5705d97..1ab91f8 100644
--- a/src/modules/pas/lpt/lpt.pas
+++ b/src/modules/pas/lpt/lpt.pas
@@ -295,6 +295,111 @@ begin
     end;
 end;
 
+
+procedure ListInstalled;
+var
+    srec: SearchRec;
+    pkgset: TPackageSet;
+    pkg: TPackage;
+    sect: TPackageSection;
+    ver: TPackageVersion;
+    dep: TDependency;
+
+    repo: TRepository;
+
+    i, j, k, l: integer;
+    filename: String;
+begin
+    ReadPkgsrc(getConfigRoot + 'pkgsrc');
+    pkgset := TPackageSet.create;
+    ReadPkglists(pkgset);
+
+    for i := 0 to pkgset.packages.count - 1 do begin
+        pkg := TPackage(pkgset.packages.items[i]);
+        for j := 0 to pkg.sections.count - 1 do begin
+            sect := TPackageSection(pkg.sections.items[j]);
+            for k := 0 to sect.versions.count - 1 do begin
+                ver := TPackageVersion(sect.versions.items[k]);
+                filename := 'file:/packages/' + ver.pkg.name + '/' +
+                    ver.version + '/' + ver.section.section + '/';
+
+                if FileExists(filename) then begin
+                    Write(pkg.name, StringOfChar(' ', 12 - Length(pkg.name)));
+                    Write(' | ', sect.section, StringOfChar(' ', 5 - Length(sect.section)));
+                    Write(' | ', ver.version : 10);
+                    if Length(pkg.desc) > 43 then begin
+                        WriteLn(' | ' + Copy(pkg.desc, 1, 40), '...');
+                    end else begin
+                        WriteLn(' | ' + pkg.desc);
+                    end;
+
+                    for l := 0 to ver.preinstDependencies.count - 1 do begin
+                        dep := TDependency(ver.preinstDependencies.items[l]);
+                        WriteLn('' : 36, rsListInstallDependency, dep.pkgname + ' (' + dep.section + ')');
+                    end;
+                    
+                    for l := 0 to ver.runDependencies.count - 1 do begin
+                        dep := TDependency(ver.runDependencies.items[l]);
+                        WriteLn('' : 36, rsListRunDependency, dep.pkgname + ' (' + dep.section + ')');
+                    end;
+                end;
+            end;
+        end;
+    end;
+end;
+
+
+procedure ListNotInstalled;
+var
+    srec: SearchRec;
+    pkgset: TPackageSet;
+    pkg: TPackage;
+    sect: TPackageSection;
+    ver: TPackageVersion;
+    dep: TDependency;
+
+    repo: TRepository;
+
+    i, j, k, l: integer;
+    filename: String;
+begin
+    ReadPkgsrc(getConfigRoot + 'pkgsrc');
+    pkgset := TPackageSet.create;
+    ReadPkglists(pkgset);
+
+    for i := 0 to pkgset.packages.count - 1 do begin
+        pkg := TPackage(pkgset.packages.items[i]);
+        for j := 0 to pkg.sections.count - 1 do begin
+            sect := TPackageSection(pkg.sections.items[j]);
+            for k := 0 to sect.versions.count - 1 do begin
+                ver := TPackageVersion(sect.versions.items[k]);
+                filename := 'file:/packages/' + ver.pkg.name + '/' +
+                    ver.version + '/' + ver.section.section + '/';
+                if not FileExists(filename) then begin
+                    Write(pkg.name, StringOfChar(' ', 12 - Length(pkg.name)));
+                    Write(' | ', sect.section, StringOfChar(' ', 5 - Length(sect.section)));
+                    Write(' | ', ver.version : 10);
+                    if Length(pkg.desc) > 43 then begin
+                        WriteLn(' | ' + Copy(pkg.desc, 1, 40), '...');
+                    end else begin
+                        WriteLn(' | ' + pkg.desc);
+                    end;
+
+                    for l := 0 to ver.preinstDependencies.count - 1 do begin
+                        dep := TDependency(ver.preinstDependencies.items[l]);
+                        WriteLn('' : 36, rsListInstallDependency, dep.pkgname + ' (' + dep.section + ')');
+                    end;
+                    
+                    for l := 0 to ver.runDependencies.count - 1 do begin
+                        dep := TDependency(ver.runDependencies.items[l]);
+                        WriteLn('' : 36, rsListRunDependency, dep.pkgname + ' (' + dep.section + ')');
+                    end;
+                end;
+            end;
+        end;
+    end;
+end;
+
 function c_lostio_create_link(target, link: PChar; hard: boolean): integer; cdecl; external name 'io_create_link';
 
 procedure CfgAddbin(path, pubname: String);
@@ -358,7 +463,19 @@ begin
     if system.ParamStr(1) = 'scan' then begin
         Scan;
     end else if system.ParamStr(1) = 'list' then begin
-        List;
+        if system.ParamCount = 1 then begin
+            List;
+        end else if system.ParamCount = 3 then begin
+            if system.ParamStr(2) = '--filter' then begin
+                if system.ParamStr(3) = 'installed' then begin
+                    ListInstalled;
+                end else if system.ParamStr(3) = 'notinstalled' then begin
+                    ListNotInstalled;
+                end;
+            end;
+        end else begin
+            WriteLn(rsWrongParamCount);
+        end;
     end else if system.ParamStr(1) = 'get' then begin
         if system.ParamCount = 2 then begin
             Get(system.ParamStr(2), false);
-- 
1.7.1