RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm/ CHANGES rpm/tools/ Makefile.am rpm2cpio.c

From: Jeff Johnson <jbj@rpm5.org>
Date: Fri 23 Nov 2007 - 17:55:42 CET
Message-Id: <20071123165542.99F61348455@rpm5.org>
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  jbj@rpm5.org
  Module: rpm                              Date:   23-Nov-2007 17:55:42
  Branch: HEAD                             Handle: 2007112316554200

  Added files:
    rpm/tools               rpm2cpio.c
  Modified files:
    rpm                     CHANGES
    rpm/tools               Makefile.am

  Log:
    - jbj: re-add rpm2cpio.c.

  Summary:
    Revision    Changes     Path
    1.1875      +1  -0      rpm/CHANGES
    2.103       +8  -2      rpm/tools/Makefile.am
    2.1         +102 -0     rpm/tools/rpm2cpio.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.1874 -r1.1875 CHANGES
  --- rpm/CHANGES	23 Nov 2007 16:35:42 -0000	1.1874
  +++ rpm/CHANGES	23 Nov 2007 16:55:42 -0000	1.1875
  @@ -1,4 +1,5 @@
   5.0a2 -> 5.0a3:
  +    - jbj: re-add rpm2cpio.c.
       - jbj: spiffy error msgs for the XAR challenged users.
       - jbj: splint fiddles for rpmxar and rpmTag.
       - jbj: bury timedRead in pkgio.c, eliminate everywhere else.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/tools/Makefile.am
  ============================================================================
  $ cvs diff -u -r2.102 -r2.103 Makefile.am
  --- rpm/tools/Makefile.am	11 Nov 2007 18:49:45 -0000	2.102
  +++ rpm/tools/Makefile.am	23 Nov 2007 16:55:42 -0000	2.103
  @@ -12,7 +12,7 @@
   
   EXTRA_DIST =	hashtab.h
   
  -EXTRA_PROGRAMS = debugedit rpmkey txar
  +EXTRA_PROGRAMS = debugedit rpm2cpio rpmkey txar
   
   myLDADD = \
   	$(top_builddir)/build/librpmbuild.la \
  @@ -41,13 +41,19 @@
   rpmdigest_LDADD =	$(myLDADD)
   
   ##
  +## Traditional rpm2cpio
  +##
  +rpm2cpio_SOURCES =	rpm2cpio.c
  +rpm2cpio_LDADD =	$(myLDADD)
  +
  +##
   ##  keyctl(1) clone
   ##
   rpmkey_SOURCES =        rpmkey.c
   rpmkey_LDADD =          $(myLDADD) -lkeyutils
   
   ##
  -## XAR package format work-in-progress.
  +## XAR <-> RPM package converter
   ##
   txar_SOURCES =		txar.c
   txar_LDADD =		$(myLDADD) @WITH_XAR_LDFLAGS@
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/tools/rpm2cpio.c
  ============================================================================
  $ cvs diff -u -r0 -r2.1 rpm2cpio.c
  --- /dev/null	2007-11-23 17:55:01 +0100
  +++ rpm2cpio.c	2007-11-23 17:55:42 +0100
  @@ -0,0 +1,102 @@
  +/* rpmarchive: spit out the main archive portion of a package */
  +
  +#include "system.h"
  +const char *__progname;
  +
  +#include <rpmio.h>
  +#include <rpmcb.h>	/* XXX fnpyKey */
  +#include <header.h>
  +#include <rpmlib.h>
  +#include <rpmts.h>
  +
  +#include "debug.h"
  +
  +int main(int argc, char **argv)
  +{
  +    FD_t fdi, fdo;
  +    Header h;
  +    char * rpmio_flags;
  +    rpmRC rc;
  +    FD_t gzdi;
  +
  +    setprogname(argv[0]);	/* Retrofit glibc __progname */
  +    if (argc == 1)
  +	fdi = fdDup(STDIN_FILENO);
  +    else
  +	fdi = Fopen(argv[1], "r");
  +
  +    if (Ferror(fdi)) {
  +	fprintf(stderr, "%s: %s: %s\n", argv[0],
  +		(argc == 1 ? "<stdin>" : argv[1]), Fstrerror(fdi));
  +	exit(EXIT_FAILURE);
  +    }
  +    fdo = fdDup(STDOUT_FILENO);
  +
  +    {	rpmts ts = rpmtsCreate();
  +	rpmVSFlags vsflags = 0;
  +
  +	/* XXX retain the ageless behavior of rpm2cpio */
  +        vsflags |= _RPMVSF_NODIGESTS;
  +        vsflags |= _RPMVSF_NOSIGNATURES;
  +        vsflags |= RPMVSF_NOHDRCHK;
  +	(void) rpmtsSetVSFlags(ts, vsflags);
  +
  +	/*@-mustmod@*/      /* LCL: segfault */
  +	rc = rpmReadPackageFile(ts, fdi, "rpm2cpio", &h);
  +	/*@=mustmod@*/
  +
  +	ts = rpmtsFree(ts);
  +    }
  +
  +    switch (rc) {
  +    case RPMRC_OK:
  +    case RPMRC_NOKEY:
  +    case RPMRC_NOTTRUSTED:
  +	break;
  +    case RPMRC_NOTFOUND:
  +	fprintf(stderr, _("argument is not an RPM package\n"));
  +	exit(EXIT_FAILURE);
  +	break;
  +    case RPMRC_FAIL:
  +    default:
  +	fprintf(stderr, _("error reading header from package\n"));
  +	exit(EXIT_FAILURE);
  +	break;
  +    }
  +
  +    /* Retrieve type of payload compression. */
  +    {	HGE_t hge = headerGetExtension;
  +	HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
  +	const char * payload_compressor = NULL;
  +	char * t;
  +	int xx;
  +
  +	he->tag = RPMTAG_PAYLOADCOMPRESSOR;
  +	xx = hge(h, he, 0);
  +	payload_compressor = (xx ? he->p.str : "gzip");
  +
  +	rpmio_flags = t = alloca(sizeof("r.gzdio"));
  +	*t++ = 'r';
  +	if (!strcmp(payload_compressor, "gzip"))
  +	    t = stpcpy(t, ".gzdio");
  +	if (!strcmp(payload_compressor, "bzip2"))
  +	    t = stpcpy(t, ".bzdio");
  +	if (!strcmp(payload_compressor, "lzma"))
  +	    t = stpcpy(t, ".lzdio");
  +	he->p.ptr = _free(he->p.ptr);
  +    }
  +
  +    gzdi = Fdopen(fdi, rpmio_flags);	/* XXX gzdi == fdi */
  +    if (gzdi == NULL) {
  +	fprintf(stderr, _("cannot re-open payload: %s\n"), Fstrerror(gzdi));
  +	exit(EXIT_FAILURE);
  +    }
  +
  +    rc = ufdCopy(gzdi, fdo);
  +    rc = (rc <= 0) ? EXIT_FAILURE : EXIT_SUCCESS;
  +    Fclose(fdo);
  +
  +    Fclose(gzdi);	/* XXX gzdi == fdi */
  +
  +    return rc;
  +}
  @@ .
Received on Fri Nov 23 17:55:42 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.