summaryrefslogtreecommitdiff
path: root/lib/rpmlib.h
blob: a694f57e4d373e0d1c77c33fe0b04f5744ce4d6c (plain)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#ifndef H_RPMLIB
#define H_RPMLIB

/* This is the *only* module users of rpmlib should need to include */

#include <db.h>

/* it shouldn't need these :-( */
#include "dbindex.h"
#include "header.h"
#include "messages.h"

struct rpmTagTableEntry {
    char * name;
    int val;
};

int pkgReadHeader(int fd, Header * hdr, int * isSource);
   /* 0 = success */
   /* 1 = bad magic */
   /* 2 = error */

extern const struct rpmTagTableEntry rpmTagTable[];
extern const int rpmTagTableSize;

/* these tags are for both the database and packages */
/* none of these can be 0 !!                         */

#define RPMTAG_NAME  			1000
#define RPMTAG_VERSION			1001
#define RPMTAG_RELEASE			1002
#define RPMTAG_SERIAL   		1003
#define	RPMTAG_SUMMARY			1004
#define RPMTAG_DESCRIPTION		1005
#define RPMTAG_BUILDTIME		1006
#define RPMTAG_BUILDHOST		1007
#define RPMTAG_INSTALLTIME		1008
#define RPMTAG_SIZE			1009
#define RPMTAG_DISTRIBUTION		1010
#define RPMTAG_VENDOR			1011
#define RPMTAG_GIF			1012
#define RPMTAG_XPM			1013
#define RPMTAG_COPYRIGHT                1014
#define RPMTAG_PACKAGER                 1015
#define RPMTAG_GROUP                    1016
#define RPMTAG_CHANGELOG                1017
#define RPMTAG_SOURCE                   1018
#define RPMTAG_PATCH                    1019
#define RPMTAG_URL                      1020
#define RPMTAG_OS                       1021
#define RPMTAG_ARCH                     1022
#define RPMTAG_PREIN                    1023
#define RPMTAG_POSTIN                   1024
#define RPMTAG_PREUN                    1025
#define RPMTAG_POSTUN                   1026
#define RPMTAG_FILENAMES		1027
#define RPMTAG_FILESIZES		1028
#define RPMTAG_FILESTATES		1029
#define RPMTAG_FILEMODES		1030
#define RPMTAG_FILEUIDS			1031
#define RPMTAG_FILEGIDS			1032
#define RPMTAG_FILERDEVS		1033
#define RPMTAG_FILEMTIMES		1034
#define RPMTAG_FILEMD5S			1035
#define RPMTAG_FILELINKTOS		1036
#define RPMTAG_FILEFLAGS		1037
#define RPMTAG_ROOT                     1038
#define RPMTAG_FILEUSERNAME             1039
#define RPMTAG_FILEGROUPNAME            1040
#define RPMTAG_EXCLUDE                  1041
#define RPMTAG_EXCLUSIVE                1042
#define RPMTAG_ICON                     1043
#define RPMTAG_SOURCERPM                1044
#define RPMTAG_FILEVERIFYFLAGS          1045
#define RPMTAG_ARCHIVESIZE              1046
#define RPMTAG_PROVIDES                 1047
#define RPMTAG_REQUIREFLAGS             1048
#define RPMTAG_REQUIRENAME              1049
#define RPMTAG_REQUIREVERSION           1050
#define RPMTAG_NOSOURCE                 1051
#define RPMTAG_NOPATCH                  1052
#define RPMTAG_CONFLICTFLAGS            1053
#define RPMTAG_CONFLICTNAME             1054
#define RPMTAG_CONFLICTVERSION          1055
#define RPMTAG_DEFAULTPREFIX            1056
#define RPMTAG_BUILDROOT                1057
#define RPMTAG_INSTALLPREFIX		1058

#define RPMFILE_STATE_NORMAL 		0
#define RPMFILE_STATE_REPLACED 		1
#define RPMFILE_STATE_NOTINSTALLED	2

/* these can be ORed together */
#define RPMFILE_CONFIG			1
#define RPMFILE_DOC			2

#define INSTALL_REPLACEPKG	(1 << 0)
#define INSTALL_REPLACEFILES	(1 << 1)
#define INSTALL_TEST		(1 << 2)
#define INSTALL_UPGRADE		(1 << 3)
#define INSTALL_UPGRADETOOLD	(1 << 4)
#define INSTALL_NODOCS		(1 << 5)
#define INSTALL_NOSCRIPTS	(1 << 6)
#define INSTALL_NOARCH		(1 << 7)
#define INSTALL_NOOS		(1 << 8)

#define UNINSTALL_TEST          (1 << 0)
#define UNINSTALL_NOSCRIPTS	(1 << 1)

#define VERIFY_NONE             0
#define VERIFY_MD5              (1 << 0)
#define VERIFY_FILESIZE         (1 << 1)
#define VERIFY_LINKTO           (1 << 2)
#define VERIFY_USER             (1 << 3)
#define VERIFY_GROUP            (1 << 4)
#define VERIFY_MTIME            (1 << 5)
#define VERIFY_MODE             (1 << 6)
#define VERIFY_RDEV             (1 << 7)
#define VERIFY_ALL              ~(VERIFY_NONE)

#define REQUIRE_ANY             0
#define REQUIRE_SERIAL          (1 << 0)
#define REQUIRE_LESS            (1 << 1)
#define REQUIRE_GREATER         (1 << 2)
#define REQUIRE_EQUAL           (1 << 3)
#define REQUIRE_PROVIDES        (1 << 4)   /* only used internally by builds */
#define REQUIRE_CONFLICTS       (1 << 5)   /* only used internally by builds */
#define REQUIRE_SENSEMASK       15         /* Mask to get senses */

/* Stuff for maintaining "variables" like SOURCEDIR, BUILDDIR, etc */

#define RPMVAR_SOURCEDIR     		0
#define RPMVAR_BUILDDIR      		1
/* #define RPMVAR_DOCDIR        	2 -- No longer used */
#define RPMVAR_OPTFLAGS      		3
#define RPMVAR_TOPDIR        		4
#define RPMVAR_SPECDIR       		5
#define RPMVAR_ROOT          		6
#define RPMVAR_RPMDIR        		7
#define RPMVAR_SRPMDIR       		8
/* #define RPMVAR_ARCHSENSITIVE 	9  -- No longer used */
#define RPMVAR_REQUIREDISTRIBUTION	10
/* #define RPMVAR_REQUIREGROUP		11 -- No longer used */
#define RPMVAR_REQUIREVENDOR		12
#define RPMVAR_DISTRIBUTION		13
#define RPMVAR_VENDOR			14
#define RPMVAR_MESSAGELEVEL		15
#define RPMVAR_REQUIREICON		16
#define RPMVAR_TIMECHECK		17
#define RPMVAR_SIGTYPE                  18
#define RPMVAR_PGP_PATH                 19
#define RPMVAR_PGP_NAME                 20
/* #define RPMVAR_PGP_SECRING           21 -- No longer used */
/* #define RPMVAR_PGP_PUBRING           22 -- No longer used */
#define RPMVAR_EXCLUDEDOCS              23
/* #define RPMVAR_BUILDARCH             24 -- No longer used */
/* #define RPMVAR_BUILDOS               25 -- No longer used */
#define RPMVAR_BUILDROOT                26
#define RPMVAR_DBPATH                   27
#define RPMVAR_PACKAGER                 28
#define RPMVAR_LASTVAR	                29 /* IMPORTANT to keep right! */

char *getVar(int var);
int getBooleanVar(int var);
void setVar(int var, char *val);

/* rpmrc.c */
int rpmReadConfigFiles(char * file, char * arch, char * os, int building);
int getOsNum(void);
int getArchNum(void);
char *getOsName(void);
char *getArchName(void);
int rpmShowRC(FILE *f);

typedef struct rpmdb * rpmdb;

typedef void (*notifyFunction)(const unsigned long amount,
			       const unsigned long total);

int rpmdbOpen (char * prefix, rpmdb * dbp, int mode, int perms);
    /* 0 on error */
int rpmdbInit(char * prefix, int perms);
    /* nonzero on error */
void rpmdbClose (rpmdb db);

unsigned int rpmdbFirstRecNum(rpmdb db);
unsigned int rpmdbNextRecNum(rpmdb db, unsigned int lastOffset);  
    /* 0 at end */

Header rpmdbGetRecord(rpmdb db, unsigned int offset);
int rpmdbFindByFile(rpmdb db, char * filespec, dbIndexSet * matches);
int rpmdbFindByGroup(rpmdb db, char * group, dbIndexSet * matches);
int rpmdbFindPackage(rpmdb db, char * name, dbIndexSet * matches);
int rpmdbFindByProvides(rpmdb db, char * filespec, dbIndexSet * matches);
int rpmdbFindByRequiredBy(rpmdb db, char * filespec, dbIndexSet * matches);

int rpmArchScore(char * arch);
int rpmOsScore(char * arch);
int rpmInstallSourcePackage(char * prefix, int fd, char ** specFile);
int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * prefix, 
		     int flags, notifyFunction notify, char * labelFormat);
int rpmRemovePackage(char * prefix, rpmdb db, unsigned int offset, int test);
int rpmdbRemove(rpmdb db, unsigned int offset, int tolerant);
int rpmdbAdd(rpmdb db, Header dbentry);
int rpmdbUpdateRecord(rpmdb db, int secOffset, Header secHeader);
int rpmVerifyFile(char * prefix, Header h, int filenum, int * result);

typedef struct rpmDependencyCheck * rpmDependencies;

struct rpmDependencyConflict {
    char * byName, * byVersion, * byRelease;
    char * needsName, * needsVersion;
    int needsFlags;
    enum { RPMDEP_SENSE_REQUIRES, RPMDEP_SENSE_CONFLICTS } sense;
} ;

rpmDependencies rpmdepDependencies(rpmdb db); 	       /* db may be NULL */
void rpmdepAddPackage(rpmDependencies rpmdep, Header h);
void rpmdepUpgradePackage(rpmDependencies rpmdep, Header h);
void rpmdepRemovePackage(rpmDependencies rpmdep, int dboffset);
int rpmdepCheck(rpmDependencies rpmdep, 
		struct rpmDependencyConflict ** conflicts, int * numConflicts);
void rpmdepDone(rpmDependencies rpmdep);

int mdfile(char *fn, unsigned char *digest);

#endif