- don't stop sorting at empty lines in %description

- fix indenting of the script

OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-format_spec_file?expand=0&rev=66
This commit is contained in:
Stephan Kulow 2012-02-24 09:49:42 +00:00 committed by Git OBS Bridge
parent bab35e6fd3
commit b6a7748a7b
3 changed files with 271 additions and 270 deletions

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri Feb 24 09:48:57 UTC 2012 - coolo@suse.com
- don't stop sorting at empty lines in %description
- fix indenting of the script
-------------------------------------------------------------------
Mon Feb 20 13:19:09 UTC 2012 - coolo@suse.com

View File

@ -34,8 +34,7 @@ my $ifhandler;
my $definelist;
my $debug = 0;
my @global_tags_list =
(
my @global_tags_list = (
'Autoreq',
'Autoreqprov',
'BuildArch',
@ -77,8 +76,7 @@ sub unify {
return grep(delete($h{$_}), @_);
}
sub capitalize_case($)
{
sub capitalize_case($) {
my ($tag) = @_;
$tag = lc($tag);
@ -103,14 +101,14 @@ sub compare_arrays {
return 1;
}
sub maybe_add_empty_line()
{
sub maybe_add_empty_line() {
return if $current_section eq "description";
push @oldspec, "XXXBLANKLINE"
if ($current_section ne "description" && $oldspec[-1] !~ /^\s*$/ && $oldspec[-1] !~ /^[#%]/);
if ($oldspec[-1] !~ /^\s*$/ && $oldspec[-1] !~ /^[#%]/);
}
sub change_section($)
{
sub change_section($) {
my ($new_section) = @_;
maybe_add_empty_line();
@ -122,8 +120,7 @@ sub change_section($)
my %license_replace = ();
use File::Basename;
sub load_license_map()
{
sub load_license_map() {
return if defined $license_replace{"GPL-2.0"};
my $scriptdir = File::Basename::dirname($0);
open(MAP, "$scriptdir/licenses_changes.txt") || die "can't open licenses_changes.txt";
@ -147,8 +144,7 @@ sub load_license_map()
}
}
sub replace_single_spdx($)
{
sub replace_single_spdx($) {
my ($l) = @_;
return '' if $l eq '';
@ -168,8 +164,7 @@ sub replace_single_spdx($)
}
sub replace_spdx_and($);
sub replace_spdx_and($)
{
sub replace_spdx_and($) {
my ($license) = @_;
# special case as or later is common in our spec files
@ -198,8 +193,7 @@ sub replace_spdx_and($)
return join('', @licenses);
}
sub replace_spdx($)
{
sub replace_spdx($) {
my ($license) = @_;
my @licenses = ();
@ -263,7 +257,8 @@ sub read_and_parse_old_spec {
if ( /^\s*$/ && $current_section ne "description") {
# stop preamble parsing on two blank lines
if ($print_comments eq "false" && $oldspec[0] && $oldspec[-1] eq "XXXBLANKLINE") {
if ($print_comments eq "false" &&
$oldspec[0] && $oldspec[-1] eq "XXXBLANKLINE") {
$print_comments = "true";
push @oldspec, "XXXDOUBLELINE";
next;
@ -300,8 +295,7 @@ sub read_and_parse_old_spec {
}
if ( /^#\s*Copyright\s*/ ) {
my $lastlineblank = 0;
for (;;)
{
for (;;) {
# check if line is ONLY a standard copyright line, if so, ignore.
my $c = $_;
$c =~ s{\s*(\d+|copyrights?|\(c\)|suse|linux|products|gmbh|nuremberg|n..?rnberg|germany|\W+)\s*}{}gi;
@ -317,7 +311,7 @@ sub read_and_parse_old_spec {
$_ =~ s/%{?epoch}?[:-]//g;
$_ =~ s/ 0:/ /g if ( /^requires/i || /^buildreq/i );
if ( /^BuildRequires:/i || /^Requires:/i || /^Provides:/i ) {
if ( /^BuildRequires:/i || /^Requires:/i || /^Provides:/i || /^Obsoletes:/i ) {
my $cur_tag = $_;
my $tag = '';
if (m/^(\S+):\s*(.*)$/) {
@ -608,6 +602,7 @@ warn ("base_package is $base_package\n") if $debug;
if ( ! stat ((glob("$specdir/$base_package*.spec"))[0] || "") ) {
$base_package =~ s/[0-9]$//;
}
if ( ! stat ((glob("$specdir/$base_package*.spec"))[0] || "") ) {
$base_package =~ s/\-[^\-]*$//;
}
@ -622,15 +617,15 @@ if ( ! stat ((glob("$specdir/$base_package*.spec"))[0] || "") ) {
read_and_parse_old_spec ( $specfile, $base_package );
for my $tag (qw(BuildRequires Requires Provides)) {
for my $tag (qw(BuildRequires Requires Provides Obsoletes)) {
my $linesmoved = 1;
sortcycle: while ($linesmoved) {
$linesmoved = 0;
my @firstlines = ();
my @tags = ();
while ($oldspec[0]) {
while (defined $oldspec[0]) {
my $l = shift @oldspec;
if ($l =~ m/^$tag:/ ) {
if ($l =~ m/^$tag:/i ) {
push(@tags, $l);
} else {
# if there are already tags, we need to sort and exit