[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [tyndur-devel] [PATCH] + lpt: FileRepository
Am Dienstag, 26. Mai 2009 17:30 schrieb Alexander Siol:
> diff --git a/trunk/src/modules/pas/lpt/filerepository.pas
> b/trunk/src/modules/pas/lpt/filerepository.pas new file mode 100644
> index 0000000..186b81d
> --- /dev/null
> +++ b/trunk/src/modules/pas/lpt/filerepository.pas
> @@ -0,0 +1,56 @@
> +unit filerepository;
> +{$MODE ObjFPC}
> +
> +interface
> +uses sysutils, classes, tar, packages, helpers, baserepository;
> +
> +type
> + TFileRepository = class(TRepository)
> + public
> + constructor create(parent : TCollection);
> + function Download(version: TPackageVersion): TTarArchive;
> override; + function PrepareLists: boolean; override;
> + function FetchLists(pkgset: TPackageSet): boolean; override;
> + end;
> +
> +implementation
> +
> +constructor TFileRepository.create(parent : TCollection);
> +begin
> + inherited;
> + repostype := 'file';
> +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;
> +
> +function TFileRepository.PrepareLists: boolean;
> +var
> + pkglisturl: String;
> +begin
> + (* Die Paketliste liegt bereits lokal, wozu also kopieren? *)
> + exit(true);
> +end;
> +
> +function TFileRepository.FetchLists(pkgset: TPackageSet): boolean;
> +begin
> + if FileExists(self.url + 'pkglist.' + self.name) then begin
> + ScanFile(pkgset, self.url + 'pkglist.' + self.name, self.name);
> + exit(true);
In welchem Fall hat man denn eine pkglist.name für file-Repos? Kopiert wird
die Liste ja nicht und im Repoverzeichnis liegt sowas eigentlich erst recht
nicht.
> + end else if FileExists(self.url + 'packages.' + getArch) then begin
> + ScanFile(pkgset, self.url + 'packages.' + getArch, self.name);
> + exit(true);
> + end else begin
> + exit(false);
> + end;
> +end;
> +
> +begin
> +end.
> diff --git a/trunk/src/modules/pas/lpt/repositories.pas
> b/trunk/src/modules/pas/lpt/repositories.pas index a68908d..28cde8d 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 sysutils, classes, helpers, baserepository, httprepository,
> sfrepository; +uses sysutils, classes, helpers, baserepository,
> httprepository, sfrepository, filerepository;
>
> procedure ReadPkgsrc(filename: String);
> procedure AddRepository(name, url, repostype: String);
> @@ -20,6 +20,8 @@ var
> begin
> if repostype = 'http' then begin
> repo := THTTPRepository.create(repos);
> + end else if repostype = 'file' then begin
> + repo := TFileRepository.create(repos);
> end else if repostype = 'singlefile' then begin
> repo := TSFRepository.create(repos);
> end else begin
> @@ -61,11 +63,13 @@ begin
> if space > 0 then begin
> name := Copy(url, 1, space - 1);
> url := Copy(url, space + 1, length(url));
> - protofinder := Pos('http://', url);
> - if protofinder > 0 then begin
> + if Pos('http://', url) > 0 then begin
> repostype := 'http';
> + end else if Pos('file:/', url) > 0 then begin
> + repostype := 'file';
> end else begin
> - repostype := '';
> + WriteLn('Ungueltige Paketquelle: ' + url);
> + continue;
> end
> end else begin
> WriteLn('Ungueltige Paketquelle: ' + url);
Kann man diese Warnungen noch noch in TextColor(6) packen, damit die auch
deutlich sichtbar sind?
Sieht sonst gut aus.