]> git.saurik.com Git - apt.git/blob - methods/mirror.h
eipp: add Allow-Temporary-Remove-of-Essentials
[apt.git] / methods / mirror.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 /* ######################################################################
4
5 MIRROR Acquire Method - This is the MIRROR acquire method for APT.
6
7 ##################################################################### */
8 /*}}}*/
9
10 #ifndef APT_MIRROR_H
11 #define APT_MIRROR_H
12
13 #include <iostream>
14 #include <string>
15 #include <vector>
16
17 using std::cout;
18 using std::cerr;
19 using std::endl;
20
21 #include "http.h"
22
23 class MirrorMethod : public HttpMethod
24 {
25 FetchResult Res;
26 // we simply transform between BaseUri and Mirror
27 std::string BaseUri; // the original mirror://... url
28 std::string Mirror; // the selected mirror uri (http://...)
29 std::vector<std::string> AllMirrors; // all available mirrors
30 std::string MirrorFile; // the file that contains the list of mirrors
31 bool DownloadedMirrorFile; // already downloaded this session
32 std::string Dist; // the target distrubtion (e.g. sid, oneiric)
33
34 bool Debug;
35
36 protected:
37 bool DownloadMirrorFile(std::string uri);
38 bool RandomizeMirrorFile(std::string file);
39 std::string GetMirrorFileName(std::string uri);
40 bool InitMirrors();
41 bool TryNextMirror();
42 void CurrentQueueUriToMirror();
43 bool Clean(std::string dir);
44
45 // we need to overwrite those to transform the url back
46 virtual void Fail(std::string Why, bool Transient = false) APT_OVERRIDE;
47 virtual void URIStart(FetchResult &Res) APT_OVERRIDE;
48 virtual void URIDone(FetchResult &Res,FetchResult *Alt = 0) APT_OVERRIDE;
49 virtual bool Configuration(std::string Message) APT_OVERRIDE;
50
51 public:
52 MirrorMethod();
53 virtual bool Fetch(FetchItem *Itm) APT_OVERRIDE;
54 };
55
56
57 #endif