summaryrefslogtreecommitdiff
path: root/build/pack.c
diff options
context:
space:
mode:
authorjbj <devnull@localhost>1999-11-12 17:20:49 +0000
committerjbj <devnull@localhost>1999-11-12 17:20:49 +0000
commit8ce88756fdb4a1cd88085acfac49c3a7180bb1bb (patch)
tree02f06c8b54b20af60f42299f65a6fca86cd61783 /build/pack.c
parente0b1d0be3607ef673555ca17078bfff6f854267e (diff)
downloadlibrpm-tizen-8ce88756fdb4a1cd88085acfac49c3a7180bb1bb.tar.gz
librpm-tizen-8ce88756fdb4a1cd88085acfac49c3a7180bb1bb.tar.bz2
librpm-tizen-8ce88756fdb4a1cd88085acfac49c3a7180bb1bb.zip
Use Fstrerror on ufdio throughut.
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
Diffstat (limited to 'build/pack.c')
-rw-r--r--build/pack.c64
1 files changed, 41 insertions, 23 deletions
diff --git a/build/pack.c b/build/pack.c
index a75dba9a2..059acdad8 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -10,7 +10,7 @@
#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);
@@ -179,8 +179,8 @@ int readRPM(const char *fileName, Spec *specp, struct rpmlead *lead, Header *sig
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;
@@ -307,9 +307,10 @@ int writeRPM(Header h, const char *fileName, int type,
}
/* 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;
@@ -370,11 +371,20 @@ int writeRPM(Header h, const char *fileName, int type,
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);
@@ -383,8 +393,8 @@ int writeRPM(Header h, const char *fileName, int type,
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);
@@ -446,29 +456,37 @@ static int cpio_copy(FD_t fdo, CSA_t *csa)
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;
}