aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--Makefile.PL4
-rw-r--r--parsehdlist.c48
-rw-r--r--rpmtools.pm30
-rw-r--r--rpmtools.spec16
-rw-r--r--rpmtools.xs22
6 files changed, 90 insertions, 34 deletions
diff --git a/Makefile b/Makefile
index 6075c16..5b5f831 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION = 2.3
+VERSION = 3.0
NAME = rpmtools
FROMC = parsehdlist rpm2header #rpm-find-leaves
FROMCC = #gendepslist2 hdlist2names hdlist2files hdlist2prereq hdlist2groups
@@ -7,7 +7,7 @@ FROMCC_STATIC = $(FROMCC:%=%_static)
ALL = $(FROMC) $(FROMCC)
ALL_STATIC = $(FROMC_STATIC) $(FROMCC_STATIC)
CFLAGS = -Wall -g
-LIBRPM = -lrpm -lrpmio -lrpmdb -lz -lbz2 -I/usr/include/rpm -lpopt
+LIBRPM = -lrpm -lrpmio `perl -e 'use rpmtools; rpmtools::version_compare(qx(rpm -q --qf %{VERSION} rpm), "4.0.3") >= 0 and print "-lrpmdb"'` -lz -lbz2 -I/usr/include/rpm -lpopt
LIBRPM_STATIC =
all: $(ALL)
diff --git a/Makefile.PL b/Makefile.PL
index be12efe..2bd224b 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -2,7 +2,9 @@ use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
-my $libs = ' -lrpm -lrpmio -lrpmdb -lpopt -lz -lbz2';
+use rpmtools;
+
+my $libs = ' -lrpm -lrpmio ' . (rpmtools::version_compare(qx(rpm -q --qf %{VERSION} rpm), "4.0.3") >= 0 && "-lrpmdb ") . '-lpopt -lz -lbz2';
WriteMakefile(
'NAME' => 'rpmtools',
diff --git a/parsehdlist.c b/parsehdlist.c
index 6b1d97b..c8ab948 100644
--- a/parsehdlist.c
+++ b/parsehdlist.c
@@ -26,6 +26,10 @@ static int interactive_mode = 0;
static int print_quiet = 0;
static int print_name = 0;
static int print_group = 0;
+static int print_size = 0;
+static int print_serial = 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;
@@ -52,26 +56,14 @@ char *get_name(Header header, int_32 tag) {
return name;
}
-/*
static
-void print_list(Header header, int_32 tag_name, char *format, char sep, char *name) {
+int get_int(Header header, int_32 tag) {
int_32 type, count;
- char **list;
- int i;
-
- headerGetEntry(header, tag_name, &type, (void **) &list, &count);
+ int_32 *i;
- if (list) {
- for(i = 0; i < count; i++) {
- if (sep && i > 0) printf("%c%s", sep, list[i]);
- else printf(format, name, list[i]);
- if (!sep) printf("\n");
- }
- if (sep) printf("\n");
- }
- free(list);
+ headerGetEntry(header, tag, &type, (void **) &i, &count);
+ return i ? *i : 0; /* assume for default, necessary for RPMTAG_SERIAL */
}
-*/
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) {
@@ -169,6 +161,10 @@ void print_help(void) {
" --name - print tag name: rpm filename (assumed if no tag given on\n"
" command line but without package name).\n"
" --group - print tag group: group.\n"
+ " --size - print tag size: size.\n"
+ " --serial - print tag serial: serial.\n"
+ " --summary - print tag summary: summary.\n"
+ " --description - print tag description: description.\n"
" --provides - print tag provides: all provides (mutliple lines).\n"
" --requires - print tag requires: all requires (multiple lines).\n"
" --files - print tag files: all files (multiple lines).\n"
@@ -192,6 +188,10 @@ print_header_flag_interactive(char *in_tag, Header header)
else if (!strncmp(in_tag, "files", 5)) print_list_files(header, "%2$s\n", "");
else if (!strncmp(in_tag, "prereqs", 7)) print_list_prereqs(header, "%2$s\n", "");
else if (!strncmp(in_tag, "group", 5)) printf("%s\n", get_name(header, RPMTAG_GROUP));
+ 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));
+ else if (!strncmp(in_tag, "size", 4)) printf("%d\n", get_int(header, RPMTAG_SIZE));
+ else if (!strncmp(in_tag, "serial", 6)) printf("%d\n", get_int(header, RPMTAG_SERIAL));
else if (!strncmp(in_tag, "name", 4)) printf("%s-%s-%s.%s.rpm\n",
get_name(header, RPMTAG_NAME),
get_name(header, RPMTAG_VERSION),
@@ -205,7 +205,7 @@ 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, "%%s");
+ n += sprintf(buff + n, !strcmp(name, "size") || !strcmp(name, "serial") ? "%%d" : "%%s");
if (final) n += sprintf(buff + n, "%s", final);
return buff; /* static string, this means to use result before calling again */
}
@@ -229,6 +229,10 @@ int main(int argc, char **argv)
else if (strcmp(argv[i], "--compact") == 0) print_sep = '@';
else if (strcmp(argv[i], "--name") == 0) print_name = 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], "--serial") == 0) print_serial = 1;
+ 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;
@@ -248,6 +252,7 @@ int main(int argc, char **argv)
} else if (strcmp(argv[i], "--all") == 0) {
print_name = 1;
print_group = 1;
+ print_summary = 1;
print_provides = 1;
print_requires = 1;
print_files = 1;
@@ -350,8 +355,15 @@ int main(int argc, char **argv)
if (print_files) print_list_files(header, printable_header(print_quiet, "files", print_sep, "\n"), name);
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_size) printf(printable_header(print_quiet, "size", print_sep, "\n"), name, get_int(header, RPMTAG_SIZE));
+ if (print_serial) printf(printable_header(print_quiet, "serial", print_sep, "\n"),
+ name, get_int(header, RPMTAG_SERIAL));
+ if (print_summary) printf(printable_header(print_quiet, "summary", print_sep, "\n"),
+ name, get_name(header, RPMTAG_SUMMARY));
+ if (print_description) printf(printable_header(print_quiet, "description", print_sep, "\n"),
+ name, get_name(header, RPMTAG_DESCRIPTION));
if (print_name || (print_provides | print_requires | print_files | print_conflicts | print_obsoletes | print_prereqs |
- print_group) == 0) {
+ print_group | print_size | print_serial | print_summary | print_description) == 0) {
if (print_name) printf(printable_header(print_quiet, "name", print_sep, 0), name);
printf("%s-%s-%s.%s.rpm\n",
name,
diff --git a/rpmtools.pm b/rpmtools.pm
index ddad337..5b08d32 100644
--- a/rpmtools.pm
+++ b/rpmtools.pm
@@ -6,7 +6,7 @@ use vars qw($VERSION @ISA %compat_arch);
require DynaLoader;
@ISA = qw(DynaLoader);
-$VERSION = '2.3';
+$VERSION = '3.0';
bootstrap rpmtools $VERSION;
@@ -86,6 +86,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
'k6' => 'i586',
'k7' => 'k6',
'k8' => 'k7',
+ 'ia32' => 'i386',
+ 'ia64' => 'noarch',
'ppc' => 'noarch',
'alpha' => 'noarch',
'sparc' => 'noarch',
@@ -98,7 +100,7 @@ sub new {
my ($class, @tags) = @_;
my %tags; @tags{@_} = ();
bless {
- flags => [ qw(name version release size arch group requires provides),
+ flags => [ qw(name version release size arch serial group requires provides),
grep { exists $tags{$_} } qw(sense files obsoletes conflicts conffiles) ],
info => {},
depslist => [],
@@ -142,11 +144,22 @@ sub build_hdlist {
-d $dir or mkdir $dir, 0755 or die "cannot create directory $dir\n";
foreach (@rpms) {
- my ($key, $name) = /(([^\/]*)-[^-]*-[^-]*\.[^\/\.]*)\.rpm$/ or next;
+ my ($key) = /([^\/]*)\.rpm$/ or next; #- get rpm filename.
+
system("rpm2header '$_' > '$dir/$key'") unless -e "$dir/$key";
$? == 0 or unlink("$dir/$key"), die "bad rpm $_\n";
-s "$dir/$key" or unlink("$dir/$key"), die "bad rpm $_\n";
- push @{$names{$name} ||= []}, $key;
+
+ my ($name, $version, $release, $arch) = $key =~ /(.*)-([^-]*)-([^-]*)\.([^\.])*$/;
+ my ($realname, $realversion, $realrelease, $realarch) =
+ `parsehdlist --raw '$dir/$key'` =~ /(.*)-([^-]*)-([^-]*)\.([^\.])*\.rpm$/;
+ unless ($name && $version && $release && $arch &&
+ $name eq $realname && $version eq $realversion && $release eq $realrelease && $arch eq $realarch) {
+ my $newkey = "$realname-$realversion-$realrelease.$realarch:$key";
+ symlink "$dir/$key", "$dir/$newkey" unless -e "$newkey";
+ $key = $newkey;
+ }
+ push @{$names{$realname} ||= []}, $key;
}
#- compression ratio are not very high, sample for cooker
@@ -361,13 +374,16 @@ sub read_depslist {
local $_;
while (<$FILE>) {
chomp; /^\s*#/ and next;
- my ($name, $version, $release, $size, $deps) = /^(\S*)-([^-\s]+)-([^-\s]+)\s+(\d+)\s*(.*)/;
+ my ($name, $version, $release, $arch, $serial, $size, $deps) =
+ /^([^:\s]*)-([^:\-\s]+)-([^:\-\s]+)\.([^:\.\-\s]*)(?::(\d+)\S*)?\s+(\d+)\s*(.*)/;
#- store values here according to it.
push @{$params->{depslist}}, $params->{info}{$name} = {
name => $name,
version => $version,
release => $release,
+ arch => $arch,
+ serial => $serial,
size => $size,
deps => $deps,
id => $global_id++,
@@ -431,7 +447,9 @@ sub write_depslist {
for ($min..$max) {
my $pkg = $params->{depslist}[$_];
- printf $FILE "%s-%s-%s %s %s\n", $pkg->{name}, $pkg->{version}, $pkg->{release}, $pkg->{size}, $pkg->{deps};
+ printf $FILE ("%s-%s-%s.%s%s %s %s\n",
+ $pkg->{name}, $pkg->{version}, $pkg->{release}, $pkg->{arch},
+ ($pkg->{serial} ? ":$pkg->{serial}" : ''), $pkg->{size}, $pkg->{deps});
}
1;
}
diff --git a/rpmtools.spec b/rpmtools.spec
index e8654bd..e33baee 100644
--- a/rpmtools.spec
+++ b/rpmtools.spec
@@ -1,10 +1,11 @@
%define name rpmtools
-%define release 25mdk
+%define release 1mdk
# do not modify here, see Makefile in the CVS
-%define version 2.3
+%define version 3.0
%{expand:%%define perlbase_version %(rpm -q --queryformat '%{VERSION}' perl-base)}
+%{expand:%%define rpm_version %(rpm -q --queryformat '%{VERSION}' rpm)}
Summary: Contains various rpm command-line tools
Name: %{name}
@@ -17,8 +18,8 @@ License: GPL
Group: System/Configuration/Packaging
BuildRoot: %{_tmppath}/%{name}-buildroot
Prefix: %{_prefix}
-BuildRequires: rpm-devel >= 4.0.3 bzip2 popt-devel zlib-devel libbzip2-devel perl-devel
-Requires: perl-base = %{perlbase_version} rpm >= 4.0.3 bzip2 >= 1.0
+BuildRequires: rpm-devel >= 4.0 bzip2 popt-devel zlib-devel libbzip2-devel perl-devel
+Requires: perl-base = %{perlbase_version} rpm >= %{rpm_version} bzip2 >= 1.0
Obsoletes: rpmtools-compat <= 2.0 rpmtools-devel <= 2.0
%description
@@ -53,6 +54,13 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/perl5/man/*/*
%changelog
+* Thu Jun 21 2001 François Pons <fpons@mandrakesoft.com> 3.0-1mdk
+- changed depslist format to fix support multi-arch.
+- changed depslist format to add serial support.
+- changed hdlist format to add non standard rpm filename.
+- added support to build rpmtools with various rpm.
+- added serial, size, summary and description tags.
+
* Wed Jun 13 2001 François Pons <fpons@mandrakesoft.com> 2.3-25mdk
- really fix with newer rpm (rpmtools.so was missing).
- update distribution tag.
diff --git a/rpmtools.xs b/rpmtools.xs
index c270994..d8f7d36 100644
--- a/rpmtools.xs
+++ b/rpmtools.xs
@@ -19,6 +19,9 @@
#define HDFLAGS_ARCH 0x00000008
#define HDFLAGS_GROUP 0x00000010
#define HDFLAGS_SIZE 0x00000020
+#define HDFLAGS_SERIAL 0x00000040
+#define HDFLAGS_SUMMARY 0x00000080
+#define HDFLAGS_DESCRIPTION 0x00000100
#define HDFLAGS_SENSE 0x00080000
#define HDFLAGS_REQUIRES 0x00100000
#define HDFLAGS_PROVIDES 0x00200000
@@ -41,7 +44,7 @@ int get_int(Header header, int_32 tag) {
int *i;
headerGetEntry(header, tag, &type, (void **) &i, &count);
- return *i;
+ return i ? *i : 0;
}
int get_bflag(AV* flag) {
@@ -68,9 +71,13 @@ int get_bflag(AV* flag) {
else if (!strncmp(str, "sense", 5)) bflag |= HDFLAGS_SENSE;
else if (!strncmp(str, "files", 5)) bflag |= HDFLAGS_FILES;
break;
+ case 6:
+ if (!strncmp(str, "serial", 6)) bflag |= HDFLAGS_SERIAL;
+ break;
case 7:
if (!strncmp(str, "version", 7)) bflag |= HDFLAGS_VERSION;
else if (!strncmp(str, "release", 7)) bflag |= HDFLAGS_RELEASE;
+ else if (!strncmp(str, "summary", 7)) bflag |= HDFLAGS_SUMMARY;
break;
case 8:
if (!strncmp(str, "requires", 8)) bflag |= HDFLAGS_REQUIRES;
@@ -81,6 +88,8 @@ int get_bflag(AV* flag) {
else if (!strncmp(str, "conflicts", 9)) bflag |= HDFLAGS_CONFLICTS;
else if (!strncmp(str, "conffiles", 9)) bflag |= HDFLAGS_CONFFILES;
break;
+ case 11:
+ if (!strncmp(str, "description", 11)) bflag |= HDFLAGS_DESCRIPTION;
}
}
bflag |= HDFLAGS_NAME; /* this one should always be used */
@@ -175,6 +184,12 @@ HV* get_info(Header header, int bflag, HV* provides) {
hv_store(header_info, "group", 5, newSVpv(get_name(header, RPMTAG_GROUP), 0), 0);
if (bflag & HDFLAGS_SIZE)
hv_store(header_info, "size", 4, newSViv(get_int(header, RPMTAG_SIZE)), 0);
+ if (bflag & HDFLAGS_SERIAL)
+ hv_store(header_info, "serial", 6, newSViv(get_int(header, RPMTAG_SERIAL)), 0);
+ if (bflag & HDFLAGS_SUMMARY)
+ hv_store(header_info, "summary", 7, newSVpv(get_name(header, RPMTAG_SUMMARY), 0), 0);
+ if (bflag & HDFLAGS_DESCRIPTION)
+ hv_store(header_info, "description", 11, newSVpv(get_name(header, RPMTAG_DESCRIPTION), 0), 0);
if (bflag & HDFLAGS_REQUIRES)
hv_store(header_info, "requires", 8, get_table_sense(header, RPMTAG_REQUIRENAME,
bflag & HDFLAGS_SENSE ? RPMTAG_REQUIREFLAGS : 0,
@@ -484,8 +499,9 @@ _parse_(fileno_or_rpmfile, flag, info, ...)
char *name = get_name(header, RPMTAG_NAME);
char *version = get_name(header, RPMTAG_VERSION);
char *release = get_name(header, RPMTAG_RELEASE);
- char *fullname = (char*)alloca(strlen(name)+strlen(version)+strlen(release)+3);
- STRLEN fullname_len = sprintf(fullname, "%s-%s-%s", name, version, release);
+ char *arch = get_name(header, RPMTAG_ARCH);
+ char *fullname = (char*)alloca(strlen(name)+strlen(version)+strlen(release)+strlen(arch)+4);
+ STRLEN fullname_len = sprintf(fullname, "%s-%s-%s.%s", name, version, release, arch);
HV* header_info = get_info(header, bflag, iprovides);
/* once the hash header_info is built, store a reference to it