From 6255fb10af875dff54ef97525e19f1d2e075c6be Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Wed, 17 Dec 2014 13:50:57 +0100 Subject: [PATCH] correctly support BuildConflicts Parsing needs to be enabled with $Build::Rpm::conflictdeps = 1 --- Build.pm | 8 ++++++-- Build/Rpm.pm | 11 ++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Build.pm b/Build.pm index f058ede17..ddc625850 100644 --- a/Build.pm +++ b/Build.pm @@ -867,10 +867,14 @@ sub expand { } @directdepsend = grep {!/^-/} splice(@directdepsend, @p + 1); } - @p = grep {!/^-/} @p; - my %p; # expanded packages my %aconflicts; # packages we are conflicting with + for (grep {/^!/} @p) { + $aconflicts{substr($_, 1)} = "is in BuildConflicts"; + } + + @p = grep {!/^[-!]/} @p; + my %p; # expanded packages # add direct dependency packages. this is different from below, # because we add packages even if the dep is already provided and diff --git a/Build/Rpm.pm b/Build/Rpm.pm index 4bdf78d9a..5d03620f6 100644 --- a/Build/Rpm.pm +++ b/Build/Rpm.pm @@ -21,6 +21,7 @@ package Build::Rpm; our $unfilteredprereqs = 0; +our $conflictdeps = 0; use strict; @@ -257,7 +258,7 @@ sub parse { next; } if ($line =~ /^\s*#/) { - next unless $line =~ /^#!BuildIgnore/; + next unless $line =~ /^#!Build(?:Ignore|Conflicts)\s*:/i; } my $expandedline = ''; if (!$skip && ($line =~ /%/)) { @@ -418,7 +419,7 @@ reexpand: if ($skip) { $xspec->[-1] = [ $xspec->[-1], undef ] if $xspec; - $ifdeps = 1 if $line =~ /^(BuildRequires|BuildPrereq|BuildConflicts|\#\!BuildIgnore)\s*:\s*(\S.*)$/i; + $ifdeps = 1 if $line =~ /^(BuildRequires|BuildPrereq|BuildConflicts|\#\!BuildIgnore|\#\!BuildConflicts)\s*:\s*(\S.*)$/i; next; } @@ -488,7 +489,7 @@ reexpand: } next; } - if ($preamble && ($line =~ /^(BuildRequires|BuildPrereq|BuildConflicts|\#\!BuildIgnore)\s*:\s*(\S.*)$/i)) { + if ($preamble && ($line =~ /^(BuildRequires|BuildPrereq|BuildConflicts|\#\!BuildIgnore|\#\!BuildConflicts)\s*:\s*(\S.*)$/i)) { my $what = $1; my $deps = $2; $ifdeps = 1 if $hasif; @@ -530,6 +531,10 @@ reexpand: $replace = 1 if grep {/^-/} @ndeps; if (lc($what) ne 'buildrequires' && lc($what) ne 'buildprereq') { + if ($conflictdeps && $what =~ /conflict/i) { + push @packdeps, map {"!$_"} @ndeps; + next; + } push @packdeps, map {"-$_"} @ndeps; next; }