summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2002-12-22 02:11:05 +0000
committerjbj <devnull@localhost>2002-12-22 02:11:05 +0000
commitb63b4a5d122e8dfb631c8fa75a9a7a92708080ec (patch)
tree83f213dc374fadf65b4c520e03bda0bc0ebf685b /build
parent1f6cdca2d549e02f3e65afa27b80cb852e283cd2 (diff)
downloadlibrpm-tizen-b63b4a5d122e8dfb631c8fa75a9a7a92708080ec.tar.gz
librpm-tizen-b63b4a5d122e8dfb631c8fa75a9a7a92708080ec.tar.bz2
librpm-tizen-b63b4a5d122e8dfb631c8fa75a9a7a92708080ec.zip
- simplify specfile query linkage loop.
- drill rpmts into parseSpec(), carrying Spec along. CVS patchset: 5958 CVS date: 2002/12/22 02:11:05
Diffstat (limited to 'build')
-rw-r--r--build/pack.c9
-rw-r--r--build/parseSpec.c14
-rw-r--r--build/rpmbuild.h36
-rw-r--r--build/rpmspec.h21
-rw-r--r--build/spec.c160
5 files changed, 186 insertions, 54 deletions
diff --git a/build/pack.c b/build/pack.c
index 5d219831d..56400cf14 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -870,10 +870,13 @@ int packageSources(Spec spec)
csa, spec->passPhrase, &(spec->cookie));
if (rc == 0 && sig != NULL) {
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
- const unsigned char * s = NULL;
+ const unsigned char * md5 = NULL;
+ rpmTagType type;
+ int_32 c;
int xx;
- xx = hge(sig, RPMSIGTAG_MD5, NULL, (void **)&s, NULL);
- spec->sourcePkgId = s;
+ xx = hge(sig, RPMSIGTAG_MD5, &type, (void **)&md5, &c);
+ if (type == RPM_BIN_TYPE && md5 != NULL && c == 16)
+ spec->sourcePkgId = memcpy(xmalloc(16), md5, 16);;
sig = headerFree(sig);
}
csa->cpioFdIn = fdFree(csa->cpioFdIn, "init (packageSources)");
diff --git a/build/parseSpec.c b/build/parseSpec.c
index 72eb34af9..147c03a05 100644
--- a/build/parseSpec.c
+++ b/build/parseSpec.c
@@ -389,7 +389,7 @@ extern int noLang; /* XXX FIXME: pass as arg */
/*@todo Skip parse recursion if os is not compatible. @*/
/*@-boundswrite@*/
-int parseSpec(Spec *specp, const char *specFile, const char *rootURL,
+int parseSpec(rpmts ts, const char *specFile, const char *rootURL,
const char *buildRootURL, int recursing, const char *passPhrase,
char *cookie, int anyarch, int force)
{
@@ -428,8 +428,6 @@ int parseSpec(Spec *specp, const char *specFile, const char *rootURL,
spec->gotBuildRootURL = 1;
spec->buildRootURL = xstrdup(buildRootURL);
addMacro(spec->macros, "buildroot", NULL, buildRoot, RMIL_SPEC);
-if (_debug)
-fprintf(stderr, "*** PS buildRootURL(%s) %p macro set to %s\n", spec->buildRootURL, spec->buildRootURL, buildRoot);
}
addMacro(NULL, "_docdir", NULL, "%{_defaultdocdir}", RMIL_SPEC);
spec->recursing = recursing;
@@ -521,9 +519,9 @@ fprintf(stderr, "*** PS buildRootURL(%s) %p macro set to %s\n", spec->buildRootU
addMacro(NULL, "_target_cpu", NULL, spec->BANames[x], RMIL_RPMRC);
#endif
spec->BASpecs[index] = NULL;
- if (parseSpec(&(spec->BASpecs[index]),
- specFile, spec->rootURL, buildRootURL, 1,
- passPhrase, cookie, anyarch, force))
+ if (parseSpec(ts, specFile, spec->rootURL, buildRootURL, 1,
+ passPhrase, cookie, anyarch, force)
+ || (spec->BASpecs[index] = rpmtsSetSpec(ts, NULL)) == NULL)
{
spec->BACount = index;
spec = freeSpec(spec);
@@ -564,7 +562,7 @@ fprintf(stderr, "*** PS buildRootURL(%s) %p macro set to %s\n", spec->buildRootU
}
/*@=branchstate@*/
- *specp = spec;
+ (void) rpmtsSetSpec(ts, spec);
return 0;
}
}
@@ -626,7 +624,7 @@ fprintf(stderr, "*** PS buildRootURL(%s) %p macro set to %s\n", spec->buildRootU
}
closeSpec(spec);
- *specp = spec;
+ (void) rpmtsSetSpec(ts, spec);
return 0;
}
diff --git a/build/rpmbuild.h b/build/rpmbuild.h
index 2eafbb26c..d1dd71cce 100644
--- a/build/rpmbuild.h
+++ b/build/rpmbuild.h
@@ -453,7 +453,7 @@ int processSourceFiles(Spec spec)
/** \ingroup rpmbuild
* Parse spec file into spec control structure.
- * @retval specp spec file control structure
+ * @param ts transaction set (spec file control in ts->spec)
* @param specFile
* @param rootURL
* @param buildRootURL
@@ -464,7 +464,7 @@ int processSourceFiles(Spec spec)
* @param force
* @return
*/
-int parseSpec(/*@out@*/ Spec * specp, const char * specFile,
+int parseSpec(rpmts ts, const char * specFile,
/*@null@*/ const char * rootURL,
/*@null@*/ const char * buildRootURL,
int recursing,
@@ -477,32 +477,6 @@ int parseSpec(/*@out@*/ Spec * specp, const char * specFile,
rpmGlobalMacroContext, fileSystem, internalState @*/;
/** \ingroup rpmbuild
- * @retval specp spec file control structure
- * @param specFile
- * @param rootdir
- * @param buildRoot
- * @param recursing parse is recursive?
- * @param passPhrase
- * @param cookie
- * @param anyarch
- * @param force
- * @return
- */
-/*@-declundef@*/
-extern int (*parseSpecVec) (Spec * specp, const char * specFile,
- const char * rootdir,
- /*@null@*/ const char * buildRoot,
- int recursing,
- /*@null@*/ const char * passPhrase,
- /*@null@*/ char * cookie,
- int anyarch, int force)
- /*@globals rpmGlobalMacroContext,
- fileSystem, internalState @*/
- /*@modifies *specp,
- rpmGlobalMacroContext, fileSystem, internalState @*/;
-/*@=declundef@*/
-
-/** \ingroup rpmbuild
* Build stages state machine driver.
* @param spec spec file control structure
* @param what bit(s) to enable stages of build
@@ -513,8 +487,8 @@ int buildSpec(Spec spec, int what, int test)
/*@globals rpmGlobalMacroContext,
fileSystem, internalState @*/
/*@modifies spec->sourceHeader, spec->sourceCpioList, spec->cookie,
- spec->sourceRpmName, spec->macros,
- spec->BASpecs,
+ spec->sourceRpmName, spec->sourcePkgId,
+ spec->macros, spec->BASpecs,
spec->buildRestrictions, spec->BANames,
spec->packages->cpioList, spec->packages->fileList,
spec->packages->specialDoc, spec->packages->header,
@@ -541,7 +515,7 @@ int packageSources(Spec spec)
/*@globals rpmGlobalMacroContext,
fileSystem, internalState @*/
/*@modifies spec->sourceHeader, spec->cookie,
- spec->sourceRpmName,
+ spec->sourceRpmName, spec->sourcePkgId,
rpmGlobalMacroContext, fileSystem, internalState @*/;
/*@=redecl@*/
diff --git a/build/rpmspec.h b/build/rpmspec.h
index 1f04558f9..5bfec8d59 100644
--- a/build/rpmspec.h
+++ b/build/rpmspec.h
@@ -8,10 +8,6 @@
/** \ingroup rpmbuild
*/
-typedef struct Spec_s * Spec;
-
-/** \ingroup rpmbuild
- */
typedef struct Package_s * Package;
/** \ingroup rpmbuild
@@ -235,14 +231,17 @@ extern "C" {
/*@modifies spec, fileSystem, internalState @*/;
/** \ingroup rpmbuild
- * @param spec spec file control structure
- * @return NULL always
+ * Function to query spec file(s).
+ * @param ts transaction set
+ * @param qva parsed query/verify options
+ * @param arg query argument
+ * @return 0 on success, else no. of failures
*/
-/*@-declundef@*/
-extern /*@null@*/ Spec (*freeSpecVec) (Spec spec) /* XXX FIXME */
- /*@globals fileSystem, internalState @*/
- /*@modifies spec, fileSystem, internalState @*/;
-/*@=declundef@*/
+int rpmspecQuery(rpmts ts, QVA_t qva, const char * arg)
+ /*@globals rpmGlobalMacroContext,
+ fileSystem, internalState @*/
+ /*@modifies ts, qva, rpmGlobalMacroContext,
+ fileSystem, internalState @*/;
/** \ingroup rpmbuild
*/
diff --git a/build/spec.c b/build/spec.c
index 686d90487..e162ce012 100644
--- a/build/spec.c
+++ b/build/spec.c
@@ -7,6 +7,7 @@
#include "buildio.h"
#include "rpmfi.h"
+#include "rpmts.h"
#include "debug.h"
@@ -555,7 +556,8 @@ Spec freeSpec(Spec spec)
return spec;
}
-/*@only@*/ struct OpenFileInfo * newOpenFileInfo(void)
+/*@only@*/
+struct OpenFileInfo * newOpenFileInfo(void)
{
struct OpenFileInfo *ofi;
@@ -571,3 +573,159 @@ Spec freeSpec(Spec spec)
return ofi;
}
+
+/**
+ * Print copy of spec file, filling in Group/Description/Summary from specspo.
+ * @param spec spec file control structure
+ */
+static void
+printNewSpecfile(Spec spec)
+ /*@globals fileSystem @*/
+ /*@modifies spec->sl->sl_lines[], fileSystem @*/
+{
+ Header h;
+ speclines sl = spec->sl;
+ spectags st = spec->st;
+ const char * msgstr = NULL;
+ int i, j;
+
+ if (sl == NULL || st == NULL)
+ return;
+
+ /*@-branchstate@*/
+ for (i = 0; i < st->st_ntags; i++) {
+ spectag t = st->st_t + i;
+ const char * tn = tagName(t->t_tag);
+ const char * errstr;
+ char fmt[1024];
+
+ fmt[0] = '\0';
+ if (t->t_msgid == NULL)
+ h = spec->packages->header;
+ else {
+ Package pkg;
+ char *fe;
+
+/*@-bounds@*/
+ strcpy(fmt, t->t_msgid);
+ for (fe = fmt; *fe && *fe != '('; fe++)
+ {} ;
+ if (*fe == '(') *fe = '\0';
+/*@=bounds@*/
+ h = NULL;
+ for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
+ const char *pkgname;
+ h = pkg->header;
+ (void) headerNVR(h, &pkgname, NULL, NULL);
+ if (!strcmp(pkgname, fmt))
+ /*@innerbreak@*/ break;
+ }
+ if (pkg == NULL || h == NULL)
+ h = spec->packages->header;
+ }
+
+ if (h == NULL)
+ continue;
+
+ fmt[0] = '\0';
+/*@-boundswrite@*/
+ (void) stpcpy( stpcpy( stpcpy( fmt, "%{"), tn), "}");
+/*@=boundswrite@*/
+ msgstr = _free(msgstr);
+
+ /* XXX this should use queryHeader(), but prints out tn as well. */
+ msgstr = headerSprintf(h, fmt, rpmTagTable, rpmHeaderFormats, &errstr);
+ if (msgstr == NULL) {
+ rpmError(RPMERR_QFMT, _("can't query %s: %s\n"), tn, errstr);
+ return;
+ }
+
+/*@-boundswrite@*/
+ switch(t->t_tag) {
+ case RPMTAG_SUMMARY:
+ case RPMTAG_GROUP:
+ /*@-unqualifiedtrans@*/
+ sl->sl_lines[t->t_startx] = _free(sl->sl_lines[t->t_startx]);
+ /*@=unqualifiedtrans@*/
+ if (t->t_lang && strcmp(t->t_lang, RPMBUILD_DEFAULT_LANG))
+ continue;
+ { char *buf = xmalloc(strlen(tn) + sizeof(": ") + strlen(msgstr));
+ (void) stpcpy( stpcpy( stpcpy(buf, tn), ": "), msgstr);
+ sl->sl_lines[t->t_startx] = buf;
+ }
+ /*@switchbreak@*/ break;
+ case RPMTAG_DESCRIPTION:
+ for (j = 1; j < t->t_nlines; j++) {
+ if (*sl->sl_lines[t->t_startx + j] == '%')
+ /*@innercontinue@*/ continue;
+ /*@-unqualifiedtrans@*/
+ sl->sl_lines[t->t_startx + j] =
+ _free(sl->sl_lines[t->t_startx + j]);
+ /*@=unqualifiedtrans@*/
+ }
+ if (t->t_lang && strcmp(t->t_lang, RPMBUILD_DEFAULT_LANG)) {
+ sl->sl_lines[t->t_startx] = _free(sl->sl_lines[t->t_startx]);
+ continue;
+ }
+ sl->sl_lines[t->t_startx + 1] = xstrdup(msgstr);
+ if (t->t_nlines > 2)
+ sl->sl_lines[t->t_startx + 2] = xstrdup("\n\n");
+ /*@switchbreak@*/ break;
+ }
+/*@=boundswrite@*/
+ }
+ /*@=branchstate@*/
+ msgstr = _free(msgstr);
+
+/*@-boundsread@*/
+ for (i = 0; i < sl->sl_nlines; i++) {
+ const char * s = sl->sl_lines[i];
+ if (s == NULL)
+ continue;
+ printf("%s", s);
+ if (strchr(s, '\n') == NULL && s[strlen(s)-1] != '\n')
+ printf("\n");
+ }
+/*@=boundsread@*/
+}
+
+int rpmspecQuery(rpmts ts, QVA_t qva, const char * arg)
+{
+ Spec spec = NULL;
+ Package pkg;
+ char * buildRoot = NULL;
+ int recursing = 0;
+ char * passPhrase = "";
+ char *cookie = NULL;
+ int anyarch = 1;
+ int force = 1;
+ int res = 1;
+ int xx;
+
+ if (qva->qva_showPackage == NULL)
+ goto exit;
+
+ /*@-mods@*/ /* FIX: make spec abstract */
+ if (parseSpec(ts, arg, "/", buildRoot, recursing, passPhrase,
+ cookie, anyarch, force)
+ || (spec = rpmtsSetSpec(ts, NULL)) == NULL)
+ {
+ rpmError(RPMERR_QUERY,
+ _("query of specfile %s failed, can't parse\n"), arg);
+ goto exit;
+ }
+ /*@=mods@*/
+
+ res = 0;
+ if (specedit) {
+ printNewSpecfile(spec);
+ goto exit;
+ }
+
+ for (pkg = spec->packages; pkg != NULL; pkg = pkg->next)
+ xx = qva->qva_showPackage(qva, ts, pkg->header);
+
+exit:
+ spec = freeSpec(spec);
+ return res;
+}