6 my $fname = shift @ARGV or die;
7 my $add = shift @ARGV or die;
8 my $msg = shift @ARGV || "requested";
14 print STDERR "\033[32;1m" . $_ . "\033[0m\n"
17 warn "Adding: $add\n";
20 $file = "$ENV{HOME}/rpm/packages/$fname/$fname.spec"
22 -r $file or die "Can't read $file";
24 open FILE, "<", $file;
28 my $brm = qr/#?(?:%\{!?\?with_\S+:)?\s*BuildRequires:\s*(\S+)\s*(?:(>|>=|==|<=|<).*)?\}?/i;
32 warn "$add already on the list\n";
40 while ( $_ = shift @in ) {
41 if ( /^\s*(build(requires|root|conflicts|arch)|requires(\(.*\))?|provides|conflicts|obsoletes|excludearch):/i ) {
49 while ( $_ = shift @in ) {
53 while ( $_ = shift @in ) {
57 } elsif ( /^%endif/ ) {
63 } elsif ( /^$brm$/o ) {
67 if ( $add lt $name ) {
68 push @out, "# AUTO: $msg\n";
69 push @out, "BuildRequires:\t$add\n";
74 } elsif ( /^\s*$/ or /^\s*#/ ) {
78 push @out, "# AUTO: $msg\n";
79 push @out, "BuildRequires:\t$add\n";
90 open FILE, ">", $file;