* prototype of mirror method added
authorMichael Vogt <michael.vogt@ubuntu.com>
Wed, 29 Nov 2006 20:24:29 +0000 (21:24 +0100)
committerMichael Vogt <michael.vogt@ubuntu.com>
Wed, 29 Nov 2006 20:24:29 +0000 (21:24 +0100)
methods/http.cc
methods/http.h
methods/http_main.cc [new file with mode: 0644]
methods/makefile
methods/mirror.cc [new file with mode: 0644]
methods/mirror.h [new file with mode: 0644]
po/apt-all.pot

index c6623c4..deaa8d0 100644 (file)
@@ -38,7 +38,6 @@
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
-#include <iostream>
 #include <apti18n.h>
 
 // Internet stuff
@@ -57,7 +56,7 @@ time_t HttpMethod::FailTime = 0;
 unsigned long PipelineDepth = 10;
 unsigned long TimeOut = 120;
 bool Debug = false;
-
+URI Proxy;
 
 unsigned long CircleBuf::BwReadLimit=0;
 unsigned long CircleBuf::BwTickReadData=0;
@@ -990,7 +989,7 @@ void HttpMethod::SigTerm(int)
    depth. */
 bool HttpMethod::Fetch(FetchItem *)
 {
-   if (Server == 0)
+   if (Server == 0) 
       return true;
 
    // Queue the requests
@@ -1223,13 +1222,5 @@ int HttpMethod::Loop()
 }
                                                                        /*}}}*/
 
-int main()
-{
-   setlocale(LC_ALL, "");
-
-   HttpMethod Mth;
-   
-   return Mth.Loop();
-}
 
 
index 541e295..5eac114 100644 (file)
@@ -13,7 +13,7 @@
 
 #define MAXLEN 360
 
-#include <iostream>
+
 
 using std::cout;
 using std::endl;
@@ -134,7 +134,6 @@ class HttpMethod : public pkgAcqMethod
    bool ServerDie(ServerState *Srv);
    int DealWithHeaders(FetchResult &Res,ServerState *Srv);
 
-   virtual bool Fetch(FetchItem *);
    virtual bool Configuration(string Message);
    
    // In the event of a fatal signal this file will be closed and timestamped.
@@ -142,6 +141,9 @@ class HttpMethod : public pkgAcqMethod
    static int FailFd;
    static time_t FailTime;
    static void SigTerm(int);
+
+   protected:
+   virtual bool Fetch(FetchItem *);
    
    public:
    friend class ServerState;
@@ -158,6 +160,5 @@ class HttpMethod : public pkgAcqMethod
    };
 };
 
-URI Proxy;
 
 #endif
diff --git a/methods/http_main.cc b/methods/http_main.cc
new file mode 100644 (file)
index 0000000..2c46ab1
--- /dev/null
@@ -0,0 +1,15 @@
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/acquire-method.h>
+
+#include "connect.h"
+#include "rfc2553emu.h"
+#include "http.h"
+
+
+int main()
+{
+   setlocale(LC_ALL, "");
+
+   HttpMethod Mth;
+   return Mth.Loop();
+}
index 1e3b1ef..12e446a 100644 (file)
@@ -49,7 +49,7 @@ include $(PROGRAM_H)
 PROGRAM=http
 SLIBS = -lapt-pkg $(SOCKETLIBS)
 LIB_MAKES = apt-pkg/makefile
-SOURCE = http.cc rfc2553emu.cc connect.cc
+SOURCE = http.cc http_main.cc rfc2553emu.cc connect.cc
 include $(PROGRAM_H)
 
 # The ftp method
@@ -66,6 +66,13 @@ LIB_MAKES = apt-pkg/makefile
 SOURCE = rsh.cc
 include $(PROGRAM_H)
 
+# The mirror method
+PROGRAM=mirror
+SLIBS = -lapt-pkg $(SOCKETLIBS)
+LIB_MAKES = apt-pkg/makefile
+SOURCE = mirror.cc http.cc rfc2553emu.cc connect.cc
+include $(PROGRAM_H)
+
 # SSH and vzip2 method symlink
 binary: $(BIN)/ssh $(BIN)/bzip2
 veryclean: clean-$(BIN)/ssh clean-$(BIN)/bzip2
diff --git a/methods/mirror.cc b/methods/mirror.cc
new file mode 100644 (file)
index 0000000..fad076e
--- /dev/null
@@ -0,0 +1,97 @@
+// -*- mode: cpp; mode: fold -*-
+// Description                                                         /*{{{*/
+// $Id: mirror.cc,v 1.59 2004/05/08 19:42:35 mdz Exp $
+/* ######################################################################
+
+   Mirror Aquire Method - This is the Mirror aquire method for APT.
+   
+   ##################################################################### */
+                                                                       /*}}}*/
+// Include Files                                                       /*{{{*/
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/acquire-method.h>
+#include <apt-pkg/acquire-item.h>
+#include <apt-pkg/acquire.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/hashes.h>
+
+#include <fstream>
+#include <iostream>
+using namespace std;
+
+#include "mirror.h"
+#include "http.h"
+
+                                                                       /*}}}*/
+
+MirrorMethod::MirrorMethod()
+   : pkgAcqMethod("1.2",Pipeline | SendConfig), HasMirrorFile(false)
+{
+#if 0
+   HasMirrorFile=true;
+   BaseUri="http://people.ubuntu.com/~mvo/mirror/mirrors///";
+   Mirror="http://de.archive.ubuntu.com/ubuntu/";
+#endif
+};
+
+bool MirrorMethod::GetMirrorFile(string uri)
+{
+   string Marker = _config->Find("Acquire::Mirror::MagicMarker","///");
+   BaseUri = uri.substr(0,uri.find(Marker));
+   BaseUri.replace(0,strlen("mirror://"),"http://");
+
+   MirrorFile = _config->FindDir("Dir::State::lists") + URItoFileName(BaseUri);
+
+   cerr << "base-uri: " << BaseUri << endl;
+   cerr << "mirror-file: " << MirrorFile << endl;
+
+   // FIXME: fetch it with curl
+   pkgAcquire Fetcher;
+   new pkgAcqFile(&Fetcher, BaseUri, "", 0, "", "", "", MirrorFile);
+   bool res = (Fetcher.Run() == pkgAcquire::Continue);
+   cerr << "fetch-result: " << res << endl;
+   
+   if(res) 
+      HasMirrorFile = true;
+   Fetcher.Shutdown();
+   return true;
+}
+
+bool MirrorMethod::SelectMirror()
+{
+   ifstream in(MirrorFile.c_str());
+   getline(in, Mirror);
+   cerr << "Mirror: " << Mirror << endl;
+}
+
+// MirrorMethod::Fetch - Fetch an item                                 /*{{{*/
+// ---------------------------------------------------------------------
+/* This adds an item to the pipeline. We keep the pipeline at a fixed
+   depth. */
+bool MirrorMethod::Fetch(FetchItem *Itm)
+{
+   // get mirror information
+   if(!HasMirrorFile)
+   {
+      GetMirrorFile(Itm->Uri);
+      SelectMirror();
+   }
+
+   // change the items in the queue
+   Itm->Uri.replace(0,BaseUri.size()+_config->Find("Acquire::Mirror::MagicMarker","///").size()+2/*len("mirror")-len("http")*/,Mirror);
+   cerr << "new Fetch-uri: " << Itm->Uri << endl;
+
+   // FIXME: fetch it with!
+   
+};
+
+int main()
+{
+   setlocale(LC_ALL, "");
+
+   MirrorMethod Mth;
+
+   return Mth.Run();
+}
+
+
diff --git a/methods/mirror.h b/methods/mirror.h
new file mode 100644 (file)
index 0000000..ca34288
--- /dev/null
@@ -0,0 +1,40 @@
+// -*- mode: cpp; mode: fold -*-
+// Description                                                         /*{{{*/// $Id: http.h,v 1.12 2002/04/18 05:09:38 jgg Exp $
+// $Id: http.h,v 1.12 2002/04/18 05:09:38 jgg Exp $
+/* ######################################################################
+
+   MIRROR Aquire Method - This is the MIRROR aquire method for APT.
+
+   ##################################################################### */
+                                                                       /*}}}*/
+
+#ifndef APT_MIRROR_H
+#define APT_MIRROR_H
+
+
+#include <iostream>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+
+#include "http.h"
+
+class MirrorMethod : public pkgAcqMethod
+{
+   FetchResult Res;
+   string Mirror;
+   string BaseUri;
+   string MirrorFile;
+   bool HasMirrorFile;
+
+ protected:
+   bool GetMirrorFile(string uri);
+   bool SelectMirror();
+ public:
+   MirrorMethod();
+   virtual bool Fetch(FetchItem *Itm);
+};
+
+
+#endif
index 5212301..b3da2ba 100644 (file)
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2006-10-11 20:34+0200\n"
+"POT-Creation-Date: 2006-11-24 16:37+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -1621,7 +1621,7 @@ msgstr ""
 msgid "Unable to accept connection"
 msgstr ""
 
-#: methods/ftp.cc:864 methods/http.cc:958 methods/rsh.cc:303
+#: methods/ftp.cc:864 methods/http.cc:957 methods/rsh.cc:303
 msgid "Problem hashing file"
 msgstr ""
 
@@ -1752,76 +1752,76 @@ msgstr ""
 msgid "Read error from %s process"
 msgstr ""
 
-#: methods/http.cc:376
+#: methods/http.cc:375
 msgid "Waiting for headers"
 msgstr ""
 
-#: methods/http.cc:522
+#: methods/http.cc:521
 #, c-format
 msgid "Got a single header line over %u chars"
 msgstr ""
 
-#: methods/http.cc:530
+#: methods/http.cc:529
 msgid "Bad header line"
 msgstr ""
 
-#: methods/http.cc:549 methods/http.cc:556
+#: methods/http.cc:548 methods/http.cc:555
 msgid "The HTTP server sent an invalid reply header"
 msgstr ""
 
-#: methods/http.cc:585
+#: methods/http.cc:584
 msgid "The HTTP server sent an invalid Content-Length header"
 msgstr ""
 
-#: methods/http.cc:600
+#: methods/http.cc:599
 msgid "The HTTP server sent an invalid Content-Range header"
 msgstr ""
 
-#: methods/http.cc:602
+#: methods/http.cc:601
 msgid "This HTTP server has broken range support"
 msgstr ""
 
-#: methods/http.cc:626
+#: methods/http.cc:625
 msgid "Unknown date format"
 msgstr ""
 
-#: methods/http.cc:773
+#: methods/http.cc:772
 msgid "Select failed"
 msgstr ""
 
-#: methods/http.cc:778
+#: methods/http.cc:777
 msgid "Connection timed out"
 msgstr ""
 
-#: methods/http.cc:801
+#: methods/http.cc:800
 msgid "Error writing to output file"
 msgstr ""
 
-#: methods/http.cc:832
+#: methods/http.cc:831
 msgid "Error writing to file"
 msgstr ""
 
-#: methods/http.cc:860
+#: methods/http.cc:859
 msgid "Error writing to the file"
 msgstr ""
 
-#: methods/http.cc:874
+#: methods/http.cc:873
 msgid "Error reading from server. Remote end closed connection"
 msgstr ""
 
-#: methods/http.cc:876
+#: methods/http.cc:875
 msgid "Error reading from server"
 msgstr ""
 
-#: methods/http.cc:1107
+#: methods/http.cc:1106
 msgid "Bad header data"
 msgstr ""
 
-#: methods/http.cc:1124
+#: methods/http.cc:1123
 msgid "Connection failed"
 msgstr ""
 
-#: methods/http.cc:1215
+#: methods/http.cc:1214
 msgid "Internal error"
 msgstr ""
 
@@ -2366,7 +2366,7 @@ msgid "MD5Sum mismatch"
 msgstr ""
 
 #: apt-pkg/acquire-item.cc:640
-msgid "There are no public key available for the following key IDs:\n"
+msgid "There is no public key available for the following key IDs:\n"
 msgstr ""
 
 #: apt-pkg/acquire-item.cc:753