- initial import of revision 374 from cnc
[apt.git] / apt-pkg / rpm / rpmpm.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description                                                          /*{{{*/
3 // $Id: rpmpm.h,v 1.4 2003/01/29 13:52:32 niemeyer Exp $
4 /* ######################################################################
5
6    rpm Package Manager - Provide an interface to rpm
7    
8    ##################################################################### 
9  */
10                                                                         /*}}}*/
11 #ifndef PKGLIB_rpmPM_H
12 #define PKGLIB_rpmPM_H
13
14 #include <rpm/rpmlib.h>
15 #if RPM_VERSION >= 0x040100
16 #include <rpm/rpmts.h>
17 #endif
18 #if RPM_VERSION >= 0x040000
19 #include <rpm/rpmcli.h>
20 #endif
21                                                                         /*}}}*/
22 typedef Header rpmHeader; 
23
24 #ifdef __GNUG__
25 #pragma interface "apt-pkg/rpmpm.h"
26 #endif
27
28 #include <apt-pkg/packagemanager.h>
29 #include <vector>
30
31 using namespace std;
32
33 class pkgRPMPM : public pkgPackageManager
34 {
35    protected:
36
37    struct Item
38    {
39       enum Ops {Install, Configure, Remove, Purge} Op;
40       enum RPMOps {RPMInstall, RPMUpgrade, RPMErase};
41       string File;
42       PkgIterator Pkg;
43       Item(Ops Op,PkgIterator Pkg,string File = "")
44          : Op(Op), File(File), Pkg(Pkg) {};
45       Item() {};
46       
47    };
48    vector<Item> List;
49
50    // Helpers
51    bool RunScripts(const char *Cnf);
52    bool RunScriptsWithPkgs(const char *Cnf);
53    
54    // The Actuall installation implementation
55    virtual bool Install(PkgIterator Pkg,string File);
56    virtual bool Configure(PkgIterator Pkg);
57    virtual bool Remove(PkgIterator Pkg,bool Purge = false);
58     
59    virtual bool Process(vector<const char*> &install,
60                 vector<const char*> &upgrade,
61                 vector<const char*> &uninstall) {return false;};
62    
63    virtual bool Go();
64    virtual void Reset();
65    
66    public:
67
68    pkgRPMPM(pkgDepCache *Cache);
69    virtual ~pkgRPMPM();
70 };
71
72 class pkgRPMExtPM : public pkgRPMPM
73 {
74    protected:
75    bool ExecRPM(Item::RPMOps op, vector<const char*> &files);
76    virtual bool Process(vector<const char*> &install,
77                 vector<const char*> &upgrade,
78                 vector<const char*> &uninstall);
79
80    public:
81    pkgRPMExtPM(pkgDepCache *Cache);
82    virtual ~pkgRPMExtPM();
83 };
84
85 class pkgRPMLibPM : public pkgRPMPM
86 {
87    protected:
88 #if RPM_VERSION >= 0x040100
89    rpmts TS;
90 #else
91    rpmTransactionSet TS;
92    rpmdb DB;
93 #endif
94
95    bool ParseRpmOpts(const char *Cnf, int *tsFlags, int *probFilter);
96    bool AddToTransaction(Item::RPMOps op, vector<const char*> &files);
97    virtual bool Process(vector<const char*> &install,
98                 vector<const char*> &upgrade,
99                 vector<const char*> &uninstall);
100
101    public:
102
103    pkgRPMLibPM(pkgDepCache *Cache);
104    virtual ~pkgRPMLibPM();
105 };
106
107 #endif
108
109 // vim:sts=3:sw=3