6 #include <rpm/rpmlib.h>              8 #include <rpm/rpmtag.h>    10 #include <rpm/rpmpgp.h>    12 #include <rpm/rpmts.h>    15 #include <archive_entry.h>    19 #define BUFSIZE (128*1024)    23     archive_entry_clear(entry);
    26     archive_entry_copy_pathname(entry, filename);
    31     archive_entry_set_filetype(entry, mode & S_IFMT);
    32     archive_entry_set_perm(entry, mode);
    34     archive_entry_set_uname(entry, 
rpmfiFUser(fi));
    40         archive_entry_set_symlink(entry, 
rpmfiFLink(fi));
    52             archive_write_data(a, buf, len);
    54             fprintf(stderr, 
"Error reading file from rpm payload\n");
    67     char * rpmio_flags = NULL;
    69     struct archive_entry *entry;
    71     if (!strcmp(filename, 
"-")) {
    72         fdi = 
fdDup(STDIN_FILENO);
    74         fdi = 
Fopen(filename, 
"r.ufdio");
    78         fprintf(stderr, 
"rpm2archive: %s: %s\n",
    91         fprintf(stderr, 
_(
"argument is not an RPM package\n"));
    96         fprintf(stderr, 
_(
"error reading header from package\n"));
   104         rpmio_flags = 
rstrscat(NULL, 
"r.", compr ? compr : 
"gzip", NULL);
   107     gzdi = 
Fdopen(fdi, rpmio_flags);    
   111         fprintf(stderr, 
_(
"cannot re-open payload: %s\n"), 
Fstrerror(gzdi));
   119     a = archive_write_new();
   120     archive_write_add_filter_gzip(a);
   121     archive_write_set_format_pax_restricted(a);
   123     if (!strcmp(filename, 
"-")) {
   124         archive_write_open_fd(a, 1);
   126         char * outname = 
rstrscat(NULL, filename, 
".tgz", NULL);
   127         archive_write_open_filename(a, outname);
   132     entry = archive_entry_new();
   135     char * hardlink = NULL;
   154                 archive_entry_set_hardlink(entry, hardlink);
   158         archive_write_header(a, entry);
   167     archive_entry_free(entry);
   168     archive_write_close(a);
   169     archive_write_free(a);
   177 int main(
int argc, 
char *argv[])
   187         if (
rstreq(argv[1], 
"-h") || 
rstreq(argv[1], 
"--help")) {
   188             fprintf(stderr, 
"Usage: rpm2archive file.rpm\n");
 
size_t rpmfiArchiveRead(rpmfi fi, void *buf, size_t size)
Read content from current file in archive. 
struct _FD_s * FD_t
RPM IO file descriptor type. 
rpmfiles rpmfilesFree(rpmfiles fi)
Destroy a file info set. 
char * rstrscat(char **dest, const char *arg,...) RPM_GNUC_NULL_TERMINATED
Concatenate multiple strings with dynamically (re)allocated memory. 
const char * Fstrerror(FD_t fd)
strerror(3) clone. 
rpmRC rpmReadPackageFile(rpmts ts, FD_t fd, const char *fn, Header *hdrp)
Return package header from file handle, verifying digests/signatures. 
rpmfi rpmfiFree(rpmfi fi)
Destroy a file info set iterator. 
FD_t Fdopen(FD_t ofd, const char *fmode)
int rpmReadConfigFiles(const char *file, const char *target)
Read macro configuration file(s) for a target. 
rpmfiles rpmfilesNew(rpmstrPool pool, Header h, rpmTagVal tagN, rpmfiFlags flags)
Create and load a file info set. 
rpm_time_t rpmfiFMtime(rpmfi fi)
Return current file modify time from file info set iterator. 
int Ferror(FD_t fd)
ferror(3) clone. 
int rpmfiArchiveHasContent(rpmfi fi)
Has current file content stored in the archive. 
const char * rpmfiFN(rpmfi fi)
Return current file name from file info set iterator. 
static int rstreq(const char *s1, const char *s2)
Test for string equality. 
struct rpmfiles_s * rpmfiles
int Fclose(FD_t fd)
fclose(3) clone. 
uint32_t rpmfiFNlink(rpmfi fi)
Return (calculated) current file nlink count from file info set iterator. 
static void write_file_content(struct archive *a, char *buf, rpmfi fi)
FD_t Fopen(const char *path, const char *fmode)
fopen(3) clone. 
const char * rpmfiFGroup(rpmfi fi)
Return current file group from file info set iterator. 
rpm_rdev_t rpmfiFRdev(rpmfi fi)
Return current file rdev from file info set iterator. 
int rpmfiNext(rpmfi fi)
Return next file iterator index. 
int main(int argc, char *argv[])
static int process_package(rpmts ts, char *filename)
rpmfi rpmfiNewArchiveReader(FD_t fd, rpmfiles files, int itype)
Get new file iterator for looping over the archive content. 
#define _RPMVSF_NOSIGNATURES
rpmts rpmtsFree(rpmts ts)
Destroy transaction set, closing the database as well. 
rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags)
Set verify signatures flag(s). 
struct rpmts_s * rpmts
The main types involved in transaction manipulation. 
rpm_loff_t rpmfiFSize(rpmfi fi)
Return current file size from file info set iterator. 
static void fill_archive_entry(struct archive *a, struct archive_entry *entry, rpmfi fi)
#define _RPMVSF_NODIGESTS
rpm_mode_t rpmfiFMode(rpmfi fi)
Return current file mode from file info set iterator. 
const char * rpmfiFLink(rpmfi fi)
Return current file linkto (i.e. 
rpmts rpmtsCreate(void)
Create an empty transaction set. 
const char * rpmfiBN(rpmfi fi)
Return current base name from file info set iterator. 
const char * rpmfiDN(rpmfi fi)
Return current directory name from file info set iterator. 
const char * rpmfiFUser(rpmfi fi)
Return current file owner from file info set iterator. 
struct headerToken_s * Header
RPM header and data retrieval types.