my $fname = shift @ARGV or die;
my $add = shift @ARGV or die;
-my $msg = shift @ARGV or die;
+my $msg = shift @ARGV || "requested";
$SIG{__WARN__} = sub
{
warn "Adding: $add\n";
-my $file = "$ENV{HOME}/rpm/packages/$fname/$fname.spec";
--r $file or die;
+my $file = $fname;
+$file = "$ENV{HOME}/rpm/packages/$fname/$fname.spec"
+ unless -r $file;
+-r $file or die "Can't read $file";
open FILE, "<", $file;
my @in = <FILE>;
close FILE;
-my $brm = qr/#?(?:%{!?\?with_\S+:)?\s*BuildRequires:\s*(\S+)\s*(?:(>|>=|==|<=|<).*)?}?/i;
+my $brm = qr/#?(?:%\{!?\?with_\S+:)?\s*BuildRequires:\s*(\S+)\s*(?:(>|>=|==|<=|<).*)?\}?/i;
foreach ( @in ) {
if ( /^$brm$/o ) {
if ( $1 eq $add ) {
warn "$add already on the list\n";
- exit;
+ exit(1);
}
}
my @out;
while ( $_ = shift @in ) {
- if ( /^\s*(build(requires|root|conflicts)|requires(\(.*\))?|provides|conflicts|obsoletes):/i ) {
+ if ( /^\s*(build(requires|root|conflicts|arch)|requires(\(.*\))?|provides|conflicts|obsoletes|excludearch):/i ) {
unshift @in, $_;
last;
}