Start abstracting compressed I/O.
CVS patchset: 2552 CVS date: 1998/11/22 19:48:48
This commit is contained in:
parent
a15a36abd1
commit
eb0436b4b2
12
Makefile.am
12
Makefile.am
|
@ -30,12 +30,12 @@ rpm_SOURCES = build.c checksig.c ftp.c install.c rpm.c url.c \
|
|||
verify.c
|
||||
rpm_LDADD = -lrpmbuild -lpopt -lrpm @LIBMISC@
|
||||
|
||||
rpm.o: rpm.c
|
||||
$(COMPILE) \
|
||||
-DLOCALEDIR=\"$(LOCALEDIR)\" \
|
||||
-DLIBRPMALIAS_FILENAME=\"$(LIBRPMALIAS_FILENAME)\" \
|
||||
-DRPMCONFIGDIR="\"$(RPMCONFIGDIR)"\" \
|
||||
-c $<
|
||||
#rpm.o: rpm.c
|
||||
# $(COMPILE) \
|
||||
# -DLOCALEDIR=\"$(LOCALEDIR)\" \
|
||||
# -DLIBRPMALIAS_FILENAME=\"$(LIBRPMALIAS_FILENAME)\" \
|
||||
# -DRPMCONFIGDIR="\"$(RPMCONFIGDIR)"\" \
|
||||
# -c $<
|
||||
|
||||
include ./Makefile.inc
|
||||
|
||||
|
|
13
Makefile.in
13
Makefile.in
|
@ -92,6 +92,7 @@ LIBRPMALIAS_FILENAME = @LIBRPMALIAS_FILENAME@
|
|||
LIBRPMRC_FILENAME = @LIBRPMRC_FILENAME@
|
||||
LIBS = @LIBS@
|
||||
LN_S = @LN_S@
|
||||
LOCALEDIR = @LOCALEDIR@
|
||||
MACROFILES = @MACROFILES@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MISCDIR = @MISCDIR@
|
||||
|
@ -682,12 +683,12 @@ clean-generic maintainer-clean-generic clean mostlyclean distclean \
|
|||
maintainer-clean
|
||||
|
||||
|
||||
rpm.o: rpm.c
|
||||
$(COMPILE) \
|
||||
-DLOCALEDIR=\"$(LOCALEDIR)\" \
|
||||
-DLIBRPMALIAS_FILENAME=\"$(LIBRPMALIAS_FILENAME)\" \
|
||||
-DRPMCONFIGDIR="\"$(RPMCONFIGDIR)"\" \
|
||||
-c $<
|
||||
#rpm.o: rpm.c
|
||||
# $(COMPILE) \
|
||||
# -DLOCALEDIR=\"$(LOCALEDIR)\" \
|
||||
# -DLIBRPMALIAS_FILENAME=\"$(LIBRPMALIAS_FILENAME)\" \
|
||||
# -DRPMCONFIGDIR="\"$(RPMCONFIGDIR)"\" \
|
||||
# -c $<
|
||||
|
||||
include ./Makefile.inc
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ LIBRPMRC_FILENAME=$(RPMCONFIGDIR)/rpmrc
|
|||
LIBRPMALIAS_FILENAME=$(RPMCONFIGDIR)/rpmpopt
|
||||
MACROFILES=$(RPMCONFIGDIR)/macros
|
||||
|
||||
LOCALEDIR=@datadir@/locale
|
||||
LOCALEDIR=@LOCALEDIR@
|
||||
PACKAGE = @PACKAGE@
|
||||
VERSION = @VERSION@
|
||||
|
||||
|
|
|
@ -90,6 +90,9 @@
|
|||
/* Define this to be whatever root's primary group is, in double quotes */
|
||||
#undef ROOT_GROUP
|
||||
|
||||
/* Full path to rpm locale directory (usually /usr/share/locale) */
|
||||
#undef LOCALEDIR
|
||||
|
||||
/* Full path to rpm configuration directory (usually /usr/lib/rpm) */
|
||||
#undef RPMCONFIGDIR
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@ LIBRPMALIAS_FILENAME = @LIBRPMALIAS_FILENAME@
|
|||
LIBRPMRC_FILENAME = @LIBRPMRC_FILENAME@
|
||||
LIBS = @LIBS@
|
||||
LN_S = @LN_S@
|
||||
LOCALEDIR = @LOCALEDIR@
|
||||
MACROFILES = @MACROFILES@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MISCDIR = @MISCDIR@
|
||||
|
|
|
@ -394,10 +394,10 @@ static int cpio_gzip(FD_t fdo, CSA_t *csa) {
|
|||
char *failedFile;
|
||||
|
||||
cfd->cpioIoType = cpioIoTypeGzFd;
|
||||
cfd->cpioGzFd = gzdopen(dup(fdFileno(fdo)), "w9");
|
||||
cfd->cpioGzFd = gzdFdopen(fdDup(fdFileno(fdo)), "w9");
|
||||
rc = cpioBuildArchive(cfd, csa->cpioList, csa->cpioCount, NULL, NULL,
|
||||
&csa->cpioArchiveSize, &failedFile);
|
||||
gzclose(cfd->cpioGzFd);
|
||||
gzdClose(cfd->cpioGzFd);
|
||||
|
||||
if (rc) {
|
||||
if (rc & CPIO_CHECK_ERRNO)
|
||||
|
|
14
configure.in
14
configure.in
|
@ -320,6 +320,16 @@ for zlib in z gz ; do
|
|||
)
|
||||
done
|
||||
|
||||
BZ2LIB=
|
||||
for bz2lib in bz2 ; do
|
||||
AC_CHECK_LIB(${bz2lib}, bzread,
|
||||
[LIBS="$LIBS -l${bz2lib}"; break],
|
||||
[if test ${bz2lib} = bz2; then
|
||||
AC_MSG_WARN([missing libbz2.a (from the bzip2 package)])
|
||||
fi]
|
||||
)
|
||||
done
|
||||
|
||||
dnl XXX these are needed only by rpmgettext right now
|
||||
AM_FUNC_ERROR_AT_LINE
|
||||
|
||||
|
@ -344,6 +354,7 @@ AC_CHECK_HEADERS(netinet/in_systm.h)
|
|||
AC_CHECK_HEADERS(machine/types.h)
|
||||
AC_CHECK_HEADERS(mntent.h sys/mnttab.h sys/systemcfg.h)
|
||||
AC_CHECK_HEADERS(sys/mount.h sys/mntctl.h sys/vmount.h)
|
||||
AC_CHECK_HEADERS(bzlib.h libio.h zlib.h)
|
||||
|
||||
AC_C_BIGENDIAN
|
||||
AC_C_INLINE
|
||||
|
@ -583,6 +594,9 @@ if test -n "$LIBOBJS" ; then
|
|||
MISCPATH=misc/libmisc.a
|
||||
fi
|
||||
|
||||
LOCALEDIR="`echo ${prefix}/share/locale`"
|
||||
AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR")
|
||||
AC_SUBST(LOCALEDIR)
|
||||
RPMCONFIGDIR="`echo ${prefix}/lib/rpm`"
|
||||
AC_DEFINE_UNQUOTED(RPMCONFIGDIR, "$RPMCONFIGDIR")
|
||||
AC_SUBST(RPMCONFIGDIR)
|
||||
|
|
|
@ -92,6 +92,7 @@ LIBRPMALIAS_FILENAME = @LIBRPMALIAS_FILENAME@
|
|||
LIBRPMRC_FILENAME = @LIBRPMRC_FILENAME@
|
||||
LIBS = @LIBS@
|
||||
LN_S = @LN_S@
|
||||
LOCALEDIR = @LOCALEDIR@
|
||||
MACROFILES = @MACROFILES@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MISCDIR = @MISCDIR@
|
||||
|
|
|
@ -77,7 +77,7 @@ static inline off_t saferead(CFD_t *cfd, void * vbuf, size_t amount) {
|
|||
nb *= amount;
|
||||
break;
|
||||
case cpioIoTypeGzFd:
|
||||
nb = gzread(cfd->cpioGzFd, buf, amount);
|
||||
nb = gzdRead(cfd->cpioGzFd, buf, amount);
|
||||
break;
|
||||
}
|
||||
if (nb <= 0)
|
||||
|
@ -132,7 +132,7 @@ static inline off_t safewrite(CFD_t *cfd, void * vbuf, size_t amount) {
|
|||
nb *= amount;
|
||||
break;
|
||||
case cpioIoTypeGzFd:
|
||||
nb = gzwrite(cfd->cpioGzFd, buf, amount);
|
||||
nb = gzdWrite(cfd->cpioGzFd, buf, amount);
|
||||
break;
|
||||
}
|
||||
if (nb <= 0)
|
||||
|
|
|
@ -60,7 +60,7 @@ typedef struct CFD {
|
|||
#define cpioFd _cfdu._cfdu_fd
|
||||
FILE * _cfdu_fp;
|
||||
#define cpioFp _cfdu._cfdu_fp
|
||||
gzFile _cfdu_gzfd;
|
||||
FD_t _cfdu_gzfd;
|
||||
#define cpioGzFd _cfdu._cfdu_gzfd
|
||||
} _cfdu;
|
||||
int cpioPos;
|
||||
|
|
20
lib/header.c
20
lib/header.c
|
@ -320,7 +320,7 @@ Header headerRead(FD_t fd, int magicp)
|
|||
return h;
|
||||
}
|
||||
|
||||
void headerGzWrite(gzFile fd, Header h, int magicp)
|
||||
void headerGzWrite(FD_t fd, Header h, int magicp)
|
||||
{
|
||||
void * p;
|
||||
int length;
|
||||
|
@ -329,17 +329,17 @@ void headerGzWrite(gzFile fd, Header h, int magicp)
|
|||
p = doHeaderUnload(h, &length);
|
||||
|
||||
if (magicp) {
|
||||
gzwrite(fd, header_magic, sizeof(header_magic));
|
||||
gzdWrite(fd, header_magic, sizeof(header_magic));
|
||||
l = htonl(0);
|
||||
gzwrite(fd, &l, sizeof(l));
|
||||
gzdWrite(fd, &l, sizeof(l));
|
||||
}
|
||||
|
||||
gzwrite(fd, p, length);
|
||||
gzdWrite(fd, p, length);
|
||||
|
||||
free(p);
|
||||
}
|
||||
|
||||
Header headerGzRead(gzFile fd, int magicp)
|
||||
Header headerGzRead(FD_t fd, int magicp)
|
||||
{
|
||||
int_32 reserved;
|
||||
int_32 * p;
|
||||
|
@ -350,24 +350,24 @@ Header headerGzRead(gzFile fd, int magicp)
|
|||
int totalSize;
|
||||
|
||||
if (magicp == HEADER_MAGIC_YES) {
|
||||
if (gzread(fd, &magic, sizeof(magic)) != sizeof(magic))
|
||||
if (gzdRead(fd, &magic, sizeof(magic)) != sizeof(magic))
|
||||
return NULL;
|
||||
if (memcmp(&magic, header_magic, sizeof(magic))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (gzread(fd, &reserved, sizeof(reserved)) != sizeof(reserved))
|
||||
if (gzdRead(fd, &reserved, sizeof(reserved)) != sizeof(reserved))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* First read the index length (count of index entries) */
|
||||
if (gzread(fd, &il, sizeof(il)) != sizeof(il))
|
||||
if (gzdRead(fd, &il, sizeof(il)) != sizeof(il))
|
||||
return NULL;
|
||||
|
||||
il = ntohl(il);
|
||||
|
||||
/* Then read the data length (number of bytes) */
|
||||
if (gzread(fd, &dl, sizeof(dl)) != sizeof(dl))
|
||||
if (gzdRead(fd, &dl, sizeof(dl)) != sizeof(dl))
|
||||
return NULL;
|
||||
|
||||
dl = ntohl(dl);
|
||||
|
@ -380,7 +380,7 @@ Header headerGzRead(gzFile fd, int magicp)
|
|||
*p++ = htonl(dl);
|
||||
|
||||
totalSize -= sizeof(int_32) + sizeof(int_32);
|
||||
if (gzread(fd, p, totalSize) != totalSize)
|
||||
if (gzdRead(fd, p, totalSize) != totalSize)
|
||||
return NULL;
|
||||
|
||||
h = headerLoad(block);
|
||||
|
|
|
@ -72,8 +72,8 @@ extern const struct headerSprintfExtension headerDefaultFormats[];
|
|||
/* read and write a header from a file */
|
||||
Header headerRead(FD_t fd, int magicp);
|
||||
void headerWrite(FD_t fd, Header h, int magicp);
|
||||
Header headerGzRead(gzFile fd, int magicp);
|
||||
void headerGzWrite(gzFile fd, Header h, int magicp);
|
||||
Header headerGzRead(FD_t fd, int magicp);
|
||||
void headerGzWrite(FD_t fd, Header h, int magicp);
|
||||
unsigned int headerSizeof(Header h, int magicp);
|
||||
|
||||
#define HEADER_MAGIC_NO 0
|
||||
|
|
|
@ -1009,12 +1009,12 @@ static int installArchive(FD_t fd, struct fileInfo * files,
|
|||
|
||||
{ CFD_t cfdbuf, *cfd = &cfdbuf;
|
||||
cfd->cpioIoType = cpioIoTypeGzFd;
|
||||
cfd->cpioGzFd = gzdopen(fdFileno(fd), "r");
|
||||
cfd->cpioGzFd = gzdFdopen(fd, "r"); /* XXX cpioGzFd == fd */
|
||||
rc = cpioInstallArchive(cfd, map, mappedFiles,
|
||||
((notify && archiveSize) || specFile) ?
|
||||
callback : NULL,
|
||||
&info, &failedFile);
|
||||
gzclose(cfd->cpioGzFd);
|
||||
gzdClose(cfd->cpioGzFd);
|
||||
}
|
||||
|
||||
if (rc) {
|
||||
|
|
179
lib/rpmio.h
179
lib/rpmio.h
|
@ -5,6 +5,9 @@
|
|||
|
||||
typedef /*@abstract@*/ struct {
|
||||
int fd_fd;
|
||||
void * fd_bzd;
|
||||
void * fd_gzd;
|
||||
|
||||
} *FD_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -19,6 +22,8 @@ extern inline /*@null@*/ FD_t fdNew(void) {
|
|||
if (fd == NULL)
|
||||
return NULL;
|
||||
fd->fd_fd = -1;
|
||||
fd->fd_bzd = NULL;
|
||||
fd->fd_gzd = NULL;
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
@ -54,9 +59,9 @@ extern inline /*@null@*/ FD_t fdDup(int fdno) {
|
|||
return fd;
|
||||
}
|
||||
|
||||
extern inline ssize_t fdLseek(FD_t fd, off_t off, int op);
|
||||
extern inline ssize_t fdLseek(FD_t fd, off_t off, int op) {
|
||||
return lseek(fdFileno(fd), off, op);
|
||||
extern inline off_t fdLseek(FD_t fd, off_t offset, int whence);
|
||||
extern inline off_t fdLseek(FD_t fd, off_t offset, int whence) {
|
||||
return lseek(fdFileno(fd), offset, whence);
|
||||
}
|
||||
|
||||
extern inline ssize_t fdRead(FD_t fd, void * buf, size_t count);
|
||||
|
@ -94,6 +99,174 @@ extern inline /*@shared@*/ FILE *fdFdopen(/*@owned@*/ FD_t fd, const char *mode)
|
|||
}
|
||||
/*@=mustfree*/
|
||||
|
||||
/*
|
||||
* Support for GZIP library.
|
||||
*/
|
||||
#ifdef HAVE_ZLIB_H
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
extern inline gzFile * gzdFileno(FD_t fd);
|
||||
extern inline gzFile * gzdFileno(FD_t fd) {
|
||||
return (fd != NULL ? ((gzFile *)fd->fd_gzd) : NULL);
|
||||
}
|
||||
|
||||
extern inline /*@null@*/ FD_t gzdOpen(const char *pathname, const char *mode);
|
||||
extern inline /*@null@*/ FD_t gzdOpen(const char *pathname, const char *mode) {
|
||||
FD_t fd;
|
||||
gzFile *gzfile;;
|
||||
if ((gzfile = gzopen(pathname, mode)) == NULL)
|
||||
return NULL;
|
||||
fd = fdNew();
|
||||
fd->fd_gzd = gzfile;
|
||||
return fd;
|
||||
}
|
||||
|
||||
extern inline /*@shared@*/ FD_t gzdFdopen(FD_t fd, const char *mode);
|
||||
extern inline /*@shared@*/ FD_t gzdFdopen(FD_t fd, const char *mode) {
|
||||
gzFile *gzfile = gzdopen(fdFileno(fd), mode);
|
||||
if (gzfile != NULL) {
|
||||
fd->fd_fd = -1;
|
||||
fd->fd_gzd = gzfile;
|
||||
return fd;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extern inline ssize_t gzdRead(FD_t fd, void * buf, size_t count);
|
||||
extern inline ssize_t gzdRead(FD_t fd, void * buf, size_t count) {
|
||||
return gzread(gzdFileno(fd), buf, count);
|
||||
}
|
||||
|
||||
extern inline ssize_t gzdWrite(FD_t fd, const void * buf, size_t count);
|
||||
extern inline ssize_t gzdWrite(FD_t fd, const void * buf, size_t count) {
|
||||
return gzwrite(gzdFileno(fd), (void *)buf, count);
|
||||
}
|
||||
|
||||
extern inline off_t gzdLseek(FD_t fd, off_t offset, int whence);
|
||||
extern inline off_t gzdLseek(FD_t fd, off_t offset, int whence) {
|
||||
return gzseek(gzdFileno(fd), offset, whence);
|
||||
}
|
||||
|
||||
extern inline int gzdFlush(FD_t fd);
|
||||
extern inline int gzdFlush(FD_t fd) {
|
||||
return gzflush(gzdFileno(fd), Z_SYNC_FLUSH); /* XXX W2DO? */
|
||||
}
|
||||
|
||||
extern inline char * gzdStrerror(FD_t fd);
|
||||
extern inline char * gzdStrerror(FD_t fd) {
|
||||
static char *zlib_err [] = {
|
||||
"OK"
|
||||
"Errno",
|
||||
"Stream",
|
||||
"Data",
|
||||
"Memory",
|
||||
"Buffer",
|
||||
"Version"
|
||||
};
|
||||
|
||||
int zerror;
|
||||
|
||||
gzerror(gzdFileno(fd), &zerror);
|
||||
switch (zerror) {
|
||||
case Z_ERRNO:
|
||||
return strerror(errno);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return zlib_err[-zerror];
|
||||
}
|
||||
|
||||
extern inline int gzdClose(/*@only@*/ FD_t fd);
|
||||
extern inline int gzdClose(/*@only@*/ FD_t fd) {
|
||||
gzFile *gzfile;
|
||||
int zerror;
|
||||
|
||||
if (fd != NULL && (gzfile = gzdFileno(fd)) != NULL) {
|
||||
fd->fd_fd = -1;
|
||||
fd->fd_bzd = NULL;
|
||||
fd->fd_gzd = NULL;
|
||||
free(fd);
|
||||
zerror = gzclose(gzfile);
|
||||
return 0;
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
|
||||
#endif /* HAVE_BZLIB_H */
|
||||
/*
|
||||
* Support for BZIP2 library.
|
||||
*/
|
||||
#ifdef HAVE_BZLIB_H
|
||||
|
||||
#include <bzlib.h>
|
||||
|
||||
extern inline BZFILE * bzdFileno(FD_t fd);
|
||||
extern inline BZFILE * bzdFileno(FD_t fd) {
|
||||
return (fd != NULL ? ((BZFILE *)fd->fd_bzd) : NULL);
|
||||
}
|
||||
|
||||
extern inline /*@null@*/ FD_t bzdOpen(const char *pathname, const char *mode);
|
||||
extern inline /*@null@*/ FD_t bzdOpen(const char *pathname, const char *mode) {
|
||||
FD_t fd;
|
||||
BZFILE *bzfile;;
|
||||
if ((bzfile = bzopen(pathname, mode)) == NULL)
|
||||
return NULL;
|
||||
fd = fdNew();
|
||||
fd->fd_bzd = bzfile;
|
||||
return fd;
|
||||
}
|
||||
|
||||
extern inline /*@shared@*/ FD_t bzdFdopen(FD_t fd, const char *mode);
|
||||
extern inline /*@shared@*/ FD_t bzdFdopen(FD_t fd, const char *mode) {
|
||||
BZFILE *bzfile = bzdopen(fdFileno(fd), mode);
|
||||
if (bzfile != NULL) {
|
||||
fd->fd_fd = -1;
|
||||
fd->fd_bzd = bzfile;
|
||||
return fd;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extern inline ssize_t bzdRead(FD_t fd, void * buf, size_t count);
|
||||
extern inline ssize_t bzdRead(FD_t fd, void * buf, size_t count) {
|
||||
return bzread(bzdFileno(fd), buf, count);
|
||||
}
|
||||
|
||||
extern inline ssize_t bzdWrite(FD_t fd, const void * buf, size_t count);
|
||||
extern inline ssize_t bzdWrite(FD_t fd, const void * buf, size_t count) {
|
||||
return bzwrite(bzdFileno(fd), (void *)buf, count);
|
||||
}
|
||||
|
||||
extern inline int bzdFlush(FD_t fd);
|
||||
extern inline int bzdFlush(FD_t fd) {
|
||||
return bzflush(bzdFileno(fd));
|
||||
}
|
||||
|
||||
extern inline char * bzdStrerror(FD_t fd);
|
||||
extern inline char * bzdStrerror(FD_t fd) {
|
||||
int bzerr;
|
||||
return (char *)bzerror(bzdFileno(fd), &bzerr);
|
||||
}
|
||||
|
||||
extern inline int bzdClose(/*@only@*/ FD_t fd);
|
||||
extern inline int bzdClose(/*@only@*/ FD_t fd) {
|
||||
BZFILE *bzfile;
|
||||
|
||||
if (fd != NULL && (bzfile = bzdFileno(fd)) != NULL) {
|
||||
fd->fd_fd = -1;
|
||||
fd->fd_bzd = NULL;
|
||||
fd->fd_gzd = NULL;
|
||||
free(fd);
|
||||
bzclose(bzfile);
|
||||
return 0;
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
|
||||
#endif /* HAVE_BZLIB_H */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -92,6 +92,7 @@ LIBRPMALIAS_FILENAME = @LIBRPMALIAS_FILENAME@
|
|||
LIBRPMRC_FILENAME = @LIBRPMRC_FILENAME@
|
||||
LIBS = @LIBS@
|
||||
LN_S = @LN_S@
|
||||
LOCALEDIR = @LOCALEDIR@
|
||||
MACROFILES = @MACROFILES@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MISCDIR = @MISCDIR@
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 1998-11-20 14:56-0500\n"
|
||||
"POT-Creation-Date: 1998-11-22 14:35-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"
|
||||
|
@ -1353,11 +1353,11 @@ msgstr ""
|
|||
msgid "error looking for package %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../rpm2cpio.c:39
|
||||
#: ../rpm2cpio.c:42
|
||||
msgid "argument is not an RPM package\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../rpm2cpio.c:42
|
||||
#: ../rpm2cpio.c:46
|
||||
msgid "error reading header from package\n"
|
||||
msgstr ""
|
||||
|
||||
|
|
2
rpm.spec
2
rpm.spec
|
@ -43,7 +43,7 @@ mkdir -p $RPM_BUILD_ROOT/usr/src/redhat/BUILD
|
|||
mkdir -p $RPM_BUILD_ROOT/usr/src/redhat/RPMS/${RPM_ARCH}
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/src/redhat/RPMS/noarch
|
||||
|
||||
make installprefix="$RPM_BUILD_ROOT" install
|
||||
make DESTDIR="$RPM_BUILD_ROOT" install
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
|
35
rpm2cpio.c
35
rpm2cpio.c
|
@ -20,7 +20,7 @@ int main(int argc, char **argv)
|
|||
int rc, isSource;
|
||||
char buffer[1024];
|
||||
int ct;
|
||||
gzFile stream;
|
||||
FD_t gzdi;
|
||||
|
||||
if (argc == 1) {
|
||||
fdi = fdDup(STDIN_FILENO);
|
||||
|
@ -35,32 +35,33 @@ int main(int argc, char **argv)
|
|||
fdo = fdDup(STDOUT_FILENO);
|
||||
|
||||
rc = rpmReadPackageHeader(fdi, &hd, &isSource, NULL, NULL);
|
||||
if (rc == 1) {
|
||||
switch (rc) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
fprintf(stderr, _("argument is not an RPM package\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
} else if (rc) {
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, _("error reading header from package\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
break;
|
||||
}
|
||||
|
||||
stream = gzdopen(fdFileno(fdi), "r");
|
||||
gzdi = gzdFdopen(fdi, "r"); /* XXX gzdi == fdi */
|
||||
|
||||
while ((ct = gzread(stream, &buffer, 1024)) > 0) {
|
||||
while ((ct = gzdRead(gzdi, &buffer, sizeof(buffer))) > 0) {
|
||||
fdWrite(fdo, &buffer, ct);
|
||||
}
|
||||
if (ct < 0){
|
||||
int zerror;
|
||||
|
||||
gzerror (stream, &zerror);
|
||||
if (zerror == Z_ERRNO){
|
||||
perror ("While uncompressing");
|
||||
gzclose(stream);
|
||||
return 1;
|
||||
}
|
||||
fprintf (stderr, "rpm2cpio: zlib: %s error\n", zlib_err [-zerror - 1]);
|
||||
|
||||
if (ct < 0) {
|
||||
fprintf (stderr, "rpm2cpio: zlib: %s\n", gzdStrerror(gzdi));
|
||||
rc = EXIT_FAILURE;
|
||||
} else {
|
||||
rc = EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
gzclose(stream);
|
||||
gzdClose(gzdi);
|
||||
|
||||
return 0;
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ LIBRPMALIAS_FILENAME = @LIBRPMALIAS_FILENAME@
|
|||
LIBRPMRC_FILENAME = @LIBRPMRC_FILENAME@
|
||||
LIBS = @LIBS@
|
||||
LN_S = @LN_S@
|
||||
LOCALEDIR = @LOCALEDIR@
|
||||
MACROFILES = @MACROFILES@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MISCDIR = @MISCDIR@
|
||||
|
|
|
@ -90,6 +90,7 @@ LIBRPMALIAS_FILENAME = @LIBRPMALIAS_FILENAME@
|
|||
LIBRPMRC_FILENAME = @LIBRPMRC_FILENAME@
|
||||
LIBS = @LIBS@
|
||||
LN_S = @LN_S@
|
||||
LOCALEDIR = @LOCALEDIR@
|
||||
MACROFILES = @MACROFILES@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MISCDIR = @MISCDIR@
|
||||
|
|
|
@ -90,6 +90,7 @@ LIBRPMALIAS_FILENAME = @LIBRPMALIAS_FILENAME@
|
|||
LIBRPMRC_FILENAME = @LIBRPMRC_FILENAME@
|
||||
LIBS = @LIBS@
|
||||
LN_S = @LN_S@
|
||||
LOCALEDIR = @LOCALEDIR@
|
||||
MACROFILES = @MACROFILES@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MISCDIR = @MISCDIR@
|
||||
|
|
|
@ -92,6 +92,7 @@ LIBRPMALIAS_FILENAME = @LIBRPMALIAS_FILENAME@
|
|||
LIBRPMRC_FILENAME = @LIBRPMRC_FILENAME@
|
||||
LIBS = @LIBS@
|
||||
LN_S = @LN_S@
|
||||
LOCALEDIR = @LOCALEDIR@
|
||||
MACROFILES = @MACROFILES@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MISCDIR = @MISCDIR@
|
||||
|
|
Loading…
Reference in New Issue