6 my $fname = shift @ARGV or die;
7 my $add = shift @ARGV or die;
8 my $msg = shift @ARGV or die;
14 print STDERR "\033[32;1m" . $_ . "\033[0m\n"
17 warn "Adding: $add\n";
19 my $file = "$ENV{HOME}/rpm/packages/$fname/$fname.spec";
22 open FILE, "<", $file;
26 my $brm = qr/#?(?:%{!?\?with_\S+:)?\s*BuildRequires:\s*(\S+)\s*(?:(>=|==|<=).*)?}?/i;
30 warn "$add already on the list\n";
38 while ( $_ = shift @in ) {
39 if ( /^\s*(build(requires|root|conflicts)|requires(\(.*\))?|provides|conflicts|obsoletes):/i ) {
47 while ( $_ = shift @in ) {
51 while ( $_ = shift @in ) {
55 } elsif ( /^%endif/ ) {
61 } elsif ( /^$brm$/o ) {
65 if ( $add lt $name ) {
66 push @out, "# AUTO: $msg\n";
67 push @out, "BuildRequires:\t$add\n";
72 } elsif ( /^\s*$/ or /^\s*#/ ) {
76 push @out, "# AUTO: $msg\n";
77 push @out, "BuildRequires:\t$add\n";
88 open FILE, ">", $file;