summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2010-08-25 15:41:09 +0300
committerPanu Matilainen <pmatilai@redhat.com>2010-08-25 15:41:09 +0300
commit555f699f11774a2692518508fe14f3eed878b3d4 (patch)
tree532a22bd9519348b7535a16c89c2bbaf3413de82
parent94a58d3864d080da7d2cb2ad4a87aaa2917facd1 (diff)
downloadrpm-555f699f11774a2692518508fe14f3eed878b3d4.tar.gz
Mass eviction of remaining internal helpers in librpmbuild API
- Yank everything qualifying as "internal helper function" into internal-only headers, loosely grouped as follows: 1) Everything involving spec-manipulation goes into rpmbuild_internal.h 2) All other miscellaneous helpers go into rpmbuild_misc.h - This leaves us a rather minimal, and nearly useful API into librpmbuild: Users need to be able to parse a spec, query or build (parts of) it and free up the spec structure when done. This is what we have now, various still exposed structures not counting.
-rw-r--r--build/Makefile.am3
-rw-r--r--build/build.c2
-rw-r--r--build/expression.c3
-rw-r--r--build/files.c3
-rw-r--r--build/misc.c3
-rw-r--r--build/names.c3
-rw-r--r--build/pack.c3
-rw-r--r--build/parseBuildInstallClean.c2
-rw-r--r--build/parseChangelog.c2
-rw-r--r--build/parseDescription.c2
-rw-r--r--build/parseFiles.c2
-rw-r--r--build/parsePreamble.c3
-rw-r--r--build/parsePrep.c3
-rw-r--r--build/parseReqs.c3
-rw-r--r--build/parseScript.c3
-rw-r--r--build/parseSpec.c3
-rw-r--r--build/reqprov.c3
-rw-r--r--build/rpmbuild.h303
-rw-r--r--build/rpmbuild_internal.h248
-rw-r--r--build/rpmbuild_misc.h110
-rw-r--r--build/rpmfc.c4
-rw-r--r--build/rpmspec.h15
-rw-r--r--build/spec.c2
-rw-r--r--rpmbuild.c1
24 files changed, 390 insertions, 339 deletions
diff --git a/build/Makefile.am b/build/Makefile.am
index 1d1c84150..36f3d6316 100644
--- a/build/Makefile.am
+++ b/build/Makefile.am
@@ -12,7 +12,8 @@ librpmbuild_la_SOURCES = \
build.c expression.c files.c misc.c names.c pack.c \
parseBuildInstallClean.c parseChangelog.c parseDescription.c \
parseFiles.c parsePreamble.c parsePrep.c parseReqs.c parseScript.c \
- parseSpec.c poptBT.c reqprov.c rpmfc.c spec.c fts.h fts.c
+ parseSpec.c poptBT.c reqprov.c rpmfc.c spec.c fts.h fts.c \
+ rpmbuild_internal.h rpmbuild_misc.h
librpmbuild_la_LDFLAGS = -version-info 1:0:0
librpmbuild_la_LIBADD = \
diff --git a/build/build.c b/build/build.c
index fa62a39ac..64c4d6c2a 100644
--- a/build/build.c
+++ b/build/build.c
@@ -8,9 +8,9 @@
#include <errno.h>
#include <sys/wait.h>
-#include <rpm/rpmbuild.h>
#include <rpm/rpmlog.h>
#include <rpm/rpmfileutil.h>
+#include "build/rpmbuild_internal.h"
#include "debug.h"
diff --git a/build/expression.c b/build/expression.c
index d87f59294..3452486ce 100644
--- a/build/expression.c
+++ b/build/expression.c
@@ -13,9 +13,8 @@
#include "system.h"
-#include <rpm/rpmbuild.h>
#include <rpm/rpmlog.h>
-
+#include "build/rpmbuild_internal.h"
#include "debug.h"
/* #define DEBUG_PARSER 1 */
diff --git a/build/files.c b/build/files.c
index 5e317fb6b..6f8bd387c 100644
--- a/build/files.c
+++ b/build/files.c
@@ -14,7 +14,6 @@
#include <sys/capability.h>
#endif
-#include <rpm/rpmbuild.h>
#include <rpm/rpmpgp.h>
#include <rpm/argv.h>
#include <rpm/rpmfc.h>
@@ -26,6 +25,8 @@
#include "build/fts.h"
#include "lib/cpio.h"
#include "lib/rpmfi_internal.h" /* XXX fi->apath */
+#include "build/rpmbuild_internal.h"
+#include "build/rpmbuild_misc.h"
#include "debug.h"
#include <libgen.h>
diff --git a/build/misc.c b/build/misc.c
index 25c4b51e0..d2d05baac 100644
--- a/build/misc.c
+++ b/build/misc.c
@@ -4,7 +4,8 @@
#include "system.h"
#include <ctype.h>
-#include <rpm/rpmbuild.h>
+#include <stdlib.h>
+#include "build/rpmbuild_misc.h"
#include "debug.h"
uint32_t parseUnsignedNum(const char * line, uint32_t * res)
diff --git a/build/names.c b/build/names.c
index 6dd78d485..838c1d5ba 100644
--- a/build/names.c
+++ b/build/names.c
@@ -8,8 +8,9 @@
#include <pwd.h>
#include <grp.h>
#include <netdb.h>
-#include <rpm/rpmbuild.h>
#include <rpm/rpmlog.h>
+#include <rpm/rpmstring.h>
+#include "build/rpmbuild_misc.h"
#include "debug.h"
#define UGIDMAX 1024
diff --git a/build/pack.c b/build/pack.c
index 26d31fbcf..28630b7ab 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -11,7 +11,6 @@
#include <rpm/rpmlib.h> /* RPMSIGTAG*, rpmReadPackageFile */
#include <rpm/rpmts.h>
-#include <rpm/rpmbuild.h>
#include <rpm/rpmfileutil.h>
#include <rpm/rpmlog.h>
@@ -22,6 +21,8 @@
#include "lib/rpmte_internal.h" /* rpmfs */
#include "lib/signature.h"
#include "lib/rpmlead.h"
+#include "build/rpmbuild_internal.h"
+#include "build/rpmbuild_misc.h"
#include "debug.h"
diff --git a/build/parseBuildInstallClean.c b/build/parseBuildInstallClean.c
index d81bd0727..5eb8fe641 100644
--- a/build/parseBuildInstallClean.c
+++ b/build/parseBuildInstallClean.c
@@ -4,8 +4,8 @@
*/
#include "system.h"
-#include <rpm/rpmbuild.h>
#include <rpm/rpmlog.h>
+#include "build/rpmbuild_internal.h"
#include "debug.h"
diff --git a/build/parseChangelog.c b/build/parseChangelog.c
index 6723922fa..b727b907d 100644
--- a/build/parseChangelog.c
+++ b/build/parseChangelog.c
@@ -6,8 +6,8 @@
#include "system.h"
#include <rpm/header.h>
-#include <rpm/rpmbuild.h>
#include <rpm/rpmlog.h>
+#include "build/rpmbuild_internal.h"
#include "debug.h"
#define SKIPSPACE(s) { while (*(s) && risspace(*(s))) (s)++; }
diff --git a/build/parseDescription.c b/build/parseDescription.c
index 5b9242d19..41f8c6a1a 100644
--- a/build/parseDescription.c
+++ b/build/parseDescription.c
@@ -6,8 +6,8 @@
#include "system.h"
#include <rpm/header.h>
-#include <rpm/rpmbuild.h>
#include <rpm/rpmlog.h>
+#include "build/rpmbuild_internal.h"
#include "debug.h"
extern int noLang;
diff --git a/build/parseFiles.c b/build/parseFiles.c
index 8cde0cb71..3cdc576d3 100644
--- a/build/parseFiles.c
+++ b/build/parseFiles.c
@@ -5,9 +5,9 @@
#include "system.h"
-#include <rpm/rpmbuild.h>
#include <rpm/rpmlog.h>
#include <rpm/rpmfileutil.h>
+#include "build/rpmbuild_internal.h"
#include "debug.h"
int parseFiles(rpmSpec spec)
diff --git a/build/parsePreamble.c b/build/parsePreamble.c
index 1de801680..6a923a96a 100644
--- a/build/parsePreamble.c
+++ b/build/parsePreamble.c
@@ -8,10 +8,11 @@
#include <ctype.h>
#include <rpm/header.h>
-#include <rpm/rpmbuild.h>
#include <rpm/rpmlog.h>
#include <rpm/rpmfileutil.h>
#include "rpmio/rpmlua.h"
+#include "build/rpmbuild_internal.h"
+#include "build/rpmbuild_misc.h"
#include "debug.h"
#define SKIPSPACE(s) { while (*(s) && risspace(*(s))) (s)++; }
diff --git a/build/parsePrep.c b/build/parsePrep.c
index 394c16249..f7849ccba 100644
--- a/build/parsePrep.c
+++ b/build/parsePrep.c
@@ -8,9 +8,10 @@
#include <errno.h>
#include <rpm/header.h>
-#include <rpm/rpmbuild.h>
#include <rpm/rpmlog.h>
#include <rpm/rpmfileutil.h>
+#include "build/rpmbuild_internal.h"
+#include "build/rpmbuild_misc.h"
#include "debug.h"
/**
diff --git a/build/parseReqs.c b/build/parseReqs.c
index 014db78bc..06ad8d9b2 100644
--- a/build/parseReqs.c
+++ b/build/parseReqs.c
@@ -7,8 +7,9 @@
#include <ctype.h>
#include <rpm/rpmtypes.h>
-#include <rpm/rpmbuild.h>
#include <rpm/rpmlog.h>
+#include "build/rpmbuild_internal.h"
+#include "build/rpmbuild_misc.h"
#include "debug.h"
/**
diff --git a/build/parseScript.c b/build/parseScript.c
index 0368fc592..483250c41 100644
--- a/build/parseScript.c
+++ b/build/parseScript.c
@@ -6,11 +6,12 @@
#include "system.h"
#include <rpm/header.h>
-#include <rpm/rpmbuild.h>
#include <rpm/rpmlog.h>
#include "rpmio/rpmlua.h"
#include "lib/rpmscript.h" /* script flags */
+#include "build/rpmbuild_internal.h"
+#include "build/rpmbuild_misc.h"
#include "debug.h"
diff --git a/build/parseSpec.c b/build/parseSpec.c
index 9488eed0c..bcb8d2a51 100644
--- a/build/parseSpec.c
+++ b/build/parseSpec.c
@@ -9,11 +9,12 @@
#include <rpm/rpmtypes.h>
#include <rpm/rpmlib.h> /* RPM_MACHTABLE & related */
-#include <rpm/rpmbuild.h>
#include <rpm/rpmds.h>
#include <rpm/rpmts.h>
#include <rpm/rpmlog.h>
#include <rpm/rpmfileutil.h>
+#include "build/rpmbuild_internal.h"
+#include "build/rpmbuild_misc.h"
#include "debug.h"
#define SKIPSPACE(s) { while (*(s) && risspace(*(s))) (s)++; }
diff --git a/build/reqprov.c b/build/reqprov.c
index a0d1c87e7..9ecdd3119 100644
--- a/build/reqprov.c
+++ b/build/reqprov.c
@@ -6,7 +6,8 @@
#include "system.h"
#include <rpm/header.h>
-#include <rpm/rpmbuild.h>
+#include <rpm/rpmstring.h>
+#include "build/rpmbuild_misc.h"
#include "debug.h"
static int isNewDep(Header h, rpmTag nametag,
diff --git a/build/rpmbuild.h b/build/rpmbuild.h
index 21ea0de7c..84491a3ac 100644
--- a/build/rpmbuild.h
+++ b/build/rpmbuild.h
@@ -8,11 +8,6 @@
#include <rpm/rpmcli.h>
#include <rpm/rpmds.h>
-
-/* and it shouldn't need these :-( */
-#include <rpm/rpmstring.h>
-
-/* but this will be needed */
#include <rpm/rpmspec.h>
#ifdef __cplusplus
@@ -38,290 +33,6 @@ typedef enum rpmBuildFlags_e {
RPMBUILD_RMSPEC = (1 << 11) /*!< Remove spec file. */
} rpmBuildFlags;
-#define PART_SUBNAME 0
-#define PART_NAME 1
-
-/** \ingroup rpmbuild
- * rpmSpec file parser states.
- */
-/** \ingroup rpmbuild
- * * Spec file parser states.
- * */
-#define PART_BASE 0
-typedef enum rpmParseState_e {
- PART_ERROR = -1, /*!< */
- PART_NONE = 0+PART_BASE, /*!< */
- /* leave room for RPMRC_NOTFOUND returns. */
- PART_PREAMBLE = 11+PART_BASE, /*!< */
- PART_PREP = 12+PART_BASE, /*!< */
- PART_BUILD = 13+PART_BASE, /*!< */
- PART_INSTALL = 14+PART_BASE, /*!< */
- PART_CHECK = 15+PART_BASE, /*!< */
- PART_CLEAN = 16+PART_BASE, /*!< */
- PART_FILES = 17+PART_BASE, /*!< */
- PART_PRE = 18+PART_BASE, /*!< */
- PART_POST = 19+PART_BASE, /*!< */
- PART_PREUN = 20+PART_BASE, /*!< */
- PART_POSTUN = 21+PART_BASE, /*!< */
- PART_PRETRANS = 22+PART_BASE, /*!< */
- PART_POSTTRANS = 23+PART_BASE, /*!< */
- PART_DESCRIPTION = 24+PART_BASE, /*!< */
- PART_CHANGELOG = 25+PART_BASE, /*!< */
- PART_TRIGGERIN = 26+PART_BASE, /*!< */
- PART_TRIGGERUN = 27+PART_BASE, /*!< */
- PART_VERIFYSCRIPT = 28+PART_BASE, /*!< */
- PART_BUILDARCHITECTURES= 29+PART_BASE,/*!< */
- PART_TRIGGERPOSTUN = 30+PART_BASE, /*!< */
- PART_TRIGGERPREIN = 31+PART_BASE, /*!< */
- PART_LAST = 32+PART_BASE /*!< */
-} rpmParseState;
-
-
-#define STRIP_NOTHING 0
-#define STRIP_TRAILINGSPACE (1 << 0)
-#define STRIP_COMMENTS (1 << 1)
-
-/** \ingroup rpmbuild
- * Destroy uid/gid caches.
- */
-void freeNames(void);
-
-/** \ingroup rpmbuild
- * Return cached user name from user id.
- * @todo Implement using hash.
- * @param uid user id
- * @return cached user name
- */
-const char * getUname(uid_t uid);
-
-/** \ingroup rpmbuild
- * Return cached user name.
- * @todo Implement using hash.
- * @param uname user name
- * @return cached user name
- */
-const char * getUnameS(const char * uname);
-
-/** \ingroup rpmbuild
- * Return cached user id.
- * @todo Implement using hash.
- * @param uname user name
- * @return cached uid
- */
-uid_t getUidS(const char * uname);
-
-/** \ingroup rpmbuild
- * Return cached group name from group id.
- * @todo Implement using hash.
- * @param gid group id
- * @return cached group name
- */
-const char * getGname(gid_t gid);
-
-/** \ingroup rpmbuild
- * Return cached group name.
- * @todo Implement using hash.
- * @param gname group name
- * @return cached group name
- */
-const char * getGnameS(const char * gname);
-
-/** \ingroup rpmbuild
- * Return cached group id.
- * @todo Implement using hash.
- * @param gname group name
- * @return cached gid
- */
-gid_t getGidS(const char * gname);
-
-/** \ingroup rpmbuild
- * Read next line from spec file.
- * @param spec spec file control structure
- * @param strip truncate comments?
- * @return 0 on success, 1 on EOF, <0 on error
- */
-int readLine(rpmSpec spec, int strip);
-
-/** \ingroup rpmbuild
- * Stop reading from spec file, freeing resources.
- * @param spec spec file control structure
- */
-void closeSpec(rpmSpec spec);
-
-/** \ingroup rpmbuild
- * Truncate comment lines.
- * @param s skip white space, truncate line at '#'
- */
-void handleComments(char * s);
-
-/** \ingroup rpmbuild
- * Check line for section separator, return next parser state.
- * @param line from spec file
- * @return next parser state
- */
-rpmParseState isPart(const char * line) ;
-
-/** \ingroup rpmbuild
- * Parse an unsigned number.
- * @param line from spec file
- * @retval res pointer to uint32_t
- * @return 0 on success, 1 on failure
- */
-uint32_t parseUnsignedNum(const char * line, uint32_t * res);
-
-/** \ingroup rpmbuild
- * Parse %%build/%%install/%%clean section(s) of a spec file.
- * @param spec spec file control structure
- * @param parsePart current rpmParseState
- * @return >= 0 next rpmParseState, < 0 on error
- */
-int parseBuildInstallClean(rpmSpec spec, rpmParseState parsePart);
-
-/** \ingroup rpmbuild
- * Parse %%changelog section of a spec file.
- * @param spec spec file control structure
- * @return >= 0 next rpmParseState, < 0 on error
- */
-int parseChangelog(rpmSpec spec);
-
-/** \ingroup rpmbuild
- * Parse %%description section of a spec file.
- * @param spec spec file control structure
- * @return >= 0 next rpmParseState, < 0 on error
- */
-int parseDescription(rpmSpec spec);
-
-/** \ingroup rpmbuild
- * Parse %%files section of a spec file.
- * @param spec spec file control structure
- * @return >= 0 next rpmParseState, < 0 on error
- */
-int parseFiles(rpmSpec spec);
-
-/** \ingroup rpmbuild
- * Parse tags from preamble of a spec file.
- * @param spec spec file control structure
- * @param initialPackage
- * @return >= 0 next rpmParseState, < 0 on error
- */
-int parsePreamble(rpmSpec spec, int initialPackage);
-
-/** \ingroup rpmbuild
- * Parse %%prep section of a spec file.
- * @param spec spec file control structure
- * @return >= 0 next rpmParseState, < 0 on error
- */
-int parsePrep(rpmSpec spec);
-
-/** \ingroup rpmbuild
- * Check for inappropriate characters. All alphanums are considered sane.
- * @param spec spec
- * @param field string to check
- * @param fsize size of string to check
- * @param whitelist string of permitted characters
- * @return RPMRC_OK if OK
- */
-rpmRC rpmCharCheck(rpmSpec spec, char *field, size_t fsize, const char *whitelist);
-
-/** \ingroup rpmbuild
- * Parse dependency relations from spec file and/or autogenerated output buffer.
- * @param spec spec file control structure
- * @param pkg package control structure
- * @param field text to parse (e.g. "foo < 0:1.2-3, bar = 5:6.7")
- * @param tagN tag, identifies type of dependency
- * @param index (0 always)
- * @param tagflags dependency flags already known from context
- * @return RPMRC_OK on success, RPMRC_FAIL on failure
- */
-rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char * field, rpmTag tagN,
- int index, rpmsenseFlags tagflags);
-
-/** \ingroup rpmbuild
- * Parse %%pre et al scriptlets from a spec file.
- * @param spec spec file control structure
- * @param parsePart current rpmParseState
- * @return >= 0 next rpmParseState, < 0 on error
- */
-int parseScript(rpmSpec spec, int parsePart);
-
-/** \ingroup rpmbuild
- * Evaluate boolean expression.
- * @param spec spec file control structure
- * @param expr expression to parse
- * @return
- */
-int parseExpressionBoolean(rpmSpec spec, const char * expr);
-
-/** \ingroup rpmbuild
- * Run a build script, assembled from spec file scriptlet section.
- *
- * @param spec spec file control structure
- * @param what type of script
- * @param name name of scriptlet section
- * @param sb lines that compose script body
- * @param test don't execute scripts or package if testing
- * @return RPMRC_OK on success
- */
-rpmRC doScript(rpmSpec spec, rpmBuildFlags what, const char * name,
- StringBuf sb, int test);
-
-/** \ingroup rpmbuild
- * Find sub-package control structure by name.
- * @param spec spec file control structure
- * @param name (sub-)package name
- * @param flag if PART_SUBNAME, then 1st package name is prepended
- * @retval pkg package control structure
- * @return 0 on success, 1 on failure
- */
-rpmRC lookupPackage(rpmSpec spec, const char * name, int flag,
- Package * pkg);
-
-/** \ingroup rpmbuild
- * Create and initialize package control structure.
- * @param spec spec file control structure
- * @return package control structure
- */
-Package newPackage(rpmSpec spec);
-
-/** \ingroup rpmbuild
- * Add dependency to header, filtering duplicates.
- * @param h header
- * @param tagN tag, identifies type of dependency
- * @param N (e.g. Requires: foo < 0:1.2-3, "foo")
- * @param EVR (e.g. Requires: foo < 0:1.2-3, "0:1.2-3")
- * @param Flags (e.g. Requires: foo < 0:1.2-3, both "Requires:" and "<")
- * @param index (0 always)
- * @return 0 on success, 1 on error
- */
-int addReqProv(Header h, rpmTag tagN,
- const char * N, const char * EVR, rpmsenseFlags Flags,
- uint32_t index);
-
-/** \ingroup rpmbuild
- * Add rpmlib feature dependency.
- * @param h header
- * @param feature rpm feature name (i.e. "rpmlib(Foo)" for feature Foo)
- * @param featureEVR rpm feature epoch/version/release
- * @return 0 always
- */
-int rpmlibNeedsFeature(Header h, const char * feature, const char * featureEVR);
-
-/** \ingroup rpmbuild
- * Post-build processing for binary package(s).
- * @param spec spec file control structure
- * @param installSpecialDoc
- * @param test don't execute scripts or package if testing
- * @return 0 on success
- */
-int processBinaryFiles(rpmSpec spec, int installSpecialDoc, int test);
-
-/** \ingroup rpmbuild
- * Post-build processing for source package.
- * @param spec spec file control structure
- * @return 0 on success
- */
-int processSourceFiles(rpmSpec spec);
-
/** \ingroup rpmbuild
* Parse spec file into spec control structure.
* @param ts transaction set (spec file control in ts->spec)
@@ -353,20 +64,6 @@ int parseSpec(rpmts ts, const char * specFile,
*/
rpmRC buildSpec(rpmts ts, rpmSpec spec, int what, int test);
-/** \ingroup rpmbuild
- * Generate binary package(s).
- * @param spec spec file control structure
- * @return RPMRC_OK on success
- */
-rpmRC packageBinaries(rpmSpec spec);
-
-/** \ingroup rpmbuild
- * Generate source package.
- * @param spec spec file control structure
- * @return RPMRC_OK on success
- */
-rpmRC packageSources(rpmSpec spec);
-
#ifdef __cplusplus
}
#endif
diff --git a/build/rpmbuild_internal.h b/build/rpmbuild_internal.h
new file mode 100644
index 000000000..7b47a5e57
--- /dev/null
+++ b/build/rpmbuild_internal.h
@@ -0,0 +1,248 @@
+#ifndef _RPMBUILD_INTERNAL_H
+#define _RPMBUILD_INTERNAL_H
+
+#include <rpm/rpmbuild.h>
+#include <rpm/rpmutil.h>
+
+#define PART_SUBNAME 0
+#define PART_NAME 1
+
+/** \ingroup rpmbuild
+ * rpmSpec file parser states.
+ */
+#define PART_BASE 0
+typedef enum rpmParseState_e {
+ PART_ERROR = -1, /*!< */
+ PART_NONE = 0+PART_BASE, /*!< */
+ /* leave room for RPMRC_NOTFOUND returns. */
+ PART_PREAMBLE = 11+PART_BASE, /*!< */
+ PART_PREP = 12+PART_BASE, /*!< */
+ PART_BUILD = 13+PART_BASE, /*!< */
+ PART_INSTALL = 14+PART_BASE, /*!< */
+ PART_CHECK = 15+PART_BASE, /*!< */
+ PART_CLEAN = 16+PART_BASE, /*!< */
+ PART_FILES = 17+PART_BASE, /*!< */
+ PART_PRE = 18+PART_BASE, /*!< */
+ PART_POST = 19+PART_BASE, /*!< */
+ PART_PREUN = 20+PART_BASE, /*!< */
+ PART_POSTUN = 21+PART_BASE, /*!< */
+ PART_PRETRANS = 22+PART_BASE, /*!< */
+ PART_POSTTRANS = 23+PART_BASE, /*!< */
+ PART_DESCRIPTION = 24+PART_BASE, /*!< */
+ PART_CHANGELOG = 25+PART_BASE, /*!< */
+ PART_TRIGGERIN = 26+PART_BASE, /*!< */
+ PART_TRIGGERUN = 27+PART_BASE, /*!< */
+ PART_VERIFYSCRIPT = 28+PART_BASE, /*!< */
+ PART_BUILDARCHITECTURES= 29+PART_BASE,/*!< */
+ PART_TRIGGERPOSTUN = 30+PART_BASE, /*!< */
+ PART_TRIGGERPREIN = 31+PART_BASE, /*!< */
+ PART_LAST = 32+PART_BASE /*!< */
+} rpmParseState;
+
+
+#define STRIP_NOTHING 0
+#define STRIP_TRAILINGSPACE (1 << 0)
+#define STRIP_COMMENTS (1 << 1)
+
+/** \ingroup rpmbuild
+ * Create and initialize rpmSpec structure.
+ * @return spec spec file control structure
+ */
+RPM_GNUC_INTERNAL
+rpmSpec newSpec(void);
+
+/** \ingroup rpmbuild
+ * Stop reading from spec file, freeing resources.
+ * @param spec spec file control structure
+ */
+RPM_GNUC_INTERNAL
+void closeSpec(rpmSpec spec);
+
+/** \ingroup rpmbuild
+ * Read next line from spec file.
+ * @param spec spec file control structure
+ * @param strip truncate comments?
+ * @return 0 on success, 1 on EOF, <0 on error
+ */
+RPM_GNUC_INTERNAL
+int readLine(rpmSpec spec, int strip);
+
+/** \ingroup rpmbuild
+ * Check line for section separator, return next parser state.
+ * @param line from spec file
+ * @return next parser state
+ */
+RPM_GNUC_INTERNAL
+rpmParseState isPart(const char * line) ;
+
+/** \ingroup rpmbuild
+ * Parse %%build/%%install/%%clean section(s) of a spec file.
+ * @param spec spec file control structure
+ * @param parsePart current rpmParseState
+ * @return >= 0 next rpmParseState, < 0 on error
+ */
+RPM_GNUC_INTERNAL
+int parseBuildInstallClean(rpmSpec spec, rpmParseState parsePart);
+
+/** \ingroup rpmbuild
+ * Parse %%changelog section of a spec file.
+ * @param spec spec file control structure
+ * @return >= 0 next rpmParseState, < 0 on error
+ */
+RPM_GNUC_INTERNAL
+int parseChangelog(rpmSpec spec);
+
+/** \ingroup rpmbuild
+ * Parse %%description section of a spec file.
+ * @param spec spec file control structure
+ * @return >= 0 next rpmParseState, < 0 on error
+ */
+RPM_GNUC_INTERNAL
+int parseDescription(rpmSpec spec);
+
+/** \ingroup rpmbuild
+ * Parse %%files section of a spec file.
+ * @param spec spec file control structure
+ * @return >= 0 next rpmParseState, < 0 on error
+ */
+RPM_GNUC_INTERNAL
+int parseFiles(rpmSpec spec);
+
+/** \ingroup rpmbuild
+ * Parse tags from preamble of a spec file.
+ * @param spec spec file control structure
+ * @param initialPackage
+ * @return >= 0 next rpmParseState, < 0 on error
+ */
+RPM_GNUC_INTERNAL
+int parsePreamble(rpmSpec spec, int initialPackage);
+
+/** \ingroup rpmbuild
+ * Parse %%prep section of a spec file.
+ * @param spec spec file control structure
+ * @return >= 0 next rpmParseState, < 0 on error
+ */
+RPM_GNUC_INTERNAL
+int parsePrep(rpmSpec spec);
+
+/** \ingroup rpmbuild
+ * Parse %%pre et al scriptlets from a spec file.
+ * @param spec spec file control structure
+ * @param parsePart current rpmParseState
+ * @return >= 0 next rpmParseState, < 0 on error
+ */
+RPM_GNUC_INTERNAL
+int parseScript(rpmSpec spec, int parsePart);
+
+/** \ingroup rpmbuild
+ * Check for inappropriate characters. All alphanums are considered sane.
+ * @param spec spec
+ * @param field string to check
+ * @param fsize size of string to check
+ * @param whitelist string of permitted characters
+ * @return RPMRC_OK if OK
+ */
+RPM_GNUC_INTERNAL
+rpmRC rpmCharCheck(rpmSpec spec, char *field, size_t fsize, const char *whitelist);
+
+/** \ingroup rpmbuild
+ * stashSt.
+ * @param spec spec file control structure
+ * @param h header
+ * @param tag tag
+ * @param lang locale
+ */
+spectag stashSt(rpmSpec spec, Header h, rpmTag tag, const char * lang);
+
+/** \ingroup rpmbuild
+ * Parse dependency relations from spec file and/or autogenerated output buffer.
+ * @param spec spec file control structure
+ * @param pkg package control structure
+ * @param field text to parse (e.g. "foo < 0:1.2-3, bar = 5:6.7")
+ * @param tagN tag, identifies type of dependency
+ * @param index (0 always)
+ * @param tagflags dependency flags already known from context
+ * @return RPMRC_OK on success, RPMRC_FAIL on failure
+ */
+RPM_GNUC_INTERNAL
+rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char * field, rpmTag tagN,
+ int index, rpmsenseFlags tagflags);
+
+/** \ingroup rpmbuild
+ * Evaluate boolean expression.
+ * @param spec spec file control structure
+ * @param expr expression to parse
+ * @return
+ */
+RPM_GNUC_INTERNAL
+int parseExpressionBoolean(rpmSpec spec, const char * expr);
+
+/** \ingroup rpmbuild
+ * Run a build script, assembled from spec file scriptlet section.
+ *
+ * @param spec spec file control structure
+ * @param what type of script
+ * @param name name of scriptlet section
+ * @param sb lines that compose script body
+ * @param test don't execute scripts or package if testing
+ * @return RPMRC_OK on success
+ */
+RPM_GNUC_INTERNAL
+rpmRC doScript(rpmSpec spec, rpmBuildFlags what, const char * name,
+ StringBuf sb, int test);
+
+/** \ingroup rpmbuild
+ * Find sub-package control structure by name.
+ * @param spec spec file control structure
+ * @param name (sub-)package name
+ * @param flag if PART_SUBNAME, then 1st package name is prepended
+ * @retval pkg package control structure
+ * @return 0 on success, 1 on failure
+ */
+RPM_GNUC_INTERNAL
+rpmRC lookupPackage(rpmSpec spec, const char * name, int flag,
+ Package * pkg);
+
+/** \ingroup rpmbuild
+ * Create and initialize package control structure.
+ * @param spec spec file control structure
+ * @return package control structure
+ */
+RPM_GNUC_INTERNAL
+Package newPackage(rpmSpec spec);
+
+/** \ingroup rpmbuild
+ * Post-build processing for binary package(s).
+ * @param spec spec file control structure
+ * @param installSpecialDoc
+ * @param test don't execute scripts or package if testing
+ * @return 0 on success
+ */
+RPM_GNUC_INTERNAL
+int processBinaryFiles(rpmSpec spec, int installSpecialDoc, int test);
+
+/** \ingroup rpmbuild
+ * Post-build processing for source package.
+ * @param spec spec file control structure
+ * @return 0 on success
+ */
+RPM_GNUC_INTERNAL
+int processSourceFiles(rpmSpec spec);
+
+/** \ingroup rpmbuild
+ * Generate binary package(s).
+ * @param spec spec file control structure
+ * @return RPMRC_OK on success
+ */
+RPM_GNUC_INTERNAL
+rpmRC packageBinaries(rpmSpec spec);
+
+/** \ingroup rpmbuild
+ * Generate source package.
+ * @param spec spec file control structure
+ * @return RPMRC_OK on success
+ */
+RPM_GNUC_INTERNAL
+rpmRC packageSources(rpmSpec spec);
+
+#endif /* _RPMBUILD_INTERNAL_H */
diff --git a/build/rpmbuild_misc.h b/build/rpmbuild_misc.h
new file mode 100644
index 000000000..dae216aa4
--- /dev/null
+++ b/build/rpmbuild_misc.h
@@ -0,0 +1,110 @@
+#ifndef _RPMBUILD_MISC_H
+#define _RPMBUILD_MISC_H
+
+#include <sys/types.h>
+#include <rpm/rpmtypes.h>
+#include <rpm/rpmds.h>
+
+/** \ingroup rpmbuild
+ * Destroy uid/gid caches.
+ * @todo Get this out of the ABI
+ */
+/* RPM_GNUC_INTERNAL XXX should be internal too but rpmbuild "needs" for now */
+void freeNames(void);
+
+/** \ingroup rpmbuild
+ * Return cached user name from user id.
+ * @todo Implement using hash.
+ * @param uid user id
+ * @return cached user name
+ */
+RPM_GNUC_INTERNAL
+const char * getUname(uid_t uid);
+
+/** \ingroup rpmbuild
+ * Return cached user name.
+ * @todo Implement using hash.
+ * @param uname user name
+ * @return cached user name
+ */
+RPM_GNUC_INTERNAL
+const char * getUnameS(const char * uname);
+
+/** \ingroup rpmbuild
+ * Return cached user id.
+ * @todo Implement using hash.
+ * @param uname user name
+ * @return cached uid
+ */
+RPM_GNUC_INTERNAL
+uid_t getUidS(const char * uname);
+
+/** \ingroup rpmbuild
+ * Return cached group name from group id.
+ * @todo Implement using hash.
+ * @param gid group id
+ * @return cached group name
+ */
+RPM_GNUC_INTERNAL
+const char * getGname(gid_t gid);
+
+/** \ingroup rpmbuild
+ * Return cached group name.
+ * @todo Implement using hash.
+ * @param gname group name
+ * @return cached group name
+ */
+RPM_GNUC_INTERNAL
+const char * getGnameS(const char * gname);
+
+/** \ingroup rpmbuild
+ * Return cached group id.
+ * @todo Implement using hash.
+ * @param gname group name
+ * @return cached gid
+ */
+RPM_GNUC_INTERNAL
+gid_t getGidS(const char * gname);
+
+/** \ingroup rpmbuild
+ * Truncate comment lines.
+ * @param s skip white space, truncate line at '#'
+ */
+RPM_GNUC_INTERNAL
+void handleComments(char * s);
+
+/** \ingroup rpmbuild
+ * Parse an unsigned number.
+ * @param line from spec file
+ * @retval res pointer to uint32_t
+ * @return 0 on success, 1 on failure
+ */
+RPM_GNUC_INTERNAL
+uint32_t parseUnsignedNum(const char * line, uint32_t * res);
+
+/** \ingroup rpmbuild
+ * Add dependency to header, filtering duplicates.
+ * @param h header
+ * @param tagN tag, identifies type of dependency
+ * @param N (e.g. Requires: foo < 0:1.2-3, "foo")
+ * @param EVR (e.g. Requires: foo < 0:1.2-3, "0:1.2-3")
+ * @param Flags (e.g. Requires: foo < 0:1.2-3, both "Requires:" and "<")
+ * @param index (0 always)
+ * @return 0 on success, 1 on error
+ */
+RPM_GNUC_INTERNAL
+int addReqProv(Header h, rpmTag tagN,
+ const char * N, const char * EVR, rpmsenseFlags Flags,
+ uint32_t index);
+
+/** \ingroup rpmbuild
+ * Add rpmlib feature dependency.
+ * @param h header
+ * @param feature rpm feature name (i.e. "rpmlib(Foo)" for feature Foo)
+ * @param featureEVR rpm feature epoch/version/release
+ * @return 0 always
+ */
+RPM_GNUC_INTERNAL
+int rpmlibNeedsFeature(Header h, const char * feature, const char * featureEVR);
+
+#endif /* _RPMBUILD_MISC_H */
diff --git a/build/rpmfc.c b/build/rpmfc.c
index 4fd32e3d3..645a25fe2 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -8,15 +8,15 @@
#include <regex.h>
#include <rpm/header.h>
-#include <rpm/rpmbuild.h>
#include <rpm/argv.h>
#include <rpm/rpmfc.h>
#include <rpm/rpmlog.h>
#include <rpm/rpmfileutil.h>
-
#include <rpm/rpmds.h>
#include <rpm/rpmfi.h>
+#include "build/rpmbuild_internal.h"
+
#include "debug.h"
typedef struct rpmfcAttr_s {
diff --git a/build/rpmspec.h b/build/rpmspec.h
index 6d6e63864..f77b077b8 100644
--- a/build/rpmspec.h
+++ b/build/rpmspec.h
@@ -165,12 +165,6 @@ struct Package_s {
};
/** \ingroup rpmbuild
- * Create and initialize rpmSpec structure.
- * @return spec spec file control structure
- */
-rpmSpec newSpec(void);
-
-/** \ingroup rpmbuild
* Destroy Spec structure.
* @param spec spec file control structure
* @return NULL always
@@ -186,15 +180,6 @@ rpmSpec freeSpec(rpmSpec spec);
*/
int rpmspecQuery(rpmts ts, QVA_t qva, const char * arg);
-/** \ingroup rpmbuild
- * stashSt.
- * @param spec spec file control structure
- * @param h header
- * @param tag tag
- * @param lang locale
- */
-spectag stashSt(rpmSpec spec, Header h, rpmTag tag, const char * lang);
-
#ifdef __cplusplus
}
#endif
diff --git a/build/spec.c b/build/spec.c
index 84d1c8419..9fe7ddbb2 100644
--- a/build/spec.c
+++ b/build/spec.c
@@ -11,9 +11,9 @@
#include <rpm/rpmts.h>
#include <rpm/rpmlog.h>
#include <rpm/rpmfileutil.h>
-#include <rpm/rpmbuild.h>
#include "rpmio/rpmlua.h"
+#include "build/rpmbuild_internal.h"
#include "debug.h"
diff --git a/rpmbuild.c b/rpmbuild.c
index 8fdf5a6ba..e58ed3fe7 100644
--- a/rpmbuild.c
+++ b/rpmbuild.c
@@ -14,6 +14,7 @@ const char *__progname;
#include <rpm/rpmps.h>
#include <rpm/rpmts.h>
#include "lib/signature.h"
+#include "build/rpmbuild_misc.h" /* XXX freeNames() */
#include "cliutils.h"
#include "debug.h"