aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--URPM.xs9
-rw-r--r--t/parse.t9
2 files changed, 13 insertions, 5 deletions
diff --git a/URPM.xs b/URPM.xs
index b05d410..23a1950 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -3654,24 +3654,27 @@ Urpm_spec2srcheader(specfile)
URPM__Package pkg;
Spec spec = NULL;
PPCODE:
+/* Do not verify architecture */
#define SPEC_ANYARCH 1
+/* Do not verify whether sources exist */
#define SPEC_FORCE 1
if (!parseSpec(ts, specfile, "/", NULL, 0, NULL, NULL, SPEC_ANYARCH, SPEC_FORCE)) {
+ SV *sv_pkg;
spec = rpmtsSetSpec(ts, NULL);
- if ( ! spec->sourceHeader)
+ if (! spec->sourceHeader)
initSourceHeader(spec);
pkg = (URPM__Package)malloc(sizeof(struct s_Package));
memset(pkg, 0, sizeof(struct s_Package));
pkg->h = headerLink(spec->sourceHeader);
- SV *sv_pkg;
EXTEND(SP, 1);
sv_pkg = sv_newmortal();
sv_setref_pv(sv_pkg, "URPM::Package", (void*)pkg);
PUSHs(sv_pkg);
spec = freeSpec(spec);
+ } else {
+ PUSHs(&PL_sv_undef);
}
ts = rpmtsFree(ts);
-
void
expand(name)
diff --git a/t/parse.t b/t/parse.t
index afe59b3..d27c15f 100644
--- a/t/parse.t
+++ b/t/parse.t
@@ -4,12 +4,15 @@
use strict;
use warnings;
-use Test::More tests => 26;
+use Test::More tests => 27;
use MDV::Packdrakeng;
use URPM;
use URPM::Build;
use URPM::Query;
+# shut up
+URPM::setVerbosity(2);
+
my $a = new URPM;
ok($a);
@@ -66,5 +69,7 @@ ok(URPM::rpmvercmp("1:1-1mdk", "2:1-1mdk") == -1, "epoch 1 vs 2 = -1");
{
my $pkg = URPM::spec2srcheader("test-rpm.spec");
ok(defined $pkg, "Parsing a spec works");
- ok($pkg->get_tag(1000) eq 'test-rpm');
+ ok($pkg->get_tag(1000) eq 'test-rpm', 'parsed correctly');
+ $pkg = URPM::spec2srcheader("doesnotexist.spec");
+ ok(!defined $pkg, "non-existent spec");
}