]> git.saurik.com Git - apt.git/blob - apt-pkg/cdrom.h
fix test/integration/test-apt-helper
[apt.git] / apt-pkg / cdrom.h
1 #ifndef PKGLIB_CDROM_H
2 #define PKGLIB_CDROM_H
3
4 #include<string>
5 #include<vector>
6
7 #include <stddef.h>
8
9 #ifndef APT_8_CLEANER_HEADERS
10 #include <apt-pkg/init.h>
11 using namespace std;
12 #endif
13
14 class Configuration;
15 class OpProgress;
16
17 class pkgCdromStatus /*{{{*/
18 {
19 protected:
20 int totalSteps;
21
22 public:
23 pkgCdromStatus() : totalSteps(0) {};
24 virtual ~pkgCdromStatus() {};
25
26 // total steps
27 virtual void SetTotal(int total) { totalSteps = total; };
28 // update steps, will be called regularly as a "pulse"
29 virtual void Update(std::string text="", int current=0) = 0;
30
31 // ask for cdrom insert
32 virtual bool ChangeCdrom() = 0;
33 // ask for cdrom name
34 virtual bool AskCdromName(std::string &Name) = 0;
35 // Progress indicator for the Index rewriter
36 virtual OpProgress* GetOpProgress() {return NULL; };
37 };
38 /*}}}*/
39 class pkgCdrom /*{{{*/
40 {
41 protected:
42 enum {
43 STEP_PREPARE = 1,
44 STEP_UNMOUNT,
45 STEP_WAIT,
46 STEP_MOUNT,
47 STEP_IDENT,
48 STEP_SCAN,
49 STEP_COPY,
50 STEP_WRITE,
51 STEP_UNMOUNT3,
52 STEP_LAST
53 };
54
55
56 bool FindPackages(std::string CD,
57 std::vector<std::string> &List,
58 std::vector<std::string> &SList,
59 std::vector<std::string> &SigList,
60 std::vector<std::string> &TransList,
61 std::string &InfoDir, pkgCdromStatus *log,
62 unsigned int Depth = 0);
63 bool DropBinaryArch(std::vector<std::string> &List);
64 bool DropRepeats(std::vector<std::string> &List,const char *Name);
65 bool DropTranslation(std::vector<std::string> &List);
66 void ReduceSourcelist(std::string CD,std::vector<std::string> &List);
67 bool WriteDatabase(Configuration &Cnf);
68 bool WriteSourceList(std::string Name,std::vector<std::string> &List,bool Source);
69 int Score(std::string Path);
70
71 public:
72 bool Ident(std::string &ident, pkgCdromStatus *log);
73 bool Add(pkgCdromStatus *log);
74
75 private:
76 bool MountAndIdentCDROM(Configuration &Database, std::string &CDROM,
77 std::string &ident, pkgCdromStatus * const log, bool const interactive);
78 };
79 /*}}}*/
80
81
82 // class that uses libudev to find cdrom/removable devices dynamically
83 struct CdromDevice /*{{{*/
84 {
85 std::string DeviceName;
86 bool Mounted;
87 std::string MountPath;
88 };
89 /*}}}*/
90 class pkgUdevCdromDevices /*{{{*/
91 {
92 protected:
93 // libudev dlopen structure
94 void *libudev_handle;
95 struct udev* (*udev_new)(void);
96 int (*udev_enumerate_add_match_property)(struct udev_enumerate *udev_enumerate, const char *property, const char *value);
97 int (*udev_enumerate_scan_devices)(struct udev_enumerate *udev_enumerate);
98 struct udev_list_entry* (*udev_enumerate_get_list_entry)(struct udev_enumerate *udev_enumerate);
99 struct udev_device* (*udev_device_new_from_syspath)(struct udev *udev, const char *syspath);
100 struct udev* (*udev_enumerate_get_udev)(struct udev_enumerate *udev_enumerate);
101 const char* (*udev_list_entry_get_name)(struct udev_list_entry *list_entry);
102 const char* (*udev_device_get_devnode)(struct udev_device *udev_device);
103 struct udev_enumerate *(*udev_enumerate_new) (struct udev *udev);
104 struct udev_list_entry *(*udev_list_entry_get_next)(struct udev_list_entry *list_entry);
105 const char* (*udev_device_get_property_value)(struct udev_device *udev_device, const char *key);
106 int (*udev_enumerate_add_match_sysattr)(struct udev_enumerate *udev_enumerate, const char *property, const char *value);
107 // end libudev dlopen
108
109 public:
110 pkgUdevCdromDevices();
111 virtual ~pkgUdevCdromDevices();
112
113 // try to open
114 bool Dlopen();
115
116 // convenience interface, this will just call ScanForRemovable
117 // with "APT::cdrom::CdromOnly"
118 std::vector<CdromDevice> Scan();
119
120 std::vector<CdromDevice> ScanForRemovable(bool CdromOnly);
121 };
122 /*}}}*/
123
124 #endif