From 5070f3f86e1897c43fb47007d9aebd55c68f5c9e Mon Sep 17 00:00:00 2001 From: Francois Pons Date: Wed, 25 Jul 2001 14:59:35 +0000 Subject: use rpmlib version comparison function, force destiny. --- Makefile.PL | 16 +++++++++++++--- rpmtools.pm | 20 +++++++++++--------- rpmtools.spec | 5 ++++- rpmtools.xs | 8 ++++++++ 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index 2052fd1..308216a 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -2,10 +2,20 @@ use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. -# needed as it bootstrap itself... -eval { require "./rpmtools.pm" }; +# old version that works actually somewhat well... +sub version_compare { + my ($a, $b) = @_; + local $_; -my $libs = ' -lrpm -lrpmio ' . (rpmtools::version_compare(qx(rpm -q --qf %{VERSION} rpm), "4.0.3") >= 0 && "-lrpmdb ") . '-lpopt -lz -lbz2'; + while ($a || $b) { + my ($sb, $sa) = map { $1 if $a =~ /^\W*\d/ ? s/^\W*0*(\d+)// : s/^\W*(\D*)// } ($b, $a); + $_ = ($sa =~ /^\d/ || $sb =~ /^\d/) && length($sa) <=> length($sb) || $sa cmp $sb and return $_ || 0; + $sa eq '' && $sb eq '' and return $a cmp $b || 0; + } + 0; +} + +my $libs = ' -lrpm -lrpmio ' . (version_compare(qx(rpm -q --qf %{VERSION} rpm), "4.0.3") >= 0 && "-lrpmdb ") . '-lpopt -lz -lbz2'; WriteMakefile( 'NAME' => 'rpmtools', diff --git a/rpmtools.pm b/rpmtools.pm index ab7e7d8..5c8445d 100644 --- a/rpmtools.pm +++ b/rpmtools.pm @@ -601,16 +601,18 @@ sub compat_arch { better_arch(arch(), $_[0]) } #- compare a version string, make sure no deadlock can occur. #- try to return always a numerical value. sub version_compare { - my ($a, $b) = @_; - local $_; - - while ($a || $b) { - my ($sb, $sa) = map { $1 if $a =~ /^\W*\d/ ? s/^\W*0*(\d+)// : s/^\W*(\D*)// } ($b, $a); - $_ = ($sa =~ /^\d/ || $sb =~ /^\d/) && length($sa) <=> length($sb) || $sa cmp $sb and return $_ || 0; - $sa eq '' && $sb eq '' and return $a cmp $b || 0; - } - 0; + return rpmvercmp(@_); } +#- historical perl version (still breaks on "4m" with "4.1m"... +#- my ($a, $b) = @_; +#- local $_; +#- +#- while ($a || $b) { +#- my ($sb, $sa) = map { $1 if $a =~ /^\W*\d/ ? s/^\W*0*(\d+)// : s/^\W*(\D*)// } ($b, $a); +#- $_ = ($sa =~ /^\d/ || $sb =~ /^\d/) && length($sa) <=> length($sb) || $sa cmp $sb and return $_ || 0; +#- $sa eq '' && $sb eq '' and return $a cmp $b || 0; +#- } +#- 0; #- compare package name to increase chance of avoiding loop in prerequisite chain. sub package_name_compare { diff --git a/rpmtools.spec b/rpmtools.spec index 8b9b694..5a40653 100644 --- a/rpmtools.spec +++ b/rpmtools.spec @@ -1,5 +1,5 @@ %define name rpmtools -%define release 1mdk +%define release 2mdk # do not modify here, see Makefile in the CVS %define version 3.1 @@ -54,6 +54,9 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/perl5/man/*/* %changelog +* Wed Jul 25 2001 François Pons 3.1-2mdk +- use rpmvercmp for version_compare. + * Mon Jul 23 2001 François Pons 3.1-1mdk - allow provides on full package name. - fixed multiple version, release or arch of the same diff --git a/rpmtools.xs b/rpmtools.xs index d96af31..89237b2 100644 --- a/rpmtools.xs +++ b/rpmtools.xs @@ -32,6 +32,9 @@ #define HDFLAGS_SOURCERPM 0x04000000 +/* duplicate definition for rpmvercmp (not needed on 4.0.3 but needed on 4.0) */ +int rpmvercmp(const char *a, const char *b); + char *get_name(Header header, int_32 tag) { int_32 type, count; char *name; @@ -309,6 +312,11 @@ void callback_empty(void) {} MODULE = rpmtools PACKAGE = rpmtools +int +rpmvercmp(a,b) + char *a + char *b + char * arch() CODE: -- cgit v1.2.1