forked from pool/obs-service-format_spec_file
Accepting request 106046 from openSUSE:Tools
- fix sorting of tag lines that are not on the beginning of the file - not only break buildrequires per (sorted) line, but also Requires and Provides OBS-URL: https://build.opensuse.org/request/show/106046 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/obs-service-format_spec_file?expand=0&rev=24
This commit is contained in:
commit
ba8cfd5ad2
@ -1,3 +1,14 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Feb 20 13:19:09 UTC 2012 - coolo@suse.com
|
||||||
|
|
||||||
|
- fix sorting of tag lines that are not on the beginning of the file
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Feb 20 08:15:52 UTC 2012 - coolo@suse.com
|
||||||
|
|
||||||
|
- not only break buildrequires per (sorted) line, but also
|
||||||
|
Requires and Provides
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Feb 14 11:05:24 UTC 2012 - coolo@suse.com
|
Tue Feb 14 11:05:24 UTC 2012 - coolo@suse.com
|
||||||
|
|
||||||
|
53
prepare_spec
53
prepare_spec
@ -230,7 +230,7 @@ sub set_current_pkg {
|
|||||||
return ($curpack, $curlang);
|
return ($curpack, $curlang);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub sort_buildrequires_helper {
|
sub sort_tags_helper {
|
||||||
if (($a =~ /^[^#]*\(/) != ($b =~ /^[^#]*\(/)) {
|
if (($a =~ /^[^#]*\(/) != ($b =~ /^[^#]*\(/)) {
|
||||||
if ($a =~ /^[^#]*\(/) {
|
if ($a =~ /^[^#]*\(/) {
|
||||||
1;
|
1;
|
||||||
@ -317,18 +317,23 @@ sub read_and_parse_old_spec {
|
|||||||
$_ =~ s/%{?epoch}?[:-]//g;
|
$_ =~ s/%{?epoch}?[:-]//g;
|
||||||
$_ =~ s/ 0:/ /g if ( /^requires/i || /^buildreq/i );
|
$_ =~ s/ 0:/ /g if ( /^requires/i || /^buildreq/i );
|
||||||
|
|
||||||
if ( /^BuildRequires:/ ) {
|
if ( /^BuildRequires:/i || /^Requires:/i || /^Provides:/i ) {
|
||||||
my $cur_buildreq = $_;
|
my $cur_tag = $_;
|
||||||
$cur_buildreq =~ s/^BuildRequires:\s*//;
|
my $tag = '';
|
||||||
|
if (m/^(\S+):\s*(.*)$/) {
|
||||||
|
$tag = $1;
|
||||||
|
$cur_tag = $2;
|
||||||
|
}
|
||||||
|
|
||||||
my %aa;
|
my %aa;
|
||||||
while ($cur_buildreq =~ m{([^,\s]+(\s*[<=>]+\s*[^,\s]+)?)}g) {
|
while ($cur_tag =~ m{([^,\s]+(\s*[<=>]+\s*[^,\s]+)?)}g) {
|
||||||
$aa{$1}=1;
|
$aa{$1}=1;
|
||||||
}
|
}
|
||||||
# ignore line if it looks like a "usedforbuild" line, i.e.
|
# ignore line if it looks like a "usedforbuild" line, i.e.
|
||||||
# if it contains too many base packages
|
# if it contains too many base packages
|
||||||
next if (grep {$aa{$_}} qw{gcc rpm glibc bash}) > 2;
|
next if (grep {$aa{$_}} qw{gcc rpm glibc bash}) > 2;
|
||||||
for my $br (sort keys(%aa)) {
|
for my $value (sort keys(%aa)) {
|
||||||
push @oldspec, "BuildRequires: $br";
|
push (@oldspec, sprintf("%-16s%s", capitalize_case($tag) . ":", $value));
|
||||||
}
|
}
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
@ -617,30 +622,38 @@ if ( ! stat ((glob("$specdir/$base_package*.spec"))[0] || "") ) {
|
|||||||
|
|
||||||
read_and_parse_old_spec ( $specfile, $base_package );
|
read_and_parse_old_spec ( $specfile, $base_package );
|
||||||
|
|
||||||
my $linesmoved = 1;
|
for my $tag (qw(BuildRequires Requires Provides)) {
|
||||||
while ($linesmoved) {
|
my $linesmoved = 1;
|
||||||
|
sortcycle: while ($linesmoved) {
|
||||||
$linesmoved = 0;
|
$linesmoved = 0;
|
||||||
my @firstlines = ();
|
my @firstlines = ();
|
||||||
my @buildrequires = ();
|
my @tags = ();
|
||||||
while ($oldspec[0]) {
|
while ($oldspec[0]) {
|
||||||
my $l = shift @oldspec;
|
my $l = shift @oldspec;
|
||||||
if ($l =~ m/^BuildRequires:/ ) {
|
if ($l =~ m/^$tag:/ ) {
|
||||||
push(@buildrequires, $l);
|
push(@tags, $l);
|
||||||
} else {
|
} else {
|
||||||
# if there are already buildrequires, we need to sort and exit
|
# if there are already tags, we need to sort and exit
|
||||||
if (@buildrequires > 0) {
|
if (@tags > 0) {
|
||||||
my @sortedbrs = sort sort_buildrequires_helper @buildrequires;
|
my @sortedtags = sort sort_tags_helper @tags;
|
||||||
$linesmoved = !compare_arrays(\@buildrequires, \@sortedbrs);
|
$linesmoved = !compare_arrays(\@tags, \@sortedtags);
|
||||||
@oldspec = (@firstlines, @sortedbrs, $l, @oldspec);
|
if ($linesmoved) {
|
||||||
@firstlines = ();
|
@oldspec = (@firstlines, @sortedtags, $l, @oldspec);
|
||||||
@buildrequires = ();
|
@firstlines = ();
|
||||||
last;
|
@tags = ();
|
||||||
|
next sortcycle;
|
||||||
|
} else {
|
||||||
|
@firstlines = (@firstlines, @tags, $l);
|
||||||
|
@tags = ();
|
||||||
|
next;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
push(@firstlines, $l);
|
push(@firstlines, $l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@oldspec = (@firstlines, @oldspec);
|
@oldspec = (@firstlines, @oldspec);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user