rpm.c: add --rmspec to usage output.
build/files.c: use ufdio to permit '%files -f <url>' (untested).
build/pack.c: use ufdio in readRPM(), writeRPM(), and addFileToTag().
build/parsePreamble.c: use ufdio in readIcon().
lib/ftp.c: httpOpen() now takes FD_t ctrl arg to uncouple from u->ctrl.
lib/install.c: usr rpmGenPath() to identify first found url in file path concat.
lib/install.c: permit url's in files[i].relativePath.
lib/macro.c: use ufdio, diddle macros for tmacro standalone build.
lib/macro.c: Create rpmGenPath().
lib/macro.c: diddle macro files path to permit url's.
lib/rpmchecksig.c: use Fopen on fdio.
lib/rpmio.c: replace copyData() with ufdCopy().
lib/rpmio.c: replace httpGetFile() with ufdGetFile().
lib/rpmio.c: add ufdWrite().
lib/rpmio.c: permit 2 simultaneous persistent malloc/open HTTP/1.1 connections.
lib/rpmio.c: Add Lstat(), Stat(), and Access().
lib/rpmio.c: assume paths in syscall stubs are loopback (WRONG).
lib/url.c: add urlPath().
CVS patchset: 3422
CVS date: 1999/11/12 17:20:49
#ifdef HAVE_FCHMOD
(void)fchmod(Fileno(fd), 0600); /* XXX fubar on ufdio */
#endif
+/* XXX FIXME: build/build.c Fdopen assertion failure, makeTempFile uses fdio */
xfd = Fdopen(fd, "w.fdio");
strcpy(buf, _preScriptEnvironment);
char *s, **files, **fp;
const char *fileName;
char buf[BUFSIZ];
- FILE *f;
AttrRec specialDocAttrRec;
char *specialDoc = NULL;
if (pkg->fileFile) {
const char *ffn;
+ FD_t fd;
/* XXX FIXME: add %{_buildsubdir} */
ffn = rpmGetPath("%{_builddir}/",
(spec->buildSubdir ? spec->buildSubdir : "") ,
"/", pkg->fileFile, NULL);
- f = fopen(ffn, "r");
+ fd = Fopen(ffn, "r.ufdio");
xfree(ffn);
- if (f == NULL) {
+ if (fd == NULL || Ferror(fd)) {
rpmError(RPMERR_BADFILENAME,
- _("Could not open %%files file: %s"), pkg->fileFile);
+ _("Could not open %%files file %s: %s"),
+ pkg->fileFile, Fstrerror(fd));
return RPMERR_BADFILENAME;
}
- while (fgets(buf, sizeof(buf), f)) {
+ while (fgets(buf, sizeof(buf), fpio->ffileno(fd))) {
handleComments(buf);
if (expandMacros(spec, spec->macros, buf, sizeof(buf))) {
rpmError(RPMERR_BADSPEC, _("line: %s"), buf);
}
appendStringBuf(pkg->fileList, buf);
}
- fclose(f);
+ Fclose(fd);
}
/* Init the file list structure */
case URL_IS_DASH: /* stdin */
case URL_IS_FTP: /* ftp://... */
case URL_IS_HTTP: /* http://... */
- continue; /* XXX just skip for now */
+ continue; /* XXX WRONG WRONG WRONG */
}
flp->diskName = xstrdup(s);
#define RPM_MAJOR_NUMBER 3
static int processScriptFiles(Spec spec, Package pkg);
-static StringBuf addFileToTagAux(Spec spec, char *file, StringBuf sb);
+static StringBuf addFileToTagAux(Spec spec, const char *file, StringBuf sb);
static int addFileToTag(Spec spec, char *file, Header h, int tag);
static int addFileToArrayTag(Spec spec, char *file, Header h, int tag);
int rc;
if (fileName != NULL) {
- fdi = Fopen(fileName, "r.fdio");
- if (Ferror(fdi)) {
+ fdi = Fopen(fileName, "r.ufdio");
+ if (fdi == NULL || Ferror(fdi)) {
rpmError(RPMERR_BADMAGIC, _("readRPM: open %s: %s\n"), fileName,
Fstrerror(fdi));
return RPMERR_BADMAGIC;
}
/* Open the output file */
- fd = Fopen(fileName, "w.fdio");
- if (Ferror(fd)) {
- rpmError(RPMERR_CREATE, _("Could not open %s: %s\n"), fileName, Fstrerror(fd));
+ fd = Fopen(fileName, "w.ufdio");
+ if (fd == NULL || Ferror(fd)) {
+ rpmError(RPMERR_CREATE, _("Could not open %s: %s\n"),
+ fileName, Fstrerror(fd));
unlink(sigtarget);
xfree(sigtarget);
return RPMERR_CREATE;
rpmFreeSignature(sig);
/* Append the header and archive */
- ifd = Fopen(sigtarget, "r.fdio");
+ ifd = Fopen(sigtarget, "r.ufdio");
+ if (ifd == NULL || Ferror(ifd)) {
+ rpmError(RPMERR_READERROR, _("Unable to open sigtarget %s: %s"),
+ sigtarget, Fstrerror(ifd));
+ Fclose(fd);
+ Unlink(sigtarget);
+ xfree(sigtarget);
+ Unlink(fileName);
+ return RPMERR_READERROR;
+ }
while ((count = Fread(buf, sizeof(buf[0]), sizeof(buf), ifd)) > 0) {
if (count == -1) {
- rpmError(RPMERR_READERROR, _("Unable to read sigtarget: %s"),
- Fstrerror(ifd));
+ rpmError(RPMERR_READERROR, _("Unable to read sigtarget %s: %s"),
+ sigtarget, Fstrerror(ifd));
Fclose(ifd);
Fclose(fd);
unlink(sigtarget);
return RPMERR_READERROR;
}
if (Fwrite(buf, sizeof(buf[0]), count, fd) < 0) {
- rpmError(RPMERR_NOSPACE, _("Unable to write package: %s"),
- Fstrerror(fd));
+ rpmError(RPMERR_NOSPACE, _("Unable to write package %s: %s"),
+ fileName, Fstrerror(fd));
Fclose(ifd);
Fclose(fd);
unlink(sigtarget);
return 0;
}
-static StringBuf addFileToTagAux(Spec spec, char *file, StringBuf sb)
+static StringBuf addFileToTagAux(Spec spec, const char *file, StringBuf sb)
{
char buf[BUFSIZ];
- FILE *f;
-
- strcpy(buf, "%{_builddir}/");
- expandMacros(spec, spec->macros, buf, sizeof(buf));
- strcat(buf, spec->buildSubdir);
- strcat(buf, "/");
- strcat(buf, file);
-
- if ((f = fopen(buf, "r")) == NULL) {
+ const char *fn = buf;
+ FD_t fd;
+
+#ifdef DYING
+ strcpy(fn, "%{_builddir}/");
+ expandMacros(spec, spec->macros, fn, sizeof(fn));
+ strcat(fn, spec->buildSubdir);
+ strcat(fn, "/");
+ strcat(fn, file);
+#else
+ fn = rpmGetPath("%{_builddir}/", spec->buildSubdir, "/", file, NULL);
+#endif
+
+ fd = Fopen(fn, "r.ufdio");
+ if (fn != buf) xfree(fn);
+ if (fd == NULL || Ferror(fd)) {
freeStringBuf(sb);
return NULL;
}
- while (fgets(buf, sizeof(buf), f)) {
+ while (fgets(buf, sizeof(buf), fpio->ffileno(fd))) {
+ /* XXX display fn in error msg */
if (expandMacros(spec, spec->macros, buf, sizeof(buf))) {
rpmError(RPMERR_BADSPEC, _("line: %s"), buf);
return NULL;
}
appendStringBuf(sb, buf);
}
- fclose(f);
+ Fclose(fd);
return sb;
}
char *icon;
struct stat statbuf;
FD_t fd;
- int rc;
+ int rc = 0;
int nb;
+ /* XXX use rpmGenPath(rootdir, "%{_sourcedir}/", file) for icon path. */
fn = rpmGetPath("%{_sourcedir}/", file, NULL);
- if (stat(fn, &statbuf)) {
+ if (Stat(fn, &statbuf)) {
rpmError(RPMERR_BADSPEC, _("Unable to stat icon: %s"), fn);
rc = RPMERR_BADSPEC;
goto exit;
icon = xmalloc(statbuf.st_size);
*icon = '\0';
- fd = Fopen(fn, "r.fdio");
- /* XXX Fstrerror */
- /* XXX Ferror check */
+
+ fd = Fopen(fn, "r.ufdio");
+ if (fd == NULL || Ferror(fd)) {
+ rpmError(RPMERR_BADSPEC, _("Unable to open icon %s: %s"),
+ fn, Fstrerror(fd));
+ rc = RPMERR_BADSPEC;
+ goto exit;
+ }
nb = Fread(icon, sizeof(char), statbuf.st_size, fd);
- Fclose(fd);
if (nb != statbuf.st_size) {
- rpmError(RPMERR_BADSPEC, _("Unable to read icon: %s"), fn);
+ rpmError(RPMERR_BADSPEC, _("Unable to read icon %s: %s"),
+ fn, Fstrerror(fd));
rc = RPMERR_BADSPEC;
- goto exit;
}
+ Fclose(fd);
+ if (rc)
+ goto exit;
if (! strncmp(icon, "GIF", sizeof("GIF")-1)) {
headerAddEntry(h, RPMTAG_GIF, RPM_BIN_TYPE, icon, statbuf.st_size);
rc = RPMERR_BADSPEC;
goto exit;
}
- free(icon);
- rc = 0;
+ xfree(icon);
exit:
FREE(fn);
case RPMTAG_BUILDROOT:
SINGLE_TOKEN_ONLY;
if (spec->buildRoot == NULL) {
+ /* XXX use rpmGenPath(rootdir, "%{buildroot}/", file) for buildroot path. */
const char *buildroot = rpmGetPath("%{buildroot}", NULL);
+ /* XXX FIXME make sure that buildroot has path, add urlbuildroot. */
if (buildroot && *buildroot != '%') {
spec->buildRoot = xstrdup(cleanFileName(buildroot));
macro = NULL;
#include "system.h"
-#include "rpmbuild.h"
+#include <rpmbuild.h>
+#include <rpmurl.h>
/* These have to be global to make up for stupid compilers */
static int leaveDirs, skipDefaultAction;
{
struct stat sb;
- if (lstat(file, &sb)) {
+ if (Lstat(file, &sb)) {
rpmError(RPMERR_BADSPEC, _("Bad source: %s: %s"), file, strerror(errno));
return RPMERR_BADSPEC;
}
/*@observer@*/ static char *doPatch(Spec spec, int c, int strip, const char *db,
int reverse, int removeEmpties)
{
- const char *fn = NULL;
+ const char *fn, *urlfn;
static char buf[BUFSIZ];
char args[BUFSIZ];
struct Source *sp;
int compressed = 0;
+ int urltype;
for (sp = spec->sources; sp != NULL; sp = sp->next) {
if ((sp->flags & RPMBUILD_ISPATCH) && (sp->num == c)) {
return NULL;
}
- fn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
+ fn = urlfn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
args[0] = '\0';
if (db) {
}
/* XXX On non-build parse's, file cannot be stat'd or read */
- if (!spec->force && (isCompressed(fn, &compressed) || checkOwners(fn))) {
- xfree(fn);
+ if (!spec->force && (isCompressed(urlfn, &compressed) || checkOwners(urlfn))) {
+ xfree(urlfn);
return NULL;
}
+ urltype = urlPath(urlfn, &fn);
+ switch (urltype) {
+ case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
+ case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
+ case URL_IS_PATH:
+ case URL_IS_UNKNOWN:
+ break;
+ case URL_IS_DASH:
+ xfree(urlfn);
+ return NULL;
+ /*@notreached@*/ break;
+ }
+
if (compressed) {
const char *zipper = rpmGetPath(
(compressed == COMPRESSED_BZIP2 ? "%{_bzip2bin}" : "%{_gzipbin}"),
NULL);
+
sprintf(buf,
- "echo \"Patch #%d:\"\n"
+ "echo \"Patch #%d (%s):\"\n"
"%s -d < %s | patch -p%d %s -s\n"
"STATUS=$?\n"
"if [ $STATUS -ne 0 ]; then\n"
" exit $STATUS\n"
"fi",
- c,
+ c, basename(fn),
zipper,
fn, strip, args);
xfree(zipper);
} else {
sprintf(buf,
- "echo \"Patch #%d:\"\n"
- "patch -p%d %s -s < %s", c, strip, args, fn);
+ "echo \"Patch #%d (%s):\"\n"
+ "patch -p%d %s -s < %s", c, basename(fn), strip, args, fn);
}
- xfree(fn);
+ xfree(urlfn);
return buf;
}
/*@observer@*/ static const char *doUntar(Spec spec, int c, int quietly)
{
- const char *fn;
+ const char *fn, *urlfn;
static char buf[BUFSIZ];
char *taropts;
struct Source *sp;
int compressed = 0;
+ int urltype;
for (sp = spec->sources; sp != NULL; sp = sp->next) {
if ((sp->flags & RPMBUILD_ISSOURCE) && (sp->num == c)) {
return NULL;
}
- fn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
+ fn = urlfn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
taropts = ((rpmIsVerbose() && !quietly) ? "-xvvf" : "-xf");
if (sp->flags & RPMTAG_NOSOURCE && autofetchnosource) {
struct stat st;
int rc;
- if (lstat(fn, &st) != 0 && errno == ENOENT &&
+ if (Lstat(urlfn, &st) != 0 && errno == ENOENT &&
urlIsUrl(sp->fullSource) != URL_IS_UNKNOWN) {
- if ((rc = urlGetFile(sp->fullSource, fn)) != 0) {
+ if ((rc = urlGetFile(sp->fullSource, urlfn)) != 0) {
rpmError(RPMERR_BADFILENAME, _("Couldn't download nosource %s: %s"),
sp->fullSource, ftpStrerror(rc));
return NULL;
#endif
/* XXX On non-build parse's, file cannot be stat'd or read */
- if (!spec->force && (isCompressed(fn, &compressed) || checkOwners(fn))) {
- xfree(fn);
+ if (!spec->force && (isCompressed(urlfn, &compressed) || checkOwners(urlfn))) {
+ xfree(urlfn);
+ return NULL;
+ }
+
+ urltype = urlPath(urlfn, &fn);
+ switch (urltype) {
+ case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
+ case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
+ case URL_IS_PATH:
+ case URL_IS_UNKNOWN:
+ break;
+ case URL_IS_DASH:
+ xfree(urlfn);
return NULL;
+ /*@notreached@*/ break;
}
if (compressed) {
sprintf(buf, "tar %s %s", taropts, fn);
}
- xfree(fn);
+ xfree(urlfn);
return buf;
}
return set.recs[recno].fileNumber;
}
-dbiIndex * dbiOpenIndex(const char * filename, int flags, int perms, DBTYPE type) {
+dbiIndex * dbiOpenIndex(const char * urlfn, int flags, int perms, DBTYPE type) {
dbiIndex * dbi;
+ const char * filename;
+ int urltype = urlPath(urlfn, &filename);
- switch (urlIsURL(filename)) {
- case URL_IS_PATH:
- filename += sizeof("file://") - 1;
- filename = strchr(filename, '/');
- /*@fallthrough@*/
- case URL_IS_UNKNOWN:
- break;
- case URL_IS_DASH:
- case URL_IS_FTP:
- case URL_IS_HTTP:
- default:
- return NULL;
- /*@notreached@*/ break;
- }
dbi = xmalloc(sizeof(*dbi));
dbi->db = dbopen(filename, flags, perms, type, NULL);
if (!dbi->db) {
return rc;
}
-int httpOpen(urlinfo u, const char *httpcmd)
+int httpOpen(urlinfo u, FD_t ctrl, const char *httpcmd)
{
const char *host;
const char *path;
int retrying = 0;
URLSANE(u);
- assert(u->ctrl != NULL);
+ assert(ctrl != NULL);
if (((host = (u->proxyh ? u->proxyh : u->host)) == NULL))
return FTPERR_BAD_HOSTNAME;
path = (u->proxyh || u->proxyp > 0) ? u->url : u->path;
reopen:
- if (fdio->fileno(u->ctrl) >= 0 && fdWritable(u->ctrl, 0) < 1)
- fdio->close(u->ctrl);
+ if (fdio->fileno(ctrl) >= 0 && fdWritable(ctrl, 0) < 1)
+ fdio->close(ctrl);
- if (fdio->fileno(u->ctrl) < 0) {
+ if (fdio->fileno(ctrl) < 0) {
rc = tcpConnect(host, port);
- fdSetFdno(u->ctrl, (rc >= 0 ? rc : -1));
+ fdSetFdno(ctrl, (rc >= 0 ? rc : -1));
if (rc < 0)
goto errxit;
- u->ctrl = fdLink(u->ctrl, "open ctrl (httpOpen)");
+ ctrl = fdLink(ctrl, "open ctrl (httpOpen)");
}
len = sizeof("\
DBG(0, (stderr, "-> %s", req));
- if (fdio->write(u->ctrl, req, len) != len) {
+ if (fdio->write(ctrl, req, len) != len) {
rc = FTPERR_SERVER_IO_ERROR;
goto errxit;
}
/*@fallthrough@*/
default:
if (!retrying) { /* not HTTP_OK */
+if (_ftp_debug)
+fprintf(stderr, "*** httpOpen ctrl %p reopening ...\n", ctrl);
retrying = 1;
- fdio->close(u->ctrl);
+ fdio->close(ctrl);
goto reopen;
}
rc = FTPERR_FILE_NOT_FOUND;
}
}
- u->ctrl = fdLink(u->ctrl, "open data (httpOpen)");
- return fdio->fileno(u->ctrl);
+ ctrl = fdLink(ctrl, "open data (httpOpen)");
+ return fdio->fileno(ctrl);
errxit:
- if (fdio->fileno(u->ctrl) >= 0)
- fdio->close(u->ctrl);
+ if (fdio->fileno(ctrl) >= 0)
+ fdio->close(ctrl);
return rc;
}
return rc;
}
-int ftpFileDone(urlinfo u, FD_t fd)
+int ftpFileDone(urlinfo u, FD_t data)
{
int rc = 0;
int ftpFileDoneNeeded;
URLSANE(u);
- ftpFileDoneNeeded = fdGetFtpFileDoneNeeded(fd);
+ ftpFileDoneNeeded = fdGetFtpFileDoneNeeded(data);
assert(ftpFileDoneNeeded);
if (ftpFileDoneNeeded) {
- fdSetFtpFileDoneNeeded(fd, 0);
+ fdSetFtpFileDoneNeeded(data, 0);
u->ctrl = fdFree(u->ctrl, "open data (ftpFileDone)");
u->ctrl = fdFree(u->ctrl, "grab data (ftpFileDone)");
rc = ftpCheckResponse(u, NULL);
return rc;
}
-int ftpFileDesc(urlinfo u, const char *cmd, FD_t fd)
+int ftpFileDesc(urlinfo u, const char *cmd, FD_t data)
{
struct sockaddr_in dataAddress;
int cmdlen;
* XXX transfer complete message (if ftpFileDone() was not
* XXX called to clear that message). Detect that condition now.
*/
- ftpFileDoneNeeded = fdGetFtpFileDoneNeeded(fd);
+ ftpFileDoneNeeded = fdGetFtpFileDoneNeeded(data);
assert(ftpFileDoneNeeded == 0);
/*
}
rc = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
- fdSetFdno(fd, (rc >= 0 ? rc : -1));
+ fdSetFdno(data, (rc >= 0 ? rc : -1));
if (rc < 0) {
rc = FTPERR_FAILED_CONNECT;
goto errxit;
}
- fd = fdLink(fd, "open data (ftpFileDesc)");
+ data = fdLink(data, "open data (ftpFileDesc)");
/* XXX setsockopt SO_LINGER */
/* XXX setsockopt SO_KEEPALIVE */
/* XXX setsockopt SO_TOS IPTOS_THROUGHPUT */
- while (connect(fdio->fileno(fd), (struct sockaddr *) &dataAddress,
+ while (connect(fdio->fileno(data), (struct sockaddr *) &dataAddress,
sizeof(dataAddress)) < 0) {
if (errno == EINTR)
continue;
- fdio->close(fd);
+ fdio->close(data);
rc = FTPERR_FAILED_DATA_CONNECT;
goto errxit;
}
DBG(0, (stderr, "-> %s", cmd));
if (fdio->write(u->ctrl, cmd, cmdlen) != cmdlen) {
- fdio->close(fd);
+ fdio->close(data);
rc = FTPERR_SERVER_IO_ERROR;
goto errxit;
}
if ((rc = ftpCheckResponse(u, NULL))) {
- fdio->close(fd);
+ fdio->close(data);
goto errxit;
}
- fdSetFtpFileDoneNeeded(fd, 1);
+ fdSetFtpFileDoneNeeded(data, 1);
u->ctrl = fdLink(u->ctrl, "grab data (ftpFileDesc)");
u->ctrl = fdLink(u->ctrl, "open data (ftpFileDesc)");
return 0;
#include "system.h"
#include <rpmlib.h>
+#include <rpmmacro.h>
+#include <rpmurl.h>
#include "cpio.h"
#include "install.h"
#include "misc.h"
#include "rpmdb.h"
-#include <rpmmacro.h>
struct callbackInfo {
unsigned long archiveSize;
const char * failedFile = NULL;
struct callbackInfo info;
FD_t cfd;
+ int urltype;
if (!files) {
/* install all files */
if (!files[i].install) continue;
map[mappedFiles].archivePath = files[i].cpioPath;
+#ifdef DYING
map[mappedFiles].fsPath = files[i].relativePath;
+#else
+ urltype = urlPath(files[i].relativePath, &map[mappedFiles].fsPath);
+#endif
map[mappedFiles].finalMode = files[i].mode;
map[mappedFiles].finalUid = files[i].uid;
map[mappedFiles].finalGid = files[i].gid;
rpmMessage(RPMMESS_DEBUG, _("installing a source package\n"));
- realSourceDir = rpmGetPath(rootdir, "/%{_sourcedir}", NULL);
- if (stat(realSourceDir, &st) < 0) {
+ realSourceDir = rpmGenPath(rootdir, "%{_sourcedir}", "");
+ if ((rc = Stat(realSourceDir, &st)) < 0) {
switch (errno) {
case ENOENT:
/* XXX this will only create last component of directory path */
- if (mkdir(realSourceDir, 0755) == 0)
+ if (Mkdir(realSourceDir, 0755) == 0)
break;
/*@fallthrough@*/
default:
/*@notreached@*/ break;
}
}
- if (access(realSourceDir, W_OK)) {
+ if ((rc = Access(realSourceDir, W_OK))) {
rpmError(RPMERR_CREATE, _("cannot write to %s"), realSourceDir);
rc = 2;
goto exit;
}
rpmMessage(RPMMESS_DEBUG, _("sources in: %s\n"), realSourceDir);
- realSpecDir = rpmGetPath(rootdir, "/%{_specdir}", NULL);
- if (stat(realSpecDir, &st) < 0) {
+ realSpecDir = rpmGenPath(rootdir, "%{_specdir}", "");
+ if ((rc = Stat(realSpecDir, &st)) < 0) {
switch (errno) {
case ENOENT:
/* XXX this will only create last component of directory path */
/*@notreached@*/ break;
}
}
- if (access(realSpecDir, W_OK)) {
+ if ((rc = Access(realSpecDir, W_OK))) {
rpmError(RPMERR_CREATE, _("cannot write to %s"), realSpecDir);
rc = 2;
goto exit;
xfree(specFile);
- rpmMessage(RPMMESS_DEBUG,
+ if (strcmp(instSpecFile, correctSpecFile)) {
+ rpmMessage(RPMMESS_DEBUG,
_("renaming %s to %s\n"), instSpecFile, correctSpecFile);
- if (rename(instSpecFile, correctSpecFile)) {
- rpmError(RPMERR_RENAME, _("rename of %s to %s failed: %s"),
- instSpecFile, correctSpecFile, strerror(errno));
- rc = 2;
- goto exit;
+ if ((rc = Rename(instSpecFile, correctSpecFile))) {
+ rpmError(RPMERR_RENAME, _("rename of %s to %s failed: %s"),
+ instSpecFile, correctSpecFile, strerror(errno));
+ rc = 2;
+ goto exit;
+ }
}
if (specFilePtr)
#define RPMERR_BADSPEC stderr
#undef _
#define _(x) x
+
+#define vmefail() (exit(1), NULL)
#define xfree(_p) free((void *)_p)
-typedef int FD_t;
-#define Ferror(_x) (_x)
-#define fdOpen open
-#define Fread(_b, _s, _n, _fd) read(_fd, _b, _s)
-#define Fclose(_fd) close(_fd)
+#define urlPath(_xr, _r) *(_r) = (_xr)
+
+typedef FILE * FD_t;
+#define Fopen(_path, _fmode) fopen(_path, "_r");
+#define Ferror ferror
+#define Fstrerror(_fd) strerror(errno)
+#define Fread fread
+#define Fclose fclose
+
#else
+
#include <rpmlib.h>
#include <rpmio.h>
-#define fdOpen fdio->open
+#include <rpmurl.h>
+
#endif
#include <rpmmacro.h>
/* fgets analogue that reads \ continuations. Last newline always trimmed. */
static char *
-rdcl(char *buf, size_t size, FILE *fp, int escapes)
+rdcl(char *buf, size_t size, FD_t fd, int escapes)
{
char *q = buf;
size_t nb = 0;
*q = '\0';
do {
- if (fgets(q, size, fp) == NULL) /* read next line */
+ if (fgets(q, size, fpio->ffileno(fd)) == NULL) /* read next line */
break;
nb = strlen(q);
nread += nb;
mc = &globalMacroContext;
for (mfile = m = xstrdup(macrofiles); *mfile; mfile = me) {
- FILE *fp;
+ FD_t fd;
char buf[BUFSIZ];
- if ((me = strchr(mfile, ':')) != NULL)
+ for (me = mfile; (me = strchr(me, ':')) != NULL; me++) {
+ if (!(me[1] == '/' && me[2] == '/'))
+ break;
+ }
+
+ if (me && *me == ':')
*me++ = '\0';
else
me = mfile + strlen(mfile);
strncat(buf, mfile, sizeof(buf) - strlen(buf));
buf[sizeof(buf)-1] = '\0';
- if ((fp=fopen(buf, "r")) == NULL)
+ fd = Fopen(buf, "r.ufdio");
+ if (fd == NULL || Ferror(fd))
continue;
/* XXX Assume new fangled macro expansion */
max_macro_depth = 16;
- while(rdcl(buf, sizeof(buf), fp, 1) != NULL) {
+ while(rdcl(buf, sizeof(buf), fd, 1) != NULL) {
char c, *n;
n = buf;
n++; /* skip % */
(void)rpmDefineMacro(NULL, n, RMIL_MACROFILES);
}
- fclose(fp);
+ Fclose(fd);
}
if (m)
free(m);
{
FD_t fd;
ssize_t nb;
- int rderrno;
+ int rc = -1;
unsigned char magic[4];
*compressed = COMPRESSED_NOT;
+#ifdef DYING
fd = fdOpen(file, O_RDONLY, 0);
- if (Ferror(fd)) {
+#else
+ fd = Fopen(file, "r.ufdio");
+#endif
+ if (fd == NULL || Ferror(fd)) {
/* XXX Fstrerror */
- rpmError(RPMERR_BADSPEC, _("File %s: %s"), file, strerror(errno));
+ rpmError(RPMERR_BADSPEC, _("File %s: %s"), file, Fstrerror(fd));
return 1;
}
nb = Fread(magic, sizeof(char), sizeof(magic), fd);
- rderrno = errno;
- Fclose(fd);
-
if (nb < 0) {
- rpmError(RPMERR_BADSPEC, _("File %s: %s"), file, strerror(rderrno));
- return 1;
+ rpmError(RPMERR_BADSPEC, _("File %s: %s"), file, Fstrerror(fd));
+ rc = 1;
} else if (nb < sizeof(magic)) {
rpmError(RPMERR_BADSPEC, _("File %s is smaller than %d bytes"),
file, sizeof(magic));
- return 0;
+ rc = 0;
}
+ Fclose(fd);
+ if (rc >= 0)
+ return rc;
+
+ rc = 0;
if (((magic[0] == 0037) && (magic[1] == 0213)) || /* gzip */
((magic[0] == 0037) && (magic[1] == 0236)) || /* old gzip */
*compressed = COMPRESSED_BZIP2;
}
- return 0;
+ return rc;
}
/* =============================================================== */
return xstrdup(buf);
}
+/* Merge 3 args into path, any or all of which may be a url. */
+const char * rpmGenPath(const char * urlroot, const char * urlmdir,
+ const char *urlfile)
+{
+ const char * xroot = rpmGetPath(urlroot, NULL), * root = xroot;
+ const char * xmdir = rpmGetPath(urlmdir, NULL), * mdir = xmdir;
+ const char * xfile = rpmGetPath(urlfile, NULL), * file = xfile;
+ const char * result;
+ const char * url = NULL;
+ int nurl = 0;
+
+ (void) urlPath(xroot, &root);
+ if (url == NULL && *root != '\0') {
+ url = xroot;
+ nurl = root - xroot;
+ }
+
+ (void) urlPath(xmdir, &mdir);
+ if (url == NULL && *mdir != '\0') {
+ url = xmdir;
+ nurl = mdir - xmdir;
+ }
+
+ (void) urlPath(xfile, &file);
+ if (url == NULL && *file != '\0') {
+ url = xfile;
+ nurl = file - xfile;
+ }
+
+ if (url && nurl > 0) {
+ char *t = strncpy(alloca(nurl+1), url, nurl);
+ t[nurl] = '\0';
+ url = t;
+ } else
+ url = "";
+
+ result = rpmGetPath(url, root, mdir, file, NULL);
+
+ xfree(xroot);
+ xfree(xmdir);
+ xfree(xfile);
+ return result;
+}
+
/* =============================================================== */
#if defined(DEBUG_MACROS)
free(list);
}
-int rpmfileexists(const char * filespec) {
+int rpmfileexists(const char * urlfn) {
+ const char *fn;
+ int urltype = urlPath(urlfn, &fn);
struct stat buf;
- switch (urlIsURL(filespec)) {
+ switch (urltype) {
+ case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
+ case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
case URL_IS_PATH:
- filespec += sizeof("file://") - 1;
- filespec = strchr(filespec, '/');
- /*@fallthrough@*/
case URL_IS_UNKNOWN:
- if (Stat(filespec, &buf)) {
+ if (Stat(fn, &buf)) {
switch(errno) {
case ENOENT:
case EINVAL:
}
}
break;
- case URL_IS_FTP:
case URL_IS_DASH:
- case URL_IS_HTTP:
default:
return 0;
break;
return 1;
/*@notreached@*/
}
-#ifdef DYING
- fd = fdio->open(tfn, O_CREAT | O_RDWR | O_EXCL, 0700);
+
+/* XXX FIXME: build/build.c Fdopen assertion failure, makeTempFile uses fdio */
+#ifndef NOTYET
+ fd = fdio->open(tfn, (O_CREAT|O_RDWR|O_EXCL), 0700);
#else
fd = Fopen(tfn, "w+x.ufdio");
-fprintf(stderr, "*** mktemp %s fd %p: %s\n", tfnbuf, fd, strerror(errno));
#endif
} while ((fd == NULL || Ferror(fd)) && errno == EEXIST);
/* open a file and set *fdp */
if (*fdp == NULL && fnp && *fnp) {
-#ifdef DYING
- mode_t mode = (flags & O_CREAT) ? 0644 : 0;
- fd = fdio->open(*fnp, flags, mode);
-#else
- fd = Fopen(*fnp, ((flags & O_RDONLY) ? "r.fdio" : "w.fdio"));
-#endif
- if (Ferror(fd)) {
+ fd = Fopen(*fnp, ((flags & O_RDONLY) ? "r.ufdio" : "w.ufdio"));
+ if (fd == NULL || Ferror(fd)) {
fprintf(stderr, _("%s: open failed: %s\n"), *fnp,
Fstrerror(fd));
return 1;
}
}
+ /* XXX undefined %{name}/%{version}/%{release} here */
+ /* XXX %{_tmpdir} does not exist */
rpmMessage(RPMMESS_DEBUG, _(" ... as %s\n"), tfn);
myrc = urlGetFile(*filename, tfn);
if (myrc < 0) {
extern "C" {
#endif
-typedef /*@null@*/ FD_t fdio_ref_function_t ( /*@only@*/ void * cookie, const char *msg, const char *file, unsigned line);
-typedef /*@null@*/ FD_t fdio_deref_function_t ( /*@only@*/ FD_t fd, const char *msg, const char *file, unsigned line);
+typedef /*@null@*/ FD_t fdio_ref_function_t ( /*@only@*/ void * cookie,
+ const char * msg, const char * file, unsigned line);
+typedef /*@null@*/ FD_t fdio_deref_function_t ( /*@only@*/ FD_t fd,
+ const char * msg, const char * file, unsigned line);
-typedef /*@null@*/ FD_t fdio_new_function_t (FDIO_t iop, const char *msg, const char *file, unsigned line);
+typedef /*@null@*/ FD_t fdio_new_function_t (FDIO_t iop, const char * msg,
+ const char * file, unsigned line);
typedef int fdio_fileno_function_t (void * cookie);
-typedef FD_t fdio_open_function_t (const char *path, int flags, mode_t mode);
-typedef FD_t fdio_fopen_function_t (const char *path, const char *fmode);
+typedef FD_t fdio_open_function_t (const char * path, int flags, mode_t mode);
+typedef FD_t fdio_fopen_function_t (const char * path, const char * fmode);
typedef void * fdio_ffileno_function_t (FD_t fd);
typedef int fdio_fflush_function_t (FD_t fd);
-typedef int fdio_mkdir_function_t (const char *path, mode_t mode);
-typedef int fdio_chdir_function_t (const char *path);
-typedef int fdio_rmdir_function_t (const char *path);
-typedef int fdio_rename_function_t (const char *oldpath, const char *newpath);
-typedef int fdio_unlink_function_t (const char *path);
+typedef int fdio_mkdir_function_t (const char * path, mode_t mode);
+typedef int fdio_chdir_function_t (const char * path);
+typedef int fdio_rmdir_function_t (const char * path);
+typedef int fdio_rename_function_t (const char * oldpath, const char * newpath);
+typedef int fdio_unlink_function_t (const char * path);
+
+typedef int fdio_stat_function_t (const char * path, struct stat * st);
+typedef int fdio_lstat_function_t (const char * path, struct stat * st);
+typedef int fdio_access_function_t (const char * path, int amode);
struct FDIO_s {
cookie_read_function_t *read;
int Chroot (const char * path);
int Unlink (const char * path);
+int Stat (const char * path, struct stat * st);
+int Lstat (const char * path, struct stat * st);
+int Access (const char * path, int amode);
+
/*@observer@*/ extern FDIO_t gzdio;
void fdSetFdno(FD_t fd, int fdno);
/*@dependent@*/ /*@null@*/ void * ufdGetUrlinfo(FD_t fd);
/*@observer@*/ const char * urlStrerror(const char * url);
-int httpGetFile( /*@killref@*/ FD_t sfd, FD_t tfd);
-int ftpGetFile( /*@killref@*/ FD_t sfd, FD_t tfd, const char * ftpcmd);
+int ufdGetFile( /*@killref@*/ FD_t sfd, FD_t tfd);
const char *const ftpStrerror(int errorNumber);
#if 0
char * rpmExpand (const char *arg, ...);
const char *rpmGetPath (const char *path, ...);
+const char *rpmGenPath (const char *root, const char *mdir, const char *file);
int rpmExpandNumeric (const char *arg);
#ifdef __cplusplus
int fdno = Fileno(fd);
size_t nb;
fstat(fdno, &sb);
- nb = (sb.st_size > 0 ? sb.st_size : 8*BUFSIZ);
+ nb = (sb.st_size > 0 ? sb.st_size : (8*BUFSIZ - 2));
next = alloca(nb + 2);
next[0] = '\0';
rc = Fread(next, sizeof(*next), nb, fd);
linenum++;
s = se = next;
+
+ /* Find end-of-line. */
while (*se && *se != '\n') se++;
if (*se) *se++ = '\0';
next = se;
+ /* Trim leading spaces */
while (*s && isspace(*s)) s++;
- /* we used to allow comments to begin anywhere, but not anymore */
+ /* We used to allow comments to begin anywhere, but not anymore. */
if (*s == '#' || *s == '\0') continue;
+ /* Find end-of-keyword. */
se = (char *)s;
while (*se && !isspace(*se) && *se != ':') se++;
}
if (*se != ':') {
- rpmError(RPMERR_RPMRC, _("missing ':' at %s:%d"),
- filename, linenum);
+ rpmError(RPMERR_RPMRC, _("missing ':' (found 0x%02x) at %s:%d"),
+ (0xff & *se), filename, linenum);
return 1;
}
- *se++ = '\0';
+ *se++ = '\0'; /* terminate keyword or option, point to value */
while (*se && isspace(*se)) se++;
/* Find keyword in table */
int ftpCheckResponse(urlinfo u, /*@out@*/ char ** str);
int ftpCommand(urlinfo u, ...);
-int httpOpen(urlinfo u, const char * httpcmd);
+int httpOpen(urlinfo u, FD_t ctrl, const char * httpcmd);
int ftpOpen(urlinfo u);
-int ftpFileDone(urlinfo u, FD_t fd);
-int ftpFileDesc(urlinfo u, const char * cmd, FD_t fd);
+int ftpFileDone(urlinfo u, FD_t data);
+int ftpFileDesc(urlinfo u, const char * cmd, FD_t data);
urlinfo urlLink(urlinfo u, const char * msg);
urlinfo XurlLink(urlinfo u, const char * msg, const char * file, unsigned line);
void urlFreeCache(void);
urltype urlIsURL(const char * url);
+int urlPath(const char * url, /*@out@*/ const char ** pathp);
int urlSplit(const char * url, /*@out@*/ urlinfo * u);
int urlGetFile(const char * url, const char * dest);
uCache = xmalloc(sizeof(*uCache));
}
uCache[i] = urlLink(u, "uCache (miss)");
- u->ctrl = fdNew(fdio, "persist ctrl");
u->bufAlloced = URL_IOBUF_SIZE;
u->buf = xcalloc(u->bufAlloced, sizeof(char));
u = urlFree(u, "urlSplit (urlFind miss)");
{ NULL, URL_IS_UNKNOWN }
};
-urltype urlIsURL(const char * url)
-{
+urltype urlIsURL(const char * url) {
struct urlstring *us;
- for (us = urlstrings; us->leadin != NULL; us++) {
- if (strncmp(url, us->leadin, strlen(us->leadin)))
- continue;
- return us->ret;
+ if (url && *url) {
+ for (us = urlstrings; us->leadin != NULL; us++) {
+ if (strncmp(url, us->leadin, strlen(us->leadin)))
+ continue;
+ return us->ret;
+ }
}
return URL_IS_UNKNOWN;
}
+int urlPath(const char * url, const char ** pathp)
+{
+ const char *path = url;
+ int urltype = urlIsURL(url);
+
+ switch (urltype) {
+ case URL_IS_FTP:
+ path += sizeof("ftp://") - 1;
+ path = strchr(path, '/');
+ break;
+ case URL_IS_HTTP:
+ case URL_IS_PATH:
+ path += sizeof("file://") - 1;
+ path = strchr(path, '/');
+ break;
+ case URL_IS_UNKNOWN:
+ break;
+ case URL_IS_DASH:
+ path = "";
+ break;
+ }
+ if (path == NULL)
+ path = "/";
+ if (pathp)
+ *pathp = path;
+ return urltype;
+}
+
/*
* Split URL into components. The URL can look like
* service://user:password@host:port/path
switch (urlIsURL(url)) {
case URL_IS_FTP:
-#ifdef DYING
- if ((rc = ftpGetFile(sfd, tfd, "RETR"))) {
- unlink(dest);
- /* XXX FIXME: sfd possibly closed by copyData */
- /*@-usereleased@*/ Fclose(sfd) /*@=usereleased@*/ ;
- }
- /* XXX Fclose(sfd) done by copyData */
- break;
-#endif
case URL_IS_HTTP:
case URL_IS_PATH:
case URL_IS_DASH:
case URL_IS_UNKNOWN:
- if ((rc = httpGetFile(sfd, tfd))) {
- unlink(dest);
+ if ((rc = ufdGetFile(sfd, tfd))) {
+ Unlink(dest);
/* XXX FIXME: sfd possibly closed by copyData */
/*@-usereleased@*/ Fclose(sfd) /*@=usereleased@*/ ;
}
- /* XXX Fclose(sfd) done by copyData */
+ /* XXX Fclose(sfd) done by ufdCopy */
break;
default:
rc = FTPERR_UNKNOWN;
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 1999-11-10 16:44-0500\n"
+"POT-Creation-Date: 1999-11-12 11:09-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: ENCODING\n"
-#: build.c:25 lib/rpminstall.c:229 lib/rpminstall.c:389
+#: build.c:25 lib/rpminstall.c:231 lib/rpminstall.c:391
#, c-format
msgid "cannot open %s/packages.rpm\n"
msgstr ""
msgstr ""
#: rpm.c:250
-msgid " [--rmsource] specfile"
+msgid " [--rmsource] [--rmspec] specfile"
msgstr ""
#: rpm.c:251
msgid "Unable to open temp file"
msgstr ""
-#: build/build.c:122
+#: build/build.c:123
#, c-format
msgid "Executing: %s\n"
msgstr ""
-#: build/build.c:142
+#: build/build.c:143
#, c-format
msgid "Exec of %s failed (%s)"
msgstr ""
-#: build/build.c:148
+#: build/build.c:149
#, c-format
msgid "Bad exit status from %s (%s)"
msgstr ""
msgstr ""
#: build/files.c:1184
-msgid "Could not open %%files file: %s"
+msgid "Could not open %%files file %s: %s"
msgstr ""
-#: build/files.c:1190 build/pack.c:466
+#: build/files.c:1191 build/pack.c:483
#, c-format
msgid "line: %s"
msgstr ""
-#: build/files.c:1531 build/parsePrep.c:29
+#: build/files.c:1532 build/parsePrep.c:30
#, c-format
msgid "Bad owner/group: %s"
msgstr ""
#. XXX this error message is probably not seen.
-#: build/files.c:1586
+#: build/files.c:1587
#, c-format
msgid "Couldn't exec %s: %s"
msgstr ""
-#: build/files.c:1591
+#: build/files.c:1592
#, c-format
msgid "Couldn't fork %s: %s"
msgstr ""
-#: build/files.c:1673
+#: build/files.c:1674
#, c-format
msgid "%s failed"
msgstr ""
-#: build/files.c:1677
+#: build/files.c:1678
#, c-format
msgid "failed to write all data to %s"
msgstr ""
-#: build/files.c:1766
+#: build/files.c:1767
#, c-format
msgid "Finding %s: (using %s)...\n"
msgstr ""
-#: build/files.c:1794 build/files.c:1803
+#: build/files.c:1795 build/files.c:1804
#, c-format
msgid "Failed to find %s:"
msgstr ""
-#: build/files.c:1909
+#: build/files.c:1910
#, c-format
msgid "Processing files: %s-%s-%s\n"
msgstr ""
msgid "Could not open %s: %s\n"
msgstr ""
-#: build/pack.c:344 build/pack.c:386
+#: build/pack.c:345
#, c-format
msgid "Unable to write package: %s"
msgstr ""
-#: build/pack.c:359
+#: build/pack.c:360
#, c-format
msgid "Generating signature: %d\n"
msgstr ""
#: build/pack.c:376
#, c-format
-msgid "Unable to read sigtarget: %s"
+msgid "Unable to open sigtarget %s: %s"
msgstr ""
-#: build/pack.c:401
+#: build/pack.c:386
+#, c-format
+msgid "Unable to read sigtarget %s: %s"
+msgstr ""
+
+#: build/pack.c:396
+#, c-format
+msgid "Unable to write package %s: %s"
+msgstr ""
+
+#: build/pack.c:411
#, c-format
msgid "Wrote: %s\n"
msgstr ""
-#: build/pack.c:416
+#: build/pack.c:426
#, c-format
msgid "create archive failed on file %s: %s"
msgstr ""
-#: build/pack.c:435
+#: build/pack.c:445
#, c-format
msgid "cpio_copy write failed: %s"
msgstr ""
-#: build/pack.c:442
+#: build/pack.c:452
#, c-format
msgid "cpio_copy read failed: %s"
msgstr ""
-#: build/pack.c:522
+#: build/pack.c:539
#, c-format
msgid "Could not open PreIn file: %s"
msgstr ""
-#: build/pack.c:529
+#: build/pack.c:546
#, c-format
msgid "Could not open PreUn file: %s"
msgstr ""
-#: build/pack.c:536
+#: build/pack.c:553
#, c-format
msgid "Could not open PostIn file: %s"
msgstr ""
-#: build/pack.c:543
+#: build/pack.c:560
#, c-format
msgid "Could not open PostUn file: %s"
msgstr ""
-#: build/pack.c:551
+#: build/pack.c:568
#, c-format
msgid "Could not open VerifyScript file: %s"
msgstr ""
-#: build/pack.c:567
+#: build/pack.c:584
#, c-format
msgid "Could not open Trigger script file: %s"
msgstr ""
msgid "Unable to stat icon: %s"
msgstr ""
-#: build/parsePreamble.c:253
+#: build/parsePreamble.c:250
#, c-format
-msgid "Unable to read icon: %s"
+msgid "Unable to open icon %s: %s"
msgstr ""
-#: build/parsePreamble.c:263
+#: build/parsePreamble.c:257
+#, c-format
+msgid "Unable to read icon %s: %s"
+msgstr ""
+
+#: build/parsePreamble.c:270
#, c-format
msgid "Unknown icon type: %s"
msgstr ""
-#: build/parsePreamble.c:327
+#: build/parsePreamble.c:333
#, c-format
msgid "line %d: Malformed tag: %s"
msgstr ""
#. Empty field
-#: build/parsePreamble.c:335
+#: build/parsePreamble.c:341
#, c-format
msgid "line %d: Empty tag: %s"
msgstr ""
-#: build/parsePreamble.c:358 build/parsePreamble.c:365
+#: build/parsePreamble.c:364 build/parsePreamble.c:371
#, c-format
msgid "line %d: Illegal char '-' in %s: %s"
msgstr ""
-#: build/parsePreamble.c:403
+#: build/parsePreamble.c:409
#, c-format
msgid "line %d: BuildRoot can not be \"/\": %s"
msgstr ""
-#: build/parsePreamble.c:416
+#: build/parsePreamble.c:422
#, c-format
msgid "line %d: Prefixes must not end with \"/\": %s"
msgstr ""
-#: build/parsePreamble.c:428
+#: build/parsePreamble.c:434
#, c-format
msgid "line %d: Docdir must begin with '/': %s"
msgstr ""
-#: build/parsePreamble.c:440
+#: build/parsePreamble.c:446
#, c-format
msgid "line %d: Epoch/Serial field must be a number: %s"
msgstr ""
-#: build/parsePreamble.c:503
+#: build/parsePreamble.c:509
#, c-format
msgid "line %d: Bad BuildArchitecture format: %s"
msgstr ""
-#: build/parsePreamble.c:513
+#: build/parsePreamble.c:519
#, c-format
msgid "Internal error: Bogus tag %d"
msgstr ""
-#: build/parsePreamble.c:659
+#: build/parsePreamble.c:665
#, c-format
msgid "Bad package specification: %s"
msgstr ""
-#: build/parsePreamble.c:665
+#: build/parsePreamble.c:671
#, c-format
msgid "Package already exists: %s"
msgstr ""
-#: build/parsePreamble.c:692
+#: build/parsePreamble.c:698
#, c-format
msgid "line %d: Unknown tag: %s"
msgstr ""
-#: build/parsePreamble.c:717
+#: build/parsePreamble.c:723
msgid "Spec file can't use BuildRoot"
msgstr ""
-#: build/parsePrep.c:25
+#: build/parsePrep.c:26
#, c-format
msgid "Bad source: %s: %s"
msgstr ""
-#: build/parsePrep.c:51
+#: build/parsePrep.c:53
#, c-format
msgid "No patch number %d"
msgstr ""
-#: build/parsePrep.c:117
+#: build/parsePrep.c:134
#, c-format
msgid "No source number %d"
msgstr ""
-#: build/parsePrep.c:136
+#: build/parsePrep.c:153
#, c-format
msgid "Couldn't download nosource %s: %s"
msgstr ""
-#: build/parsePrep.c:190
+#: build/parsePrep.c:220
msgid "Error parsing %%setup: %s"
msgstr ""
-#: build/parsePrep.c:205
+#: build/parsePrep.c:235
msgid "line %d: Bad arg to %%setup %c: %s"
msgstr ""
-#: build/parsePrep.c:223
+#: build/parsePrep.c:253
msgid "line %d: Bad %%setup option %s: %s"
msgstr ""
-#: build/parsePrep.c:346
+#: build/parsePrep.c:376
msgid "line %d: Need arg to %%patch -b: %s"
msgstr ""
-#: build/parsePrep.c:354
+#: build/parsePrep.c:384
msgid "line %d: Need arg to %%patch -z: %s"
msgstr ""
-#: build/parsePrep.c:366
+#: build/parsePrep.c:396
msgid "line %d: Need arg to %%patch -p: %s"
msgstr ""
-#: build/parsePrep.c:372
+#: build/parsePrep.c:402
msgid "line %d: Bad arg to %%patch -p: %s"
msgstr ""
-#: build/parsePrep.c:379
+#: build/parsePrep.c:409
msgid "Too many patches!"
msgstr ""
-#: build/parsePrep.c:383
+#: build/parsePrep.c:413
msgid "line %d: Bad arg to %%patch: %s"
msgstr ""
-#: build/parsePrep.c:419
+#: build/parsePrep.c:449
msgid "line %d: second %%prep"
msgstr ""
msgid " failed - "
msgstr ""
-#: lib/dbindex.c:47
+#: lib/dbindex.c:35
#, c-format
msgid "cannot open file %s: %s"
msgstr ""
-#: lib/dbindex.c:99
+#: lib/dbindex.c:87
#, c-format
msgid "error getting record %s from %s"
msgstr ""
-#: lib/dbindex.c:126
+#: lib/dbindex.c:114
#, c-format
msgid "error storing record %s into %s"
msgstr ""
-#: lib/dbindex.c:133
+#: lib/dbindex.c:121
#, c-format
msgid "error removing record %s into %s"
msgstr ""
msgid "(unknown type)"
msgstr ""
-#: lib/install.c:141 lib/uninstall.c:194
+#: lib/install.c:142 lib/uninstall.c:194
#, c-format
msgid " file: %s action: %s\n"
msgstr ""
-#: lib/install.c:159
+#: lib/install.c:160
#, c-format
msgid "user %s does not exist - using root"
msgstr ""
-#: lib/install.c:167
+#: lib/install.c:168
#, c-format
msgid "group %s does not exist - using root"
msgstr ""
-#: lib/install.c:195
+#: lib/install.c:196
msgid "%%instchangelog value in macro file should be a number, but isn't"
msgstr ""
#. this would probably be a good place to check if disk space
#. was used up - if so, we should return a different error
-#: lib/install.c:355
+#: lib/install.c:361
#, c-format
msgid "unpacking of archive failed%s%s: %s"
msgstr ""
-#: lib/install.c:356
+#: lib/install.c:362
msgid " on file "
msgstr ""
-#: lib/install.c:399
+#: lib/install.c:405
msgid "installing a source package\n"
msgstr ""
-#: lib/install.c:410
+#: lib/install.c:416
#, c-format
msgid "cannot create %s: %s"
msgstr ""
-#: lib/install.c:418 lib/install.c:440
+#: lib/install.c:424 lib/install.c:446
#, c-format
msgid "cannot write to %s"
msgstr ""
-#: lib/install.c:422
+#: lib/install.c:428
#, c-format
msgid "sources in: %s\n"
msgstr ""
-#: lib/install.c:433
+#: lib/install.c:439
#, c-format
msgid "cannot create %s"
msgstr ""
-#: lib/install.c:444
+#: lib/install.c:450
#, c-format
msgid "spec file in: %s\n"
msgstr ""
-#: lib/install.c:478 lib/install.c:506
+#: lib/install.c:484 lib/install.c:512
msgid "source package contains no .spec file"
msgstr ""
-#: lib/install.c:527
+#: lib/install.c:534
#, c-format
msgid "renaming %s to %s\n"
msgstr ""
-#: lib/install.c:529 lib/install.c:807 lib/uninstall.c:27
+#: lib/install.c:536 lib/install.c:815 lib/uninstall.c:27
#, c-format
msgid "rename of %s to %s failed: %s"
msgstr ""
-#: lib/install.c:619
+#: lib/install.c:627
msgid "source package expected, binary found"
msgstr ""
-#: lib/install.c:676
+#: lib/install.c:684
#, c-format
msgid "package: %s-%s-%s files test = %d\n"
msgstr ""
-#: lib/install.c:737
+#: lib/install.c:745
msgid "stopping install as we're running --test\n"
msgstr ""
-#: lib/install.c:742
+#: lib/install.c:750
msgid "running preinstall script (if any)\n"
msgstr ""
-#: lib/install.c:767
+#: lib/install.c:775
#, c-format
msgid "warning: %s created as %s"
msgstr ""
-#: lib/install.c:803
+#: lib/install.c:811
#, c-format
msgid "warning: %s saved as %s"
msgstr ""
-#: lib/install.c:877
+#: lib/install.c:885
msgid "running postinstall scripts (if any)\n"
msgstr ""
msgid "cannot read header at %d for lookup"
msgstr ""
-#: lib/macro.c:153
+#: lib/macro.c:161
#, c-format
msgid "======================== active %d empty %d\n"
msgstr ""
#. XXX just in case
-#: lib/macro.c:247
+#: lib/macro.c:255
#, c-format
msgid "%3d>%*s(empty)"
msgstr ""
-#: lib/macro.c:282
+#: lib/macro.c:290
#, c-format
msgid "%3d<%*s(empty)\n"
msgstr ""
-#: lib/macro.c:461
+#: lib/macro.c:469
msgid "Macro %%%s has unterminated body"
msgstr ""
-#: lib/macro.c:487
+#: lib/macro.c:495
msgid "Macro %%%s has illegal name (%%define)"
msgstr ""
-#: lib/macro.c:493
+#: lib/macro.c:501
msgid "Macro %%%s has unterminated opts"
msgstr ""
-#: lib/macro.c:498
+#: lib/macro.c:506
msgid "Macro %%%s has empty body"
msgstr ""
-#: lib/macro.c:503
+#: lib/macro.c:511
msgid "Macro %%%s failed to expand"
msgstr ""
-#: lib/macro.c:528
+#: lib/macro.c:536
msgid "Macro %%%s has illegal name (%%undefine)"
msgstr ""
-#: lib/macro.c:605
+#: lib/macro.c:613
msgid "Macro %%%s (%s) was not used below level %d"
msgstr ""
-#: lib/macro.c:702
+#: lib/macro.c:710
#, c-format
msgid "Unknown option %c in %s(%s)"
msgstr ""
-#: lib/macro.c:874
+#: lib/macro.c:882
#, c-format
msgid "Recursion depth(%d) greater than max(%d)"
msgstr ""
-#: lib/macro.c:940 lib/macro.c:956
+#: lib/macro.c:948 lib/macro.c:964
#, c-format
msgid "Unterminated %c: %s"
msgstr ""
-#: lib/macro.c:996
+#: lib/macro.c:1004
msgid "A %% is followed by an unparseable macro"
msgstr ""
-#: lib/macro.c:1119
+#: lib/macro.c:1127
msgid "Macro %%%.*s not found, skipping"
msgstr ""
-#: lib/macro.c:1200
+#: lib/macro.c:1208
msgid "Target buffer overflow"
msgstr ""
#. XXX Fstrerror
-#: lib/macro.c:1349 lib/macro.c:1357
+#: lib/macro.c:1367 lib/macro.c:1372
#, c-format
msgid "File %s: %s"
msgstr ""
-#: lib/macro.c:1360
+#: lib/macro.c:1375
#, c-format
msgid "File %s is smaller than %d bytes"
msgstr ""
msgstr ""
#. XXX Fstrerror
-#: lib/query.c:467
+#: lib/query.c:468
#, c-format
msgid "open of %s failed: %s\n"
msgstr ""
-#: lib/query.c:485
+#: lib/query.c:486
msgid "old format source packages cannot be queried\n"
msgstr ""
-#: lib/query.c:494 lib/rpminstall.c:210
+#: lib/query.c:495 lib/rpminstall.c:212
#, c-format
msgid "%s does not appear to be a RPM package\n"
msgstr ""
-#: lib/query.c:497
+#: lib/query.c:498
#, c-format
msgid "query of %s failed\n"
msgstr ""
-#: lib/query.c:525
+#: lib/query.c:526
#, c-format
msgid "query of specfile %s failed, can't parse\n"
msgstr ""
-#: lib/query.c:550
+#: lib/query.c:551
msgid "could not read database record!\n"
msgstr ""
-#: lib/query.c:561
+#: lib/query.c:562
#, c-format
msgid "group %s does not contain any packages\n"
msgstr ""
-#: lib/query.c:571
+#: lib/query.c:572
#, c-format
msgid "no package provides %s\n"
msgstr ""
-#: lib/query.c:581
+#: lib/query.c:582
#, c-format
msgid "no package triggers %s\n"
msgstr ""
-#: lib/query.c:591
+#: lib/query.c:592
#, c-format
msgid "no package requires %s\n"
msgstr ""
-#: lib/query.c:606
+#: lib/query.c:607
#, c-format
msgid "file %s: %s\n"
msgstr ""
-#: lib/query.c:609
+#: lib/query.c:610
#, c-format
msgid "file %s is not owned by any package\n"
msgstr ""
-#: lib/query.c:622
+#: lib/query.c:623
#, c-format
msgid "invalid package number: %s\n"
msgstr ""
-#: lib/query.c:625
+#: lib/query.c:626
#, c-format
msgid "package record number: %d\n"
msgstr ""
-#: lib/query.c:628
+#: lib/query.c:629
#, c-format
msgid "record %d could not be read\n"
msgstr ""
-#: lib/query.c:640 lib/rpminstall.c:400
+#: lib/query.c:641 lib/rpminstall.c:402
#, c-format
msgid "package %s is not installed\n"
msgstr ""
-#: lib/query.c:643
+#: lib/query.c:644
#, c-format
msgid "error looking for package %s\n"
msgstr ""
-#: lib/query.c:665
+#: lib/query.c:666
msgid "rpmQuery: rpmdbOpen() failed\n"
msgstr ""
-#: lib/query.c:724
+#: lib/query.c:725
msgid "query package owning file"
msgstr ""
-#: lib/query.c:726
+#: lib/query.c:727
msgid "query packages in group"
msgstr ""
-#: lib/query.c:728
+#: lib/query.c:729
msgid "query a package file"
msgstr ""
-#: lib/query.c:732
+#: lib/query.c:733
msgid "query a spec file"
msgstr ""
-#: lib/query.c:734
+#: lib/query.c:735
msgid "query the pacakges triggered by the package"
msgstr ""
-#: lib/query.c:736
+#: lib/query.c:737
msgid "query the packages which require a capability"
msgstr ""
-#: lib/query.c:738
+#: lib/query.c:739
msgid "query the packages which provide a capability"
msgstr ""
-#: lib/query.c:777
+#: lib/query.c:778
msgid "list all configuration files"
msgstr ""
-#: lib/query.c:779
+#: lib/query.c:780
msgid "list all documentation files"
msgstr ""
-#: lib/query.c:781
+#: lib/query.c:782
msgid "dump basic file information"
msgstr ""
-#: lib/query.c:783
+#: lib/query.c:784
msgid "list files in package"
msgstr ""
-#: lib/query.c:787
+#: lib/query.c:788
msgid "use the following query format"
msgstr ""
-#: lib/query.c:789
+#: lib/query.c:790
msgid "substitute i18n sections from the following catalogue"
msgstr ""
-#: lib/query.c:792
+#: lib/query.c:793
msgid "display the states of the listed files"
msgstr ""
-#: lib/query.c:794
+#: lib/query.c:795
msgid "display a verbose file listing"
msgstr ""
msgid "failed to remove directory %s: %s\n"
msgstr ""
-#: lib/rpmchecksig.c:36
+#: lib/rpmchecksig.c:31
#, c-format
msgid "%s: open failed: %s\n"
msgstr ""
-#: lib/rpmchecksig.c:47
+#: lib/rpmchecksig.c:42
msgid "makeTempFile failed\n"
msgstr ""
-#: lib/rpmchecksig.c:79
+#: lib/rpmchecksig.c:74
#, c-format
msgid "%s: Fwrite failed: %s\n"
msgstr ""
-#: lib/rpmchecksig.c:85
+#: lib/rpmchecksig.c:80
#, c-format
msgid "%s: Fread failed: %s\n"
msgstr ""
-#: lib/rpmchecksig.c:118 lib/rpmchecksig.c:248
+#: lib/rpmchecksig.c:113 lib/rpmchecksig.c:243
#, c-format
msgid "%s: readLead failed\n"
msgstr ""
-#: lib/rpmchecksig.c:123
+#: lib/rpmchecksig.c:118
#, c-format
msgid "%s: Can't sign v1.0 RPM\n"
msgstr ""
-#: lib/rpmchecksig.c:127
+#: lib/rpmchecksig.c:122
#, c-format
msgid "%s: Can't re-sign v2.0 RPM\n"
msgstr ""
-#: lib/rpmchecksig.c:135 lib/rpmchecksig.c:262
+#: lib/rpmchecksig.c:130 lib/rpmchecksig.c:257
#, c-format
msgid "%s: rpmReadSignature failed\n"
msgstr ""
-#: lib/rpmchecksig.c:139 lib/rpmchecksig.c:267
+#: lib/rpmchecksig.c:134 lib/rpmchecksig.c:262
#, c-format
msgid "%s: No signature available\n"
msgstr ""
-#: lib/rpmchecksig.c:172
+#: lib/rpmchecksig.c:167
#, c-format
msgid "%s: writeLead failed: %s\n"
msgstr ""
-#: lib/rpmchecksig.c:178
+#: lib/rpmchecksig.c:173
#, c-format
msgid "%s: rpmWriteSignature failed: %s\n"
msgstr ""
-#: lib/rpmchecksig.c:254
+#: lib/rpmchecksig.c:249
#, c-format
msgid "%s: No signature available (v1.0 RPM)\n"
msgstr ""
-#: lib/rpmchecksig.c:417
+#: lib/rpmchecksig.c:412
msgid "NOT OK"
msgstr ""
-#: lib/rpmchecksig.c:418 lib/rpmchecksig.c:432
+#: lib/rpmchecksig.c:413 lib/rpmchecksig.c:427
msgid " (MISSING KEYS:"
msgstr ""
-#: lib/rpmchecksig.c:420 lib/rpmchecksig.c:434
+#: lib/rpmchecksig.c:415 lib/rpmchecksig.c:429
msgid ") "
msgstr ""
-#: lib/rpmchecksig.c:421 lib/rpmchecksig.c:435
+#: lib/rpmchecksig.c:416 lib/rpmchecksig.c:430
msgid " (UNTRUSTED KEYS:"
msgstr ""
-#: lib/rpmchecksig.c:423 lib/rpmchecksig.c:437
+#: lib/rpmchecksig.c:418 lib/rpmchecksig.c:432
msgid ")"
msgstr ""
-#: lib/rpmchecksig.c:431
+#: lib/rpmchecksig.c:426
msgid "OK"
msgstr ""
msgid "opening database mode 0x%x in %s\n"
msgstr ""
-#: lib/rpmdb.c:155 lib/url.c:403
+#: lib/rpmdb.c:155 lib/url.c:431
#, c-format
msgid "failed to open %s: %s\n"
msgstr ""
msgid "Retrieving %s\n"
msgstr ""
-#: lib/rpminstall.c:167
+#. XXX undefined %{name}/%{version}/%{release} here
+#. XXX %{_tmpdir} does not exist
+#: lib/rpminstall.c:169
#, c-format
msgid " ... as %s\n"
msgstr ""
-#: lib/rpminstall.c:171
+#: lib/rpminstall.c:173
#, c-format
msgid "skipping %s - transfer failed - %s\n"
msgstr ""
-#: lib/rpminstall.c:188
+#: lib/rpminstall.c:190
#, c-format
msgid "retrieved %d packages\n"
msgstr ""
-#: lib/rpminstall.c:197 lib/rpminstall.c:339
+#: lib/rpminstall.c:199 lib/rpminstall.c:341
#, c-format
msgid "cannot open file %s: %s\n"
msgstr ""
-#: lib/rpminstall.c:214 lib/rpminstall.c:477
+#: lib/rpminstall.c:216 lib/rpminstall.c:479
#, c-format
msgid "%s cannot be installed\n"
msgstr ""
-#: lib/rpminstall.c:250
+#: lib/rpminstall.c:252
#, c-format
msgid "package %s is not relocateable\n"
msgstr ""
-#: lib/rpminstall.c:268
+#: lib/rpminstall.c:270
#, c-format
msgid "error reading from file %s\n"
msgstr ""
-#: lib/rpminstall.c:273
+#: lib/rpminstall.c:275
#, c-format
msgid "file %s requires a newer version of RPM\n"
msgstr ""
-#: lib/rpminstall.c:290
+#: lib/rpminstall.c:292
#, c-format
msgid "found %d source and %d binary packages\n"
msgstr ""
-#: lib/rpminstall.c:301
+#: lib/rpminstall.c:303
msgid "failed dependencies:\n"
msgstr ""
-#: lib/rpminstall.c:319
+#: lib/rpminstall.c:321
msgid "installing binary packages\n"
msgstr ""
-#: lib/rpminstall.c:404
+#: lib/rpminstall.c:406
#, c-format
msgid "searching for package %s\n"
msgstr ""
-#: lib/rpminstall.c:413
+#: lib/rpminstall.c:415
#, c-format
msgid "\"%s\" specifies multiple packages\n"
msgstr ""
-#: lib/rpminstall.c:439
+#: lib/rpminstall.c:441
msgid "removing these packages would break dependencies:\n"
msgstr ""
-#: lib/rpminstall.c:466
+#: lib/rpminstall.c:468
#, c-format
msgid "cannot open %s: %s\n"
msgstr ""
-#: lib/rpminstall.c:472
+#: lib/rpminstall.c:474
#, c-format
msgid "Installing %s\n"
msgstr ""
-#: lib/rpmio.c:339
+#: lib/rpmio.c:340
msgid "Success"
msgstr ""
-#: lib/rpmio.c:342
+#: lib/rpmio.c:343
msgid "Bad server response"
msgstr ""
-#: lib/rpmio.c:345
+#: lib/rpmio.c:346
msgid "Server IO error"
msgstr ""
-#: lib/rpmio.c:348
+#: lib/rpmio.c:349
msgid "Server timeout"
msgstr ""
-#: lib/rpmio.c:351
+#: lib/rpmio.c:352
msgid "Unable to lookup server host address"
msgstr ""
-#: lib/rpmio.c:354
+#: lib/rpmio.c:355
msgid "Unable to lookup server host name"
msgstr ""
-#: lib/rpmio.c:357
+#: lib/rpmio.c:358
msgid "Failed to connect to server"
msgstr ""
-#: lib/rpmio.c:360
+#: lib/rpmio.c:361
msgid "Failed to establish data connection to server"
msgstr ""
-#: lib/rpmio.c:363
+#: lib/rpmio.c:364
msgid "IO error to local file"
msgstr ""
-#: lib/rpmio.c:366
+#: lib/rpmio.c:367
msgid "Error setting remote server to passive mode"
msgstr ""
-#: lib/rpmio.c:369
+#: lib/rpmio.c:370
msgid "File not found on server"
msgstr ""
-#: lib/rpmio.c:372
+#: lib/rpmio.c:373
msgid "Abort in progress"
msgstr ""
-#: lib/rpmio.c:376
+#: lib/rpmio.c:377
msgid "Unknown or unexpected error"
msgstr ""
-#: lib/rpmio.c:424
+#: lib/rpmio.c:425
#, c-format
msgid "logging into %s as %s, pw %s\n"
msgstr ""
msgid "Failed to read %s: %s."
msgstr ""
-#: lib/rpmrc.c:633
+#: lib/rpmrc.c:637
#, c-format
-msgid "missing ':' at %s:%d"
+msgid "missing ':' (found 0x%02x) at %s:%d"
msgstr ""
-#: lib/rpmrc.c:650 lib/rpmrc.c:724
+#: lib/rpmrc.c:654 lib/rpmrc.c:728
#, c-format
msgid "missing argument for %s at %s:%d"
msgstr ""
-#: lib/rpmrc.c:667 lib/rpmrc.c:689
+#: lib/rpmrc.c:671 lib/rpmrc.c:693
#, c-format
msgid "%s expansion failed at %s:%d \"%s\""
msgstr ""
-#: lib/rpmrc.c:676
+#: lib/rpmrc.c:680
#, c-format
msgid "cannot open %s at %s:%d: %s"
msgstr ""
-#: lib/rpmrc.c:716
+#: lib/rpmrc.c:720
#, c-format
msgid "missing architecture for %s at %s:%d"
msgstr ""
-#: lib/rpmrc.c:783
+#: lib/rpmrc.c:787
#, c-format
msgid "bad option '%s' at %s:%d"
msgstr ""
-#: lib/rpmrc.c:1151
+#: lib/rpmrc.c:1155
#, c-format
msgid "Unknown system: %s\n"
msgstr ""
-#: lib/rpmrc.c:1152
+#: lib/rpmrc.c:1156
msgid "Please contact rpm-list@redhat.com\n"
msgstr ""
msgid "warning: uCache[%d] %p nrefs(%d) != 1 (%s %s)\n"
msgstr ""
-#: lib/url.c:207
+#: lib/url.c:206
#, c-format
msgid "Password for %s@%s: "
msgstr ""
-#: lib/url.c:232 lib/url.c:258
+#: lib/url.c:231 lib/url.c:257
#, c-format
msgid "error: %sport must be a number\n"
msgstr ""
-#: lib/url.c:367
+#: lib/url.c:395
msgid "url port must be a number\n"
msgstr ""
#. XXX Fstrerror
-#: lib/url.c:426
+#: lib/url.c:454
#, c-format
msgid "failed to create %s: %s\n"
msgstr ""
puts(_(" rpm {-b|t}[plciba] [-v] [--short-circuit] [--clean] [--rcfile <file>]"));
puts(_(" [--sign] [--nobuild] [--timecheck <s>] ]"));
puts(_(" [--target=platform1[,platform2...]]"));
- puts(_(" [--rmsource] specfile"));
+ puts(_(" [--rmsource] [--rmspec] specfile"));
puts(_(" rpm {--rmsource} [--rcfile <file>] [-v] specfile"));
puts(_(" rpm {--rebuild} [--rcfile <file>] [-v] source1.rpm ... sourceN.rpm"));
puts(_(" rpm {--recompile} [--rcfile <file>] [-v] source1.rpm ... sourceN.rpm"));
#define RPMERR_BADSPEC stderr
#undef _
#define _(x) x
+
+#define vmefail() (exit(1), NULL)
#define xfree(_p) free((void *)_p)
-typedef int FD_t;
-#define Ferror(_x) (_x)
-#define fdOpen open
-#define Fread(_b, _s, _n, _fd) read(_fd, _b, _s)
-#define Fclose(_fd) close(_fd)
+#define urlPath(_xr, _r) *(_r) = (_xr)
+
+typedef FILE * FD_t;
+#define Fopen(_path, _fmode) fopen(_path, "_r");
+#define Ferror ferror
+#define Fstrerror(_fd) strerror(errno)
+#define Fread fread
+#define Fclose fclose
+
#else
+
#include <rpmlib.h>
#include <rpmio.h>
-#define fdOpen fdio->open
+#include <rpmurl.h>
+
#endif
#include <rpmmacro.h>
/* fgets analogue that reads \ continuations. Last newline always trimmed. */
static char *
-rdcl(char *buf, size_t size, FILE *fp, int escapes)
+rdcl(char *buf, size_t size, FD_t fd, int escapes)
{
char *q = buf;
size_t nb = 0;
*q = '\0';
do {
- if (fgets(q, size, fp) == NULL) /* read next line */
+ if (fgets(q, size, fpio->ffileno(fd)) == NULL) /* read next line */
break;
nb = strlen(q);
nread += nb;
mc = &globalMacroContext;
for (mfile = m = xstrdup(macrofiles); *mfile; mfile = me) {
- FILE *fp;
+ FD_t fd;
char buf[BUFSIZ];
- if ((me = strchr(mfile, ':')) != NULL)
+ for (me = mfile; (me = strchr(me, ':')) != NULL; me++) {
+ if (!(me[1] == '/' && me[2] == '/'))
+ break;
+ }
+
+ if (me && *me == ':')
*me++ = '\0';
else
me = mfile + strlen(mfile);
strncat(buf, mfile, sizeof(buf) - strlen(buf));
buf[sizeof(buf)-1] = '\0';
- if ((fp=fopen(buf, "r")) == NULL)
+ fd = Fopen(buf, "r.ufdio");
+ if (fd == NULL || Ferror(fd))
continue;
/* XXX Assume new fangled macro expansion */
max_macro_depth = 16;
- while(rdcl(buf, sizeof(buf), fp, 1) != NULL) {
+ while(rdcl(buf, sizeof(buf), fd, 1) != NULL) {
char c, *n;
n = buf;
n++; /* skip % */
(void)rpmDefineMacro(NULL, n, RMIL_MACROFILES);
}
- fclose(fp);
+ Fclose(fd);
}
if (m)
free(m);
{
FD_t fd;
ssize_t nb;
- int rderrno;
+ int rc = -1;
unsigned char magic[4];
*compressed = COMPRESSED_NOT;
+#ifdef DYING
fd = fdOpen(file, O_RDONLY, 0);
- if (Ferror(fd)) {
+#else
+ fd = Fopen(file, "r.ufdio");
+#endif
+ if (fd == NULL || Ferror(fd)) {
/* XXX Fstrerror */
- rpmError(RPMERR_BADSPEC, _("File %s: %s"), file, strerror(errno));
+ rpmError(RPMERR_BADSPEC, _("File %s: %s"), file, Fstrerror(fd));
return 1;
}
nb = Fread(magic, sizeof(char), sizeof(magic), fd);
- rderrno = errno;
- Fclose(fd);
-
if (nb < 0) {
- rpmError(RPMERR_BADSPEC, _("File %s: %s"), file, strerror(rderrno));
- return 1;
+ rpmError(RPMERR_BADSPEC, _("File %s: %s"), file, Fstrerror(fd));
+ rc = 1;
} else if (nb < sizeof(magic)) {
rpmError(RPMERR_BADSPEC, _("File %s is smaller than %d bytes"),
file, sizeof(magic));
- return 0;
+ rc = 0;
}
+ Fclose(fd);
+ if (rc >= 0)
+ return rc;
+
+ rc = 0;
if (((magic[0] == 0037) && (magic[1] == 0213)) || /* gzip */
((magic[0] == 0037) && (magic[1] == 0236)) || /* old gzip */
*compressed = COMPRESSED_BZIP2;
}
- return 0;
+ return rc;
}
/* =============================================================== */
return xstrdup(buf);
}
+/* Merge 3 args into path, any or all of which may be a url. */
+const char * rpmGenPath(const char * urlroot, const char * urlmdir,
+ const char *urlfile)
+{
+ const char * xroot = rpmGetPath(urlroot, NULL), * root = xroot;
+ const char * xmdir = rpmGetPath(urlmdir, NULL), * mdir = xmdir;
+ const char * xfile = rpmGetPath(urlfile, NULL), * file = xfile;
+ const char * result;
+ const char * url = NULL;
+ int nurl = 0;
+
+ (void) urlPath(xroot, &root);
+ if (url == NULL && *root != '\0') {
+ url = xroot;
+ nurl = root - xroot;
+ }
+
+ (void) urlPath(xmdir, &mdir);
+ if (url == NULL && *mdir != '\0') {
+ url = xmdir;
+ nurl = mdir - xmdir;
+ }
+
+ (void) urlPath(xfile, &file);
+ if (url == NULL && *file != '\0') {
+ url = xfile;
+ nurl = file - xfile;
+ }
+
+ if (url && nurl > 0) {
+ char *t = strncpy(alloca(nurl+1), url, nurl);
+ t[nurl] = '\0';
+ url = t;
+ } else
+ url = "";
+
+ result = rpmGetPath(url, root, mdir, file, NULL);
+
+ xfree(xroot);
+ xfree(xmdir);
+ xfree(xfile);
+ return result;
+}
+
/* =============================================================== */
#if defined(DEBUG_MACROS)
char * rpmExpand (const char *arg, ...);
const char *rpmGetPath (const char *path, ...);
+const char *rpmGenPath (const char *root, const char *mdir, const char *file);
int rpmExpandNumeric (const char *arg);
#ifdef __cplusplus