1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#include <config.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/indexcopy.h>
#include <string>
#include <stdio.h>
#include "assert.h"
class NoCopy : public IndexCopy {
public:
std::string ConvertToSourceList(std::string CD,std::string Path) {
IndexCopy::ConvertToSourceList(CD, Path);
return Path;
}
bool GetFile(std::string &/*Filename*/, unsigned long long &/*Size*/) { return false; }
bool RewriteEntry(FILE * /*Target*/, std::string /*File*/) { return false; }
const char *GetFileName() { return NULL; }
const char *Type() { return NULL; }
};
int main() {
NoCopy ic;
std::string const CD("/media/cdrom/");
char const * Releases[] = { "unstable", "wheezy-updates", NULL };
char const * Components[] = { "main", "non-free", NULL };
for (char const ** Release = Releases; *Release != NULL; ++Release) {
for (char const ** Component = Components; *Component != NULL; ++Component) {
std::string const Path = std::string("dists/") + *Release + "/" + *Component + "/";
std::string const Binary = Path + "binary-";
std::string const A = Binary + "armel/";
std::string const B = Binary + "mips/";
std::string const C = Binary + "kfreebsd-mips/";
std::string const S = Path + "source/";
std::string const List = std::string(*Release) + " " + *Component;
_config->Clear("APT");
APT::Configuration::getArchitectures(false);
equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A);
equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B);
equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
_config->Clear("APT");
_config->Set("APT::Architecture", "mips");
_config->Set("APT::Architectures::", "mips");
APT::Configuration::getArchitectures(false);
equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A);
equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), List);
equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
_config->Clear("APT");
_config->Set("APT::Architecture", "kfreebsd-mips");
_config->Set("APT::Architectures::", "kfreebsd-mips");
APT::Configuration::getArchitectures(false);
equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A);
equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B);
equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), List);
equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
_config->Clear("APT");
_config->Set("APT::Architecture", "armel");
_config->Set("APT::Architectures::", "armel");
APT::Configuration::getArchitectures(false);
equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), List);
equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B);
equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
_config->Clear("APT");
_config->Set("APT::Architecture", "armel");
_config->Set("APT::Architectures::", "armel");
_config->Set("APT::Architectures::", "mips");
APT::Configuration::getArchitectures(false);
equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), List);
equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), List);
equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
}
}
return 0;
}
|