4.0.4-alt95.M41.25
- rpmio: Updated lzma compression routines for xz-5.0 API. - Packaged /usr/bin/rpm2cpio.static.
This commit is contained in:
commit
776a15f6b8
@ -26,7 +26,7 @@ myLDADD = $(mylibLDADD) $(top_builddir)/build/librpmbuild.la
|
||||
rpmbindir = `echo $(bindir) | sed -e s,usr/bin,bin,`
|
||||
rpmbin_PROGRAMS =
|
||||
|
||||
bin_PROGRAMS = rpm rpm.static rpm2cpio
|
||||
bin_PROGRAMS = rpm rpm.static rpm2cpio rpm2cpio.static
|
||||
bin_SCRIPTS = gendiff
|
||||
|
||||
pkglibdir = @RPMCONFIGDIR@
|
||||
@ -86,6 +86,10 @@ rpm2cpio_SOURCES = rpm2cpio.c
|
||||
rpm2cpio_LDFLAGS = $(myLDFLAGS)
|
||||
rpm2cpio_LDADD = $(mylibLDADD)
|
||||
|
||||
rpm2cpio_static_SOURCES = rpm2cpio.c
|
||||
rpm2cpio_static_LDFLAGS = @LDFLAGS_STATIC@ $(myLDFLAGS)
|
||||
rpm2cpio_static_LDADD = $(mylibLDADD)
|
||||
|
||||
$(PROGRAMS): $(myLDADD) @WITH_APIDOCS_TARGET@
|
||||
|
||||
.PHONY: lclint
|
||||
|
@ -441,6 +441,11 @@ int writeRPM(Header *hdrp, const char *fileName, int type,
|
||||
"lzma", 1);
|
||||
(void) rpmlibNeedsFeature(h, "PayloadIsLzma", NULL);
|
||||
}
|
||||
if (s[1] == 'x' && s[2] == 'z') {
|
||||
(void) headerAddEntry(h, RPMTAG_PAYLOADCOMPRESSOR, RPM_STRING_TYPE,
|
||||
"xz", 1);
|
||||
(void) rpmlibNeedsFeature(h, "PayloadIsXz", NULL);
|
||||
}
|
||||
strcpy(buf, rpmio_flags);
|
||||
buf[s - rpmio_flags] = '\0';
|
||||
(void) headerAddEntry(h, RPMTAG_PAYLOADFLAGS, RPM_STRING_TYPE, buf+1, 1);
|
||||
|
@ -1873,6 +1873,8 @@ assert(psm->mi == NULL);
|
||||
t = stpcpy(t, ".bzdio");
|
||||
if (!strcmp(payload_compressor, "lzma"))
|
||||
t = stpcpy(t, ".lzdio");
|
||||
if (!strcmp(payload_compressor, "xz"))
|
||||
t = stpcpy(t, ".xzdio");
|
||||
rc = RPMRC_OK;
|
||||
} break;
|
||||
|
||||
|
@ -25,6 +25,9 @@ static struct rpmlibProvides_s {
|
||||
{ "rpmlib(PayloadIsLzma)", "4.4.2-1",
|
||||
(RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
|
||||
N_("package payload can be compressed using lzma.") },
|
||||
{ "rpmlib(PayloadIsXz)", "5.2-1",
|
||||
(RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
|
||||
N_("package payload can be compressed using xz.") },
|
||||
{ "rpmlib(PayloadFilesHavePrefix)", "4.0-1",
|
||||
(RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
|
||||
N_("package payload file(s) have \"./\" prefix.") },
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
Name: %rpm_name
|
||||
Version: %rpm_version
|
||||
Release: alt95.M41.24
|
||||
Release: alt95.M41.25
|
||||
|
||||
%define ifdef() %if %{expand:%%{?%{1}:1}%%{!?%{1}:0}}
|
||||
%define get_dep() %(rpm -q --qf '%%{NAME} >= %%|SERIAL?{%%{SERIAL}:}|%%{VERSION}-%%{RELEASE}' %1 2>/dev/null || echo '%1 >= unknown')
|
||||
@ -506,6 +506,7 @@ fi
|
||||
|
||||
%files static
|
||||
%_bindir/rpm.static
|
||||
%_bindir/rpm2cpio.static
|
||||
|
||||
%if_with contrib
|
||||
%files contrib
|
||||
@ -528,6 +529,10 @@ fi
|
||||
%endif #with contrib
|
||||
|
||||
%changelog
|
||||
* Thu Sep 24 2009 Alexey Tourbin <at@altlinux.ru> 4.0.4-alt95.M41.25
|
||||
- rpmio: Updated lzma compression routines for xz-5.0 API.
|
||||
- Packaged /usr/bin/rpm2cpio.static.
|
||||
|
||||
* Thu Sep 24 2009 Alexey Tourbin <at@altlinux.ru> 4.0.4-alt95.M41.24
|
||||
- Backported changes by Dmitry V. Levin:
|
||||
- rpmio/macro.c (doShellEscape): Fixed potential buffer underflow (closes: #11921).
|
||||
|
@ -55,6 +55,8 @@ int main(int argc, char **argv)
|
||||
t = stpcpy(t, ".bzdio");
|
||||
if (!strcmp(payload_compressor, "lzma"))
|
||||
t = stpcpy(t, ".lzdio");
|
||||
if (!strcmp(payload_compressor, "xz"))
|
||||
t = stpcpy(t, ".xzdio");
|
||||
}
|
||||
|
||||
gzdi = Fdopen(fdi, rpmio_flags); /* XXX gzdi == fdi */
|
||||
|
115
rpmio/rpmio.c
115
rpmio/rpmio.c
@ -86,7 +86,7 @@ static int inet_aton(const char *cp, struct in_addr *inp)
|
||||
#define FDONLY(fd) assert(fdGetIo(fd) == fdio)
|
||||
#define GZDONLY(fd) assert(fdGetIo(fd) == gzdio)
|
||||
#define BZDONLY(fd) assert(fdGetIo(fd) == bzdio)
|
||||
#define LZDONLY(fd) assert(fdGetIo(fd) == lzdio)
|
||||
#define LZDONLY(fd) assert(fdGetIo(fd) == xzdio || fdGetIo(fd) == lzdio)
|
||||
|
||||
#define UFDONLY(fd) /* assert(fdGetIo(fd) == ufdio) */
|
||||
|
||||
@ -186,6 +186,8 @@ static /*@observer@*/ const char * fdbg(/*@null@*/ FD_t fd)
|
||||
#endif
|
||||
} else if (fps->io == lzdio) {
|
||||
sprintf(be, "LZD %p fdno %d", fps->fp, fps->fdno);
|
||||
} else if (fps->io == xzdio) {
|
||||
sprintf(be, "XZD %p fdno %d", fps->fp, fps->fdno);
|
||||
} else if (fps->io == fpio) {
|
||||
/*@+voidabstract@*/
|
||||
sprintf(be, "%s %p(%d) fdno %d",
|
||||
@ -2764,9 +2766,9 @@ typedef struct lzfile {
|
||||
|
||||
} LZFILE;
|
||||
|
||||
static LZFILE *lzopen_internal(const char *path, const char *mode, int fd)
|
||||
static LZFILE *lzopen_internal(const char *path, const char *mode, int fd, int xz)
|
||||
{
|
||||
int level = 5;
|
||||
int level = LZMA_PRESET_DEFAULT;
|
||||
int encoding = 0;
|
||||
FILE *fp;
|
||||
LZFILE *lzfile;
|
||||
@ -2794,14 +2796,21 @@ static LZFILE *lzopen_internal(const char *path, const char *mode, int fd)
|
||||
lzfile->file = fp;
|
||||
lzfile->encoding = encoding;
|
||||
lzfile->eof = 0;
|
||||
lzfile->strm = LZMA_STREAM_INIT_VAR;
|
||||
lzfile->strm = (lzma_stream)LZMA_STREAM_INIT;
|
||||
if (encoding) {
|
||||
lzma_options_alone alone;
|
||||
alone.uncompressed_size = LZMA_VLI_VALUE_UNKNOWN;
|
||||
memcpy(&alone.lzma, &lzma_preset_lzma[level - 1], sizeof(alone.lzma));
|
||||
ret = lzma_alone_encoder(&lzfile->strm, &alone);
|
||||
if (xz) {
|
||||
/* xz(1) uses CRC64 by default */
|
||||
ret = lzma_easy_encoder(&lzfile->strm, level, LZMA_CHECK_CRC64);
|
||||
} else {
|
||||
lzma_options_lzma options;
|
||||
lzma_lzma_preset(&options, level);
|
||||
ret = lzma_alone_encoder(&lzfile->strm, &options);
|
||||
}
|
||||
} else {
|
||||
ret = lzma_auto_decoder(&lzfile->strm, 0, 0);
|
||||
/* We set the memlimit for decompression to 100MiB which should be
|
||||
* more than enough to be sufficient for level 9 which requires 65 MiB.
|
||||
*/
|
||||
ret = lzma_auto_decoder(&lzfile->strm, 100<<20, 0);
|
||||
}
|
||||
if (ret != LZMA_OK) {
|
||||
fclose(fp);
|
||||
@ -2811,16 +2820,28 @@ static LZFILE *lzopen_internal(const char *path, const char *mode, int fd)
|
||||
return lzfile;
|
||||
}
|
||||
|
||||
static LZFILE *xzopen(const char *path, const char *mode)
|
||||
{
|
||||
return lzopen_internal(path, mode, -1, 1);
|
||||
}
|
||||
|
||||
static LZFILE *lzopen(const char *path, const char *mode)
|
||||
{
|
||||
return lzopen_internal(path, mode, -1);
|
||||
return lzopen_internal(path, mode, -1, 0);
|
||||
}
|
||||
|
||||
static LZFILE *xzdopen(int fd, const char *mode)
|
||||
{
|
||||
if (fd < 0)
|
||||
return 0;
|
||||
return lzopen_internal(0, mode, fd, 1);
|
||||
}
|
||||
|
||||
static LZFILE *lzdopen(int fd, const char *mode)
|
||||
{
|
||||
if (fd < 0)
|
||||
return 0;
|
||||
return lzopen_internal(0, mode, fd);
|
||||
return lzopen_internal(0, mode, fd, 0);
|
||||
}
|
||||
|
||||
static int lzflush(LZFILE *lzfile)
|
||||
@ -2831,7 +2852,8 @@ static int lzflush(LZFILE *lzfile)
|
||||
static int lzclose(LZFILE *lzfile)
|
||||
{
|
||||
lzma_ret ret;
|
||||
int n, rc;
|
||||
size_t n;
|
||||
int rc;
|
||||
|
||||
if (!lzfile)
|
||||
return -1;
|
||||
@ -2890,7 +2912,7 @@ static ssize_t lzread(LZFILE *lzfile, void *buf, size_t len)
|
||||
static ssize_t lzwrite(LZFILE *lzfile, void *buf, size_t len)
|
||||
{
|
||||
lzma_ret ret;
|
||||
int n;
|
||||
size_t n;
|
||||
if (!lzfile || !lzfile->encoding)
|
||||
return -1;
|
||||
if (!len)
|
||||
@ -2924,7 +2946,7 @@ static inline /*@dependent@*/ void * lzdFileno(FD_t fd)
|
||||
/*@-boundsread@*/
|
||||
FDSTACK_t * fps = &fd->fps[i];
|
||||
/*@=boundsread@*/
|
||||
if (fps->io != lzdio)
|
||||
if (fps->io != xzdio && fps->io != lzdio)
|
||||
continue;
|
||||
rc = fps->fp;
|
||||
break;
|
||||
@ -2933,6 +2955,21 @@ static inline /*@dependent@*/ void * lzdFileno(FD_t fd)
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*@-globuse@*/
|
||||
static /*@null@*/ FD_t xzdOpen(const char * path, const char * mode)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/
|
||||
{
|
||||
FD_t fd;
|
||||
LZFILE *lzfile;
|
||||
if ((lzfile = xzopen(path, mode)) == NULL)
|
||||
return NULL;
|
||||
fd = fdNew("open (xzdOpen)");
|
||||
fdPop(fd); fdPush(fd, xzdio, lzfile, -1);
|
||||
return fdLink(fd, "xzdOpen");
|
||||
}
|
||||
/*@=globuse@*/
|
||||
|
||||
/*@-globuse@*/
|
||||
static /*@null@*/ FD_t lzdOpen(const char * path, const char * mode)
|
||||
/*@globals fileSystem @*/
|
||||
@ -2948,6 +2985,25 @@ static /*@null@*/ FD_t lzdOpen(const char * path, const char * mode)
|
||||
}
|
||||
/*@=globuse@*/
|
||||
|
||||
/*@-globuse@*/
|
||||
static /*@null@*/ FD_t xzdFdopen(void * cookie, const char * fmode)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/
|
||||
{
|
||||
FD_t fd = c2f(cookie);
|
||||
int fdno;
|
||||
LZFILE *lzfile;
|
||||
|
||||
if (fmode == NULL) return NULL;
|
||||
fdno = fdFileno(fd);
|
||||
fdSetFdno(fd, -1); /* XXX skip the fdio close */
|
||||
if (fdno < 0) return NULL;
|
||||
lzfile = xzdopen(fdno, fmode);
|
||||
if (lzfile == NULL) return NULL;
|
||||
fdPush(fd, xzdio, lzfile, fdno);
|
||||
return fdLink(fd, "xzdFdopen");
|
||||
}
|
||||
/*@=globuse@*/
|
||||
|
||||
/*@-globuse@*/
|
||||
static /*@null@*/ FD_t lzdFdopen(void * cookie, const char * fmode)
|
||||
@ -3088,6 +3144,14 @@ static struct FDIO_s lzdio_s = {
|
||||
/*@=type@*/
|
||||
FDIO_t lzdio = /*@-compmempass@*/ &lzdio_s /*@=compmempass@*/ ;
|
||||
|
||||
/*@-type@*/ /* LCL: function typedefs */
|
||||
static struct FDIO_s xzdio_s = {
|
||||
lzdRead, lzdWrite, lzdSeek, lzdClose, XfdLink, XfdFree, XfdNew, fdFileno,
|
||||
NULL, xzdOpen, lzdFileno, lzdFlush, NULL, NULL, NULL, NULL, NULL
|
||||
};
|
||||
/*@=type@*/
|
||||
FDIO_t xzdio = /*@-compmempass@*/ &xzdio_s /*@=compmempass@*/ ;
|
||||
|
||||
/* =============================================================== */
|
||||
/*@observer@*/
|
||||
static const char * getFdErrstr (FD_t fd)
|
||||
@ -3106,9 +3170,9 @@ static const char * getFdErrstr (FD_t fd)
|
||||
errstr = fd->errcookie;
|
||||
} else
|
||||
#endif /* HAVE_BZLIB_H */
|
||||
if (fdGetIo(fd) == lzdio) {
|
||||
errstr = fd->errcookie;
|
||||
} else
|
||||
if (fdGetIo(fd) == xzdio || fdGetIo(fd) == lzdio) {
|
||||
errstr = fd->errcookie;
|
||||
} else
|
||||
{
|
||||
errstr = (fd->syserrno ? strerror(fd->syserrno) : "");
|
||||
}
|
||||
@ -3406,9 +3470,12 @@ fprintf(stderr, "*** Fdopen(%p,%s) %s\n", fd, fmode, fdbg(fd));
|
||||
fd = bzdFdopen(fd, zstdio);
|
||||
/*@=internalglobs@*/
|
||||
#endif
|
||||
} else if (!strcmp(end, "lzdio")) {
|
||||
iof = lzdio;
|
||||
fd = lzdFdopen(fd, zstdio);
|
||||
} else if (!strcmp(end, "lzdio")) {
|
||||
iof = lzdio;
|
||||
fd = lzdFdopen(fd, zstdio);
|
||||
} else if (!strcmp(end, "xzdio")) {
|
||||
iof = xzdio;
|
||||
fd = xzdFdopen(fd, zstdio);
|
||||
} else if (!strcmp(end, "ufdio")) {
|
||||
iof = ufdio;
|
||||
} else if (!strcmp(end, "fadio")) {
|
||||
@ -3574,7 +3641,9 @@ int Fflush(FD_t fd)
|
||||
if (vh && fdGetIo(fd) == bzdio)
|
||||
return bzdFlush(vh);
|
||||
#endif
|
||||
|
||||
if (vh && (fdGetIo(fd) == xzdio || fdGetIo(fd) == lzdio))
|
||||
return lzdFlush(vh);
|
||||
/* FIXME: If we get here, something went wrong above */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -3599,9 +3668,9 @@ int Ferror(FD_t fd)
|
||||
ec = (fd->syserrno || fd->errcookie != NULL) ? -1 : 0;
|
||||
i--; /* XXX fdio under bzdio always has fdno == -1 */
|
||||
#endif
|
||||
} else if (fps->io == lzdio) {
|
||||
} else if (fps->io == xzdio || fps->io == lzdio) {
|
||||
ec = (fd->syserrno || fd->errcookie != NULL) ? -1 : 0;
|
||||
i--; /* XXX fdio under lzdio always has fdno == -1 */
|
||||
i--; /* XXX fdio under xzdio/lzdio always has fdno == -1 */
|
||||
} else {
|
||||
/* XXX need to check ufdio/gzdio/bzdio/fdio errors correctly. */
|
||||
ec = (fdFileno(fd) < 0 ? -1 : 0);
|
||||
|
@ -622,6 +622,10 @@ int ufdGetFile( /*@killref@*/ FD_t sfd, FD_t tfd)
|
||||
*/
|
||||
/*@observer@*/ /*@unchecked@*/ extern FDIO_t lzdio;
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@observer@*/ /*@unchecked@*/ extern FDIO_t xzdio;
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@observer@*/ /*@unchecked@*/ extern FDIO_t fadio;
|
||||
|
@ -23,16 +23,4 @@ dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`
|
||||
hdrsize=`expr 8 + 16 \* $il + $dl`
|
||||
o=`expr $o + $hdrsize`
|
||||
|
||||
magic=`dd if="$pkg" ibs=$o skip=1 count=1 2>/dev/null | dd bs=3 count=1 2>/dev/null`
|
||||
gzip_magic=`printf '\037\213'`
|
||||
|
||||
case "$magic" in
|
||||
BZh) filter=bunzip2 ;;
|
||||
"$gzip_magic"?) filter=gunzip ;;
|
||||
# plain cpio
|
||||
070) filter=cat ;;
|
||||
# no magic in old lzma format
|
||||
*) filter=unlzma ;;
|
||||
esac
|
||||
|
||||
dd if=$pkg ibs=$o skip=1 2>/dev/null | $filter
|
||||
exec dd if=$pkg ibs=$o skip=1 2>/dev/null
|
||||
|
Loading…
Reference in New Issue
Block a user