diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dbindex.c | 8 | ||||
-rw-r--r-- | lib/install.c | 4 | ||||
-rw-r--r-- | lib/macro.c | 15 | ||||
-rw-r--r-- | lib/misc.c | 26 | ||||
-rw-r--r-- | lib/url.c | 19 |
5 files changed, 31 insertions, 41 deletions
diff --git a/lib/dbindex.c b/lib/dbindex.c index e6ea87dc8..5e8659f47 100644 --- a/lib/dbindex.c +++ b/lib/dbindex.c @@ -26,13 +26,13 @@ unsigned int dbiIndexRecordFileNumber(dbiIndexSet set, int recno) { dbiIndex * dbiOpenIndex(const char * urlfn, int flags, int perms, DBTYPE type) { dbiIndex * dbi; const char * filename; - int urltype = urlPath(urlfn, &filename); + (void) urlPath(urlfn, &filename); dbi = xmalloc(sizeof(*dbi)); - dbi->db = dbopen(filename, flags, perms, type, NULL); - if (!dbi->db) { + if (*filename == '\0' || + (dbi->db = dbopen(filename, flags, perms, type, NULL)) == NULL) { free(dbi); - rpmError(RPMERR_DBOPEN, _("cannot open file %s: %s"), filename, + rpmError(RPMERR_DBOPEN, _("cannot open file %s: %s"), urlfn, strerror(errno)); return NULL; } diff --git a/lib/install.c b/lib/install.c index 1089e4d06..e2835b5df 100644 --- a/lib/install.c +++ b/lib/install.c @@ -349,11 +349,7 @@ static int installArchive(FD_t fd, struct fileInfo * files, notifyData); (void) Fflush(fd); -#ifndef DYING cfd = Fdopen(fdDup(Fileno(fd)), "r.gzdio"); -#else - cfd = Fdopen(fd, "r.gzdio"); -#endif rc = cpioInstallArchive(cfd, map, mappedFiles, ((notify && archiveSize) || specFile) ? callback : NULL, &info, &failedFile); diff --git a/lib/macro.c b/lib/macro.c index b206e2c45..ea71b43c1 100644 --- a/lib/macro.c +++ b/lib/macro.c @@ -785,7 +785,7 @@ doOutput(MacroBuf *mb, int waserror, const char *msg, size_t msglen) } static void -doFoo(MacroBuf *mb, const char *f, size_t fn, const char *g, size_t glen) +doFoo(MacroBuf *mb, int negate, const char *f, size_t fn, const char *g, size_t glen) { char buf[BUFSIZ], *b = NULL, *be; int c; @@ -811,6 +811,14 @@ doFoo(MacroBuf *mb, const char *f, size_t fn, const char *g, size_t glen) b++; } else if (STREQ("expand", f, fn)) { b = buf; + } else if (STREQ("verbose", f, fn)) { + if (negate) + b = (rpmIsVerbose() ? NULL : buf); + else + b = (rpmIsVerbose() ? buf : NULL); + } else if (STREQ("url2path", f, fn) || STREQ("u2p", f, fn)) { + (void)urlPath(buf, (const char **)&b); + if (*b == '\0') b = "/"; } else if (STREQ("uncompress", f, fn)) { int compressed = 1; for (b = buf; (c = *b) && isblank(c);) @@ -1061,11 +1069,14 @@ expandMacro(MacroBuf *mb) if (STREQ("basename", f, fn) || STREQ("suffix", f, fn) || STREQ("expand", f, fn) || + STREQ("verbose", f, fn) || STREQ("uncompress", f, fn) || + STREQ("url2path", f, fn) || + STREQ("u2p", f, fn) || STREQ("S", f, fn) || STREQ("P", f, fn) || STREQ("F", f, fn)) { - doFoo(mb, f, fn, g, gn); + doFoo(mb, negate, f, fn, g, gn); s = se; continue; } diff --git a/lib/misc.c b/lib/misc.c index 7b3c8a125..5a22f205b 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -53,6 +53,7 @@ int rpmfileexists(const char * urlfn) { int urltype = urlPath(urlfn, &fn); struct stat buf; + if (*fn == '\0') fn = "/"; switch (urltype) { case URL_IS_FTP: /* XXX WRONG WRONG WRONG */ case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */ @@ -355,16 +356,14 @@ char * gidToGname(gid_t gid) { } int makeTempFile(const char * prefix, const char ** fnptr, FD_t * fdptr) { - const char * tempfn; - const char * tfn; + const char * tempfn = NULL; + const char * tfn = NULL; int temput; FD_t fd; int ran; if (!prefix) prefix = ""; - tfn = NULL; - /* XXX should probably use mktemp here */ srand(time(NULL)); ran = rand() % 100000; @@ -375,15 +374,17 @@ int makeTempFile(const char * prefix, const char ** fnptr, FD_t * fdptr) { char tfnbuf[64]; #ifndef NOTYET sprintf(tfnbuf, "rpm-tmp.%d", ran++); - if (tfn) xfree(tfn); + if (tempfn) xfree(tempfn); tempfn = rpmGenPath(prefix, "%{_tmppath}/", tfnbuf); #else strcpy(tfnbuf, "rpm-tmp.XXXXXX"); - if (tfn) xfree(tfn); + if (tempfn) xfree(tempfn); tempfn = rpmGenPath(prefix, "%{_tmppath}/", mktemp(tfnbuf)); #endif temput = urlPath(tempfn, &tfn); + if (*tfn == '\0') goto errxit; + switch (temput) { case URL_IS_HTTP: case URL_IS_DASH: @@ -393,12 +394,7 @@ int makeTempFile(const char * prefix, const char ** fnptr, FD_t * fdptr) { break; } -/* XXX FIXME: build/build.c Fdopen assertion failure, makeTempFile uses fdio */ -#ifdef DYING - fd = fdio->open(tfn, (O_CREAT|O_RDWR|O_EXCL), 0700); -#else - fd = Fopen(tfn, "w+x.ufdio"); -#endif + fd = Fopen(tempfn, "w+x.ufdio"); } while ((fd == NULL || Ferror(fd)) && errno == EEXIST); switch(temput) { @@ -427,15 +423,15 @@ int makeTempFile(const char * prefix, const char ** fnptr, FD_t * fdptr) { } if (fnptr) - *fnptr = tfn; - else + *fnptr = tempfn; + else if (tempfn) xfree(tempfn); *fdptr = fd; return 0; errxit: - xfree(tempfn); + if (tempfn) xfree(tempfn); return 1; } @@ -309,17 +309,12 @@ urltype urlIsURL(const char * url) { return URL_IS_UNKNOWN; } +/* Return path portion of url (or pointer to NUL if url == NULL) */ int urlPath(const char * url, const char ** pathp) { const char *path; int urltype; - if (url == NULL) { /* XXX paranoia */ - if (pathp) - *pathp = xstrdup("/"); - return URL_IS_UNKNOWN; - } - path = url; urltype = urlIsURL(url); switch (urltype) { @@ -338,8 +333,8 @@ int urlPath(const char * url, const char ** pathp) path = ""; break; } - if (path == NULL) - path = "/"; + if (path == NULL) /* XXX gotta return something */ + path = ""; if (pathp) *pathp = path; return urltype; @@ -370,14 +365,6 @@ int urlSplit(const char * url, urlinfo *uret) while (1) { /* Point to end of next item */ while (*se && *se != '/') se++; -#ifdef DYING - if (*se == '\0') { - /* XXX can't find path */ - if (myurl) free(myurl); - u = urlFree(u, "urlSplit (error #2)"); - return -1; - } -#endif /* Item was service. Save service and go for the rest ...*/ if (*se && (se != s) && se[-1] == ':' && se[0] == '/' && se[1] == '/') { se[-1] = '\0'; |