aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.PL26
-rw-r--r--URPM.xs55
2 files changed, 40 insertions, 41 deletions
diff --git a/Makefile.PL b/Makefile.PL
index f760e93..f7271d3 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -16,13 +16,18 @@ unless (defined $rpm_path) {
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 $pversion = eval "v$version";
-$pversion ge v4.2 or die "Unable to build URPM with too old (or undetected) rpm version $version\n";
+my $hversion = hexversion($version);
+$hversion ge hexversion("4.2") or die "Unable to build URPM with too old (or undetected) rpm version $version\n";
# to generate the ChangeLog depending on the checkout layout
my $commonusername = "../common/";
@@ -45,23 +50,12 @@ ChangeLog:
}
my @rpmflags;
-if ($pversion ge v4.4.90 && $pversion lt v4.5) {
+if ($hversion ge hexversion("4.4.90") && $hversion lt hexversion("4.5")) {
# rpm.org version
- push @rpmflags, '-DRPM_ORG';
+ push @rpmflags, "-DRPM_ORG";
} else {
# rpm5.org version
- if ($pversion ge v4.4.6) {
- push @rpmflags, '-DRPM_446';
- }
- if ($pversion ge v4.4.8) {
- push @rpmflags, '-DRPM_448';
- }
- if ($pversion ge v4.5) {
- push @rpmflags, '-DRPM_450';
- }
- if ($pversion ge v5.0) {
- push @rpmflags, '-DRPM_500';
- }
+ push @rpmflags, "-DRPM_VERSION_CODE=$hversion";
}
my $ccflags = join(' ', '-Wall -fno-strict-aliasing', @rpmflags);
diff --git a/URPM.xs b/URPM.xs
index 8f9bfbb..df5cd0c 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -27,6 +27,8 @@
#undef Mkdir
#undef Stat
+#define RPM_VERSION(maj,min,pl) (((maj) << 16) + ((min) << 8) + (pl))
+
#ifdef RPM_ORG
#define byte uint8_t
static inline void *_free(const void * p) {
@@ -35,8 +37,10 @@ static inline void *_free(const void * p) {
}
typedef struct rpmSpec_s * Spec;
#else
-#if !defined(RPM_450) || !defined(RPM_500)
+#if RPM_VERSION_CODE < RPM_VERSION(5,0,0)
#define rpmtsImportPubkey rpmcliImportPubkey
+#endif
+#if RPM_VERSION_CODE <= RPM_VERSION(4,5,0)
#define rpmProblemGetType(p) p->type
#define rpmProblemGetPkgNEVR(p) p->pkgNEVR
#define rpmProblemGetAltNEVR(p) p->altNEVR
@@ -44,14 +48,14 @@ typedef struct rpmSpec_s * Spec;
#define rpmProblemGetLong(p) p->ulong1
#endif
#endif
-#ifdef RPM_446
+#if RPM_VERSION_CODE >= RPM_VERSION(4,4,6)
# define _RPMPS_INTERNAL
#endif
-#ifdef RPM_450
+#if RPM_VERSION_CODE >= RPM_VERSION(4,5,0)
# define _RPMEVR_INTERNAL
#include <rpm/rpmevr.h>
#endif
-#ifdef RPM_500
+#if RPM_VERSION_CODE >= RPM_VERSION(5,0,0)
#include <rpm/rpm4compat.h>
#else
@@ -139,7 +143,8 @@ static const void* unused_variable(const void *p) {
}
static int rpmError_callback_data;
-#if defined(RPM_ORG) || defined(RPM_500)
+#if defined(RPM_ORG) || RPM_VERSION_CODE >= RPM_VERSION(5,0,0)
+
int rpmError_callback() {
write_nocheck(rpmError_callback_data, rpmlogMessage(), strlen(rpmlogMessage()));
return RPMLOG_DEFAULT;
@@ -580,7 +585,7 @@ return_list_tag(URPM__Package pkg, int_32 tag_name) {
switch (type) {
case RPM_NULL_TYPE:
break;
-#ifndef RPM_500
+#if RPM_VERSION_CODE < RPM_VERSION(5,0,0)
case RPM_CHAR_TYPE:
#endif
case RPM_INT8_TYPE:
@@ -1205,7 +1210,7 @@ static void drop_tags(Header *h) {
headerRemoveEntry(*h, RPMTAG_FILESIZES); /* ? */
headerRemoveEntry(*h, RPMTAG_FILERDEVS); /* it seems unused. always empty */
headerRemoveEntry(*h, RPMTAG_FILEVERIFYFLAGS); /* only used for -V */
-#ifdef RPM_446
+#if RPM_VERSION_CODE >= RPM_VERSION(4,4,6)
headerRemoveEntry(*h, RPMTAG_FILEDIGESTALGOS); /* only used for -V */
headerRemoveEntry(*h, RPMTAG_FILEDIGESTS); /* only used for -V */ /* alias: RPMTAG_FILEMD5S */
#endif
@@ -1310,7 +1315,7 @@ ts_nosignature(rpmts ts) {
rpmtsSetVSFlags(ts, _RPMVSF_NODIGESTS | _RPMVSF_NOSIGNATURES);
}
-#if HAVE_RPM_RPMCB_H
+#if RPM_VERSION_CODE >= RPM_VERSION(4,4,5)
typedef uint64_t rpmCallbackSize_t;
#else
typedef unsigned long rpmCallbackSize_t;
@@ -1513,7 +1518,7 @@ int
Pkg_is_arch_compat__XS(pkg)
URPM::Package pkg
INIT:
-#ifdef RPM_448
+#if RPM_VERSION_CODE >= RPM_VERSION(4,4,8)
char * platform;
#endif
CODE:
@@ -1524,7 +1529,7 @@ Pkg_is_arch_compat__XS(pkg)
get_fullname_parts(pkg, NULL, NULL, NULL, &arch, &eos);
*eos = 0;
-#ifdef RPM_448
+#if RPM_VERSION_CODE >= RPM_VERSION(4,4,8)
platform = rpmExpand(arch, "-%{_target_vendor}-%{_target_os}%{?_gnu}", NULL);
RETVAL = rpmPlatformScore(platform, NULL, 0);
_free(platform);
@@ -1534,7 +1539,7 @@ Pkg_is_arch_compat__XS(pkg)
*eos = '@';
} else if (pkg->h && headerIsEntry(pkg->h, RPMTAG_SOURCERPM)) {
char *arch = get_name(pkg->h, RPMTAG_ARCH);
-#ifdef RPM_448
+#if RPM_VERSION_CODE >= RPM_VERSION(4,4,8)
platform = rpmExpand(arch, "-%{_target_vendor}-%{_target_os}%{?_gnu}", NULL);
RETVAL = rpmPlatformScore(platform, NULL, 0);
_free(platform);
@@ -1551,11 +1556,11 @@ int
Pkg_is_platform_compat(pkg)
URPM::Package pkg
INIT:
-#ifdef RPM_448
+#if RPM_VERSION_CODE >= RPM_VERSION(4,4,8)
char * platform = NULL;
#endif
CODE:
-#ifdef RPM_448
+#if RPM_VERSION_CODE >= RPM_VERSION(4,4,8)
read_config_files(0);
if (pkg->h && headerIsEntry(pkg->h, RPMTAG_PLATFORM)) {
int_32 count, type;
@@ -2948,7 +2953,7 @@ Trans_add(trans, pkg, ...)
CODE:
if ((pkg->flag & FLAG_ID) <= FLAG_ID_MAX && pkg->h != NULL) {
int update = 0;
-#ifdef RPM_446
+#if RPM_VERSION_CODE >= RPM_VERSION(4,4,6)
rpmRelocation relocations = NULL;
#else
rpmRelocation *relocations = NULL;
@@ -2968,7 +2973,7 @@ Trans_add(trans, pkg, ...)
if (SvROK(ST(i+1)) && SvTYPE(SvRV(ST(i+1))) == SVt_PVAV) {
AV *excludepath = (AV*)SvRV(ST(i+1));
I32 j = 1 + av_len(excludepath);
-#ifdef RPM_446
+#if RPM_VERSION_CODE >= RPM_VERSION(4,4,6)
relocations = calloc(j + 1, sizeof(*relocations));
#else
relocations = calloc(j + 1, sizeof(rpmRelocation));
@@ -3277,7 +3282,7 @@ Urpm_list_rpm_tag(urpm=Nullsv)
while (ext->name != NULL) {
if (ext->type == HEADER_EXT_MORE) {
-#ifdef RPM_500
+#if RPM_VERSION_CODE >= RPM_VERSION(5,0,0)
ext = *ext->u.more;
#else
ext = ext->u.more;
@@ -3745,12 +3750,12 @@ int
Urpm_archscore(arch)
const char * arch
PREINIT:
-#ifdef RPM_448
+#if RPM_VERSION_CODE >= RPM_VERSION(4,4,8)
char * platform = NULL;
#endif
CODE:
read_config_files(0);
-#ifdef RPM_448
+#if RPM_VERSION_CODE >= RPM_VERSION(4,4,8)
platform = rpmExpand(arch, "-%{_target_vendor}-%{_target_os}%{?_gnu}", NULL);
RETVAL=rpmPlatformScore(platform, NULL, 0);
_free(platform);
@@ -3764,12 +3769,12 @@ int
Urpm_osscore(os)
const char * os
PREINIT:
-#ifdef RPM_448
+#if RPM_VERSION_CODE >= RPM_VERSION(4,4,8)
char * platform = NULL;
#endif
CODE:
read_config_files(0);
-#ifdef RPM_448
+#if RPM_VERSION_CODE >= RPM_VERSION(4,4,8)
platform = rpmExpand("%{_target_cpu}-%{_target_vendor}-", os, "%{?_gnu}", NULL);
RETVAL=rpmPlatformScore(platform, NULL, 0);
_free(platform);
@@ -3784,7 +3789,7 @@ Urpm_platformscore(platform)
const char * platform
CODE:
read_config_files(0);
-#ifdef RPM_448
+#if RPM_VERSION_CODE >= RPM_VERSION(4,4,8)
RETVAL=rpmPlatformScore(platform, NULL, 0);
#else
unused_variable(platform);
@@ -3832,11 +3837,11 @@ Urpm_spec2srcheader(specfile)
/* check what it does */
#define SPEC_VERIFY 0
if (!parseSpec(ts, specfile, "/"
-#ifndef RPM_448
+#if RPM_VERSION_CODE < RPM_VERSION(4,4,8)
, NULL
#endif
, 0, NULL, NULL, SPEC_ANYARCH, SPEC_FORCE
-#ifdef RPM_448
+#if RPM_VERSION_CODE >= RPM_VERSION(4,4,8)
, SPEC_VERIFY
#endif
)) {
@@ -3845,7 +3850,7 @@ Urpm_spec2srcheader(specfile)
spec = rpmtsSetSpec(ts, NULL);
if (! spec->sourceHeader)
initSourceHeader(spec
-#ifdef RPM_450
+#if RPM_VERSION_CODE >= RPM_VERSION(4,5,0)
, NULL
#endif
);
@@ -3918,7 +3923,7 @@ rpmErrorWriteTo(fd)
CODE:
rpmError_callback_data = fd;
rpmlogSetCallback(rpmError_callback
-#if defined(RPM_ORG) || defined(RPM_500)
+#if defined(RPM_ORG) || RPM_VERSION_CODE >= RPM_VERSION(5,0,0)
, NULL
#endif
);