Add macro %isu_package to generate ISU Package
[platform/upstream/rpm.git] / lib / rpmlib.h
1 #ifndef H_RPMLIB
2 #define H_RPMLIB
3
4 /** \ingroup rpmcli rpmrc rpmdep rpmtrans rpmdb lead signature header payload dbi
5  * \file lib/rpmlib.h
6  *
7  * In Memoriam: Steve Taylor <staylor@redhat.com> was here, now he's not.
8  *
9  */
10
11 #include <popt.h>
12
13 #include <rpm/rpmio.h>
14 #include <rpm/header.h>
15 #include <rpm/rpmtag.h>
16 #include <rpm/rpmds.h>  /* XXX move rpmlib provides to rpmds instead */
17 #include <rpm/rpmpgp.h>
18 #ifdef _RPM_4_4_COMPAT
19 #include <rpm/rpmlegacy.h> /* legacy compat definitions if enabled */
20 #endif
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 extern struct rpmMacroContext_s * rpmGlobalMacroContext;
27
28 extern struct rpmMacroContext_s * rpmCLIMacroContext;
29
30 extern const char * const RPMVERSION;
31
32 extern const char * const rpmNAME;
33
34 extern const char * const rpmEVR;
35
36 extern const int rpmFLAGS;
37
38 /* ==================================================================== */
39 /** \name RPMRC */
40
41 /** \ingroup rpmrc
42  * Build and install arch/os table identifiers.
43  * @todo Eliminate from API.
44  */
45 enum rpm_machtable_e {
46     RPM_MACHTABLE_INSTARCH      = 0,    /*!< Install platform architecture. */
47     RPM_MACHTABLE_INSTOS        = 1,    /*!< Install platform operating system. */
48     RPM_MACHTABLE_BUILDARCH     = 2,    /*!< Build platform architecture. */
49     RPM_MACHTABLE_BUILDOS       = 3     /*!< Build platform operating system. */
50 };
51 #define RPM_MACHTABLE_COUNT     4       /*!< No. of arch/os tables. */
52
53 /** \ingroup rpmrc
54  * Read macro configuration file(s) for a target.
55  * @param file          colon separated files to read (NULL uses default)
56  * @param target        target platform (NULL uses default)
57  * @return              0 on success, -1 on error
58  */
59 int rpmReadConfigFiles(const char * file,
60                 const char * target);
61
62 /** \ingroup rpmrc
63  * Return current arch name and/or number.
64  * @todo Generalize to extract arch component from target_platform macro.
65  * @retval name         address of arch name (or NULL)
66  * @retval num          address of arch number (or NULL)
67  */
68 void rpmGetArchInfo( const char ** name,
69                 int * num);
70
71 /** \ingroup rpmrc
72  * Return color for an arch
73  * @param arch          name of an architecture
74  * @return color        color of arch, -1 if the arch couldn't be determined
75  */
76 int rpmGetArchColor(const char *arch);
77
78 /** \ingroup rpmrc
79  * Return current os name and/or number.
80  * @todo Generalize to extract os component from target_platform macro.
81  * @retval name         address of os name (or NULL)
82  * @retval num          address of os number (or NULL)
83  */
84 void rpmGetOsInfo( const char ** name,
85                 int * num);
86
87 /** \ingroup rpmrc
88  * Return arch/os score of a name.
89  * An arch/os score measures the "nearness" of a name to the currently
90  * running (or defined) platform arch/os. For example, the score of arch
91  * "i586" on an i686 platform is (usually) 2. The arch/os score is used
92  * to select one of several otherwise identical packages using the arch/os
93  * tags from the header as hints of the intended platform for the package.
94  * @todo Rewrite to use RE's against config.guess target platform output.
95  *
96  * @param type          any of the RPM_MACHTABLE_* constants
97  * @param name          name
98  * @return              arch score (0 is no match, lower is preferred)
99  */
100 int rpmMachineScore(int type, const char * name);
101
102 /** \ingroup rpmrc
103  * Display current rpmrc (and macro) configuration.
104  * @param fp            output file handle
105  * @return              0 always
106  */
107 int rpmShowRC(FILE * fp);
108
109 /** \ingroup rpmrc
110  * Destroy rpmrc arch/os compatibility tables.
111  * @todo Eliminate from API.
112  */
113 void rpmFreeRpmrc(void);
114
115 /**
116  * Compare headers to determine which header is "newer".
117  * @param first         1st header
118  * @param second        2nd header
119  * @return              result of comparison
120  */
121 int rpmVersionCompare(Header first, Header second);
122
123 /**  \ingroup header
124  * Check header consistency, performing headerGetEntry() the hard way.
125  *  
126  * Sanity checks on the header are performed while looking for a
127  * header-only digest or signature to verify the blob. If found,
128  * the digest or signature is verified.
129  *
130  * @param ts            transaction set
131  * @param uh            unloaded header blob
132  * @param uc            no. of bytes in blob (or 0 to disable)
133  * @retval *msg         verification error message (or NULL)
134  * @return              RPMRC_OK on success
135  */
136 rpmRC headerCheck(rpmts ts, const void * uh, size_t uc, char ** msg);
137
138 /**  \ingroup header
139  * Return checked and loaded header.
140  * @param ts            transaction set
141  * @param fd            file handle
142  * @retval hdrp         address of header (or NULL)
143  * @retval *msg         verification error message (or NULL)
144  * @return              RPMRC_OK on success
145  */
146 rpmRC rpmReadHeader(rpmts ts, FD_t fd, Header *hdrp, char ** msg);
147
148 /** \ingroup header
149  * Return package header from file handle, verifying digests/signatures.
150  * @param ts            transaction set
151  * @param fd            file handle
152  * @param fn            file name
153  * @retval hdrp         address of header (or NULL)
154  * @return              RPMRC_OK on success
155  */
156 rpmRC rpmReadPackageFile(rpmts ts, FD_t fd,
157                 const char * fn, Header * hdrp);
158
159 /** \ingroup rpmtrans
160  * Install source package.
161  * @param ts            transaction set
162  * @param fd            file handle
163  * @retval specFilePtr  address of spec file name (or NULL)
164  * @retval cookie       address of cookie pointer (or NULL)
165  * @return              rpmRC return code
166  */
167 rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
168                         char ** specFilePtr,
169                         char ** cookie);
170
171 /** \ingroup rpmtrans
172  * Segmented string compare for version or release strings.
173  *
174  * @param a             1st string
175  * @param b             2nd string
176  * @return              +1 if a is "newer", 0 if equal, -1 if b is "newer"
177  */
178 int rpmvercmp(const char * a, const char * b);
179
180 #ifdef __cplusplus
181 }
182 #endif
183
184 #endif  /* H_RPMLIB */