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

[tyndur-devel] [PATCH] Lokale Pakete für lpt



Siehe Betreff ;) test via lpt install [pfad_zum_paket]
Paket muss Metadaten enthalten, siehe entsprechenden lbuilds-Patch

-- 
Alexander Siol
alex@xxxxxxxxxx
dunklermeuchler@xxxxxxxxx
diff --git a/trunk/src/modules/pas/lpt/lpt.pas b/trunk/src/modules/pas/lpt/lpt.pas
index 1da6527..1edbf33 100644
--- a/trunk/src/modules/pas/lpt/lpt.pas
+++ b/trunk/src/modules/pas/lpt/lpt.pas
@@ -116,10 +116,11 @@ end;
 
 procedure PrintUsage;
 begin
-    WriteLn('Aufruf: lpt [scan|list|get <Paket>]');
-    WriteLn('  scan: Lädt die Paketlisten von den Servern');
-    WriteLn('  list: Zeigt alle installierten Pakete an');
-    WriteLn('  get:  Installiert das angegebene Paket');
+    WriteLn(' Aufruf: lpt [scan|list|get <Paket>]');
+    WriteLn('   scan: Lädt die Paketlisten von den Servern');
+    WriteLn('   list: Zeigt alle installierten Pakete an');
+    WriteLn('    get:  Installiert das angegebene Paket');
+    WriteLn('install: Installiert ein Paket aus lokaler Datei');
 end;
 
 procedure Scan;
@@ -191,6 +192,53 @@ begin
     end;
 end;
 
+procedure Install(pkgfile: String; reinstall: boolean);
+var
+    temp_path, pkgname, pkgversion, pkgsection, pkgarch: String;
+    packageinfo: Text;
+    packageinfo_file: File;
+    archive: TTarArchive;
+begin
+    mkpath('file:/tmp/');
+    temp_path := 'file:/tmp/packageinfo-'+pkgfile;
+    archive := TTarArchive.create(pkgfile);
+    while archive.hasNext do begin
+        if archive.NextFilename = 'packageinfo' then begin
+            Assign(packageinfo_file, temp_path);
+            Rewrite(packageinfo_file, 1);
+            archive.ExtractFile(packageinfo_file);
+            Close(packageinfo_file);
+            break;
+        end;
+    end;
+    Assign(packageinfo, temp_path);
+    Reset(packageinfo);
+    ReadLn(packageinfo, pkgname);
+    ReadLn(packageinfo, pkgversion);
+    ReadLn(packageinfo, pkgsection);
+    ReadLn(packageinfo, pkgarch);
+    Close(packageinfo);
+
+    // ggf. irgendwie Abhängigkeiten prüfen?
+
+    // Installieren
+    temp_path := 'file:/packages/' + pkgname + '/' + pkgversion + '/' +
+        pkgsection + '/';
+    if FileExists(temp_path) and not reinstall then begin
+        TextColor(15);
+        WriteLn('Bereits installiert: ' + pkgname + '/' + pkgsection);
+        TextColor(7);
+        exit;
+    end;
+    Untar(pkgfile);
+    temp_path := 'file:/packages/' + pkgname + '/' +
+        pkgversion + '/postinstall-' + pkgsection;
+    if FileExists(temp_path) then begin
+        WriteLn('Richte ' + pkgname + '/' + pkgsection + ' ein');
+        exec(temp_path, '');
+    end;
+end;
+
 procedure Get(pkgname: String; reinstall: boolean);
 
 
@@ -402,6 +450,13 @@ begin
             WriteLn('Falsche Parameterzahl');
             PrintUsage;
         end;
+    end else if system.ParamStr(1) = 'install' then begin
+        if system.ParamCount = 2 then begin
+            Install(system.ParamStr(2), false);
+        end else begin
+            WriteLn('Falsche Parameterzahl');
+            PrintUsage;
+        end;
     end else if system.ParamStr(1) = 'reget' then begin
         if system.ParamCount = 2 then begin
             Get(system.ParamStr(2), true);

Attachment: signature.asc
Description: Digital signature