diff options
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | lib/rpmfi.c | 63 | ||||
-rw-r--r-- | lib/rpmfi.h | 2 | ||||
-rw-r--r-- | rpm.spec.in | 2 | ||||
-rw-r--r-- | rpmdb/header.c | 8 | ||||
-rw-r--r-- | rpmpopt.in | 26 | ||||
-rwxr-xr-x | scripts/tgpg | 5 |
7 files changed, 66 insertions, 42 deletions
@@ -86,6 +86,8 @@ - add rpmfi methods to access color, class, and dependencies. - don't segfault with packages produced by rpm-2.93 (#80618). - python: eliminate hash.[ch] and upgrade.[ch], methods too. + - fix :armor query extension, tgpg mktmp handling (#80684). + - use rpmfiClass() underneath --fileclass. 4.0.4 -> 4.1: - loosely wire beecrypt library into rpm. diff --git a/lib/rpmfi.c b/lib/rpmfi.c index 8573d0b0a..ebe5eb7b5 100644 --- a/lib/rpmfi.c +++ b/lib/rpmfi.c @@ -1225,58 +1225,49 @@ fprintf(stderr, "*** fi %p\t%s[%d]\n", fi, Type, (fi ? fi->fc : 0)); void rpmfiBuildFClasses(Header h, /*@out@*/ const char *** fclassp, /*@out@*/ int * fcp) { - HGE_t hge = (HGE_t)headerGetEntryMinMemory; - HFD_t hfd = headerFreeData; - const char ** cdict; - const int_32 * fcdictx; - int_32 ncdict, nfcdictx; + int scareMem = 1; + rpmfi fi = rpmfiNew(NULL, h, RPMTAG_BASENAMES, scareMem); + int ac; const char ** av; - int_32 ac = 0; + const char * FClass; size_t nb; - rpmTagType fct, cdt; char * t; - int i, j, xx; - if (!hge(h, RPMTAG_FILESIZES, NULL, (void **) NULL, &ac) || ac == 0) { - if (fclassp) *fclassp = NULL; - if (fcp) *fcp = 0; - return; /* no file list */ + if ((ac = rpmfiFC(fi)) <= 0) { + av = NULL; + ac = 0; + goto exit; } - fcdictx = NULL; - nfcdictx = 0; - xx = hge(h, RPMTAG_FILECLASS, &fct, (void **) &fcdictx, &nfcdictx); - cdict = NULL; - ncdict = 0; - xx = hge(h, RPMTAG_CLASSDICT, &cdt, (void **) &cdict, &ncdict); - + /* Compute size of file class argv array blob. */ nb = (ac + 1) * sizeof(*av); - for (i = 0; i < ac; i++) { - if (fcdictx != NULL && cdict != NULL) { - j = fcdictx[i]; -assert(j < ncdict); - nb += strlen(cdict[j]); - } + fi = rpmfiInit(fi, 0); + if (fi != NULL) + while (rpmfiNext(fi) >= 0) { + FClass = rpmfiFClass(fi); + if (FClass && *FClass != '\0') + nb += strlen(FClass); nb += 1; } + /* Create and load file class argv array. */ av = xmalloc(nb); t = ((char *) av) + ((ac + 1) * sizeof(*av)); - /*@-branchstate@*/ - for (i = 0; i < ac; i++) { - av[i] = t; - if (fcdictx != NULL && cdict != NULL) { - j = fcdictx[i]; - t = stpcpy(t, cdict[j]); - } + ac = 0; + fi = rpmfiInit(fi, 0); + if (fi != NULL) + while (rpmfiNext(fi) >= 0) { + FClass = rpmfiFClass(fi); + av[ac++] = t; + if (FClass && *FClass != '\0') + t = stpcpy(t, FClass); *t++ = '\0'; } av[ac] = NULL; /*@=branchstate@*/ - cdict = hfd(cdict, cdt); - fcdictx = hfd(fcdictx, fct); - +exit: + fi = rpmfiFree(fi); /*@-branchstate@*/ if (fclassp) *fclassp = av; @@ -1289,9 +1280,9 @@ assert(j < ncdict); void rpmfiBuildFDeps(Header h, rpmTag tagN, /*@out@*/ const char *** fdepsp, /*@out@*/ int * fcp) { + int scareMem = 1; HGE_t hge = (HGE_t)headerGetEntryMinMemory; HFD_t hfd = headerFreeData; - int scareMem = 1; char deptype = 'R'; char mydt; rpmds ds; diff --git a/lib/rpmfi.h b/lib/rpmfi.h index a598691af..7950422b7 100644 --- a/lib/rpmfi.h +++ b/lib/rpmfi.h @@ -478,7 +478,7 @@ rpmfi rpmfiFree(/*@killref@*/ /*@only@*/ /*@null@*/ rpmfi fi) /** * Create and load a file info set. - * @param ts transaction set + * @param ts transaction set (NULL skips path relocation) * @param h header * @param tagN RPMTAG_BASENAMES * @param scareMem Use pointers to refcounted header memory? diff --git a/rpm.spec.in b/rpm.spec.in index 79bf4bb6b..cb69b2eec 100644 --- a/rpm.spec.in +++ b/rpm.spec.in @@ -462,6 +462,8 @@ exit 0 * Sun Dec 29 2002 Jeff Johnson <jbj@redhat.com> 4.2-0.46 - don't segfault with packages produced by rpm-2.93 (#80618). - python: eliminate hash.[ch] and upgrade.[ch], methods too. +- fix :armor query extension, tgpg mktmp handling (#80684). +- use rpmfiClass() underneath --fileclass. * Sat Dec 28 2002 Jeff Johnson <jbj@redhat.com> 4.2-0.45 - error if querying with iterator on different sized arrays. diff --git a/rpmdb/header.c b/rpmdb/header.c index 995c59209..269bf9312 100644 --- a/rpmdb/header.c +++ b/rpmdb/header.c @@ -2735,6 +2735,7 @@ static int parseExpression(sprintfToken token, char * str, /*@=boundswrite@*/ /** + * Call a header extension only once, saving results. * @param h header * @param fn * @retval *typeptr @@ -2898,7 +2899,7 @@ static char * formatValue(sprintfTag tag, Header h, case RPM_STRING_TYPE: if (tagtype) - val = tagtype(RPM_STRING_ARRAY_TYPE, data, buf, tag->pad, 0); + val = tagtype(RPM_STRING_TYPE, data, buf, tag->pad, 0); if (val) { need = strlen(val); @@ -2931,7 +2932,7 @@ static char * formatValue(sprintfTag tag, Header h, } if (tagtype) - val = tagtype(RPM_INT32_TYPE, &intVal, buf, tag->pad, element); + val = tagtype(RPM_INT32_TYPE, &intVal, buf, tag->pad, element); if (val) { need = strlen(val); @@ -2946,11 +2947,12 @@ static char * formatValue(sprintfTag tag, Header h, break; case RPM_BIN_TYPE: + /* XXX HACK ALERT: element field abused as no. bytes of binary data. */ if (tagtype) val = tagtype(RPM_BIN_TYPE, data, buf, tag->pad, count); if (val) { - need = count; /* XXX broken iff RPM_BIN_TYPE extension */ + need = strlen(val); } else { #ifdef NOTYET val = memcpy(xmalloc(count), data, count); diff --git a/rpmpopt.in b/rpmpopt.in index 45c1b5f09..19d64f320 100644 --- a/rpmpopt.in +++ b/rpmpopt.in @@ -353,6 +353,19 @@ rpmq alias --last --qf '%|INSTALLTIME?{%{INSTALLTIME}}:{000000000}| %{NAME}-%{VE rpmq alias --filesbypkg --qf '[%-25{=NAME} %{FILENAMES}\n]' \ --POPTdesc=$"list all files from each package" + +rpmq alias --fileclass --qf '[%{FILENAMES}\t%{FILECLASS}\n]' \ + --POPTdesc=$"list file names with classes" + +rpmq alias --filecolor --qf '[%{FILENAMES}\t%{FILECOLOR}\n]' \ + --POPTdesc=$"list file names with colors" + +rpmq alias --fileprovide --qf '[%{FILENAMES}\t%{FILEPROVIDE}\n]' \ + --POPTdesc=$"list file names with provides" + +rpmq alias --filerequire --qf '[%{FILENAMES}\t%{FILEREQUIRE}\n]' \ + --POPTdesc=$"list file names with requires" + #============================================================================== rpmquery alias --dbpath --define '_dbpath !#:+' \ --POPTdesc=$"use database in DIRECTORY" \ @@ -425,6 +438,19 @@ rpmquery alias --last --qf '%|INSTALLTIME?{%{INSTALLTIME}}:{000000000}| %{NAME}- rpmquery alias --filesbypkg --qf '[%-25{=NAME} %{FILENAMES}\n]' \ --POPTdesc=$"list all files from each package" + +rpmquery alias --fileclass --qf '[%{FILENAMES}\t%{FILECLASS}\n]' \ + --POPTdesc=$"list file names with classes" + +rpmquery alias --filecolor --qf '[%{FILENAMES}\t%{FILECOLOR}\n]' \ + --POPTdesc=$"list file names with colors" + +rpmquery alias --fileprovide --qf '[%{FILENAMES}\t%{FILEPROVIDE}\n]' \ + --POPTdesc=$"list file names with provides" + +rpmquery alias --filerequire --qf '[%{FILENAMES}\t%{FILEREQUIRE}\n]' \ + --POPTdesc=$"list file names with requires" + #============================================================================== rpmu alias --dbpath --define '_dbpath !#:+' \ --POPTdesc=$"use database in DIRECTORY" \ diff --git a/scripts/tgpg b/scripts/tgpg index 4ab738265..21c1ffac0 100755 --- a/scripts/tgpg +++ b/scripts/tgpg @@ -1,5 +1,6 @@ #!/bin/sh + for pkg in $* do if [ "$pkg" = "" -o ! -e "$pkg" ]; then @@ -7,8 +8,8 @@ do exit 1 fi - plaintext=`mktemp $0-$$.XXXXXX` - detached=`mktemp $0-$$.XXXXXX` + plaintext=`mktemp /tmp/tgpg-$$.XXXXXX` + detached=`mktemp /tmp/tgpg-$$.XXXXXX` # --- Extract detached signature rpm -qp -vv --qf '%{siggpg:armor}' $pkg > $detached |