RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: jbj@rpm5.org
Module: rpm Date: 30-Jan-2010 22:54:44
Branch: HEAD Handle: 2010013021544201
Modified files:
rpm CHANGES
rpm/lib rpminstall.c
rpm/rpmdb fprint.c
rpm/rpmio macro.c rpmmacro.h
Log:
- rpmio: teach rpmGetPath() to append explicit pesky trailing '/'.
Summary:
Revision Changes Path
1.3266 +1 -0 rpm/CHANGES
1.225 +9 -3 rpm/lib/rpminstall.c
1.38 +21 -33 rpm/rpmdb/fprint.c
2.242 +15 -1 rpm/rpmio/macro.c
2.55 +2 -0 rpm/rpmio/rpmmacro.h
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/CHANGES
============================================================================
$ cvs diff -u -r1.3265 -r1.3266 CHANGES
--- rpm/CHANGES 30 Jan 2010 20:29:49 -0000 1.3265
+++ rpm/CHANGES 30 Jan 2010 21:54:42 -0000 1.3266
@@ -1,5 +1,6 @@
5.2b1 -> 5.3a1
+ - jbj: rpmio: teach rpmGetPath() to append explicit pesky trailing '/'.
- jbj: hrmib: fix: add lazy Mkdir to instantiate in chroot's.
- jbj: begin to finalize upgrade fingerprint handling.
- jbj: satsify Requires: / internally & always, SuSE doesn't package "/".
@@ .
patch -p0 <<'@@ .'
Index: rpm/lib/rpminstall.c
============================================================================
$ cvs diff -u -r1.224 -r1.225 rpminstall.c
--- rpm/lib/rpminstall.c 13 Dec 2009 14:40:50 -0000 1.224
+++ rpm/lib/rpminstall.c 30 Jan 2010 21:54:43 -0000 1.225
@@ -450,14 +450,20 @@
ARGV_t nav = NULL;
int nac = 0;
- /* Insure only directory paths are matched. */
+ /* Make sure only directory paths are matched. */
fn = rpmGetPath(dav[i], "/", NULL);
xx = rpmGlob(fn, &nac, &nav);
- /* Insure that final directory paths have trailing '/' */
if (nav != NULL)
for (i = 0; i < nac; i++) {
- char * t = rpmExpand(nav[i], "/", NULL);
+ const char * t = nav[i];
+ size_t nt = strlen(t);
+
+ /* Make sure that final directory paths have trailing '/' */
+ if (!(nt > 0 && t[nt-1] == '/'))
+ continue;
+
+ t = rpmExpand(t, "/", NULL);
nav[i] = _free(nav[i]);
nav[i] = t;
}
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/fprint.c
============================================================================
$ cvs diff -u -r1.37 -r1.38 fprint.c
--- rpm/rpmdb/fprint.c 30 Jan 2010 20:19:53 -0000 1.37
+++ rpm/rpmdb/fprint.c 30 Jan 2010 21:54:43 -0000 1.38
@@ -269,7 +269,7 @@
int xx;
he->tag = RPMTAG_BASENAMES;
- xx = headerGet(h, he->tag, &he->t, he->p, &he->c);
+ xx = headerGet(h, he, 0);
baseNames = he_p.argv;
fileCount = he->c;
if (!xx)
@@ -290,6 +290,7 @@
}
#endif
+/* XXX fpLookupSubdir should be moved to lib/rpmfi.c somewhen. */
#define _RPMFI_INTERNAL
#include "rpmfi.h"
#define _RPMTE_INTERNAL
@@ -302,10 +303,9 @@
rpmfi fi = p->fi;
fingerPrint *const fps = fi->fps + filenr;
- char link[PATH_MAX];
-
struct fingerPrint_s current_fp;
fingerPrint * cfp = ¤t_fp;
+ int symlinkcount = 0;
const char * s;
const char * se;
@@ -335,17 +335,15 @@
while (te < se) {
struct rpmffi_s * recs;
int numRecs;
- int symlinkcount;
int i;
recs = NULL;
numRecs = 0;
(void) htGetEntry(symlinks, cfp, &recs, &numRecs, NULL);
- symlinkcount = 0;
for (i = 0; i < numRecs; i++) {
const char * flink;
- char * le;
+ char * link;
int fx;
fx = recs[i].fileno;
@@ -354,34 +352,24 @@
if (!(flink && *flink != '\0'))
continue;
- /* Follow a "directory" symlink. */
- le = link;
- *le = '\0';
-
- /* Prepend current path for iff relative symlink. */
- if (*flink != '/') {
- le = stpcpy(le, cfp->entry->dirName);
- if (cfp->subDir) {
- if (le[-1] != '/') *le++ = '/';
- le = stpcpy(le, cfp->subDir);
- }
- if (le[-1] != '/') *le++ = '/';
- }
-
- /* Append the symlink destination to the path. */
- le = stpcpy(le, flink);
-
- /* Append the remaining subdirs to search (if any). */
- if (te[1] != '\0') {
- if (le[-1] != '/') *le++ = '/';
- le = stpcpy(le, te+1);
- }
- if (le[-1] != '/') *le++ = '/';
- *le = '\0';
- (void) rpmCleanPath(link);
+ /* Build a new (directory) fingerprint path. */
+ /* XXX Paths containing '%' will be macro expanded. */
+ if (*flink == '/')
+ link = rpmGetPath(flink, "/", te+1, "/", NULL);
+ else if (cfp->subDir == NULL)
+ link = rpmGetPath(cfp->entry->dirName, "/",
+ flink, "/", te+1, "/", NULL);
+ else
+ link = rpmGetPath(cfp->entry->dirName, "/", cfp->subDir, "/",
+ flink, "/", te+1, "/", NULL);
+
+#ifdef NOTNOW /* XXX avoid strlen on fast path */
+assert(link[strlen(link)-1] == '/');
+#endif
- /* Find a new fingerprint starting point. */
+ /* Find the new (directory) fingerprint starting point. */
*fps = fpLookup(fpc, link, fps->baseName, 0);
+ link = _free(link);
s = _free(s);
if (++symlinkcount > 50)
@@ -396,7 +384,7 @@
t = te;
cfp->baseName = t + 1;
- /* set baseName to the next lower dir */
+ /* Set baseName to the next lower dir. */
te++;
while (*te != '\0' && *te != '/')
te++;
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/macro.c
============================================================================
$ cvs diff -u -r2.241 -r2.242 macro.c
--- rpm/rpmio/macro.c 18 Jan 2010 17:32:53 -0000 2.241
+++ rpm/rpmio/macro.c 30 Jan 2010 21:54:43 -0000 2.242
@@ -3124,6 +3124,7 @@
char *buf = alloca(bufn);
const char * s;
char * t, * te;
+ int slashed = 0;
va_list ap;
if (path == NULL)
@@ -3136,15 +3137,28 @@
va_start(ap, path);
while ((s = va_arg(ap, const char *)) != NULL) {
+ /* Specifically requested pesky trailing '/'? */
+ slashed = (s[0] == '/' && s[1] == '\0');
te = stpcpy(te, s);
- *te = '\0';
}
va_end(ap);
+ *te = '\0';
+
/*@-modfilesys@*/
(void) expandMacros(NULL, NULL, buf, bufn);
/*@=modfilesys@*/
+ /* Note: rpmCleanPath will strip pesky trailing '/'. */
(void) rpmCleanPath(buf);
+
+ /* Re-append specifically requested pesky trailing '/'. */
+ if (slashed) {
+ size_t nb = strlen(buf);
+ if (buf[nb-1] != '/')
+ buf[nb++] = '/';
+ buf[nb] = '\0';
+ }
+
return xstrdup(buf); /* XXX xstrdup has side effects. */
}
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/rpmmacro.h
============================================================================
$ cvs diff -u -r2.54 -r2.55 rpmmacro.h
--- rpm/rpmio/rpmmacro.h 21 Aug 2009 03:18:38 -0000 2.54
+++ rpm/rpmio/rpmmacro.h 30 Jan 2010 21:54:43 -0000 2.55
@@ -250,6 +250,7 @@
/**
* Canonicalize file path.
+ * @note Path canonicalization always removes the pesky trailing '/'.
* @param path path to canonicalize (in-place)
* @return pointer to path
*/
@@ -259,6 +260,7 @@
/**
* Return (malloc'ed) expanded, canonicalized, file path.
+ * @note A final "/" argument will force append a pesky trailing '/'.
* @param path macro(s) to expand (NULL terminates list)
* @return canonicalized path (malloc'ed)
*/
@@ .
Received on Sat Jan 30 22:54:44 2010