Durch die Exceptiondinger nochmal. Nix Weltbewegendes ;) -- Alexander Siol alex@xxxxxxxxxx dunklermeuchler@xxxxxxxxx
diff --git a/trunk/src/modules/pas/lpt/repositories.pas b/trunk/src/modules/pas/lpt/repositories.pas index 658429e..9e77f0b 100644 --- a/trunk/src/modules/pas/lpt/repositories.pas +++ b/trunk/src/modules/pas/lpt/repositories.pas @@ -2,7 +2,7 @@ unit repositories; {$MODE ObjFPC} interface -uses crt, sysutils, classes, helpers, repository_base, repository_http, repository_single; +uses crt, sysutils, classes, helpers, repository_base, repository_http, repository_single, repository_file; procedure ReadPkgsrc(filename: String); procedure AddRepository(name, url: String; repostype: Trepostype); @@ -22,6 +22,8 @@ begin repo := THTTPRepository.create(repos); end else if repostype = singlefile then begin repo := TSFRepository.create(repos); + end else if repostype = files then begin + repo := TFileRepository.create(repos); end else begin raise EInvalidRepository.create('Repository unbekannten Types!'); end; @@ -60,6 +62,8 @@ begin url := Copy(url, space + 1, length(url)); if Pos('http://', url) > 0 then begin repostype := http; + end else if Pos('file:/', url) > 0 then begin + repostype := files; end else begin TextColor(12); WriteLn('Ungueltige Paketquelle: ' + url); diff --git a/trunk/src/modules/pas/lpt/repository_base.pas b/trunk/src/modules/pas/lpt/repository_base.pas index c9b16a5..f2a4712 100644 --- a/trunk/src/modules/pas/lpt/repository_base.pas +++ b/trunk/src/modules/pas/lpt/repository_base.pas @@ -9,7 +9,7 @@ type EPackageList = class(Exception) end; EInvalidRepository = class(Exception) end; - Trepostype = ( none, http, singlefile ); + Trepostype = ( none, http, singlefile, files ); TRepository = class(TCollectionItem) public diff --git a/trunk/src/modules/pas/lpt/repository_file.pas b/trunk/src/modules/pas/lpt/repository_file.pas new file mode 100644 index 0000000..6cc353c --- /dev/null +++ b/trunk/src/modules/pas/lpt/repository_file.pas @@ -0,0 +1,54 @@ +unit repository_file; +{$MODE ObjFPC} + +interface +uses crt, sysutils, classes, tar, packages, helpers, repository_base; + +type + TFileRepository = class(TRepository) + public + constructor create(parent : TCollection); + function repostype: Trepostype; override; + function Download(version: TPackageVersion): TTarArchive; override; + procedure PrepareLists; override; + procedure FetchLists(pkgset: TPackageSet); override; + end; + +implementation + +constructor TFileRepository.create(parent : TCollection); +begin + inherited; +end; + +function TFileRepository.repostype: Trepostype; +begin + exit(files); +end; + +function TFileRepository.Download(version: TPackageVersion): TTarArchive; +var + archiveURI: String; +begin + archiveURI := self.url + version.pkg.name + '-' + + version.section.section + '-' + version.version + '-' + getArch + + '.tar'; + exit(TTarArchive.create(archiveURI)); +end; + +procedure TFileRepository.PrepareLists; +begin + (* Die Paketliste liegt bereits lokal, wozu also kopieren? *) + exit; +end; + +procedure TFileRepository.FetchLists(pkgset: TPackageSet); +begin + if FileExists(self.url + 'packages.' + getArch) then begin + ScanFile(pkgset, self.url + 'packages.' + getArch, self.name); + end else begin + raise EPackageList.create('Keine Paketliste für ' + self.name + ' vorhanden!'); + end; +end; + +end.
Attachment:
signature.asc
Description: Digital signature