]> git.saurik.com Git - apt.git/blame - methods/aptmethod.h
eipp: add Allow-Temporary-Remove-of-Essentials
[apt.git] / methods / aptmethod.h
CommitLineData
30c8107e
DK
1#ifndef APT_APTMETHOD_H
2#define APT_APTMETHOD_H
3
4#include <apt-pkg/acquire-method.h>
23e64f6d 5#include <apt-pkg/configuration.h>
30c8107e 6
8b79c94a 7#include <locale>
30c8107e
DK
8#include <string>
9
10class aptMethod : public pkgAcqMethod
11{
12 char const * const Binary;
30c8107e 13
23e64f6d
DK
14public:
15 virtual bool Configuration(std::string Message) APT_OVERRIDE
16 {
17 if (pkgAcqMethod::Configuration(Message) == false)
18 return false;
19
20 std::string const conf = std::string("Binary::") + Binary;
21 _config->MoveSubTree(conf.c_str(), NULL);
22
23 DropPrivsOrDie();
24
25 return true;
26 }
27
28 bool CalculateHashes(FetchItem const * const Itm, FetchResult &Res) const
29 {
30 Hashes Hash(Itm->ExpectedHashes);
31 FileFd Fd;
32 if (Fd.Open(Res.Filename, FileFd::ReadOnly) == false || Hash.AddFD(Fd) == false)
33 return false;
34 Res.TakeHashes(Hash);
35 return true;
36 }
37
8c9b7725
JAK
38 void Warning(const char *Format,...)
39 {
40 va_list args;
41 va_start(args,Format);
42 PrintStatus("104 Warning", Format, args);
43 va_end(args);
44 }
45
23e64f6d
DK
46 aptMethod(char const * const Binary, char const * const Ver, unsigned long const Flags) :
47 pkgAcqMethod(Ver, Flags), Binary(Binary)
8b79c94a 48 {
62600666
DK
49 try {
50 std::locale::global(std::locale(""));
51 } catch (...) {
52 setlocale(LC_ALL, "");
53 }
8b79c94a 54 }
30c8107e 55};
30c8107e
DK
56
57#endif