From 5142bf78e626b861ec1af6be7d81d3bb5c0afe03 Mon Sep 17 00:00:00 2001 From: jbj Date: Thu, 30 Jul 1998 22:09:42 +0000 Subject: 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 965eeefb2..bdb832482 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 c564216b0..35ef5a2f1 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 b013509e1..46968c3c9 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 8ffc02d8d..8f4dcc55a 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 290596fc3..000000000 --- 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 e0a38d391..604e24abe 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 462b549f8..8094a14a0 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 5639457a8..eae2ed412 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 e74bc1eb3..773854b11 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 b88c5c80f..000000000 --- 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 6850ec100..94de2cd7c 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 49bf2f15b..000000000 --- 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 9fc2ee8f2..fb34b4531 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 d9c55d521..000000000 --- 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 fb20934c4..000000000 --- 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 80e0ec67d..000000000 --- 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 917b8cd2b..000000000 --- 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 76ef92c67..ee7c17aa1 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 6703b8c12..cb3540107 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 30c4c8051..912823ded 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 f3a1e6621..5fc3c1179 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 6fbf4881f..58a1c074b 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 a2d73b062..d6c55840c 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 59eb02e64..67cf01a71 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 3214c482b..ec1f7922b 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 4f394b72b..af86a9dce 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 2fb84e365..000000000 --- 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 390dc462e..000000000 --- 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 f006374a7..000000000 --- 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 dbe1fdaf4..000000000 --- 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 b80d2263a..19745c521 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 14cbc379d..000000000 --- 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 000000000..318252c61 --- /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 22dbb54b5..dd3cd5ca5 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 6579e7599..40bf0c4f9 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 cb03bfc93..7c8ac23f6 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 9852520cf..2ebe241b0 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 78bb7c574..0c3469fb2 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 d3d581a3f..9ad5eef8b 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 bfa024491..f855c279f 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 b9957cd56..eb4806320 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 d0d38adb5..612f79a6c 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 4985d5ca7..d1e6eb8c8 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 c76a78d78..e50f088ab 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 c7d9f6313..cad64db9b 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 70562fc67..ae1efc4ef 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 b82f7d75e..2e48546cd 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 9b01315f6..da182cc1e 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 6e8305dfd..e9a17908f 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 5f1e0e288..968c650f2 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 225661e9b..0067aa0d1 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 0c6fb4d4a..d8f5a1786 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 4ea4eedf7..061a176c5 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 93df3c94a..6b8f7cc49 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 679c5df56..73d0bd0a1 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 0cadecde2..d2c37140e 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 2ca2e30c3..53a049946 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 0af51c632..e8384b534 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 d0fa93104..7921bca72 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 a74d6f99b..468ba6b75 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 dd2cec708..f85d9cd52 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 02d9db010..4ce31fda1 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 95099641e..7405bf305 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 c5872c2fc..1611370e7 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 00d959bbe..f802d4042 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 4c0a400bc..47db9962b 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 4f83457db..13190ab76 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 b26eac8b3..c49852036 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 7048390b0..000000000 --- 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 197218f03..80bf36343 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 8f0e68d49..7d9233d01 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 b585b020f..06d144aed 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 ec0ffe4fb..84e31299e 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 17f6902fd..5674ae09f 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 5f1e0e288..968c650f2 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 51868a207..77d8e5b4c 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 a6e75802e..38aaa5578 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 70db0f5f4..912afac12 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 1aa7fb60c..b8f83d394 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 5f2b89bed..d3d1ac1d4 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 bc2ec0501..7d750d695 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 99274eec4..ece6a47ed 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 da009ebda..ca578c659 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 37b8f03fe..51d83296d 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 24c3c0b2e..76289e0f5 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" -- cgit v1.2.3