my $file = shift;
my $flags = shift;
- $flags = RPM2->vsf_default unless defined $flags;
+ if (RPM2->rpm_api_version > 4.0 and not defined $flags) {
+ $flags = RPM2->vsf_default;
+ }
+ $flags ||= 0;
open FH, "<$file"
or die "Can't open $file: $!";
sub is_source_package {
my $self = shift;
- return $self->tag("sourcepackage");
+ return RPM2::C::Header::_header_is_source($self->{c_header});
}
sub filename {
#include "perl.h"
#include "XSUB.h"
+#if !defined(RPM2_RPM41) && !defined(RPM2_RPM40)
+#error Must define one of RPM2_RPM41 or RPM2_RPM40; perhaps Makefile.PL could not guess your RPM API version?
+#endif
+
void
_populate_header_tags(HV *href)
{
constants = perl_get_hv("RPM2::constants", TRUE);
/* not the 'standard' way of doing perl constants, but a lot easier to maintain */
+#ifdef RPM2_RPM41
REGISTER_CONSTANT(RPMVSF_DEFAULT);
REGISTER_CONSTANT(RPMVSF_NOHDRCHK);
REGISTER_CONSTANT(RPMVSF_NEEDPAYLOAD);
REGISTER_CONSTANT(_RPMVSF_NOSIGNATURES);
REGISTER_CONSTANT(_RPMVSF_NOHEADER);
REGISTER_CONSTANT(_RPMVSF_NOPAYLOAD);
+#endif
}
+double
+rpm_api_version(pkg)
+ char * pkg
+ CODE:
+#if defined(RPM2_RPM41) && ! defined(RPM2_RPM40)
+ RETVAL = (double)4.1;
+#endif
+#if ! defined(RPM2_RPM41) && defined(RPM2_RPM40)
+ RETVAL = (double)4.0;
+#endif
+ OUTPUT:
+ RETVAL
+
+
void
add_macro(pkg, name, val)
char * pkg
OUTPUT:
RETVAL
+int
+_header_is_source(h)
+ Header h
+ CODE:
+ RETVAL = headerIsEntry(h, RPMTAG_SOURCEPACKAGE);
+ OUTPUT:
+ RETVAL
+
void
_header_sprintf(h, format)
Header h
use Test;
use strict;
-BEGIN { plan tests => 33 };
+BEGIN { plan tests => 35 };
use RPM2;
ok(1); # If we made it this far, we're ok.
RPM2->delete_macro("rpm2_test_macro");
ok(RPM2->expand_macro("%rpm2_test_macro") eq "%rpm2_test_macro");
-ok(RPM2->vsf_nosha1 == 65536);
+ok(RPM2->rpm_api_version == 4.1 or RPM2->rpm_api_version == 4.0);
+ok(RPM2->rpm_api_version == 4.0 or RPM2->vsf_nosha1 == 65536);