[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tyndur-devel] [PATCH] + lpt: Unterstützung für Repositorybau aus lokalen Files
---
trunk/src/modules/pas/lpt/packages.pas | 58 +++++++++++++++++++++++++++++++-
1 files changed, 57 insertions(+), 1 deletions(-)
diff --git a/trunk/src/modules/pas/lpt/packages.pas b/trunk/src/modules/pas/lpt/packages.pas
index 67ca831..9ae8302 100644
--- a/trunk/src/modules/pas/lpt/packages.pas
+++ b/trunk/src/modules/pas/lpt/packages.pas
@@ -2,7 +2,7 @@ unit packages;
{$MODE ObjFPC}
interface
-uses sysutils, classes, repositories;
+uses sysutils, classes, repositories, tar;
type
EPackageFileFormat = class(Exception) end;
@@ -24,6 +24,7 @@ type
destructor destroy; override;
procedure ScanFile(filename: String; repository: TRepository);
+ procedure ScanPackage(filename: String; repository: TRepository);
function add(name: String): TPackage;
procedure AddAll(pkgset: TPackageSet);
procedure AddVersion(ver: TPackageVersion);
@@ -182,6 +183,61 @@ begin
end;
end;
+procedure TPackageSet.ScanPackage(filename: String; repository: TRepository);
+var
+ package: TTarArchive;
+ line: String;
+ i: integer;
+ size: integer;
+
+ package_file: ^String;
+ package_file_string: String;
+ pkg_name, pkg_version, pkg_section, pkg_arch: String;
+
+ packageinfo_data: PChar;
+
+ pkg: TPackage;
+ section: TPackageSection;
+ version: TPackageVersion;
+begin
+ package := TTarArchive.create(filename);
+ while package.hasNext do begin
+ line := package.nextFilename;
+ size := package.nextSize;
+ i := Pos('packageinfo', line);
+ if i > 0 then begin
+ package_file_string := package.ExtractString();
+ i := Pos(#10, package_file_string);
+ pkg_name := Copy(package_file_string, 1, i - 1);
+ package_file_string :=
+ Copy(package_file_string, i + 1, Length(package_file_string));
+ i := Pos(#10, package_file_string);
+ pkg_version := Copy(package_file_string, 1, i - 1);
+ package_file_string :=
+ Copy(package_file_string, i + 1, Length(package_file_string));
+ i := Pos(#10, package_file_string);
+ pkg_section := Copy(package_file_string, 1, i - 1);
+ package_file_string :=
+ Copy(package_file_string, i + 1, Length(package_file_string));
+ i := Pos(#10, package_file_string);
+ pkg_arch := Copy(package_file_string, 1, i - 1);
+ package_file_string :=
+ Copy(package_file_string, i + 1, Length(package_file_string));
+ pkg := self.add(pkg_name);
+ pkg.desc := 'none (local file)';
+ section := pkg.add(pkg_section);
+ version := section.add(pkg_version);
+ version.pkg := pkg;
+ version.section := section;
+ version.repository := repository;
+ end else begin
+ package.skipFile();
+ end;
+ end;
+ package.destroy();
+ WriteLn('finished scanpackage');
+end;
+
function TPackageSet.add(name: String): TPackage;
var
pkg: TPackage;
--
1.5.6.3