00001 #ifndef _H_RPMBUILD_
00002 #define _H_RPMBUILD_
00003
00009 #include "rpmlib.h"
00010
00011
00012 #include "stringbuf.h"
00013 #include "misc.h"
00014
00015
00016 #include "rpmspec.h"
00017
00021 typedef enum rpmBuildFlags_e {
00022 RPMBUILD_PREP = (1 << 0),
00023 RPMBUILD_BUILD = (1 << 1),
00024 RPMBUILD_INSTALL = (1 << 2),
00025 RPMBUILD_CLEAN = (1 << 3),
00026 RPMBUILD_FILECHECK = (1 << 4),
00027 RPMBUILD_PACKAGESOURCE = (1 << 5),
00028 RPMBUILD_PACKAGEBINARY = (1 << 6),
00029 RPMBUILD_RMSOURCE = (1 << 7),
00030 RPMBUILD_RMBUILD = (1 << 8),
00031 RPMBUILD_STRINGBUF = (1 << 9),
00032 RPMBUILD_RMSPEC = (1 << 10)
00033 } rpmBuildFlags;
00034
00035 #include <ctype.h>
00036
00037 #define FREE(x) { if (x) free((void *)x); x = NULL; }
00038 #define SKIPSPACE(s) { while (*(s) && isspace(*(s))) (s)++; }
00039 #define SKIPNONSPACE(s) { while (*(s) && !isspace(*(s))) (s)++; }
00040
00041 #define PART_SUBNAME 0
00042 #define PART_NAME 1
00043
00047 typedef enum rpmParseState_e {
00048 PART_NONE = 0,
00049 PART_PREAMBLE = 1,
00050 PART_PREP = 2,
00051 PART_BUILD = 3,
00052 PART_INSTALL = 4,
00053 PART_CLEAN = 5,
00054 PART_FILES = 6,
00055 PART_PRE = 7,
00056 PART_POST = 8,
00057 PART_PREUN = 9,
00058 PART_POSTUN = 10,
00059 PART_DESCRIPTION = 11,
00060 PART_CHANGELOG = 12,
00061 PART_TRIGGERIN = 13,
00062 PART_TRIGGERUN = 14,
00063 PART_VERIFYSCRIPT = 15,
00064 PART_BUILDARCHITECTURES= 16,
00065 PART_TRIGGERPOSTUN = 17,
00066 PART_LAST = 18
00067 } rpmParseState;
00068
00069 #define STRIP_NOTHING 0
00070 #define STRIP_TRAILINGSPACE (1 << 0)
00071 #define STRIP_COMMENTS (1 << 1)
00072
00073 #ifdef __cplusplus
00074 extern "C" {
00075 #endif
00076
00080 void freeNames(void);
00081
00088 const char *getUname(uid_t uid);
00089
00096 const char *getUnameS(const char *uname);
00097
00104 const char *getGname(gid_t gid);
00105
00112 const char *getGnameS(const char *gname);
00113
00118 const char *const buildHost(void);
00119
00124 time_t *const getBuildTime(void);
00125
00132 int readLine(Spec spec, int strip);
00133
00138 void closeSpec(Spec spec);
00139
00144 void handleComments(char *s);
00145
00151 rpmParseState isPart(const char *line);
00152
00159 int parseNum(const char *line, int *res);
00160
00168 void addChangelogEntry(Header h, time_t time, const char *name, const char *text);
00169
00176 int parseBuildInstallClean(Spec spec, rpmParseState parsePart);
00177
00183 int parseChangelog(Spec spec);
00184
00190 int parseDescription(Spec spec);
00191
00197 int parseFiles(Spec spec);
00198
00205 int parsePreamble(Spec spec, int initialPackage);
00206
00212 int parsePrep(Spec spec);
00213
00224 int parseRCPOT(Spec spec, Package pkg, const char *field, int tag, int index,
00225 int flags);
00226
00233 int parseScript(Spec spec, int parsePart);
00234
00243 int parseTrigger(Spec spec, Package pkg, char *field, int tag);
00244
00251 int parseExpressionBoolean(Spec spec, const char * expr);
00252
00259 char *parseExpressionString(Spec spec, const char * expr);
00260
00271 int doScript(Spec spec, int what, const char *name, StringBuf sb, int test);
00272
00281 int lookupPackage(Spec spec, const char *name, int flag, Package *pkg);
00282
00288 Package newPackage(Spec spec);
00289
00294 void freePackages(Spec spec);
00295
00300 void freePackage( Package pkg);
00301
00312 int addReqProv(Spec spec, Header h,
00313 int flag, const char *depName, const char *depEVR, int index);
00314
00322 int rpmlibNeedsFeature(Header h, const char * feature, const char * featureEVR);
00323
00331 int processBinaryFiles(Spec spec, int installSpecialDoc, int test);
00332
00337 void initSourceHeader(Spec spec);
00338
00344 int processSourceFiles(Spec spec);
00345
00346
00347
00361 int parseSpec(Spec *specp, const char *specFile, const char *rootdir,
00362 const char *buildRoot, int inBuildArch, const char *passPhrase,
00363 char *cookie, int anyarch, int force);
00364
00377 extern int (*parseSpecVec) (Spec *specp, const char *specFile,
00378 const char *rootdir, const char *buildRoot,
00379 int inBuildArch, const char *passPhrase,
00380 char *cookie, int anyarch, int force);
00381
00389 int buildSpec(Spec spec, int what, int test);
00390
00396 int packageBinaries(Spec spec);
00397
00403 int packageSources(Spec spec);
00404
00405 #ifdef __cplusplus
00406 }
00407 #endif
00408
00409 #endif