1 // -*- mode: cpp; mode: fold -*-
3 // $Id: mirror.cc,v 1.59 2004/05/08 19:42:35 mdz Exp $
4 /* ######################################################################
6 Mirror Aquire Method - This is the Mirror aquire method for APT.
8 ##################################################################### */
10 // Include Files /*{{{*/
11 #include <apt-pkg/fileutl.h>
12 #include <apt-pkg/acquire-method.h>
13 #include <apt-pkg/acquire-item.h>
14 #include <apt-pkg/acquire.h>
15 #include <apt-pkg/error.h>
16 #include <apt-pkg/hashes.h>
27 MirrorMethod::MirrorMethod()
28 : pkgAcqMethod("1.2",Pipeline
| SendConfig
), HasMirrorFile(false)
32 BaseUri
="http://people.ubuntu.com/~mvo/mirror/mirrors///";
33 Mirror
="http://de.archive.ubuntu.com/ubuntu/";
37 bool MirrorMethod::GetMirrorFile(string uri
)
39 string Marker
= _config
->Find("Acquire::Mirror::MagicMarker","///");
40 BaseUri
= uri
.substr(0,uri
.find(Marker
));
41 BaseUri
.replace(0,strlen("mirror://"),"http://");
43 MirrorFile
= _config
->FindDir("Dir::State::lists") + URItoFileName(BaseUri
);
45 cerr
<< "base-uri: " << BaseUri
<< endl
;
46 cerr
<< "mirror-file: " << MirrorFile
<< endl
;
48 // FIXME: fetch it with curl
50 new pkgAcqFile(&Fetcher
, BaseUri
, "", 0, "", "", "", MirrorFile
);
51 bool res
= (Fetcher
.Run() == pkgAcquire::Continue
);
52 cerr
<< "fetch-result: " << res
<< endl
;
60 bool MirrorMethod::SelectMirror()
62 ifstream
in(MirrorFile
.c_str());
64 cerr
<< "Mirror: " << Mirror
<< endl
;
67 // MirrorMethod::Fetch - Fetch an item /*{{{*/
68 // ---------------------------------------------------------------------
69 /* This adds an item to the pipeline. We keep the pipeline at a fixed
71 bool MirrorMethod::Fetch(FetchItem
*Itm
)
73 // get mirror information
76 GetMirrorFile(Itm
->Uri
);
80 // change the items in the queue
81 Itm
->Uri
.replace(0,BaseUri
.size()+_config
->Find("Acquire::Mirror::MagicMarker","///").size()+2/*len("mirror")-len("http")*/,Mirror
);
82 cerr
<< "new Fetch-uri: " << Itm
->Uri
<< endl
;
84 // FIXME: fetch it with!
90 setlocale(LC_ALL
, "");