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