aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MANIFEST3
-rw-r--r--Makefile.PL56
-rw-r--r--NEWS5
-rw-r--r--parsehdlist.c623
-rw-r--r--rpm2cpio.pl106
-rw-r--r--rpm2header.c89
6 files changed, 7 insertions, 875 deletions
diff --git a/MANIFEST b/MANIFEST
index 3d8d63c..b33d015 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -9,7 +9,4 @@ MANIFEST
NEWS
packdrake
packdrake.pm
-parsehdlist.c
-rpm2cpio.pl
-rpm2header.c
t/01packdrake.t
diff --git a/Makefile.PL b/Makefile.PL
index f8ab70e..cf61c9c 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -3,61 +3,15 @@
use strict;
use ExtUtils::MakeMaker;
-my $rpmtools_version = "5.8";
+my $rpmtools_version = "5.9";
# where to find the rpm utility
-my $rpm_path = $ENV{RPM_PATH}; # this overrides
-
-unless (defined $rpm_path) {
- for (qw(/bin/rpm /usr/bin/rpm)) {
- if (-x) {
- $rpm_path = $_;
- last;
- }
- }
-}
-
-defined $rpm_path or die "Can't find rpm on this system\n";
-
-sub hexversion {
- my ($major, $minor, $micro) = (@_[0] =~ /(\d+)\.(\d+)\.?(\d+)?/);
- return int($major<<16) + int($minor<<8) + int($micro<<0)
-}
-
-my $version = `LC_ALL=C $rpm_path --version`;
-# fix compiling with RCs:
-$version =~ s/(-.*)|(\.DEVEL)//;
-chomp $version;
-$version =~ s/(RPM version )|(rpm \(RPM\) )//;
-my $hversion = hexversion($version);
-
-my @rpmflags;
-if ($hversion ge hexversion("4.4.90") && $hversion lt hexversion("4.5")) {
- # rpm.org version
- push @rpmflags, "-DRPM_ORG";
-} else {
- # rpm5.org version
- push @rpmflags, "-DRPM_VERSION_CODE=$hversion";
-}
-my $ccflags = join(' ', '-Wall -fno-strict-aliasing', @rpmflags);
-
-print "Found RPM version $version (compiling with flags: $ccflags)\n";
-
sub MY::postamble {
<<MAKEMAKEFILE;
.PHONY: ChangeLog
-\$(FROMCC): %: %.cc
- \$(CXX) \$(CCFLAGS) \$(OPTIMIZE) -DVERSION_STRING=\\"\$(RPMTOOLSVERSION)\\" $ccflags \$< \$(LIBRPM) \$(INCRPM) -o \$@
-
-\$(FROMC): %: %.c
- \$(CC) \$(CCFLAGS) \$(OPTIMIZE) -DVERSION_STRING=\\"\$(RPMTOOLSVERSION)\\" $ccflags \$< \$(LIBRPM) \$(INCRPM) -o \$@
-
-buildc: \$(FROMC) \$(FROMCC)
-
cleanc:
- rm -f \$(FROMC) \$(FROMCC)
rm -rf *.cz test
ChangeLog:
@@ -72,23 +26,17 @@ WriteMakefile(
VERSION => $rpmtools_version,
macro => {
RPMTOOLSVERSION => $rpmtools_version,
- FROMC => 'parsehdlist rpm2header #rpm-find-leaves',
- FROMCC => '#gendepslist2 hdlist2names hdlist2files hdlist2prereq hdlist2groups',
- LIBRPM => '-lrpm -lrpmio -lrpmdb -lrpmbuild -lz -lbz2 -lpopt',
- INCRPM => '-I/usr/include/rpm',
},
depend => {
clean_subdirs => 'cleanc',
- pm_to_blib => 'buildc',
},
PM => {
'packdrake.pm' => '$(INST_LIBDIR)/packdrake.pm',
},
- EXE_FILES => [ qw(gendistrib genhdlist-old genhdlist2 packdrake rpm2header parsehdlist rpm2cpio.pl dumpdistribconf) ],
+ EXE_FILES => [ qw(gendistrib genhdlist-old genhdlist2 packdrake dumpdistribconf) ],
C => [],
OBJECT => '',
CCFLAGS => '-Wall',
- OPTIMIZE => '-O3 -fomit-frame-pointer -fno-exceptions -pipe -s -ffast-math -fexpensive-optimizations',
INC => '',
LIBS => [ '' ],
INSTALLDIRS => 'vendor',
diff --git a/NEWS b/NEWS
index b0aa772..291f21d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+Version 5.9 - 20 January 2008, by Pascal "Pixel" Rigaux
+
+- drop parsehdlist, rpm2header: unused, partially duplicated with perl-URPM
+- drop rpm2cpio.pl (doesn't handle lzma payload which is the default)
+
Version 5.8 - 30 September 2008, by Pascal "Pixel" Rigaux
- gendistrib:
diff --git a/parsehdlist.c b/parsehdlist.c
deleted file mode 100644
index 4947b04..0000000
--- a/parsehdlist.c
+++ /dev/null
@@ -1,623 +0,0 @@
-#include <sys/select.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-
-#define RPM_VERSION(maj,min,pl) (((maj) << 16) + ((min) << 8) + (pl))
-
-#if RPM_VERSION_CODE >= RPM_VERSION(5,0,0)
-#include <rpm/rpm4compat.h>
-#else
-#include <rpm/rpmlib.h>
-#include <rpm/header.h>
-#endif
-
-#ifndef VERSION_STRING
-#define VERSION_STRING "0.0"
-#endif
-
-/* static data for very simple list */
-static struct {
- char *name;
- unsigned long hash_name;
- Header header;
-} headers[16384];
-static int count_headers = 0;
-
-static int raw_hdlist = 0;
-static int sql_mode = 0;
-static int sql_state = 0;
-static int interactive_mode = 0;
-static int silent = 0;
-static int print_quiet = 0;
-static int print_name = 0;
-static int print_info = 0;
-static int print_group = 0;
-static int print_packagesize = 0;
-static int print_size = 0;
-static int print_epoch = 0;
-static int print_summary = 0;
-static int print_description = 0;
-static int print_provides = 0;
-static int print_requires = 0;
-static int print_conflicts = 0;
-static int print_obsoletes = 0;
-static int print_files = 0;
-static int print_files_more_info = 0;
-static int print_prereqs = 0;
-static int print_url = 0;
-static char print_sep = 0;
-
-static
-unsigned long hash(char *str) {
- unsigned long result = 0;
- while (*str) {
- result += (result<<5) + (unsigned char)*str++;
- }
- return result;
-}
-
-static
-char *get_name(Header header, int_32 tag) {
- int_32 type, count;
- char *name;
-
- headerGetEntry(header, tag, &type, (void **) &name, &count);
- return name;
-}
-
-static
-int get_int(Header header, int_32 tag) {
- int_32 type, count;
- int_32 *i;
-
- headerGetEntry(header, tag, &type, (void **) &i, &count);
- return i ? *i : 0; /* assume for default, necessary for RPMTAG_EPOCH */
-}
-
-char *
-printable_header(int quiet, char *name, char sep, char* final)
-{
- static char buff[128];
- int n = sprintf(buff, "%%s%c", sep ? sep : ':');
- if (!quiet) n += sprintf(buff + n, "%s%c", name, sep ? sep : ':');
- n += sprintf(buff + n, !strcmp(name, "size") || !strcmp(name, "epoch") || !strcmp(name, "pkgsize") ? "%%d" : "%%s");
- if (final) n += sprintf(buff + n, "%s", final);
- return buff; /* static string, this means to use result before calling again */
-}
-
-static
-void print_list_flags(Header header, int_32 tag_name, int_32 tag_flags, int_32 tag_version, char *format, char sep, char *name) {
- int_32 type, count;
- char **list;
- int_32 *flags;
- char **list_evr;
- int i;
-
- headerGetEntry(header, tag_name, &type, (void **) &list, &count);
- headerGetEntry(header, tag_flags, &type, (void **) &flags, &count);
- headerGetEntry(header, tag_version, &type, (void **) &list_evr, &count);
-
- if (list) {
- for(i = 0; i < count; i++) {
- /* skip internal deps from the rpmlib */
- if (strncmp(list[i], "rpmlib(", 7) == 0) continue;
- if (sep && i > 0) printf("%c%s", sep, list[i]);
- else printf(format, name, list[i]);
- if (list_evr[i] && list_evr[i][0]) {
- printf(" ");
- if (flags[i] & RPMSENSE_LESS) printf("<");
- if (flags[i] & RPMSENSE_GREATER) printf(">");
- if (flags[i] & RPMSENSE_EQUAL) printf("=");
- if ((flags[i] & (RPMSENSE_LESS|RPMSENSE_EQUAL|RPMSENSE_GREATER)) == RPMSENSE_EQUAL) printf("=");
- printf(" %s", list_evr[i]);
- }
- if (!sep) printf("\n");
- }
- if (sep) printf("\n");
- }
- free(list);
-}
-
-static
-void print_list_prereqs(Header header, char *format, char *name) {
- int_32 type, count;
- char **list;
- int_32 *flags;
- int i;
-
- headerGetEntry(header, RPMTAG_REQUIRENAME, &type, (void **) &list, &count);
- headerGetEntry(header, RPMTAG_REQUIREFLAGS, &type, (void **) &flags, &count);
-
- if (flags && list)
- for(i = 0; i < count; i++)
- if (flags[i] & RPMSENSE_PREREQ) printf(format, name, list[i]);
- free(list);
-}
-
-static
-void print_list_files(Header header, char *format, char *name, int moreinfo) {
- int_32 type, count;
- char **list;
- char ** baseNames, ** dirNames;
- int_32 * dirIndexes;
- int i;
-
- headerGetEntry(header, RPMTAG_OLDFILENAMES, &type, (void **) &list, &count);
-
- if (list)
- for (i = 0; i < count; i++) printf(format, name, list[i]);
- free(list);
-
- headerGetEntry(header, RPMTAG_BASENAMES, &type, (void **) &baseNames, &count);
- headerGetEntry(header, RPMTAG_DIRINDEXES, &type, (void **) &dirIndexes, NULL);
- headerGetEntry(header, RPMTAG_DIRNAMES, &type, (void **) &dirNames, NULL);
- if (moreinfo)
- printf("NAME<%s> VERSION<%s> RELEASE<%s> ARCH<%s> EPOCH<%ld> SIZE<%ld> GROUP<%s>\n",
- get_name(header, RPMTAG_NAME), get_name(header, RPMTAG_VERSION), get_name(header, RPMTAG_RELEASE),
- get_name(header, RPMTAG_ARCH), (long)get_name(header, RPMTAG_EPOCH), (long)get_name(header, RPMTAG_SIZE), get_name(header, RPMTAG_GROUP));
- if (baseNames && dirNames && dirIndexes) {
- char buff[4096];
- for(i = 0; i < count; i++) {
- sprintf(buff, "%s%s", dirNames[dirIndexes[i]], baseNames[i]);
- printf(format, name, buff);
- }
- }
- free(baseNames);
- free(dirNames);
-}
-
-static
-void print_list_name(Header header, char *format, char print_sep, int extension) {
- char *name = get_name(header, RPMTAG_NAME);
- char *version = get_name(header, RPMTAG_VERSION);
- char *release = get_name(header, RPMTAG_RELEASE);
- char *arch = headerIsEntry(header, RPMTAG_SOURCERPM) ? get_name(header, RPMTAG_ARCH) : "src";
-
- printf(format, name, "");
-
- if (extension)
- printf("%s-%s-%s.%s%c%u%c%u%c%s\n", name, version, release, arch,
- print_sep ? print_sep : ':', get_int(header, RPMTAG_EPOCH),
- print_sep ? print_sep : ':', get_int(header, RPMTAG_SIZE),
- print_sep ? print_sep : ':', get_name(header, RPMTAG_GROUP));
- else
- printf("%s-%s-%s.%s\n", name, version, release, arch);
-}
-
-static
-void print_filename(Header header) {
- char *name = get_name(header, RPMTAG_NAME);
- char *version = get_name(header, RPMTAG_VERSION);
- char *release = get_name(header, RPMTAG_RELEASE);
- char *arch = headerIsEntry(header, RPMTAG_SOURCERPM) ? get_name(header, RPMTAG_ARCH) : "src";
-
- printf("%s-%s-%s.%s.rpm\n", name, version, release, arch);
-}
-
-static
-void print_multiline(char *format, char *name, char *multiline_str) {
- char *s, *e;
- if ((e = strchr(multiline_str, '\n'))) {
- char buf[4096];
- for (s = multiline_str;(e = strchr(s, '\n')); s = e+1) {
- if (e-s >= sizeof(buf)-1) continue; /* else it will fails */
- memcpy(buf, s, e-s); buf[e-s] = 0;
- printf(format, name, buf);
- }
- } else {
- printf(format, name, multiline_str);
- }
-}
-
-static
-int sql_print_name (Header header, int tag, int state) {
- char *value;
- if (state) putchar(',');
- value = get_name(header, tag);
- putchar('\'');
- if (value != NULL) {
- while (*value) {
- switch (*value) {
- case '\'':
- printf("\\'");
- break;
- case '\n':
- printf("\\n");
- break;
- case '\t':
- printf("\\t");
- break;
- case '\\':
- printf("\\\\");
- break;
- default:
- if (isprint(*value))
- putchar(*value);
- else
- putchar('?');
- }
- ++value;
- }
- }
- putchar('\'');
- if (!state)
- ++state;
- return state;
-}
-
-static
-int sql_print_int(Header header, int tag, int state) {
- int *value;
- if (state) putchar(',');
- value = (int *) get_name(header, tag);
- if (value == NULL)
- printf("null");
- else
- printf("%d", *value);
- if (! state)
- ++state;
- return state;
-}
-
-static
-void print_help(void) {
- printf(
- "parsehdlist version " VERSION_STRING "\n"
- "Copyright (C) 2000-2006 Mandriva SA.\n"
- "This is free software and may be redistributed under the terms of the GNU GPL.\n"
- "\n"
- "usage:\n"
- " --help - print this help message.\n"
- " --raw - assume raw hdlist (always the case for -).\n"
- " --sql - SQL mode (output results as INSERT statements)\n"
- " --interactive - interactive mode (following options are taken from stdin\n"
- " and output only the necessary data, end as emtpy line, not\n"
- " compatible with any print tag commands).\n"
- " --quiet - do not print tag name (default if no tag given on command\n"
- " line, incompatible with interactive mode).\n"
- " --compact - print compact provides, requires, conflicts, obsoletes flags.\n"
- " --all - print all tags (incompatible with interactive mode).\n"
- " --synthesis - print synthesis tags (incompatible with interactive mode).\n"
- " --name - print tag name and rpm filename if needed.\n"
- " --info - print tag name, epoch and rpm filename if needed.\n"
- " --group - print tag group: group.\n"
- " --size - print tag size: size.\n"
- " --epoch - print tag epoch: epoch.\n"
- " --summary - print tag summary: summary.\n"
- " --description - print tag description: description.\n"
- " --provides - print tag provides: all provides (multiple lines).\n"
- " --requires - print tag requires: all requires (multiple lines).\n"
- " --files - print tag files: all files (multiple lines).\n"
- " --fileswinfo - print tag files: all files (multiple lines) with more\n"
- " information on each package.\n"
- " --conflicts - print tag conflicts: all conflicts (multiple lines).\n"
- " --obsoletes - print tag obsoletes: all obsoletes (multiple lines).\n"
- " --prereqs - print tag prereqs: all prereqs (multiple lines).\n"
- " --url - print tag url: source URL for package.\n"
- "\nwithout any option, print only rpm filenames\n"
- "\n");
-}
-
-void
-print_header_flag_interactive(char *in_tag, Header header)
-{
- if (!strncmp(in_tag, "provides", 8)) print_list_flags(header, RPMTAG_PROVIDENAME, RPMTAG_PROVIDEFLAGS,
- RPMTAG_PROVIDEVERSION, "%2$s", 0, "");
- else if (!strncmp(in_tag, "requires", 8)) print_list_flags(header, RPMTAG_REQUIRENAME, RPMTAG_REQUIREFLAGS,
- RPMTAG_REQUIREVERSION, "%2$s", 0, "");
- else if (!strncmp(in_tag, "conflicts", 9)) print_list_flags(header, RPMTAG_CONFLICTNAME, RPMTAG_CONFLICTFLAGS,
- RPMTAG_CONFLICTVERSION, "%2$s", 0, "");
- else if (!strncmp(in_tag, "obsoletes", 9)) print_list_flags(header, RPMTAG_OBSOLETENAME, RPMTAG_OBSOLETEFLAGS,
- RPMTAG_OBSOLETEVERSION,"%2$s", 0, "");
- else if (!strncmp(in_tag, "files", 5)) print_list_files(header, "%2$s\n", "", 0);
- else if (!strncmp(in_tag, "prereqs", 7)) print_list_prereqs(header, "%2$s\n", "");
- else if (!strncmp(in_tag, "name", 4)) print_list_name(header, "%2$s", 0, 0);
- else if (!strncmp(in_tag, "info", 4)) print_list_name(header, "%2$s", 0, 1);
- else if (!strncmp(in_tag, "epoch", 6)) printf("%d\n", get_int(header, RPMTAG_EPOCH));
- else if (!strncmp(in_tag, "size", 4)) printf("%d\n", get_int(header, RPMTAG_SIZE));
- else if (!strncmp(in_tag, "group", 5)) printf("%s\n", get_name(header, RPMTAG_GROUP));
- else if (!strncmp(in_tag, "url", 3)) printf("%s\n", get_name(header, RPMTAG_URL));
- else if (!strncmp(in_tag, "summary", 7)) printf("%s\n", get_name(header, RPMTAG_SUMMARY));
- else if (!strncmp(in_tag, "description", 11)) printf("%s\n", get_name(header, RPMTAG_DESCRIPTION));
-}
-
-int main(int argc, char **argv)
-{
- int i;
-
- if (argc <= 1) {
- print_help();
- exit(1);
- }
- for (i = 1; i < argc; i++) {
- if (argv[i][0] == '-' && argv[i][1] == '-') {
- if (strcmp(argv[i], "--help") == 0) {
- print_help();
- exit(0);
- } else if (strcmp(argv[i], "--raw") == 0) raw_hdlist = 1;
- else if (strcmp(argv[i], "--sql") == 0) sql_mode = 1;
- else if (strcmp(argv[i], "--interactive") == 0) interactive_mode = 1;
- else if (strcmp(argv[i], "--silent") == 0) silent = 1;
- else if (strcmp(argv[i], "--quiet") == 0) print_quiet = 1;
- else if (strcmp(argv[i], "--compact") == 0) print_sep = '@';
- else if (strcmp(argv[i], "--name") == 0) print_name = 1;
- else if (strcmp(argv[i], "--info") == 0) print_info = 1;
- else if (strcmp(argv[i], "--group") == 0) print_group = 1;
- else if (strcmp(argv[i], "--size") == 0) print_size = 1;
- else if (strcmp(argv[i], "--epoch") == 0) print_epoch = 1;
- else if (strcmp(argv[i], "--serial") == 0) print_epoch = 1; /* deprecated option, backwards compat */
- else if (strcmp(argv[i], "--summary") == 0) print_summary = 1;
- else if (strcmp(argv[i], "--description") == 0) print_description = 1;
- else if (strcmp(argv[i], "--provides") == 0) print_provides = 1;
- else if (strcmp(argv[i], "--requires") == 0) print_requires = 1;
- else if (strcmp(argv[i], "--files") == 0) print_files = 1;
- else if (strcmp(argv[i], "--fileswinfo") == 0) print_files_more_info = 1;
- else if (strcmp(argv[i], "--conflicts") == 0) print_conflicts = 1;
- else if (strcmp(argv[i], "--obsoletes") == 0) print_obsoletes = 1;
- else if (strcmp(argv[i], "--prereqs") == 0) print_prereqs = 1;
- else if (strcmp(argv[i], "--url") == 0) print_url = 1;
- else if (strcmp(argv[i], "--output") == 0) {
- if (i+1 >= argc || !argv[i+1] || !argv[i+1][0]) {
- if (!silent) { fprintf(stderr, "option --output need a valid filename after it\n"); }
- exit(1);
- }
- if (!freopen(argv[i+1], "w", stdout)) {
- unlink(argv[i+1]);
- if (!silent) { fprintf(stderr, "unable to redirect output to [%s]\n", argv[i+1]); }
- exit(1);
- } else ++i; /* avoid parsing filename as an argument */
- } else if (strcmp(argv[i], "--all") == 0) {
- print_info = 1;
- print_group = 1;
- print_packagesize = 1;
- print_summary = 1;
- print_provides = 1;
- print_requires = 1;
- print_files = 1;
- print_conflicts = 1;
- print_obsoletes = 1;
- print_prereqs = 1;
- print_url = 1;
- } else if (strcmp(argv[i], "--synthesis") == 0) {
- print_sep = '@';
- print_info = 1;
- print_provides = 1;
- print_requires = 1;
- print_conflicts = 1;
- print_obsoletes = 1;
- } else {
- if (!silent) { fprintf(stderr, "parsehdlist: unknown option %s\n", argv[i]); }
- }
- } else {
- FD_t fd;
- pid_t pid = 0;
- if (strcmp(argv[i], "-") == 0) fd = fdDup(STDIN_FILENO);
- else if (raw_hdlist) fd = Fopen(argv[i], "r");
- else {
- int fdno[2];
- if (!pipe(fdno)) {
- if ((pid = fork()) != 0) {
- fd_set readfds;
- struct timeval timeout;
-
- FD_ZERO(&readfds);
- FD_SET(fdno[0], &readfds);
- timeout.tv_sec = 1;
- timeout.tv_usec = 0;
- select(fdno[0]+1, &readfds, NULL, NULL, &timeout);
-
- fd = fdDup(fdno[0]);
- close(fdno[0]);
- close(fdno[1]);
- } else {
- int fda, fdn;
- struct {
- char header[4];
- char toc_d_count[4];
- char toc_l_count[4];
- char toc_f_count[4];
- char toc_str_size[4];
- char uncompress[40];
- char trailer[4];
- } buf;
- char *unpacker[22]; /* enough for 40 bytes above to never overbuf */
- char *p = buf.uncompress;
- int ip = 0;
- char *ld_loader = getenv("LD_LOADER");
-
- if (ld_loader && *ld_loader) {
- unpacker[ip++] = ld_loader;
- }
-
- dup2(fdno[1], STDOUT_FILENO); close(fdno[1]);
- fda = open(argv[i], O_RDONLY);
- if (fda < 0) { perror("parsehdlist"); exit(1); }
- lseek(fda, -sizeof(buf), SEEK_END);
- if (read(fda, &buf, sizeof(buf)) != sizeof(buf) ||
- strncmp(buf.header, "cz[0", 4) ||
- strncmp(buf.trailer, "0]cz", 4)) {
- if (!silent) { fprintf(stderr, "parsehdlist: invalid archive %s\n", argv[i]); }
- exit(1);
- }
- buf.trailer[0] = 0; /* make sure end-of-string is right */
- while (*p) {
- if (*p == ' ' || *p == '\t') *p++ = 0;
- else {
- unpacker[ip++] = p;
- while (*p && *p != ' ' && *p != '\t') ++p;
- }
- }
- unpacker[ip] = NULL; /* needed for execlp */
-
- lseek(fda, 0, SEEK_SET);
- dup2(fda, STDIN_FILENO); close(fda);
- fdn = open("/dev/null", O_WRONLY);
- dup2(fdn, STDERR_FILENO); close(fdn);
- execvp(unpacker[0], unpacker);
- exit(2);
- }
- } else {
- if (!silent) { fprintf(stderr, "parsehdlist: unable to create pipe for parsehdlist\n"); }
- }
- }
- if (Fileno(fd) < 0) {
- if (!silent) { fprintf(stderr, "parsehdlist: cannot open file %s\n", argv[i]); }
- exit(1);
- } else {
- Header header;
- long count = 0;
-
- while (count < 20 && (header=headerRead(fd, HEADER_MAGIC_YES)) == 0) {
- struct timeval timeout;
-
- timeout.tv_sec = 0;
- timeout.tv_usec = 10000;
- select(0, NULL, NULL, NULL, &timeout);
-
- ++count;
- }
- count = 0;
- while (header != 0) {
- char *name = get_name(header, RPMTAG_NAME);
-
- ++count;
- if (interactive_mode) {
- headers[count_headers].name = name;
- headers[count_headers].hash_name = hash(name);
- headers[count_headers].header = header;
-
- ++count_headers;
- } else if (sql_mode) {
- sql_state = 0;
- printf("INSERT INTO rpms VALUES(");
- if (print_name) {
- sql_state = sql_print_name(header, RPMTAG_NAME, sql_state);
- sql_state = sql_print_name(header, RPMTAG_VERSION, sql_state);
- sql_state = sql_print_name(header, RPMTAG_RELEASE, sql_state);
- }
- if (print_group) sql_state = sql_print_name(header, RPMTAG_GROUP, sql_state);
- if (print_size) sql_state = sql_print_int(header, RPMTAG_SIZE, sql_state);
- if (print_epoch) sql_state = sql_print_name(header, RPMTAG_EPOCH, sql_state);
- if (print_url) sql_state = sql_print_name(header, RPMTAG_URL, sql_state);
- if (print_summary) sql_state = sql_print_name(header, RPMTAG_SUMMARY, sql_state);
- if (print_description) sql_state = sql_print_name(header, RPMTAG_DESCRIPTION, sql_state);
- printf (");\n");
- headerFree(header);
- } else {
- if (print_provides) print_list_flags(header, RPMTAG_PROVIDENAME, RPMTAG_PROVIDEFLAGS, RPMTAG_PROVIDEVERSION,
- printable_header(print_quiet, "provides", print_sep, 0), print_sep, name);
- if (print_requires) print_list_flags(header, RPMTAG_REQUIRENAME, RPMTAG_REQUIREFLAGS, RPMTAG_REQUIREVERSION,
- printable_header(print_quiet, "requires", print_sep, 0), print_sep, name);
- if (print_conflicts) print_list_flags(header, RPMTAG_CONFLICTNAME, RPMTAG_CONFLICTFLAGS, RPMTAG_CONFLICTVERSION,
- printable_header(print_quiet, "conflicts", print_sep, 0), print_sep, name);
- if (print_obsoletes) print_list_flags(header, RPMTAG_OBSOLETENAME, RPMTAG_OBSOLETEFLAGS, RPMTAG_OBSOLETEVERSION,
- printable_header(print_quiet, "obsoletes", print_sep, 0), print_sep, name);
- if (print_files) print_list_files(header, printable_header(print_quiet, "files", print_sep, "\n"), name, 0);
- if (print_files_more_info) print_list_files(header, printable_header(print_quiet, "files", print_sep, "\n"), name, 1);
- if (print_prereqs) print_list_prereqs(header, printable_header(print_quiet, "prereqs", print_sep, "\n"), name);
- if (print_group) printf(printable_header(print_quiet, "group", print_sep, "\n"), name, get_name(header, RPMTAG_GROUP));
- if (print_packagesize) printf(printable_header(print_quiet, "pkgsize", print_sep, "\n"), name, get_int(header, 1000001));
- if (print_size) printf(printable_header(print_quiet, "size", print_sep, "\n"), name, get_int(header, RPMTAG_SIZE));
- if (print_epoch) printf(printable_header(print_quiet, "epoch", print_sep, "\n"),
- name, get_int(header, RPMTAG_EPOCH));
- if (print_summary) print_multiline(printable_header(print_quiet, "summary", print_sep, "\n"),
- name, get_name(header, RPMTAG_SUMMARY));
- if (print_description) print_multiline(printable_header(print_quiet, "description", print_sep, "\n"),
- name, get_name(header, RPMTAG_DESCRIPTION));
- if (print_name) print_list_name(header, printable_header(print_quiet, "name", print_sep, 0), print_sep, 0);
- if (print_info) print_list_name(header, printable_header(print_quiet, "info", print_sep, 0), print_sep, 1);
- if ((print_name | print_info | print_group | print_size | print_epoch | print_summary | print_description |
- print_provides | print_requires | print_files | print_conflicts | print_obsoletes | print_prereqs | print_files_more_info) == 0) {
- print_filename(header);
- }
- headerFree(header);
- }
- header=headerRead(fd, HEADER_MAGIC_YES);
- }
- if (!count) exit(3); /* no package is an error */
- }
- fdClose(fd);
- if (pid) {
- kill(pid, SIGTERM);
- waitpid(pid, NULL, 0);
- pid = 0;
- }
- }
- }
-
- /* interactive mode */
- while (interactive_mode) {
- char in_name[4096];
- char *in_tag, *in_version, *in_release, *in_arch;
- unsigned long hash_in_name;
- int i, count = 0;
-
- if (!fgets(in_name, sizeof(in_name), stdin) || *in_name == '\n' || !*in_name) break;
- if ((in_tag = strchr(in_name, ':')) == NULL) {
- if (!silent) { fprintf(stderr, "invalid command, should be name:tag\n"); }
- break;
- }
- *in_tag++ = 0;
- if ((in_arch = strrchr(in_name, '.')) != NULL && !strchr(in_arch, '-')) *in_arch++ = 0; else in_arch = 0;
- if ((in_release = strrchr(in_name, '-')) != NULL) {
- *in_release++ = 0;
- if ((in_version = strrchr(in_name, '-')) != NULL) {
- *in_version++ = 0;
- hash_in_name = hash(in_name);
- for (i = 0; i < count_headers; ++i) {
- if (headers[i].hash_name == hash_in_name && !strcmp(headers[i].name, in_name)) {
- if (strcmp(get_name(headers[i].header, RPMTAG_VERSION), in_version)) continue;
- if (strcmp(get_name(headers[i].header, RPMTAG_RELEASE), in_release)) {
- if (in_arch) in_arch[-1] = '.';
- if (strcmp(get_name(headers[i].header, RPMTAG_RELEASE), in_release)) {
- if (in_arch) in_arch[-1] = 0;
- continue;
- }
- } else if (in_arch && strcmp(get_name(headers[i].header, RPMTAG_ARCH), in_arch)) continue;
- print_header_flag_interactive(in_tag, headers[i].header);
- ++count;
- break; /* special case to avoid multiple output for multiply defined same package */
- }
- }
- in_version[-1] = '-';
- }
- if (!count) {
- if (in_arch) in_arch[-1] = '.';
- in_version = in_release;
- hash_in_name = hash(in_name);
- for (i = 0; i < count_headers; ++i) {
- if (headers[i].hash_name == hash_in_name && !strcmp(headers[i].name, in_name)) {
- if (strcmp(get_name(headers[i].header, RPMTAG_VERSION), in_version)) continue;
- print_header_flag_interactive(in_tag, headers[i].header);
- ++count;
- }
- }
- in_version[-1] = '-';
- }
- }
- if (!count) {
- if (in_arch) in_arch[-1] = '.';
- hash_in_name = hash(in_name);
- for (i = 0; i < count_headers; ++i) {
- if (headers[i].hash_name == hash_in_name && !strcmp(headers[i].name, in_name)) {
- print_header_flag_interactive(in_tag, headers[i].header);
- ++count;
- }
- }
- }
- printf("\n");
- fflush(stdout);
- }
-
- return 0;
-}
diff --git a/rpm2cpio.pl b/rpm2cpio.pl
deleted file mode 100644
index 1121a04..0000000
--- a/rpm2cpio.pl
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright (C) 1997,1998,1999, Roger Espel Llima
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and any associated documentation files (the "Software"), to
-# deal in the Software without restriction, including without limitation the
-# rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# SOFTWARE'S COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE
-
-# (whew, that's done!)
-
-# why does the world need another rpm2cpio? because the existing one
-# won't build unless you have half a ton of things that aren't really
-# required for it, since it uses the same library used to extract RPM's.
-# in particular, it won't build on the HPsUX box i'm on.
-
-# sw 2002-Mar-6 Don't slurp the whole file
-
-# 2004-Aug-18: minor changes for Mandrakelinux by Rafael Garcia-Suarez
-
-# adjust path if desired
-$gzip = "/bin/gzip";
--x $gzip or die "No /bin/gzip found, aborting\n";
-
-sub printhelp {
- print <<HERE;
-rpm2cpio.pl, perl version by orabidoo <odar\@pobox.com> +sw
-dumps the contents to stdout as a cpio archive
-
-use: rpm2cpio.pl [file.rpm] > file.cpio
-
-Here's how to use cpio:
- list of contents: cpio -t -i < /file/name
- extract files: cpio -d -i < /file/name
-HERE
-
- exit 0;
-}
-
-if ($#ARGV == -1) {
- printhelp if -t STDIN;
- $f = "STDIN";
-} elsif ($#ARGV == 0) {
- open(F, "< $ARGV[0]") or die "Can't read file $ARGV[0]\n";
- $f = 'F';
-} else {
- printhelp;
-}
-
-printhelp if -t STDOUT;
-
-read $f,$rpm,96;
-
-($magic, $major, $minor, $crap) = unpack("NCC C90", $rpm);
-
-die "Not an RPM\n" if $magic != 0xedabeedb;
-die "Not a version 3 or 4 RPM\n" if $major != 3 && $major != 4;
-
-while (!eof($f)) {
- $pos = tell($f);
- read $f,$rpm,16;
- $smagic = unpack("n", $rpm);
- last if $smagic eq 0x1f8b;
- # Turns out that every header except the start of the gzip one is
- # padded to an 8 bytes boundary.
- if ($pos & 0x7) {
- $pos += 7;
- $pos &= ~0x7; # Round to 8 byte boundary
- seek $f, $pos, 0;
- read $f,$rpm,16;
- }
- ($magic, $crap, $sections, $bytes) = unpack("N4", $rpm);
- die "Error: header not recognized\n" if $magic != 0x8eade801;
- $pos += 16; # for header
- $pos += 16 * $sections;
- $pos += $bytes;
- seek $f, $pos, 0;
-}
-
-if (eof($f)) {
- die "bogus RPM\n";
-}
-
-open(ZCAT, "|$gzip -cd") || die "can't pipe to gzip\n";
-
-print ZCAT $rpm;
-
-while (read($f, ($_=''), 16384) > 0) {
- print ZCAT;
-}
-
-close ZCAT;
-
diff --git a/rpm2header.c b/rpm2header.c
deleted file mode 100644
index 0055ed0..0000000
--- a/rpm2header.c
+++ /dev/null
@@ -1,89 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdint.h>
-
-#define RPM_VERSION(maj,min,pl) (((maj) << 16) + ((min) << 8) + (pl))
-
-#if RPM_VERSION_CODE >= RPM_VERSION(5,0,0)
-#include <rpm/rpm4compat.h>
-#endif
-#include <rpmlib.h>
-#include <rpm/rpmts.h>
-
-const char *basename(const char *f) {
- char *p = strrchr(f, '/');
- return p ? p + 1 : f;
-}
-
-int_32 FD_size(FD_t fd) {
- struct stat sb;
- fstat(Fileno(fd), &sb);
- return sb.st_size;
-}
-
-int main(int argc, char **argv) {
- int i;
- FD_t fout;
-
- if (argc < 2) {
- fprintf(stderr, "usage: rpm2header <rpms>\n");
- exit(1);
- }
-
- fout = fdDup(1 /*stdout*/);
-
- for (i = 1; i < argc; i++) {
- FD_t fd;
- Header h;
- int_32 size;
- const char *name = basename(argv[i]);
- rpmts ts;
-
- fprintf(stderr, "%s\n", argv[i]);
-
- if (!(fd = Fopen(argv[i], "r"))) {
- perror("open");
- exit(1);
- }
- size = FD_size(fd);
-
- ts = rpmtsCreate();
- rpmtsSetVSFlags(ts, _RPMVSF_NOSIGNATURES);
- if (rpmReadPackageFile(ts, fd, argv[1], &h) == 0) {
- headerRemoveEntry(h, RPMTAG_POSTIN);
- headerRemoveEntry(h, RPMTAG_POSTUN);
- headerRemoveEntry(h, RPMTAG_PREIN);
- headerRemoveEntry(h, RPMTAG_PREUN);
- headerRemoveEntry(h, RPMTAG_FILEUSERNAME);
- headerRemoveEntry(h, RPMTAG_FILEGROUPNAME);
- headerRemoveEntry(h, RPMTAG_FILEVERIFYFLAGS);
- headerRemoveEntry(h, RPMTAG_FILERDEVS);
- headerRemoveEntry(h, RPMTAG_FILEMTIMES);
- headerRemoveEntry(h, RPMTAG_FILEDEVICES);
- headerRemoveEntry(h, RPMTAG_FILEINODES);
- headerRemoveEntry(h, RPMTAG_TRIGGERSCRIPTS);
- headerRemoveEntry(h, RPMTAG_TRIGGERVERSION);
- headerRemoveEntry(h, RPMTAG_TRIGGERFLAGS);
- headerRemoveEntry(h, RPMTAG_TRIGGERNAME);
- headerRemoveEntry(h, RPMTAG_CHANGELOGTIME);
- headerRemoveEntry(h, RPMTAG_CHANGELOGNAME);
- headerRemoveEntry(h, RPMTAG_CHANGELOGTEXT);
- headerRemoveEntry(h, RPMTAG_ICON);
- headerRemoveEntry(h, RPMTAG_GIF);
- headerRemoveEntry(h, RPMTAG_VENDOR);
- headerRemoveEntry(h, RPMTAG_EXCLUDE);
- headerRemoveEntry(h, RPMTAG_EXCLUSIVE);
- headerRemoveEntry(h, RPMTAG_DISTRIBUTION);
- headerRemoveEntry(h, RPMTAG_VERIFYSCRIPT);
- headerWrite(fout, h, HEADER_MAGIC_YES);
- headerFree(h);
- }
- fdClose(fd);
- }
- return 0;
-}