From 5142bf78e626b861ec1af6be7d81d3bb5c0afe03 Mon Sep 17 00:00:00 2001 From: jbj Date: Thu, 30 Jul 1998 22:09:42 +0000 Subject: [PATCH] Consolidated includes for librpmbuild API. CVS patchset: 2213 CVS date: 1998/07/30 22:09:42 --- CHANGES | 1 + build.c | 6 +- build/Makefile.in | 10 +- build/build.c | 9 +- build/build.h | 28 ----- build/files.c | 28 +---- build/files.h | 1 - build/macro.c | 7 +- build/misc.c | 6 +- build/misc.h | 39 ------ build/names.c | 9 +- build/names.h | 24 ---- build/pack.c | 12 +- build/pack.h | 17 --- build/package.c | 148 ---------------------- build/package.h | 17 --- build/parse.h | 27 ---- build/parseBuildInstallClean.c | 4 +- build/parseChangelog.c | 203 +++++++++++++++--------------- build/parseDescription.c | 9 +- build/parseFiles.c | 9 +- build/parsePreamble.c | 10 +- build/parsePrep.c | 10 +- build/parseReqs.c | 4 +- build/parseScript.c | 10 +- build/parseSpec.c | 273 ++++++++++++++++++++++++++++++++++++----- build/part.c | 65 ---------- build/part.h | 33 ----- build/read.c | 156 ----------------------- build/read.h | 26 ---- build/reqprov.c | 7 +- build/reqprov.h | 25 ---- build/rpmbuild.h | 150 ++++++++++++++++++++++ build/spec.c | 167 +++++++++++++++++++++++-- build/spec.h | 3 - checksig.c | 5 +- configure.in | 4 +- convertdb.c | 6 +- ftp.c | 7 +- install.c | 5 +- lib/cpio.c | 3 - lib/dbindex.c | 9 +- lib/dbindex.h | 12 +- lib/depends.c | 4 +- lib/formats.c | 5 +- lib/fs.c | 5 +- lib/header.c | 5 +- lib/install.c | 11 +- lib/lookup.c | 4 +- lib/messages.c | 4 +- lib/misc.c | 6 +- lib/oldheader.c | 4 +- lib/package.c | 5 +- lib/rebuilddb.c | 3 +- lib/rpmdb.c | 4 +- lib/rpmlead.c | 2 +- lib/rpmlib.h | 7 +- lib/rpmrc.c | 6 +- lib/signature.c | 5 +- lib/stringbuf.c | 1 - lib/test.c | 1 - lib/tread.c | 3 - lib/uninstall.c | 6 +- lib/verify.c | 5 +- misc/fnmatch.c | 2 - misc/getmntent.c | 7 +- misc/glob.c | 6 +- misc/inet_aton.c | 1 - misc/miscfn.h | 12 -- oldrpmdb.c | 7 +- query.c | 8 +- rpm-qo.c | 5 +- rpm.c | 9 +- rpm2cpio.c | 2 - rpmio/messages.c | 4 +- system.h | 49 ++++++++ tools/dump.c | 8 +- tools/dumpdb.c | 10 +- tools/rpmarchive.c | 4 +- tools/rpmchecksig.c | 5 +- tools/rpmheader.c | 4 +- tools/rpmlead.c | 4 +- tools/rpmsignature.c | 4 +- url.c | 6 +- verify.c | 4 +- 85 files changed, 799 insertions(+), 1062 deletions(-) delete mode 100644 build/build.h delete mode 100644 build/misc.h delete mode 100644 build/names.h delete mode 100644 build/pack.h delete mode 100644 build/package.c delete mode 100644 build/package.h delete mode 100644 build/parse.h delete mode 100644 build/part.c delete mode 100644 build/part.h delete mode 100644 build/read.c delete mode 100644 build/read.h delete mode 100644 build/reqprov.h create mode 100644 build/rpmbuild.h delete mode 100644 misc/miscfn.h diff --git a/CHANGES b/CHANGES index 965eeef..bdb8324 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,5 @@ 2.5.3 -> 2.9 + - consolidated includes for librpmbuild. - fixed lib/rpmrc.c to accept include: tags (AdV) - fixed the CHANGES file to reflect that this is 2.9, not 3.0 (AdV) - aggregate system includes into system.h. diff --git a/build.c b/build.c index c564216..35ef5a2 100644 --- a/build.c +++ b/build.c @@ -1,11 +1,9 @@ #include "system.h" +#include "build/rpmbuild.h" + #include "build.h" #include "intl.h" -#include "lib/rpmlib.h" -#include "build/build.h" -#include "build/parse.h" -#include "build/spec.h" int build(char *arg, int buildAmount, char *passPhrase, char *buildRoot, int fromTarball, int test, char *cookie) { diff --git a/build/Makefile.in b/build/Makefile.in index b013509..46968c3 100644 --- a/build/Makefile.in +++ b/build/Makefile.in @@ -3,12 +3,10 @@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ LIBOBJECTS = \ -misc.o parsePreamble.o part.o \ -package.o parseDescription.o parsePrep.o read.o \ -parseFiles.o parseReqs.o reqprov.o \ -parseChangelog.o parseSpec.o spec.o \ -parseScript.o parseBuildInstallClean.o build.o \ -files.o myftw.o names.o pack.o macro.o + build.o files.o macro.o misc.o myftw.o names.o pack.o \ + parseBuildInstallClean.o parseChangelog.o parseDescription.o \ + parseFiles.o parsePreamble.o parsePrep.o parseReqs.o \ + parseScript.o parseSpec.o reqprov.o spec.o LIBBUILD = librpmbuild.a LOADLIBES = -lrpm -lz ../popt/libpopt.a $(LIBEFENCE) diff --git a/build/build.c b/build/build.c index 8ffc02d..8f4dcc5 100644 --- a/build/build.c +++ b/build/build.c @@ -1,12 +1,7 @@ #include "system.h" -#include "misc.h" -#include "spec.h" -#include "build.h" -#include "lib/misc.h" -#include "lib/messages.h" -#include "rpmlib.h" -#include "pack.h" +#include "rpmbuild.h" + #include "files.h" #ifdef DYING diff --git a/build/build.h b/build/build.h deleted file mode 100644 index 290596f..0000000 --- a/build/build.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _H_BUILD_ -#define _H_BUILD_ - -#include "spec.h" - -#define RPMBUILD_PREP (1 << 0) -#define RPMBUILD_BUILD (1 << 1) -#define RPMBUILD_INSTALL (1 << 2) -#define RPMBUILD_CLEAN (1 << 3) -#define RPMBUILD_FILECHECK (1 << 4) -#define RPMBUILD_PACKAGESOURCE (1 << 5) -#define RPMBUILD_PACKAGEBINARY (1 << 6) -#define RPMBUILD_RMSOURCE (1 << 7) -#define RPMBUILD_RMBUILD (1 << 8) -#define RPMBUILD_STRINGBUF (1 << 9) /* only for doScript() */ - -#ifdef __cplusplus -extern "C" { -#endif - -int buildSpec(Spec spec, int what, int test); -int doScript(Spec spec, int what, char *name, StringBuf sb, int test); - -#ifdef __cplusplus -} -#endif - -#endif /* _H_BUILD_ */ diff --git a/build/files.c b/build/files.c index e0a38d3..604e24a 100644 --- a/build/files.c +++ b/build/files.c @@ -2,23 +2,13 @@ #include #include /* getOutputFrom() */ -#include -#include "spec.h" -#include "package.h" -#include "rpmlib.h" -#include "misc.h" -#include "lib/misc.h" +#include "rpmbuild.h" + #include "myftw.h" #include "lib/cpio.h" -#include "header.h" #include "md5.h" -#include "names.h" -#include "messages.h" #include "macro.h" -#include "build.h" -#include "read.h" -#include "reqprov.h" #define MAXDOCDIR 1024 @@ -1227,20 +1217,6 @@ static int processPackageFiles(Spec spec, Package pkg, return fl.processingFailed; } -void freeCpioList(struct cpioFileMapping *cpioList, int cpioCount) -{ - struct cpioFileMapping *p = cpioList; - - while (cpioCount--) { - rpmMessage(RPMMESS_DEBUG, "archive = %s, fs = %s\n", - p->archivePath, p->fsPath); - FREE(p->archivePath); - FREE(p->fsPath); - p++; - } - FREE(cpioList); -} - int processSourceFiles(Spec spec) { struct Source *srcPtr; diff --git a/build/files.h b/build/files.h index 462b549..8094a14 100644 --- a/build/files.h +++ b/build/files.h @@ -2,7 +2,6 @@ #define _H_FILES_ #include "spec.h" -#include "package.h" #include "lib/cpio.h" #ifdef __cplusplus diff --git a/build/macro.c b/build/macro.c index 5639457..eae2ed4 100644 --- a/build/macro.c +++ b/build/macro.c @@ -11,10 +11,9 @@ typedef void * Spec; #define RPMERR_BADSPEC stderr #define FREE(_x) { if (_x) free(_x); ((void *)(_x)) = NULL; } #else -#include "spec.h" -#include "miscfn.h" -#include "misc.h" -#include "lib/rpmlib.h" + +#include "rpmbuild.h" + #endif #include "macro.h" diff --git a/build/misc.c b/build/misc.c index e74bc1e..773854b 100644 --- a/build/misc.c +++ b/build/misc.c @@ -1,9 +1,7 @@ #include "system.h" -#include "misc.h" -#include "spec.h" -#include "rpmlib.h" -#include "header.h" +#include "rpmbuild.h" + #include "popt/popt.h" int parseNum(char *line, int *res) diff --git a/build/misc.h b/build/misc.h deleted file mode 100644 index b88c5c8..0000000 --- a/build/misc.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef _H_MISC_ -#define _H_MISC_ - -#include "spec.h" -#include "ctype.h" - -#define FREE(x) { if (x) free(x); x = NULL; } - -#define SKIPSPACE(s) { while (*(s) && isspace(*(s))) (s)++; } - -#define SKIPNONSPACE(s) { while (*(s) && !isspace(*(s))) (s)++; } - -#define SKIPTONEWLINE(s) { while (*s && *s != '\n') s++; } - -#define PART_SUBNAME 0 -#define PART_NAME 1 - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef DYING -void addOrAppendListEntry(Header h, int_32 tag, char *line); -int parseSimplePart(char *line, char **name, int *flag); -char *findLastChar(char *s); -int parseYesNo(char *s); -StringBuf getOutputFrom(char *dir, char *argv[], - char *writePtr, int writeBytesLeft, - int failNonZero); -#endif /* DYING */ - -int parseNum(char *line, int *res); -char *cleanFileName(char *name); - -#ifdef __cplusplus -} -#endif - -#endif /* _H_MISC_ */ diff --git a/build/names.c b/build/names.c index 6850ec1..94de2cd 100644 --- a/build/names.c +++ b/build/names.c @@ -2,14 +2,7 @@ #include "system.h" -#include -#include -#include -#include - -#include "names.h" -#include "rpmlib.h" -#include "messages.h" +#include "rpmbuild.h" static uid_t uids[1024]; static char *unames[1024]; diff --git a/build/names.h b/build/names.h deleted file mode 100644 index 49bf2f1..0000000 --- a/build/names.h +++ /dev/null @@ -1,24 +0,0 @@ -/* names.h -- user/group name/id cache plus hostname and buildtime */ - -#ifndef _H_NAMES_ -#define _H_NAMES_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -char *getUname(uid_t uid); -char *getUnameS(char *uname); -char *getGname(gid_t gid); -char *getGnameS(char *gname); - -char *buildHost(void); -time_t *getBuildTime(void); - -#ifdef __cplusplus -} -#endif - -#endif /* _H_NAMES_ */ diff --git a/build/pack.c b/build/pack.c index 9fc2ee8..fb34b45 100644 --- a/build/pack.c +++ b/build/pack.c @@ -1,22 +1,14 @@ #include "system.h" #include -#include -#include "spec.h" -#include "header.h" -#include "misc.h" -#include "reqprov.h" -#include "names.h" -#include "macro.h" +#include "rpmbuild.h" -#include "rpmlib.h" #include "files.h" + #include "lib/cpio.h" -#include "lib/misc.h" #include "lib/signature.h" #include "lib/rpmlead.h" -#include "lib/messages.h" #define RPM_MAJOR_NUMBER 3 diff --git a/build/pack.h b/build/pack.h deleted file mode 100644 index d9c55d5..0000000 --- a/build/pack.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _H_PACK_ -#define _H_PACK_ - -#include "spec.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int packageBinaries(Spec spec); -int packageSources(Spec spec); - -#ifdef __cplusplus -} -#endif - -#endif /* _H_PACK_ */ diff --git a/build/package.c b/build/package.c deleted file mode 100644 index fb20934..0000000 --- a/build/package.c +++ /dev/null @@ -1,148 +0,0 @@ -#include "system.h" - -#include "spec.h" -#include "package.h" -#include "misc.h" -#include "rpmlib.h" -#include "files.h" - -static void freeTriggerFiles(struct TriggerFileEntry *p); - -int lookupPackage(Spec spec, char *name, int flag, Package *pkg) -{ - char buf[BUFSIZ]; - char *n, *fullName; - Package p; - - /* "main" package */ - if (! name) { - if (pkg) { - *pkg = spec->packages; - } - return 0; - } - - /* Construct package name */ - if (flag == PART_SUBNAME) { - headerGetEntry(spec->packages->header, RPMTAG_NAME, - NULL, (void *) &n, NULL); - sprintf(buf, "%s-%s", n, name); - fullName = buf; - } else { - fullName = name; - } - - p = spec->packages; - while (p) { - headerGetEntry(p->header, RPMTAG_NAME, NULL, (void *) &n, NULL); - if (n && (! strcmp(fullName, n))) { - if (pkg) { - *pkg = p; - } - return 0; - } - p = p->next; - } - - if (pkg) { - *pkg = NULL; - } - return 1; -} - -Package newPackage(Spec spec) -{ - Package p; - Package pp; - - p = malloc(sizeof(*p)); - - p->header = headerNew(); - p->icon = NULL; - p->autoReqProv = 1; - -#if 0 - p->reqProv = NULL; - p->triggers = NULL; - p->triggerScripts = NULL; -#endif - - p->triggerFiles = NULL; - - p->fileFile = NULL; - p->fileList = NULL; - p->next = NULL; - - p->cpioList = NULL; - p->cpioCount = 0; - - p->preInFile = NULL; - p->postInFile = NULL; - p->preUnFile = NULL; - p->postUnFile = NULL; - p->verifyFile = NULL; - - p->specialDoc = NULL; - - if (! spec->packages) { - spec->packages = p; - } else { - /* Always add package to end of list */ - pp = spec->packages; - while (pp->next) { - pp = pp->next; - } - pp->next = p; - } - - return p; -} - -void freePackages(Spec spec) -{ - Package p; - - while (spec->packages) { - p = spec->packages; - spec->packages = p->next; - freePackage(p); - } -} - -void freePackage(Package p) -{ - if (! p) { - return; - } - - FREE(p->preInFile); - FREE(p->postInFile); - FREE(p->preUnFile); - FREE(p->postUnFile); - FREE(p->verifyFile); - - headerFree(p->header); - freeStringBuf(p->fileList); - FREE(p->fileFile); - freeCpioList(p->cpioList, p->cpioCount); - - freeStringBuf(p->specialDoc); - - freeTriggerFiles(p->triggerFiles); - - free(p); -} - -static void freeTriggerFiles(struct TriggerFileEntry *p) -{ - struct TriggerFileEntry *o; - - while (p) { - FREE(p->fileName); - FREE(p->script); - FREE(p->prog); - o = p; - p = p->next; - free(o); - } -} diff --git a/build/package.h b/build/package.h deleted file mode 100644 index 80e0ec6..0000000 --- a/build/package.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _H_PACKAGE_ -#define _H_PACKAGE_ - -#ifdef __cplusplus -extern "C" { -#endif - -int lookupPackage(Spec spec, char *name, int flag, Package *pkg); -Package newPackage(Spec spec); -void freePackages(Spec spec); -void freePackage(Package p); - -#ifdef __cplusplus -} -#endif - -#endif /* _H_PACKAGE_ */ diff --git a/build/parse.h b/build/parse.h deleted file mode 100644 index 917b8cd..0000000 --- a/build/parse.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _H_PARSE_ -#define _H_PARSE_ - -#ifdef __cplusplus -extern "C" { -#endif - -int parseChangelog(Spec spec); -int parseDescription(Spec spec); -int parseFiles(Spec spec); -int parsePreamble(Spec spec, int initialPackage); -int parsePrep(Spec spec); -int parseRequiresConflicts(Spec spec, Package pkg, char *field, - int tag, int index); -int parseProvidesObsoletes(Spec spec, Package pkg, char *field, int tag); -int parseTrigger(Spec spec, Package pkg, char *field, int tag); -int parseScript(Spec spec, int parsePart); -int parseBuildInstallClean(Spec spec, int parsePart); - -int parseSpec(Spec *specp, char *specFile, char *buildRoot, - int inBuildArch, char *passPhrase, char *cookie); - -#ifdef __cplusplus -} -#endif - -#endif /* _H_PARSE_ */ diff --git a/build/parseBuildInstallClean.c b/build/parseBuildInstallClean.c index 76ef92c..ee7c17a 100644 --- a/build/parseBuildInstallClean.c +++ b/build/parseBuildInstallClean.c @@ -1,8 +1,6 @@ #include "system.h" -#include "read.h" -#include "part.h" -#include "rpmlib.h" +#include "rpmbuild.h" int parseBuildInstallClean(Spec spec, int parsePart) { diff --git a/build/parseChangelog.c b/build/parseChangelog.c index 6703b8c..cb35401 100644 --- a/build/parseChangelog.c +++ b/build/parseChangelog.c @@ -1,49 +1,87 @@ #include "system.h" -#include - -#include "read.h" -#include "part.h" -#include "stringbuf.h" -#include "misc.h" -#include "header.h" -#include "rpmlib.h" +#include "rpmbuild.h" +#ifdef DYING static void addChangelogEntry(Header h, int time, char *name, char *text); static int addChangelog(Header h, StringBuf sb); static int dateToTimet(const char * datestr, time_t * secs); - -int parseChangelog(Spec spec) -{ - int nextPart, res, rc; - StringBuf sb; +#endif - sb = newStringBuf(); - - /* There are no options to %changelog */ - if ((rc = readLine(spec, STRIP_COMMENTS)) > 0) { - freeStringBuf(sb); - return PART_NONE; - } - if (rc) { - return rc; +static void addChangelogEntry(Header h, int time, char *name, char *text) +{ + if (headerIsEntry(h, RPMTAG_CHANGELOGTIME)) { + headerAppendEntry(h, RPMTAG_CHANGELOGTIME, RPM_INT32_TYPE, + &time, 1); + headerAppendEntry(h, RPMTAG_CHANGELOGNAME, RPM_STRING_ARRAY_TYPE, + &name, 1); + headerAppendEntry(h, RPMTAG_CHANGELOGTEXT, RPM_STRING_ARRAY_TYPE, + &text, 1); + } else { + headerAddEntry(h, RPMTAG_CHANGELOGTIME, RPM_INT32_TYPE, + &time, 1); + headerAddEntry(h, RPMTAG_CHANGELOGNAME, RPM_STRING_ARRAY_TYPE, + &name, 1); + headerAddEntry(h, RPMTAG_CHANGELOGTEXT, RPM_STRING_ARRAY_TYPE, + &text, 1); } +} + +/* datestr is of the form 'Wed Jan 1 1997' */ +static int dateToTimet(const char * datestr, time_t * secs) +{ + struct tm time; + char * chptr, * end, ** idx; + char * date = strcpy(alloca(strlen(datestr) + 1), datestr); + static char * days[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", + NULL }; + static char * months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL }; + static char lengths[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - while (! (nextPart = isPart(spec->line))) { - appendStringBuf(sb, spec->line); - if ((rc = readLine(spec, STRIP_COMMENTS)) > 0) { - nextPart = PART_NONE; - break; - } - if (rc) { - return rc; - } - } + memset(&time, 0, sizeof(time)); - res = addChangelog(spec->packages->header, sb); - freeStringBuf(sb); + end = chptr = date; - return (res) ? res : nextPart; + /* day of week */ + if ((chptr = strtok(date, " \t\n")) == NULL) return -1; + idx = days; + while (*idx && strcmp(*idx, chptr)) idx++; + if (!*idx) return -1; + + /* month */ + if ((chptr = strtok(NULL, " \t\n")) == NULL) return -1; + idx = months; + while (*idx && strcmp(*idx, chptr)) idx++; + if (!*idx) return -1; + + time.tm_mon = idx - months; + + /* day */ + if ((chptr = strtok(NULL, " \t\n")) == NULL) return -1; + + /* make this noon so the day is always right (as we make this UTC) */ + time.tm_hour = 12; + + time.tm_mday = strtol(chptr, &chptr, 10); + if (*chptr) return -1; + if (time.tm_mday < 0 || time.tm_mday > lengths[time.tm_mon]) return -1; + + /* year */ + if ((chptr = strtok(NULL, " \t\n")) == NULL) return -1; + + time.tm_year = strtol(chptr, &chptr, 10); + if (*chptr) return -1; + if (time.tm_year < 1997 || time.tm_year >= 3000) return -1; + time.tm_year -= 1900; + + *secs = mktime(&time); + if (*secs == -1) return -1; + + /* adjust to GMT */ + *secs += timezone; + + return 0; } static int addChangelog(Header h, StringBuf sb) @@ -138,78 +176,35 @@ static int addChangelog(Header h, StringBuf sb) return 0; } -static void addChangelogEntry(Header h, int time, char *name, char *text) +int parseChangelog(Spec spec) { - if (headerIsEntry(h, RPMTAG_CHANGELOGTIME)) { - headerAppendEntry(h, RPMTAG_CHANGELOGTIME, RPM_INT32_TYPE, - &time, 1); - headerAppendEntry(h, RPMTAG_CHANGELOGNAME, RPM_STRING_ARRAY_TYPE, - &name, 1); - headerAppendEntry(h, RPMTAG_CHANGELOGTEXT, RPM_STRING_ARRAY_TYPE, - &text, 1); - } else { - headerAddEntry(h, RPMTAG_CHANGELOGTIME, RPM_INT32_TYPE, - &time, 1); - headerAddEntry(h, RPMTAG_CHANGELOGNAME, RPM_STRING_ARRAY_TYPE, - &name, 1); - headerAddEntry(h, RPMTAG_CHANGELOGTEXT, RPM_STRING_ARRAY_TYPE, - &text, 1); - } -} + int nextPart, res, rc; + StringBuf sb; -/* datestr is of the form 'Wed Jan 1 1997' */ -static int dateToTimet(const char * datestr, time_t * secs) -{ - struct tm time; - char * chptr, * end, ** idx; - char * date = strcpy(alloca(strlen(datestr) + 1), datestr); - static char * days[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", - NULL }; - static char * months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL }; - static char lengths[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + sb = newStringBuf(); - memset(&time, 0, sizeof(time)); - - end = chptr = date; - - /* day of week */ - if ((chptr = strtok(date, " \t\n")) == NULL) return -1; - idx = days; - while (*idx && strcmp(*idx, chptr)) idx++; - if (!*idx) return -1; - - /* month */ - if ((chptr = strtok(NULL, " \t\n")) == NULL) return -1; - idx = months; - while (*idx && strcmp(*idx, chptr)) idx++; - if (!*idx) return -1; - - time.tm_mon = idx - months; - - /* day */ - if ((chptr = strtok(NULL, " \t\n")) == NULL) return -1; - - /* make this noon so the day is always right (as we make this UTC) */ - time.tm_hour = 12; - - time.tm_mday = strtol(chptr, &chptr, 10); - if (*chptr) return -1; - if (time.tm_mday < 0 || time.tm_mday > lengths[time.tm_mon]) return -1; - - /* year */ - if ((chptr = strtok(NULL, " \t\n")) == NULL) return -1; - - time.tm_year = strtol(chptr, &chptr, 10); - if (*chptr) return -1; - if (time.tm_year < 1997 || time.tm_year >= 3000) return -1; - time.tm_year -= 1900; - - *secs = mktime(&time); - if (*secs == -1) return -1; + /* There are no options to %changelog */ + if ((rc = readLine(spec, STRIP_COMMENTS)) > 0) { + freeStringBuf(sb); + return PART_NONE; + } + if (rc) { + return rc; + } + + while (! (nextPart = isPart(spec->line))) { + appendStringBuf(sb, spec->line); + if ((rc = readLine(spec, STRIP_COMMENTS)) > 0) { + nextPart = PART_NONE; + break; + } + if (rc) { + return rc; + } + } - /* adjust to GMT */ - *secs += timezone; + res = addChangelog(spec->packages->header, sb); + freeStringBuf(sb); - return 0; + return (res) ? res : nextPart; } diff --git a/build/parseDescription.c b/build/parseDescription.c index 30c4c80..912823d 100644 --- a/build/parseDescription.c +++ b/build/parseDescription.c @@ -1,12 +1,7 @@ #include "system.h" -#include "spec.h" -#include "header.h" -#include "read.h" -#include "part.h" -#include "misc.h" -#include "rpmlib.h" -#include "package.h" +#include "rpmbuild.h" + #include "popt/popt.h" /* These have to be global scope to make up for *stupid* compilers */ diff --git a/build/parseFiles.c b/build/parseFiles.c index f3a1e66..5fc3c11 100644 --- a/build/parseFiles.c +++ b/build/parseFiles.c @@ -1,12 +1,7 @@ #include "system.h" -#include "header.h" -#include "read.h" -#include "part.h" -#include "misc.h" -#include "rpmlib.h" -#include "package.h" -#include "stringbuf.h" +#include "rpmbuild.h" + #include "popt/popt.h" /* These have to be global scope to make up for *stupid* compilers */ diff --git a/build/parsePreamble.c b/build/parsePreamble.c index 6fbf488..58a1c07 100644 --- a/build/parsePreamble.c +++ b/build/parsePreamble.c @@ -1,13 +1,7 @@ #include "system.h" -#include "read.h" -#include "part.h" -#include "rpmlib.h" -#include "spec.h" -#include "package.h" -#include "misc.h" -#include "reqprov.h" -#include "parse.h" +#include "rpmbuild.h" + #include "popt/popt.h" static int copyTags[] = { diff --git a/build/parsePrep.c b/build/parsePrep.c index a2d73b0..d6c5584 100644 --- a/build/parsePrep.c +++ b/build/parsePrep.c @@ -1,14 +1,8 @@ #include "system.h" -#include "spec.h" -#include "read.h" -#include "part.h" -#include "rpmlib.h" -#include "lib/misc.h" +#include "rpmbuild.h" + #include "popt/popt.h" -#include "names.h" -#include "misc.h" -#include "config.h" /* These have to be global to make up for stupid compilers */ static int leaveDirs, skipDefaultAction; diff --git a/build/parseReqs.c b/build/parseReqs.c index 59eb02e..67cf01a 100644 --- a/build/parseReqs.c +++ b/build/parseReqs.c @@ -1,8 +1,6 @@ #include "system.h" -#include "spec.h" -#include "rpmlib.h" -#include "reqprov.h" +#include "rpmbuild.h" static struct ReqComp { char *token; diff --git a/build/parseScript.c b/build/parseScript.c index 3214c48..ec1f792 100644 --- a/build/parseScript.c +++ b/build/parseScript.c @@ -1,14 +1,8 @@ #include "system.h" -#include "header.h" -#include "read.h" -#include "part.h" -#include "misc.h" -#include "rpmlib.h" +#include "rpmbuild.h" + #include "popt/popt.h" -#include "reqprov.h" -#include "package.h" -#include "parse.h" static int addTriggerIndex(Package pkg, char *file, char *script, char *prog); diff --git a/build/parseSpec.c b/build/parseSpec.c index 4f394b7..af86a9d 100644 --- a/build/parseSpec.c +++ b/build/parseSpec.c @@ -1,14 +1,246 @@ #include "system.h" -#include "header.h" -#include "rpmlib.h" -#include "part.h" -#include "spec.h" -#include "parse.h" -#include "read.h" -#include "misc.h" +#include "rpmbuild.h" +#ifdef DYING static void setStandardMacros(Spec spec, char *arch, char *os); +#endif + +static void setStandardMacros(Spec spec, char *arch, char *os) +{ + char buf[BUFSIZ]; + int x; + + addMacro(&spec->macros, "sourcedir", NULL, rpmGetVar(RPMVAR_SOURCEDIR), -1); + addMacro(&spec->macros, "builddir", NULL, rpmGetVar(RPMVAR_BUILDDIR), -1); + addMacro(&spec->macros, "optflags", NULL, rpmGetVar(RPMVAR_OPTFLAGS), -1); + addMacro(&spec->macros, "buildarch", NULL, arch, -1); + addMacro(&spec->macros, "buildos", NULL, os, -1); + + x = 0; + while (arch[x]) { + buf[x] = tolower(arch[x]); + x++; + } + buf[x] = '\0'; + addMacro(&spec->macros, "buildarch_lc", NULL, buf, -1); + x = 0; + while (os[x]) { + buf[x] = tolower(os[x]); + x++; + } + buf[x] = '\0'; + addMacro(&spec->macros, "buildos_lc", NULL, buf, -1); +} + +static struct PartRec { + int part; + int len; + char *token; +} partList[] = { + {PART_PREAMBLE, 0, "%package"}, + {PART_PREP, 0, "%prep"}, + {PART_BUILD, 0, "%build"}, + {PART_INSTALL, 0, "%install"}, + {PART_CLEAN, 0, "%clean"}, + {PART_PREUN, 0, "%preun"}, + {PART_POSTUN, 0, "%postun"}, + {PART_PRE, 0, "%pre"}, + {PART_POST, 0, "%post"}, + {PART_FILES, 0, "%files"}, + {PART_CHANGELOG, 0, "%changelog"}, + {PART_DESCRIPTION, 0, "%description"}, + {PART_TRIGGERPOSTUN, 0, "%triggerpostun"}, + {PART_TRIGGERUN, 0, "%triggerun"}, + {PART_TRIGGERIN, 0, "%triggerin"}, + {PART_TRIGGERIN, 0, "%trigger"}, + {PART_VERIFYSCRIPT, 0, "%verifyscript"}, + {0, 0, 0} +}; + +static void initParts(void) +{ + struct PartRec *p = partList; + + while (p->token) { + p->len = strlen(p->token); + p++; + } +} + +int isPart(char *line) +{ + char c; + struct PartRec *p = partList; + + if (p->len == 0) { + initParts(); + } + + while (p->token) { + if (! strncmp(line, p->token, p->len)) { + c = *(line + p->len); + if (c == '\0' || isspace(c)) { + break; + } + } + p++; + } + + if (p->token) { + return p->part; + } else { + return PART_NONE; + } +} + +#ifdef DYING +static int matchTok(char *token, char *line); +#endif + +static int matchTok(char *token, char *line) +{ + char buf[BUFSIZ], *tok; + + strcpy(buf, line); + strtok(buf, " \n\t"); + while ((tok = strtok(NULL, " \n\t"))) { + if (! strcmp(tok, token)) { + return 1; + } + } + + return 0; +} + +void handleComments(char *s) +{ + SKIPSPACE(s); + if (*s == '#') { + *s = '\0'; + } +} + +/* returns 0 - success */ +/* 1 - EOF */ +/* <0 - error */ + +int readLine(Spec spec, int strip) +{ + char *from, *to, *last, *s, *arch, *os; + int match; + char ch; + struct ReadLevelEntry *rl; + + /* Make sure the spec file is open */ + if (!spec->file) { + if (!(spec->file = fopen(spec->specFile, "r"))) { + rpmError(RPMERR_BADSPEC, "Unable to open: %s\n", spec->specFile); + return RPMERR_BADSPEC; + } + spec->lineNum = 0; + } + + /* Make sure we have something in the read buffer */ + if (!spec->readPtr || ! *(spec->readPtr)) { + if (!fgets(spec->readBuf, BUFSIZ, spec->file)) { + /* EOF */ + if (spec->readStack->next) { + rpmError(RPMERR_UNMATCHEDIF, "Unclosed %%if"); + return RPMERR_UNMATCHEDIF; + } + return 1; + } + spec->readPtr = spec->readBuf; + spec->lineNum++; + /*rpmMessage(RPMMESS_DEBUG, "LINE: %s", spec->readBuf);*/ + } + + /* Copy a single line to the line buffer */ + from = spec->readPtr; + to = last = spec->line; + ch = ' '; + while (*from && ch != '\n') { + ch = *to++ = *from++; + if (!isspace(ch)) { + last = to; + } + } + *to = '\0'; + spec->readPtr = from; + + if (strip & STRIP_COMMENTS) { + handleComments(spec->line); + } + + if (strip & STRIP_TRAILINGSPACE) { + *last = '\0'; + } + + if (spec->readStack->reading) { + if (expandMacros(spec, &spec->macros, spec->line, sizeof(spec->line))) { + rpmError(RPMERR_BADSPEC, "line %d: %s", spec->lineNum, spec->line); + return RPMERR_BADSPEC; + } + } + + rpmGetArchInfo(&arch, NULL); + rpmGetOsInfo(&os, NULL); + s = spec->line; + SKIPSPACE(s); + match = -1; + if (! strncmp("%ifarch", s, 7)) { + match = matchTok(arch, s); + } else if (! strncmp("%ifnarch", s, 8)) { + match = !matchTok(arch, s); + } else if (! strncmp("%ifos", s, 5)) { + match = matchTok(os, s); + } else if (! strncmp("%ifnos", s, 6)) { + match = !matchTok(os, s); + } else if (! strncmp("%else", s, 5)) { + if (! spec->readStack->next) { + /* Got an else with no %if ! */ + rpmError(RPMERR_UNMATCHEDIF, "line %d: Got a %%else with no if", + spec->lineNum); + return RPMERR_UNMATCHEDIF; + } + spec->readStack->reading = + spec->readStack->next->reading && ! spec->readStack->reading; + spec->line[0] = '\0'; + } else if (! strncmp("%endif", s, 6)) { + if (! spec->readStack->next) { + /* Got an end with no %if ! */ + rpmError(RPMERR_UNMATCHEDIF, "line %d: Got a %%endif with no if", + spec->lineNum); + return RPMERR_UNMATCHEDIF; + } + rl = spec->readStack; + spec->readStack = spec->readStack->next; + free(rl); + spec->line[0] = '\0'; + } + if (match != -1) { + rl = malloc(sizeof(struct ReadLevelEntry)); + rl->reading = spec->readStack->reading && match; + rl->next = spec->readStack; + spec->readStack = rl; + spec->line[0] = '\0'; + } + + if (! spec->readStack->reading) { + spec->line[0] = '\0'; + } + + return 0; +} + +void closeSpec(Spec spec) +{ + if (spec->file) { + fclose(spec->file); + } + spec->file = NULL; +} int parseSpec(Spec *specp, char *specFile, char *buildRoot, int inBuildArch, char *passPhrase, char *cookie) @@ -158,30 +390,3 @@ int parseSpec(Spec *specp, char *specFile, char *buildRoot, return 0; } - -static void setStandardMacros(Spec spec, char *arch, char *os) -{ - char buf[BUFSIZ]; - int x; - - addMacro(&spec->macros, "sourcedir", NULL, rpmGetVar(RPMVAR_SOURCEDIR), -1); - addMacro(&spec->macros, "builddir", NULL, rpmGetVar(RPMVAR_BUILDDIR), -1); - addMacro(&spec->macros, "optflags", NULL, rpmGetVar(RPMVAR_OPTFLAGS), -1); - addMacro(&spec->macros, "buildarch", NULL, arch, -1); - addMacro(&spec->macros, "buildos", NULL, os, -1); - - x = 0; - while (arch[x]) { - buf[x] = tolower(arch[x]); - x++; - } - buf[x] = '\0'; - addMacro(&spec->macros, "buildarch_lc", NULL, buf, -1); - x = 0; - while (os[x]) { - buf[x] = tolower(os[x]); - x++; - } - buf[x] = '\0'; - addMacro(&spec->macros, "buildos_lc", NULL, buf, -1); -} diff --git a/build/part.c b/build/part.c deleted file mode 100644 index 2fb84e3..0000000 --- a/build/part.c +++ /dev/null @@ -1,65 +0,0 @@ -#include "system.h" - -#include "part.h" - -static struct PartRec { - int part; - int len; - char *token; -} partList[] = { - {PART_PREAMBLE, 0, "%package"}, - {PART_PREP, 0, "%prep"}, - {PART_BUILD, 0, "%build"}, - {PART_INSTALL, 0, "%install"}, - {PART_CLEAN, 0, "%clean"}, - {PART_PREUN, 0, "%preun"}, - {PART_POSTUN, 0, "%postun"}, - {PART_PRE, 0, "%pre"}, - {PART_POST, 0, "%post"}, - {PART_FILES, 0, "%files"}, - {PART_CHANGELOG, 0, "%changelog"}, - {PART_DESCRIPTION, 0, "%description"}, - {PART_TRIGGERPOSTUN, 0, "%triggerpostun"}, - {PART_TRIGGERUN, 0, "%triggerun"}, - {PART_TRIGGERIN, 0, "%triggerin"}, - {PART_TRIGGERIN, 0, "%trigger"}, - {PART_VERIFYSCRIPT, 0, "%verifyscript"}, - {0, 0, 0} -}; - -static void initParts(void) -{ - struct PartRec *p = partList; - - while (p->token) { - p->len = strlen(p->token); - p++; - } -} - -int isPart(char *line) -{ - char c; - struct PartRec *p = partList; - - if (p->len == 0) { - initParts(); - } - - while (p->token) { - if (! strncmp(line, p->token, p->len)) { - c = *(line + p->len); - if (c == '\0' || isspace(c)) { - break; - } - } - p++; - } - - if (p->token) { - return p->part; - } else { - return PART_NONE; - } -} - diff --git a/build/part.h b/build/part.h deleted file mode 100644 index 390dc46..0000000 --- a/build/part.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _H_PART_ -#define _H_PART_ - -#define PART_NONE 0 -#define PART_PREAMBLE 1 -#define PART_PREP 2 -#define PART_BUILD 3 -#define PART_INSTALL 4 -#define PART_CLEAN 5 -#define PART_FILES 6 -#define PART_PRE 7 -#define PART_POST 8 -#define PART_PREUN 9 -#define PART_POSTUN 10 -#define PART_DESCRIPTION 11 -#define PART_CHANGELOG 12 -#define PART_TRIGGERIN 13 -#define PART_TRIGGERUN 14 -#define PART_VERIFYSCRIPT 15 -#define PART_BUILDARCHITECTURES 16 -#define PART_TRIGGERPOSTUN 17 - -#ifdef __cplusplus -extern "C" { -#endif - -int isPart(char *line); - -#ifdef __cplusplus -} -#endif - -#endif /* _H_PART_ */ diff --git a/build/read.c b/build/read.c deleted file mode 100644 index f006374..0000000 --- a/build/read.c +++ /dev/null @@ -1,156 +0,0 @@ -#include "system.h" - -#include "spec.h" -#include "rpmlib.h" -#include "messages.h" -#include "macro.h" -#include "misc.h" -#include "read.h" - -#ifdef DYING -static int matchTok(char *token, char *line); -#endif - -static int matchTok(char *token, char *line) -{ - char buf[BUFSIZ], *tok; - - strcpy(buf, line); - strtok(buf, " \n\t"); - while ((tok = strtok(NULL, " \n\t"))) { - if (! strcmp(tok, token)) { - return 1; - } - } - - return 0; -} - -void handleComments(char *s) -{ - SKIPSPACE(s); - if (*s == '#') { - *s = '\0'; - } -} - -/* returns 0 - success */ -/* 1 - EOF */ -/* <0 - error */ - -int readLine(Spec spec, int strip) -{ - char *from, *to, *last, *s, *arch, *os; - int match; - char ch; - struct ReadLevelEntry *rl; - - /* Make sure the spec file is open */ - if (!spec->file) { - if (!(spec->file = fopen(spec->specFile, "r"))) { - rpmError(RPMERR_BADSPEC, "Unable to open: %s\n", spec->specFile); - return RPMERR_BADSPEC; - } - spec->lineNum = 0; - } - - /* Make sure we have something in the read buffer */ - if (!spec->readPtr || ! *(spec->readPtr)) { - if (!fgets(spec->readBuf, BUFSIZ, spec->file)) { - /* EOF */ - if (spec->readStack->next) { - rpmError(RPMERR_UNMATCHEDIF, "Unclosed %%if"); - return RPMERR_UNMATCHEDIF; - } - return 1; - } - spec->readPtr = spec->readBuf; - spec->lineNum++; - /*rpmMessage(RPMMESS_DEBUG, "LINE: %s", spec->readBuf);*/ - } - - /* Copy a single line to the line buffer */ - from = spec->readPtr; - to = last = spec->line; - ch = ' '; - while (*from && ch != '\n') { - ch = *to++ = *from++; - if (!isspace(ch)) { - last = to; - } - } - *to = '\0'; - spec->readPtr = from; - - if (strip & STRIP_COMMENTS) { - handleComments(spec->line); - } - - if (strip & STRIP_TRAILINGSPACE) { - *last = '\0'; - } - - if (spec->readStack->reading) { - if (expandMacros(spec, &spec->macros, spec->line, sizeof(spec->line))) { - rpmError(RPMERR_BADSPEC, "line %d: %s", spec->lineNum, spec->line); - return RPMERR_BADSPEC; - } - } - - rpmGetArchInfo(&arch, NULL); - rpmGetOsInfo(&os, NULL); - s = spec->line; - SKIPSPACE(s); - match = -1; - if (! strncmp("%ifarch", s, 7)) { - match = matchTok(arch, s); - } else if (! strncmp("%ifnarch", s, 8)) { - match = !matchTok(arch, s); - } else if (! strncmp("%ifos", s, 5)) { - match = matchTok(os, s); - } else if (! strncmp("%ifnos", s, 6)) { - match = !matchTok(os, s); - } else if (! strncmp("%else", s, 5)) { - if (! spec->readStack->next) { - /* Got an else with no %if ! */ - rpmError(RPMERR_UNMATCHEDIF, "line %d: Got a %%else with no if", - spec->lineNum); - return RPMERR_UNMATCHEDIF; - } - spec->readStack->reading = - spec->readStack->next->reading && ! spec->readStack->reading; - spec->line[0] = '\0'; - } else if (! strncmp("%endif", s, 6)) { - if (! spec->readStack->next) { - /* Got an end with no %if ! */ - rpmError(RPMERR_UNMATCHEDIF, "line %d: Got a %%endif with no if", - spec->lineNum); - return RPMERR_UNMATCHEDIF; - } - rl = spec->readStack; - spec->readStack = spec->readStack->next; - free(rl); - spec->line[0] = '\0'; - } - if (match != -1) { - rl = malloc(sizeof(struct ReadLevelEntry)); - rl->reading = spec->readStack->reading && match; - rl->next = spec->readStack; - spec->readStack = rl; - spec->line[0] = '\0'; - } - - if (! spec->readStack->reading) { - spec->line[0] = '\0'; - } - - return 0; -} - -void closeSpec(Spec spec) -{ - if (spec->file) { - fclose(spec->file); - } - spec->file = NULL; -} diff --git a/build/read.h b/build/read.h deleted file mode 100644 index dbe1fda..0000000 --- a/build/read.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _H_READ_ -#define _H_READ_ - -#include "spec.h" - -#define STRIP_NOTHING 0 -#define STRIP_TRAILINGSPACE (1 << 0) -#define STRIP_COMMENTS (1 << 1) - -/* returns 0 - success */ -/* 1 - EOF */ -/* <0 - error */ - -#ifdef __cplusplus -extern "C" { -#endif - -int readLine(Spec spec, int strip); -void closeSpec(Spec spec); -void handleComments(char *s); - -#ifdef __cplusplus -} -#endif - -#endif /* _H_READ_ */ diff --git a/build/reqprov.c b/build/reqprov.c index b80d226..19745c5 100644 --- a/build/reqprov.c +++ b/build/reqprov.c @@ -2,12 +2,7 @@ #include "system.h" -#include "spec.h" -#include "reqprov.h" -#include "messages.h" -#include "rpmlib.h" -#include "misc.h" -#include "lib/misc.h" +#include "rpmbuild.h" int addReqProv(Spec spec, Package pkg, int flag, char *name, char *version, int index) diff --git a/build/reqprov.h b/build/reqprov.h deleted file mode 100644 index 14cbc37..0000000 --- a/build/reqprov.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _H_REQPROV_ -#define _H_REQPROV_ - -#include "spec.h" -#include "package.h" -#include "lib/cpio.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int addReqProv(Spec spec, Package pkg, - int flag, char *name, char *version, int index); - -#ifdef DYING -int generateAutoReqProv(Spec spec, Package pkg, - struct cpioFileMapping *cpioList, int cpioCount); -void printReqs(Spec spec, Package pkg); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _H_REQPROV_ */ diff --git a/build/rpmbuild.h b/build/rpmbuild.h new file mode 100644 index 0000000..318252c --- /dev/null +++ b/build/rpmbuild.h @@ -0,0 +1,150 @@ +#ifndef _H_RPMBUILD_ +#define _H_RPMBUILD_ + +/* This is the *only* module users of librpmbuild should need to include */ +#include "rpmlib.h" + +/* and it shouldn't need these :-( */ +#include "stringbuf.h" +#include "messages.h" +#include "misc.h" + +/* but this will be needed */ +#include "spec.h" + +/* from build/build.h */ + +#define RPMBUILD_PREP (1 << 0) +#define RPMBUILD_BUILD (1 << 1) +#define RPMBUILD_INSTALL (1 << 2) +#define RPMBUILD_CLEAN (1 << 3) +#define RPMBUILD_FILECHECK (1 << 4) +#define RPMBUILD_PACKAGESOURCE (1 << 5) +#define RPMBUILD_PACKAGEBINARY (1 << 6) +#define RPMBUILD_RMSOURCE (1 << 7) +#define RPMBUILD_RMBUILD (1 << 8) +#define RPMBUILD_STRINGBUF (1 << 9) /* only for doScript() */ + +/* from build/misc.h */ + +#include + +#define FREE(x) { if (x) free(x); x = NULL; } +#define SKIPSPACE(s) { while (*(s) && isspace(*(s))) (s)++; } +#define SKIPNONSPACE(s) { while (*(s) && !isspace(*(s))) (s)++; } +#define SKIPTONEWLINE(s) { while (*s && *s != '\n') s++; } + +#define PART_SUBNAME 0 +#define PART_NAME 1 + +/* from build/part.h */ + +#define PART_NONE 0 +#define PART_PREAMBLE 1 +#define PART_PREP 2 +#define PART_BUILD 3 +#define PART_INSTALL 4 +#define PART_CLEAN 5 +#define PART_FILES 6 +#define PART_PRE 7 +#define PART_POST 8 +#define PART_PREUN 9 +#define PART_POSTUN 10 +#define PART_DESCRIPTION 11 +#define PART_CHANGELOG 12 +#define PART_TRIGGERIN 13 +#define PART_TRIGGERUN 14 +#define PART_VERIFYSCRIPT 15 +#define PART_BUILDARCHITECTURES 16 +#define PART_TRIGGERPOSTUN 17 + +/* from build/read.h */ + +#define STRIP_NOTHING 0 +#define STRIP_TRAILINGSPACE (1 << 0) +#define STRIP_COMMENTS (1 << 1) + +#ifdef __cplusplus +extern "C" { +#endif + +int isCompressed(char *file, int *compressed); + +/* from build/names.h */ + +char *getUname(uid_t uid); +char *getUnameS(char *uname); +char *getGname(gid_t gid); +char *getGnameS(char *gname); + +char *buildHost(void); +time_t *getBuildTime(void); + +/* from build/read.h */ + +/* returns 0 - success */ +/* 1 - EOF */ +/* <0 - error */ +int readLine(Spec spec, int strip); + +void closeSpec(Spec spec); +void handleComments(char *s); + +/* from build/part.h */ + +int isPart(char *line); + +/* from build/misc.h */ + +int parseNum(char *line, int *res); +char *cleanFileName(char *name); + +/* from build/parse.h */ + +int parseChangelog(Spec spec); +int parseDescription(Spec spec); +int parseFiles(Spec spec); +int parsePreamble(Spec spec, int initialPackage); +int parsePrep(Spec spec); +int parseRequiresConflicts(Spec spec, Package pkg, char *field, + int tag, int index); +int parseProvidesObsoletes(Spec spec, Package pkg, char *field, int tag); +int parseTrigger(Spec spec, Package pkg, char *field, int tag); +int parseScript(Spec spec, int parsePart); +int parseBuildInstallClean(Spec spec, int parsePart); + +/* from build/build.h */ + +int doScript(Spec spec, int what, char *name, StringBuf sb, int test); + +/* from build/package.h */ + +int lookupPackage(Spec spec, char *name, int flag, Package *pkg); +Package newPackage(Spec spec); +void freePackages(Spec spec); +void freePackage(Package p); + +/* from build/reqprov.h */ + +int addReqProv(Spec spec, Package pkg, + int flag, char *name, char *version, int index); + +/* from build/files.h */ + +int processBinaryFiles(Spec spec, int installSpecialDoc, int test); +int processSourceFiles(Spec spec); + +/* global entry points */ + +int parseSpec(Spec *specp, char *specFile, char *buildRoot, + int inBuildArch, char *passPhrase, char *cookie); +int buildSpec(Spec spec, int what, int test); + +int packageBinaries(Spec spec); +int packageSources(Spec spec); + +#ifdef __cplusplus +} +#endif + +#endif /* _H_RPMBUILD_ */ diff --git a/build/spec.c b/build/spec.c index 22dbb54..dd3cd5c 100644 --- a/build/spec.c +++ b/build/spec.c @@ -1,12 +1,165 @@ #include "system.h" -#include "spec.h" -#include "misc.h" -#include "rpmlib.h" -#include "package.h" -#include "read.h" -#include "files.h" -#include "macro.h" +#include "rpmbuild.h" + +#include "lib/cpio.h" + +#ifdef DYING +static void freeTriggerFiles(struct TriggerFileEntry *p); +#endif + +static void freeTriggerFiles(struct TriggerFileEntry *p) +{ + struct TriggerFileEntry *o; + + while (p) { + FREE(p->fileName); + FREE(p->script); + FREE(p->prog); + o = p; + p = p->next; + free(o); + } +} + +void freeCpioList(struct cpioFileMapping *cpioList, int cpioCount) +{ + struct cpioFileMapping *p = cpioList; + + while (cpioCount--) { + rpmMessage(RPMMESS_DEBUG, "archive = %s, fs = %s\n", + p->archivePath, p->fsPath); + FREE(p->archivePath); + FREE(p->fsPath); + p++; + } + FREE(cpioList); +} + +int lookupPackage(Spec spec, char *name, int flag, Package *pkg) +{ + char buf[BUFSIZ]; + char *n, *fullName; + Package p; + + /* "main" package */ + if (! name) { + if (pkg) { + *pkg = spec->packages; + } + return 0; + } + + /* Construct package name */ + if (flag == PART_SUBNAME) { + headerGetEntry(spec->packages->header, RPMTAG_NAME, + NULL, (void *) &n, NULL); + sprintf(buf, "%s-%s", n, name); + fullName = buf; + } else { + fullName = name; + } + + p = spec->packages; + while (p) { + headerGetEntry(p->header, RPMTAG_NAME, NULL, (void *) &n, NULL); + if (n && (! strcmp(fullName, n))) { + if (pkg) { + *pkg = p; + } + return 0; + } + p = p->next; + } + + if (pkg) { + *pkg = NULL; + } + return 1; +} + +Package newPackage(Spec spec) +{ + Package p; + Package pp; + + p = malloc(sizeof(*p)); + + p->header = headerNew(); + p->icon = NULL; + p->autoReqProv = 1; + +#if 0 + p->reqProv = NULL; + p->triggers = NULL; + p->triggerScripts = NULL; +#endif + + p->triggerFiles = NULL; + + p->fileFile = NULL; + p->fileList = NULL; + p->next = NULL; + + p->cpioList = NULL; + p->cpioCount = 0; + + p->preInFile = NULL; + p->postInFile = NULL; + p->preUnFile = NULL; + p->postUnFile = NULL; + p->verifyFile = NULL; + + p->specialDoc = NULL; + + if (! spec->packages) { + spec->packages = p; + } else { + /* Always add package to end of list */ + pp = spec->packages; + while (pp->next) { + pp = pp->next; + } + pp->next = p; + } + + return p; +} + +void freePackage(Package p) +{ + if (! p) { + return; + } + + FREE(p->preInFile); + FREE(p->postInFile); + FREE(p->preUnFile); + FREE(p->postUnFile); + FREE(p->verifyFile); + + headerFree(p->header); + freeStringBuf(p->fileList); + FREE(p->fileFile); + freeCpioList(p->cpioList, p->cpioCount); + + freeStringBuf(p->specialDoc); + + freeTriggerFiles(p->triggerFiles); + + free(p); +} + +void freePackages(Spec spec) +{ + Package p; + + while (spec->packages) { + p = spec->packages; + spec->packages = p->next; + freePackage(p); + } +} #ifdef DYING static char *getSourceAux(Spec spec, int num, int flag, int full); diff --git a/build/spec.h b/build/spec.h index 6579e75..40bf0c4 100644 --- a/build/spec.h +++ b/build/spec.h @@ -1,9 +1,6 @@ #ifndef _H_SPEC_ #define _H_SPEC_ -#include "header.h" -#include "stringbuf.h" - typedef struct SpecStruct *Spec; #include "macro.h" diff --git a/checksig.c b/checksig.c index cb03bfc..7c8ac23 100644 --- a/checksig.c +++ b/checksig.c @@ -2,13 +2,12 @@ #include "system.h" +#include "build/rpmbuild.h" + #include "checksig.h" #include "intl.h" -#include "rpmlib.h" #include "rpmlead.h" #include "signature.h" -#include "messages.h" -#include "lib/misc.h" int doReSign(int add, char *passPhrase, char **argv) { diff --git a/configure.in b/configure.in index 9852520..2ebe241 100644 --- a/configure.in +++ b/configure.in @@ -349,13 +349,15 @@ AC_CHECK_HEADERS(mntent.h sys/mnttab.h sys/systemcfg.h) AC_CHECK_HEADERS(sys/mount.h sys/mntctl.h sys/vmount.h) AC_CHECK_HEADERS(glob.h,,MISCOBJS="$MISCOBJS glob.o") AC_CHECK_HEADERS(fnmatch.h,,MISCOBJS="$MISCOBJS fnmatch.o") -AC_CHECK_HEADERS(fcntl.h malloc.h memory.h sys/wait.h) +AC_CHECK_HEADERS(fcntl.h grp.h malloc.h memory.h netdb.h pwd.h utime.h) +AC_CHECK_HEADERS(sys/mman.h sys/param.h sys/resource.h sys/utsname.h sys/wait.h) AC_CHECK_HEADERS(db_185.h) if test "$PO" = po; then AC_CHECK_HEADERS(libintl.h) fi +AC_HEADER_TIME AC_C_BIGENDIAN AC_C_INLINE diff --git a/convertdb.c b/convertdb.c index 78bb7c5..0c3469f 100644 --- a/convertdb.c +++ b/convertdb.c @@ -2,13 +2,11 @@ #include "system.h" -#include "dbindex.h" +#include "build/rpmbuild.h" + #include "falloc.h" -#include "header.h" -#include "misc.h" #include "oldrpmdb.h" #include "oldheader.h" -#include "rpmlib.h" int convertDB(void); diff --git a/ftp.c b/ftp.c index d3d581a..9ad5eef 100644 --- a/ftp.c +++ b/ftp.c @@ -1,8 +1,6 @@ #include "system.h" -#if HAVE_CONFIG_H -# include "miscfn.h" -#else +#if !defined(HAVE_CONFIG_H) #define HAVE_MACHINE_TYPES_H 1 #define HAVE_ALLOCA_H 1 #define HAVE_NETINET_IN_SYSTM_H 1 @@ -22,11 +20,8 @@ extern int h_errno; #endif -#include -#include #include -#include #include #include diff --git a/install.c b/install.c index bfa0244..f855c27 100644 --- a/install.c +++ b/install.c @@ -1,10 +1,9 @@ #include "system.h" -#include "miscfn.h" +#include "build/rpmbuild.h" + #include "install.h" #include "intl.h" -#include "lib/rpmlib.h" -#include "messages.h" #include "query.h" #include "url.h" diff --git a/lib/cpio.c b/lib/cpio.c index b9957cd..eb48063 100644 --- a/lib/cpio.c +++ b/lib/cpio.c @@ -1,7 +1,4 @@ #include "system.h" -#include "miscfn.h" - -#include #include "cpio.h" diff --git a/lib/dbindex.c b/lib/dbindex.c index d0d38ad..612f79a 100644 --- a/lib/dbindex.c +++ b/lib/dbindex.c @@ -1,15 +1,8 @@ #include "system.h" -#include "miscfn.h" -#ifdef HAVE_DB_185_H -#include -#else -#include -#endif +#include "rpmlib.h" -#include "dbindex.h" #include "intl.h" -#include "rpmlib.h" dbiIndex * dbiOpenIndex(char * filename, int flags, int perms) { dbiIndex * db; diff --git a/lib/dbindex.h b/lib/dbindex.h index 4985d5c..d1e6eb8 100644 --- a/lib/dbindex.h +++ b/lib/dbindex.h @@ -1,18 +1,14 @@ #ifndef H_DBINDEX #define H_DBINDEX -#ifdef __cplusplus -extern "C" { -#endif - -/* this will break if sizeof(int) != 4 */ - #ifdef HAVE_DB_185_H #include #else #include #endif +/* this will break if sizeof(int) != 4 */ + typedef struct { unsigned int recOffset; unsigned int fileNumber; @@ -28,6 +24,10 @@ typedef struct { char * indexname; } dbiIndex; +#ifdef __cplusplus +extern "C" { +#endif + dbiIndex * dbiOpenIndex(char * filename, int flags, int perms); void dbiCloseIndex(dbiIndex * dbi); void dbiSyncIndex(dbiIndex * dbi); diff --git a/lib/depends.c b/lib/depends.c index c76a78d..e50f088 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -1,10 +1,10 @@ #include "system.h" -#include "miscfn.h" + +#include "rpmlib.h" #include "depends.h" #include "intl.h" #include "misc.h" -#include "rpmlib.h" #include "messages.h" struct availablePackage { diff --git a/lib/formats.c b/lib/formats.c index c7d9f63..cad64db 100644 --- a/lib/formats.c +++ b/lib/formats.c @@ -1,10 +1,9 @@ #include "system.h" -#include "miscfn.h" -#include "header.h" -#include "intl.h" #include "rpmlib.h" +#include "intl.h" + static char * permsFormat(int_32 type, const void * data, char * formatPrefix, int padding, int element); static char * depflagsFormat(int_32 type, const void * data, diff --git a/lib/fs.c b/lib/fs.c index 70562fc..ae1efc4 100644 --- a/lib/fs.c +++ b/lib/fs.c @@ -1,10 +1,9 @@ #include "system.h" -#include "miscfn.h" -#include "header.h" -#include "intl.h" #include "rpmlib.h" +#include "intl.h" + struct fsinfo { char * mntPoint; dev_t dev; diff --git a/lib/header.c b/lib/header.c index b82f7d7..2e48546 100644 --- a/lib/header.c +++ b/lib/header.c @@ -8,14 +8,11 @@ /* network byte order and is converted on the fly to host order. */ #include "system.h" -#include "miscfn.h" -#include - -#include #include #include "header.h" + #include "intl.h" #include "tread.h" diff --git a/lib/install.c b/lib/install.c index 9b01315..da182cc 100644 --- a/lib/install.c +++ b/lib/install.c @@ -1,22 +1,15 @@ #include "system.h" -#include "miscfn.h" -#include #include -#include -#include -#include -#include -#include + +#include "rpmlib.h" #include "cpio.h" -#include "header.h" #include "install.h" #include "md5.h" #include "messages.h" #include "misc.h" #include "rpmdb.h" -#include "rpmlib.h" enum instActions { UNKNOWN, CREATE, BACKUP, KEEP, SAVE, SKIP, ALTNAME }; enum fileTypes { XDIR, BDEV, CDEV, SOCK, PIPE, REG, LINK } ; diff --git a/lib/lookup.c b/lib/lookup.c index 6e8305d..e9a1790 100644 --- a/lib/lookup.c +++ b/lib/lookup.c @@ -1,9 +1,9 @@ #include "system.h" -#include "miscfn.h" -#include "intl.h" #include "rpmlib.h" +#include "intl.h" + static int findMatches(rpmdb db, char * name, char * version, char * release, dbiIndexSet * matches); diff --git a/lib/messages.c b/lib/messages.c index 5f1e0e2..968c650 100644 --- a/lib/messages.c +++ b/lib/messages.c @@ -2,9 +2,9 @@ #include -#include "intl.h" -#include "messages.h" #include "rpmlib.h" + +#include "messages.h" #include "intl.h" static int minLevel = RPMMESS_NORMAL; diff --git a/lib/misc.c b/lib/misc.c index 225661e..0067aa0 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -1,13 +1,9 @@ #include "system.h" -#include "miscfn.h" -#include -#include -#include +#include "rpmlib.h" #include "intl.h" #include "misc.h" -#include "rpmlib.h" #include "messages.h" char * RPMVERSION = VERSION; /* just to put a marker in librpm.a */ diff --git a/lib/oldheader.c b/lib/oldheader.c index 0c6fb4d..d8f5a17 100644 --- a/lib/oldheader.c +++ b/lib/oldheader.c @@ -1,11 +1,11 @@ #include "system.h" -#include "miscfn.h" #include +#include "rpmlib.h" + #include "misc.h" #include "oldheader.h" -#include "rpmlib.h" #include "tread.h" /* This *can't* read 1.0 headers -- it needs 1.1 (w/ group and icon fields) diff --git a/lib/package.c b/lib/package.c index 4ea4eed..061a176 100644 --- a/lib/package.c +++ b/lib/package.c @@ -1,14 +1,13 @@ #include "system.h" -#include "miscfn.h" #include -#include "header.h" +#include "rpmlib.h" + #include "intl.h" #include "misc.h" #include "oldheader.h" #include "rpmlead.h" -#include "rpmlib.h" #include "signature.h" #include "messages.h" diff --git a/lib/rebuilddb.c b/lib/rebuilddb.c index 93df3c9..6b8f7cc 100644 --- a/lib/rebuilddb.c +++ b/lib/rebuilddb.c @@ -1,9 +1,10 @@ #include "system.h" +#include "rpmlib.h" + #include "intl.h" #include "messages.h" #include "rpmdb.h" -#include "rpmlib.h" int rpmdbRebuild(char * rootdir) { rpmdb olddb, newdb; diff --git a/lib/rpmdb.c b/lib/rpmdb.c index 679c5df..73d0bd0 100644 --- a/lib/rpmdb.c +++ b/lib/rpmdb.c @@ -4,13 +4,13 @@ #include #include +#include "rpmlib.h" + #include "dbindex.h" #include "falloc.h" -#include "header.h" #include "intl.h" #include "misc.h" #include "rpmdb.h" -#include "rpmlib.h" #include "messages.h" /* XXX the signal handling in here is not thread safe */ diff --git a/lib/rpmlead.c b/lib/rpmlead.c index 0cadecd..d2c3714 100644 --- a/lib/rpmlead.c +++ b/lib/rpmlead.c @@ -1,5 +1,4 @@ #include "system.h" -#include "miscfn.h" #if HAVE_MACHINE_TYPES_H # include @@ -8,6 +7,7 @@ #include #include "rpmlib.h" + #include "rpmlead.h" #include "tread.h" #include "intl.h" diff --git a/lib/rpmlib.h b/lib/rpmlib.h index 2ca2e30..53a0499 100644 --- a/lib/rpmlib.h +++ b/lib/rpmlib.h @@ -3,13 +3,8 @@ /* This is the *only* module users of rpmlib should need to include */ -#ifdef HAVE_DB_185_H -#include -#else -#include -#endif +/* and it shouldn't need these :-( */ -/* it shouldn't need these :-( */ #include "dbindex.h" #include "header.h" diff --git a/lib/rpmrc.c b/lib/rpmrc.c index 0af51c6..e8384b5 100644 --- a/lib/rpmrc.c +++ b/lib/rpmrc.c @@ -1,14 +1,10 @@ #include "system.h" -#include "miscfn.h" -#include -#include -#include +#include "rpmlib.h" #include "intl.h" #include "messages.h" #include "misc.h" -#include "rpmlib.h" #include "intl.h" #if HAVE_SYS_SYSTEMCFG_H diff --git a/lib/signature.c b/lib/signature.c index d0fa931..7921bca 100644 --- a/lib/signature.c +++ b/lib/signature.c @@ -8,19 +8,16 @@ */ #include "system.h" -#include "miscfn.h" #if HAVE_ASM_BYTEORDER_H #include #endif -#include -#include +#include "rpmlib.h" #include "intl.h" #include "md5.h" #include "misc.h" -#include "rpmlib.h" #include "rpmlead.h" #include "signature.h" #include "tread.h" diff --git a/lib/stringbuf.c b/lib/stringbuf.c index a74d6f9..468ba6b 100644 --- a/lib/stringbuf.c +++ b/lib/stringbuf.c @@ -1,5 +1,4 @@ #include "system.h" -#include "miscfn.h" #include "stringbuf.h" diff --git a/lib/test.c b/lib/test.c index dd2cec7..f85d9cd 100644 --- a/lib/test.c +++ b/lib/test.c @@ -1,6 +1,5 @@ #include "system.h" -#include "header.h" #include "rpmlib.h" void main(int argc, char **argv) diff --git a/lib/tread.c b/lib/tread.c index 02d9db0..4ce31fd 100644 --- a/lib/tread.c +++ b/lib/tread.c @@ -1,7 +1,4 @@ #include "system.h" -#include "miscfn.h" - -#include #include "tread.h" diff --git a/lib/uninstall.c b/lib/uninstall.c index 9509964..7405bf3 100644 --- a/lib/uninstall.c +++ b/lib/uninstall.c @@ -1,10 +1,7 @@ #include "system.h" -#include "miscfn.h" -#include -#include +#include "rpmlib.h" -#include "dbindex.h" #include "depends.h" #include "install.h" #include "intl.h" @@ -12,7 +9,6 @@ #include "md5.h" #include "misc.h" #include "rpmdb.h" -#include "rpmlib.h" static char * SCRIPT_PATH = "PATH=/sbin:/bin:/usr/sbin:/usr/bin:" "/usr/X11R6/bin"; diff --git a/lib/verify.c b/lib/verify.c index c5872c2..1611370 100644 --- a/lib/verify.c +++ b/lib/verify.c @@ -1,13 +1,10 @@ #include "system.h" -#include "miscfn.h" -#include -#include +#include "rpmlib.h" #include "md5.h" #include "misc.h" #include "messages.h" -#include "rpmlib.h" #include "install.h" #define S_ISDEV(m) (S_ISBLK((m)) || S_ISCHR((m))) diff --git a/misc/fnmatch.c b/misc/fnmatch.c index 00d959b..f802d40 100644 --- a/misc/fnmatch.c +++ b/misc/fnmatch.c @@ -18,8 +18,6 @@ Cambridge, MA 02139, USA. */ #include #include -#include "miscfn.h" - /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C diff --git a/misc/getmntent.c b/misc/getmntent.c index 4c0a400..47db996 100644 --- a/misc/getmntent.c +++ b/misc/getmntent.c @@ -1,9 +1,4 @@ -#include "miscfn.h" - -#include -#include -#include -#include +#include "system.h" #ifdef __aix__ #define COMMENTCHAR '*' diff --git a/misc/glob.c b/misc/glob.c index 4f83457..13190ab 100644 --- a/misc/glob.c +++ b/misc/glob.c @@ -32,10 +32,7 @@ Cambridge, MA 02139, USA. */ #pragma alloca #endif -#include -#include - -#include "config.h" +#include "system.h" /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C @@ -202,7 +199,6 @@ extern char *alloca (); #undef GLOB_APPEND #undef GLOB_NOESCAPE #undef GLOB_PERIOD -#include "miscfn.h" __ptr_t (*__glob_opendir_hook) __P ((const char *directory)); const char *(*__glob_readdir_hook) __P ((__ptr_t stream)); diff --git a/misc/inet_aton.c b/misc/inet_aton.c index b26eac8..c498520 100644 --- a/misc/inet_aton.c +++ b/misc/inet_aton.c @@ -1,5 +1,4 @@ #include "system.h" -#include "miscfn.h" #ifdef HAVE_NETINET_IN_SYSTM_H # include diff --git a/misc/miscfn.h b/misc/miscfn.h deleted file mode 100644 index 7048390..0000000 --- a/misc/miscfn.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef H_MISCFN -#define H_MISCFN - -#if HAVE_SYS_STDTYPES_H -# include -#endif - -#if NEED_TIMEZONE -extern time_t timezone; -#endif - -#endif diff --git a/oldrpmdb.c b/oldrpmdb.c index 197218f..80bf363 100644 --- a/oldrpmdb.c +++ b/oldrpmdb.c @@ -1,11 +1,8 @@ #include "system.h" -#include "miscfn.h" -#include "rpmlib.h" +#include "build/rpmbuild.h" + #include "rpm_malloc.h" -#include "messages.h" -#include "misc.h" -#include "miscfn.h" #include "oldrpmdb.h" static int labelstrlistToLabelList(char * str, int length, diff --git a/query.c b/query.c index 8f0e68d..7d9233d 100644 --- a/query.c +++ b/query.c @@ -1,16 +1,12 @@ #include "system.h" -#include -#include - #ifndef PATH_MAX # define PATH_MAX 255 #endif +#include "build/rpmbuild.h" + #include "intl.h" -#include "lib/messages.h" -#include "miscfn.h" -#include "rpmlib.h" #include "query.h" #include "url.h" diff --git a/rpm-qo.c b/rpm-qo.c index b585b02..06d144a 100644 --- a/rpm-qo.c +++ b/rpm-qo.c @@ -3,15 +3,14 @@ #include #include +#include "build/rpmbuild.h" + #include "install.h" #include -#include "lib/messages.h" #include "lib/signature.h" #include "query.h" #include "verify.h" #include "checksig.h" -#include "rpmlib.h" -#include "build/build.h" #define GETOPT_QUERYFORMAT 1000 #define GETOPT_WHATREQUIRES 1001 diff --git a/rpm.c b/rpm.c index ec0ffe4..84e3129 100755 --- a/rpm.c +++ b/rpm.c @@ -1,21 +1,16 @@ #include "system.h" -#include "miscfn.h" #include -#include -#include + +#include "build/rpmbuild.h" #include "build.h" -#include "build/build.h" #include "checksig.h" #include "install.h" #include "intl.h" -#include "lib/messages.h" #include "lib/signature.h" #include "popt/popt.h" -#include "miscfn.h" #include "query.h" -#include "rpmlib.h" #include "verify.h" #define GETOPT_QUERYFORMAT 1000 diff --git a/rpm2cpio.c b/rpm2cpio.c index 17f6902..5674ae0 100644 --- a/rpm2cpio.c +++ b/rpm2cpio.c @@ -2,8 +2,6 @@ #include "system.h" -#include - #include "rpmlib.h" char *zlib_err [] = { diff --git a/rpmio/messages.c b/rpmio/messages.c index 5f1e0e2..968c650 100644 --- a/rpmio/messages.c +++ b/rpmio/messages.c @@ -2,9 +2,9 @@ #include -#include "intl.h" -#include "messages.h" #include "rpmlib.h" + +#include "messages.h" #include "intl.h" static int minLevel = RPMMESS_NORMAL; diff --git a/system.h b/system.h index 51868a2..77d8e5b 100644 --- a/system.h +++ b/system.h @@ -26,12 +26,32 @@ #include #include +#ifdef HAVE_SYS_PARAM_H +#include +#endif + /* should be included before any preprocessor test of _POSIX_VERSION. */ #ifdef HAVE_UNISTD_H #include #endif +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + +#if NEED_TIMEZONE +extern time_t timezone; +#endif + + /* Since major is a function on SVR4, we can't use `ifndef major'. */ #if MAJOR_IN_MKDEV #include @@ -52,6 +72,10 @@ #endif #undef HAVE_MAJOR +#ifdef HAVE_UTIME_H +#include +#endif + #ifndef __P #if defined (__GNUC__) || (defined (__STDC__) && __STDC__) #define __P(args) args @@ -137,10 +161,27 @@ char *alloca (); #include +#if HAVE_SYS_MMAN_H +#include +#endif + +/* XXX FIXME: popt on sunos4.1.3: requires */ +#if HAVE_SYS_RESOURCE_H && HAVE_SYS_TIME_H +#include +#endif + +#if HAVE_SYS_UTSNAME_H +#include +#endif + #if HAVE_SYS_WAIT_H #include #endif +#if HAVE_GRP_H +#include +#endif + #if HAVE_LIMITS_H #include #endif @@ -149,6 +190,14 @@ char *alloca (); #include #endif +#if HAVE_NETDB_H +#include +#endif + +#if HAVE_PWD_H +#include +#endif + /* ============== from misc/miscfn.h */ #if HAVE_FNMATCH_H diff --git a/tools/dump.c b/tools/dump.c index a6e7580..38aaa55 100644 --- a/tools/dump.c +++ b/tools/dump.c @@ -1,11 +1,7 @@ -#include -#include -#include -#include -#include +#include "system.h" -#include "header.h" #include "rpmlib.h" + #include "intl.h" int main(int argc, char ** argv) diff --git a/tools/dumpdb.c b/tools/dumpdb.c index 70db0f5..912afac 100644 --- a/tools/dumpdb.c +++ b/tools/dumpdb.c @@ -1,11 +1,5 @@ -#include -#include -#include -#include -#include -#include - -#include "header.h" +#include "system.h" + #include "rpmlib.h" #include "intl.h" diff --git a/tools/rpmarchive.c b/tools/rpmarchive.c index 1aa7fb6..b8f83d3 100644 --- a/tools/rpmarchive.c +++ b/tools/rpmarchive.c @@ -1,8 +1,6 @@ /* rpmarchive: spit out the main archive portion of a package */ -#include -#include -#include +#include "system.h" #include "rpmlead.h" #include "signature.h" diff --git a/tools/rpmchecksig.c b/tools/rpmchecksig.c index 5f2b89b..d3d1ac1 100644 --- a/tools/rpmchecksig.c +++ b/tools/rpmchecksig.c @@ -1,10 +1,9 @@ /* rpmchecksig: verify the signature of an RPM */ -#include -#include -#include +#include "system.h" #include "rpmlib.h" + #include "rpmlead.h" #include "signature.h" #include "intl.h" diff --git a/tools/rpmheader.c b/tools/rpmheader.c index bc2ec05..7d750d6 100644 --- a/tools/rpmheader.c +++ b/tools/rpmheader.c @@ -1,8 +1,6 @@ /* rpmheader: spit out the header portion of a package */ -#include -#include -#include +#include "system.h" #include "rpmlead.h" #include "signature.h" diff --git a/tools/rpmlead.c b/tools/rpmlead.c index 99274ee..ece6a47 100644 --- a/tools/rpmlead.c +++ b/tools/rpmlead.c @@ -1,8 +1,6 @@ /* rpmlead: spit out the lead portion of a package */ -#include -#include -#include +#include "system.h" #include "rpmlead.h" #include "intl.h" diff --git a/tools/rpmsignature.c b/tools/rpmsignature.c index da009eb..ca578c6 100644 --- a/tools/rpmsignature.c +++ b/tools/rpmsignature.c @@ -1,8 +1,6 @@ /* rpmsignature: spit out the signature portion of a package */ -#include -#include -#include +#include "system.h" #include "rpmlead.h" #include "signature.h" diff --git a/url.c b/url.c index 37b8f03..51d8329 100644 --- a/url.c +++ b/url.c @@ -1,13 +1,9 @@ #include "system.h" -#include "miscfn.h" -#include +#include "build/rpmbuild.h" #include "ftp.h" #include "intl.h" -#include "messages.h" -#include "miscfn.h" -#include "rpmlib.h" #include "url.h" struct pwcacheEntry { diff --git a/verify.c b/verify.c index 24c3c0b..76289e0 100644 --- a/verify.c +++ b/verify.c @@ -1,10 +1,10 @@ #include "system.h" -#include "lib/messages.h" +#include "build/rpmbuild.h" + #include "install.h" #include "intl.h" #include "query.h" -#include "rpmlib.h" #include "url.h" #include "verify.h" -- 2.7.4