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