diff options
author | Per Øyvind Karlsen <peroyvind@mandriva.org> | 2008-07-18 13:43:12 +0000 |
---|---|---|
committer | Per Øyvind Karlsen <peroyvind@mandriva.org> | 2008-07-18 13:43:12 +0000 |
commit | 42b8201a89325abb266d3d2020e4b3d2c9660000 (patch) | |
tree | a180bc99f2e39c03b9ac552baaa3cf94555cf5c6 | |
parent | 6aa7fd7ee05075b2793445e42d838c281b40ecea (diff) | |
download | rpmtools-42b8201a89325abb266d3d2020e4b3d2c9660000.tar rpmtools-42b8201a89325abb266d3d2020e4b3d2c9660000.tar.gz rpmtools-42b8201a89325abb266d3d2020e4b3d2c9660000.tar.bz2 rpmtools-42b8201a89325abb266d3d2020e4b3d2c9660000.tar.xz rpmtools-42b8201a89325abb266d3d2020e4b3d2c9660000.zip |
fix version detection
-rw-r--r-- | Makefile.PL | 43 | ||||
-rw-r--r-- | parsehdlist.c | 6 |
2 files changed, 45 insertions, 4 deletions
diff --git a/Makefile.PL b/Makefile.PL index 7c9f0f6..ea26b78 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -5,15 +5,54 @@ use ExtUtils::MakeMaker; my $rpmtools_version = "5.6"; +# 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)\\" \$< \$(LIBRPM) \$(INCRPM) -o \$@ + \$(CXX) \$(CCFLAGS) \$(OPTIMIZE) -DVERSION_STRING=\\"\$(RPMTOOLSVERSION)\\" $ccflags \$< \$(LIBRPM) \$(INCRPM) -o \$@ \$(FROMC): %: %.c - \$(CC) \$(CCFLAGS) \$(OPTIMIZE) -DVERSION_STRING=\\"\$(RPMTOOLSVERSION)\\" \$< \$(LIBRPM) \$(INCRPM) -o \$@ + \$(CC) \$(CCFLAGS) \$(OPTIMIZE) -DVERSION_STRING=\\"\$(RPMTOOLSVERSION)\\" $ccflags \$< \$(LIBRPM) \$(INCRPM) -o \$@ buildc: \$(FROMC) \$(FROMCC) diff --git a/parsehdlist.c b/parsehdlist.c index 32143e4..f460961 100644 --- a/parsehdlist.c +++ b/parsehdlist.c @@ -12,10 +12,12 @@ #include <string.h> #include <ctype.h> -#include <rpm/rpmlib.h> -#if defined(RPM_FORMAT_VERSION) && RPM_FORMAT_VERSION >= 5 +#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 |