Browse Source

* Added OCurl based downloader

git-svn-id: trunk@5212 -
michael 19 years ago
parent
commit
6f4201bcfc
5 changed files with 100 additions and 2 deletions
  1. 1 0
      .gitattributes
  2. 23 0
      utils/fppkg/README
  3. 1 1
      utils/fppkg/fppkg.lpi
  4. 4 1
      utils/fppkg/pkgmessages.pp
  5. 71 0
      utils/fppkg/pkgocurl.pp

+ 1 - 0
.gitattributes

@@ -7790,6 +7790,7 @@ utils/fppkg/pkgdownload.pp svneol=native#text/plain
 utils/fppkg/pkghandler.pp svneol=native#text/plain
 utils/fppkg/pkghandler.pp svneol=native#text/plain
 utils/fppkg/pkgmessages.pp svneol=native#text/plain
 utils/fppkg/pkgmessages.pp svneol=native#text/plain
 utils/fppkg/pkgmkconv.pp svneol=native#text/plain
 utils/fppkg/pkgmkconv.pp svneol=native#text/plain
+utils/fppkg/pkgocurl.pp svneol=native#text/plain
 utils/fppkg/pkgropts.pp svneol=native#text/plain
 utils/fppkg/pkgropts.pp svneol=native#text/plain
 utils/fppkg/pkgsynapse.pp svneol=native#text/plain
 utils/fppkg/pkgsynapse.pp svneol=native#text/plain
 utils/fppkg/pkgwget.pp svneol=native#text/plain
 utils/fppkg/pkgwget.pp svneol=native#text/plain

+ 23 - 0
utils/fppkg/README

@@ -22,6 +22,10 @@ create a manifest file (in XML) to import in a repository.
 All packager functionality will be implemented in units so
 All packager functionality will be implemented in units so
 these units can be used in command-line and GUI package managers.
 these units can be used in command-line and GUI package managers.
 
 
+All packager command handling is implemented in descendents fom 
+TPackageHandler (pkghandler.pp). All messages emitted by these
+handlers are in pkgmessages. 
+
 Units:
 Units:
 -----
 -----
 
 
@@ -43,6 +47,25 @@ rep2xml
   test program for the fprepos unit.
   test program for the fprepos unit.
 reptest
 reptest
   creates some test packages for use in the rep2xml test program.
   creates some test packages for use in the rep2xml test program.
+fppkg
+  the package manager application
+fpmkconv
+  Makefile.fpc to fpmake converter.
+pkgmessages
+  the messages used in pkghandler and below.
+pkghandler
+  the base for all fppkg command handlers
+pkgdownload
+  a base implementation for download functionality in fppkg
+pkgwget
+  a downloader based on spawning wget.
+pkgsynapse
+  a downloader based on Synapse. Do not put in makefile, as Synapse is
+  not distributed by default with FPC.
+pkgocurl
+  a downloader based on CurlPas (object version). Do not put in makefile,
+  as CurlPas is not distributed with FPC.
+ 
 
 
 Options supported in packager config file:
 Options supported in packager config file:
 ------------------------------------------
 ------------------------------------------

+ 1 - 1
utils/fppkg/fppkg.lpi

@@ -105,7 +105,7 @@
         <Filename Value="pkgdownload.pp"/>
         <Filename Value="pkgdownload.pp"/>
         <IsPartOfProject Value="True"/>
         <IsPartOfProject Value="True"/>
         <UnitName Value="pkgdownload"/>
         <UnitName Value="pkgdownload"/>
-        <CursorPos X="1" Y="94"/>
+        <CursorPos X="34" Y="64"/>
         <TopLine Value="59"/>
         <TopLine Value="59"/>
         <EditorIndex Value="3"/>
         <EditorIndex Value="3"/>
         <UsageCount Value="20"/>
         <UsageCount Value="20"/>

+ 4 - 1
utils/fppkg/pkgmessages.pp

@@ -17,7 +17,10 @@ Resourcestring
   SErrUnknownProtocol        = 'Unknown download protocol: "%s"';
   SErrUnknownProtocol        = 'Unknown download protocol: "%s"';
   SErrNoSuchFile             = 'File "%s" does not exist.';
   SErrNoSuchFile             = 'File "%s" does not exist.';
   SErrWGetDownloadFailed     = 'Download failed: wget reported exit status %d.';
   SErrWGetDownloadFailed     = 'Download failed: wget reported exit status %d.';
-    
+  SErrHTTPGetFailed          = 'HTTP Download failed.';
+  SErrLoginFailed            = 'FTP LOGIN command failed.';
+  SErrCWDFailed              = 'FTP CWD "%s" command failed.';  
+  SErrGETFailed              = 'FTP GET "%s" command failed.';
   SLogGeneratingFPMake       = 'Generating fpmake.pp';
   SLogGeneratingFPMake       = 'Generating fpmake.pp';
   SLogCompilingFPMake        = 'Compiling fpmake.pp: ';
   SLogCompilingFPMake        = 'Compiling fpmake.pp: ';
   SLogRunningFPMake          = 'Running fpmake';
   SLogRunningFPMake          = 'Running fpmake';

+ 71 - 0
utils/fppkg/pkgocurl.pp

@@ -0,0 +1,71 @@
+{$mode objfpc}
+{$h+}
+unit pkgoCurl; 
+
+interface
+
+uses Classes,pkgdownload;
+
+Type 
+  TOCurlDownloader = Class(TBasePackageDownloader)
+  Private 
+    FCurl : String;
+  Protected
+    Procedure OCurlDownload(Const URL : String; Dest : TStream); virtual;
+    Procedure FTPDownload(Const URL : String; Dest : TStream); override;
+    Procedure HTTPDownload(Const URL : String; Dest : TStream); override;
+ Public
+    Property Curl : String Read FCurl Write FCurl; 
+ end;   
+
+implementation
+
+uses sysutils,curlobj,pkgmessages;
+
+Procedure TOCurlDownloader.OCurlDownload(Const URL : String; Dest : TStream);
+
+Var
+  ACurl : TCurl;
+  FN : String;
+  F : TFileStream;
+
+begin
+  FN:=GetTempFileName();
+  Try
+    ACurl:=TCurl.Create(Nil);
+    Try
+      ACurl.URL:=URL;
+      ACurl.OutputFile:=FN;
+      ACurl.NoProgress:=True;
+      ACurl.Verbose:=False;
+      ACurl.FollowLocation:=True;
+      If Not ACurl.Perform then
+        Error(ACurl.ErrorString);
+    Finally
+      ACurl.Free;
+    end;
+    F:=TFileStream.Create(FN,fmOpenRead);
+    Try
+      Dest.CopyFrom(F,0);
+    Finally
+      F.Free;
+    end;
+  Finally
+    If FileExists(FN) then
+      DeleteFile(FN);
+  end;
+end;
+
+Procedure TOCurlDownloader.FTPDownload(Const URL : String; Dest : TStream);
+
+begin
+  OCurlDownload(URL,Dest);
+end;
+
+Procedure TOCurlDownloader.HTTPDownload(Const URL : String; Dest : TStream); 
+
+begin
+  OCurlDownload(URL,Dest);
+end;
+
+end.