commit 419a9e9feb7d2d52ed85954795dfbfc91e941a370a78c57ba090670f4be1c8a8 Author: Adrian Schröter Date: Wed May 25 12:17:35 2011 +0000 Accepting request 71284 from openSUSE:Tools:Unstable move to stable project OBS-URL: https://build.opensuse.org/request/show/71284 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-format_spec_file?expand=0&rev=1 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/format_spec_file b/format_spec_file new file mode 100644 index 0000000..da13fda --- /dev/null +++ b/format_spec_file @@ -0,0 +1,27 @@ +#!/bin/bash + +# just a wrapper for the perl script. + + +while test $# -gt 0; do + case $1 in + *-outdir) + MYOUTDIR="$2" + shift + ;; + *) + echo Unknown parameter $1. + echo 'Usage: this service is not excepting parameters' + exit 1 + ;; + esac + shift +done + +RETURN=0 +for i in *.spec; do + /usr/lib/obs/service/format_spec_file.files/prepare_spec "$i" > "$MYOUTDIR/$i" || RETURN=1 +done + +exit $RETURN + diff --git a/format_spec_file.service b/format_spec_file.service new file mode 100644 index 0000000..8b502ac --- /dev/null +++ b/format_spec_file.service @@ -0,0 +1,5 @@ + + Validate sources + The default SUSE source validator which catches common pitfalls before build. + + diff --git a/obs-service-format_spec_file.changes b/obs-service-format_spec_file.changes new file mode 100644 index 0000000..7d0c5c9 --- /dev/null +++ b/obs-service-format_spec_file.changes @@ -0,0 +1,17 @@ +------------------------------------------------------------------- +Wed May 25 14:00:35 CEST 2011 - ro@suse.de + +- fix uninitialized warning in prepare_spec + +------------------------------------------------------------------- +Wed May 4 01:55:04 CEST 2011 - ro@suse.de + +- cleanup prepare_spec, drop Needed.pm +- make it ready for public usage + +------------------------------------------------------------------- +Wed Jan 26 17:02:42 UTC 2011 - adrian@suse.de + +- initial version. + not usable outside of SUSE network yet. + diff --git a/obs-service-format_spec_file.spec b/obs-service-format_spec_file.spec new file mode 100644 index 0000000..93ac8c1 --- /dev/null +++ b/obs-service-format_spec_file.spec @@ -0,0 +1,38 @@ +Name: obs-service-format_spec_file +License: GPL v2 or later +Group: Development/Tools/Building +Summary: An OBS source service: reformats a spec file to SUSE standard. +Version: 0.1 +Release: 1 +Source: format_spec_file +Source1: format_spec_file.service +Source2: prepare_spec +Requires: osc-source_validator +BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildArch: noarch + +%description +This is a source service for openSUSE Build Service. + +This source service is formating the spec file to SUSE standard. The rational +behind is to make it easier to review spec files from unknown packagers. + +This should be used in "trylocal" mode, so that osc is adapting the existing +spec file instead of creating a new one. + +%prep + +%setup -q -D -T 0 -n . + +%build + +%install +mkdir -p $RPM_BUILD_ROOT/usr/lib/obs/service/format_spec_file.files +install -m 0755 %{SOURCE0} $RPM_BUILD_ROOT/usr/lib/obs/service +install -m 0644 %{SOURCE1} $RPM_BUILD_ROOT/usr/lib/obs/service +install -m 0755 %{SOURCE2} $RPM_BUILD_ROOT/usr/lib/obs/service/format_spec_file.files + +%files +%defattr(-,root,root) +%dir /usr/lib/obs +/usr/lib/obs/service diff --git a/prepare_spec b/prepare_spec new file mode 100644 index 0000000..e27a4d0 --- /dev/null +++ b/prepare_spec @@ -0,0 +1,604 @@ +#! /usr/bin/perl -w +# +# vim:sw=2:et +# + +BEGIN { + unshift @INC, "."; + unshift @INC, "/usr/lib/build/"; +} + +use Time::localtime; +use Data::Dumper; +use strict; + +my @oldspec = (); +my @newspec = (); +my $base_package = ""; +my $neededforbuild = ""; +my $icecreamforbuild = ""; +my $norootforbuild = 0; +my @copyrights = (); +my $needsrootforbuild = 0; +my $needsbinariesforbuild = 0; +my $nodebuginfo = 0; +my %multiline_macros = (); +my $nosrc_result = 0; +my $current_section = "header"; +my $had_debug_package = 0; +my %pkg_version = (); +my %pkg_release = (); +my %please_replace = (); +my %replace_hash = (); +my $build_root = $ENV{'BUILD_ROOT'}; +my $disabled_packs; +my $ifhandler; +my $definelist; +my $debug = 0; + +my @global_tags_list = +( + 'Autoreq', + 'Autoreqprov', + 'BuildArch', + 'BuildArchitectures', + 'BuildRequires', + 'Conflicts', + 'DocDir', + 'Enhances', + 'Enhances', + 'EssentialFor', + 'ExcludeArch', + 'ExclusiveArch', + 'Freshens', + 'NoPatch', + 'NoSource', + 'Obsoletes', + 'Patch\d*', + 'Prefix', + 'PreReq', + 'Provides', + 'Recommends', + 'Requires', + 'Source\d*', + 'Suggests', + 'Supplements', + 'Url', +); + +my $global_tags_re = '^\s*(' . join("|", @global_tags_list) . ')\s*:'; + +my $section_tags_re ='^\s*%(?:clean|check|prep|build|install|pre|post|preun|postun|posttrans|package|' . + 'description|files|triggerin|triggerun|triggerpostun)\b'; + +sub unify { + my %h = map {$_ => 1} @_; + return grep(delete($h{$_}), @_); +} + +sub capitalize_case($) +{ + my ($tag) = @_; + + $tag = lc($tag); + + $tag =~ s/docdir/DocDir/i; + $tag =~ s/arch/Arch/i; + $tag =~ s/patch/Patch/i; + $tag =~ s/source/Source/i; + $tag =~ s/req/Req/i; + $tag =~ s/prov/Prov/i; + $tag =~ s/^(\w)/uc($1)/e; + + return $tag; +} + +sub maybe_add_empty_line() +{ + push @oldspec, "" + if ($current_section ne "description" && $oldspec[-1] !~ /^\s*$/); +} + +sub maybe_add_debug_package() +{ + if ( $ENV{'BUILD_DEBUG_FLAGS'} + && ( !$nosrc_result || $base_package =~ /^kernel/ || $base_package =~ /^java/ || $base_package =~ /^texlive-bin/ || $base_package =~ /^glibc/ ) + && !$nodebuginfo + && !$had_debug_package ) + { + my @spec_back; + while(1) { + my $line = pop @oldspec; + unshift @spec_back, $line; + next if ($line =~ /^\s*$/); + next if ($line =~ /^\s*%if\b/); + last; + } + # insert the %debug_package just before the first %if + push @oldspec, shift @spec_back; + push @oldspec, "%debug_package", @spec_back; + $had_debug_package = 1; + } +} + +sub change_section($) +{ + my ($new_section) = @_; + + maybe_add_empty_line(); + + $current_section = $new_section; + warn "section changed to $current_section\n" if $debug; +} + +sub set_current_pkg { + my ( $arg ) = @_; + print "DEBUG: set_current_pkg receiving $arg\n" if $debug; + my ( @argarray ) = split ( '\s+' , $arg ); + my $curpack = $base_package; + my $curlang = ""; + while (my $carg = shift @argarray) { + next if ($carg eq "%description" || $carg eq "%package" || $carg eq "%prep"); + if ($carg eq "-l") { + $curlang = shift @argarray; + } elsif ($carg eq "-n") { + $curpack = shift @argarray; + } else { + $curpack = "$base_package-" if $base_package; + $curpack .= $carg; + } + } + print "DEBUG: set_current_pkg returning $curpack, $curlang\n" if $debug; + return ($curpack, $curlang); +} + +sub read_and_parse_old_spec { + my ( $specfile, $base_package ) = @_; + my $current_package = $base_package; + my $current_lang = ""; + my $check_printed = "false"; + my $print_comments = "false"; + my %version; + my $ifhandler; + $ifhandler->{"disabled"} = 0; + + my @readspec; + open ( SPEC , "$specfile" ) || die "can't read specfile"; + @readspec = ; + close SPEC; + chomp @readspec; + + while (@readspec) { + $_ = shift @readspec; + if ( /^\s*$/ && $current_section ne "description") { + push @oldspec, "XXXBLANKLINE"; + next; + } + + if ( /^#\s*norootforbuild\s*$/ ) { + $norootforbuild = 1; + next; + } + if ( /^#\s*needsrootforbuild\s*$/ ) { + $needsrootforbuild = 1; + next; + } + if ( /^#\s*needsbinariesforbuild\s*$/ ) { + $needsbinariesforbuild = 1; + next; + } + if ( /^#\s*nodebuginfo\s*$/ ) { + $nodebuginfo = 1; + next; + } + if ( /^#\s*icecream/ ) { + $icecreamforbuild = $_; + $icecreamforbuild =~ s/^#\s*icecream\s*//; + next; + } + if ( /^#\s*Copyright\s*/ ) { + 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; + push(@copyrights, $_) if length $c > 5; + last if length $readspec[0] < 10 || $readspec[0] =~ m{modifications and additions}i || $readspec[0] !~ /^[\#\s]/ + || grep { $readspec[0] =~ /^#\s*$_/ } ("norootforbuild","needsrootforbuild","needsbinariesforbuild","nodebuginfo","icecream","neededforbuild","usedforbuild","Commandline","MD5SUM","!BuildIgnore"); + $_ = shift @readspec; + } + next; + } + if ( /^#\s*neededforbuild/ ) { + $neededforbuild = $_; + $neededforbuild =~ s/^#\s*neededforbuild\s*//; + my (%aa) = (); + foreach my $x (split(' ',$neededforbuild)){ + $aa{$x}=1; + } + $neededforbuild = join(' ',sort keys (%aa)); + + next; + } + # evil epoch removal + next if ( /^Epoch:/ ); + $_ =~ s/%{?epoch}?[:-]//g; + $_ =~ s/ 0:/ /g if ( /^requires/i || /^buildreq/i ); + + if ( /^BuildRequires:/ ) { + my $cur_buildreq = $_; + $cur_buildreq =~ s/^BuildRequires:\s*//; + my %aa; + while ($cur_buildreq =~ m{([^,\s]+(\s*[<=>]+\s*[^,\s]+)?)}g) { + $aa{$1}=1; + } + # ignore line if it looks like a "usedforbuild" line, i.e. + # if it contains too many base packages + next if (grep {$aa{$_}} qw{gcc rpm glibc bash}) > 2; + push @oldspec, "BuildRequires: ".join(' ',sort keys(%aa)); + next; + } + next if ( /^#\s*usedforbuild/ ); + if ( /^%\?__\*BuildRequires:/ ) { + push @oldspec, $_; + next; + } + if ( /^#!__\*BuildRequires:/ ) { + push @oldspec, $_; + next; + } + if ( /^#!BuildIgnore:/ ) { + push @oldspec, $_; + next; + } + if ( /^#/ && $current_section ne "description") { + warn "$_ $current_section\n" if $debug; + if ( $print_comments eq "true" || $readspec[0] =~ /^%define/ || $readspec[0] =~ /^%if/) { + push @oldspec, $_; + } + next; + } + if ( /^%debug_package/ ) { + # remove, we add this ourselves + next; + } + $print_comments = "true" unless /^#/; + + if ( /^%define\s*vendor\s/ || /^%define\s*distribution\s/ ) { + next; + } + if ( /^%define\s+(\w[\w\d]+).*\\$/ ) { + $multiline_macros{$1} = 1; + } + if ( /^\s*%if/ || /^\s*%\{/ || /^\s*%define/ || /^\s*%el/ || /^\s*%endif/ ) { + change_section("header") if ($current_section eq "description"); + push @oldspec, $_; + if ( /^\s*%if\s/ ) { + my @args = split (/\s+/,$_); + $_ =~ s/[\{\}\"]//g for (@args); + $ifhandler->{"last_if_disabled"} = 0; + $ifhandler->{"last_if_if"} = 1; + $ifhandler->{"depth"}++; + my $if_not = 0; + if ( $args[1] =~ /^\!/ ) { + $args[1] =~ s/^\!//; + $if_not = 1; + } + if ( ($args[1] eq "0") + || ($args[1] eq "%name" && $args[2] eq "!=" && $args[3] eq $base_package) + || ($args[1] eq "%name" && $args[2] eq "==" && $args[3] ne $base_package) + || ($args[1] && !$args[3] && !$if_not && $definelist->{$args[1]} && $definelist->{$args[1]} eq "0") + || ($args[2] eq "==" && $args[3] ne "0" && $definelist->{$args[1]} && $definelist->{$args[1]} eq "0") + || ($args[2] eq "!=" && $args[3] eq "0" && $definelist->{$args[1]} && $definelist->{$args[1]} eq "0") + || ($args[1] && !$args[3] && $if_not && $definelist->{$args[1]} && $definelist->{$args[1]} eq "1") + || ($args[1] && $args[2] eq "!=" && $args[3] eq "1" && $definelist->{$args[1]} && $definelist->{$args[1]} eq "1") ) { + $ifhandler->{"disabled"} = $ifhandler->{"depth"}; + $ifhandler->{"last_if_disabled"} = 1; + } + } elsif ( /^\s*%if/ ) { + $ifhandler->{"last_if_disabled"} = 0; + $ifhandler->{"last_if_if"} = 0; + $ifhandler->{"depth"}++; + } elsif ( /^\s*%endif/ ) { + $ifhandler->{"disabled"} = 0 if $ifhandler->{"disabled"} == $ifhandler->{"depth"}; + $ifhandler->{"depth"}--; + } elsif ( /^\s*%else/ ) { + if ($ifhandler->{"disabled"} == $ifhandler->{"depth"} && $ifhandler->{"last_if_disabled"} == 1) { + $ifhandler->{"disabled"} = 0; + } elsif ($ifhandler->{"disabled"} == 0 && $ifhandler->{"depth"} == 1 && $ifhandler->{"last_if_if"} == 1) { + $ifhandler->{"disabled"} = 1; + } + } elsif ( /^\s*%define\s/ ) { + my @args = split (/\s+/,$_); + $_ =~ s/[\{\}\"]//g for (@args); + $args[2] =~ s/\Q$_\E/$definelist->{$_}/g for sort { length($b) <=> length($a) } keys (%{$definelist}); + if ( $args[2] !~ /[\(\)\{\}\@\%\"\\]/ ) { + $definelist->{"%".$args[1]} = $args[2] if $ifhandler->{"disabled"} == 0; + $definelist->{"%{".$args[1]."}"} = $args[2] if $ifhandler->{"disabled"} == 0; + $definelist->{"%{?".$args[1]."}"} = $args[2] if $ifhandler->{"disabled"} == 0; + } + while ($_ =~ /\\$/) { + $_ = shift @readspec; + push @oldspec, $_; + } + } + next; + } + if ( /^%package\b/i or /^%prep\b/i ) { + if (/^%package\b/i) { + change_section("header"); + } else { + change_section("prep"); + } + maybe_add_debug_package(); + $_ =~ s/^(%\w+)/lc($1)/e; + if ($debug) { + warn "key: $_ value: $definelist->{$_}\n" for (sort { length($b) <=> length($a) } keys (%{$definelist})); + } + push @oldspec, $_; + for my $xx (sort { length($b) <=> length($a) } keys (%{$definelist})) { + $_ =~ s/\Q$xx\E/$definelist->{$xx}/; + } + $_ =~ s/%{\?[^\}]*}//; + if ($debug) { + warn "after: $_\n"; + } + ($current_package, $current_lang) = set_current_pkg ( $_ ); + $disabled_packs->{$current_package} = 1 if $ifhandler->{"disabled"}; + warn "$current_package is disabled\n" if $ifhandler->{"disabled"} && $debug; + next; + } + if ( /^%description\b/i ) { + change_section("description"); + $_ =~ s/^(%\w+)/lc($1)/e; + push @oldspec, $_; + ($current_package, $current_lang) = set_current_pkg ( $_ ); + my $target = $current_package; + $target .= "_$current_lang" if $current_lang; + $target .= "_disabled" if $ifhandler->{"disabled"}; + push @oldspec, "XXXDESCRIPTION $target"; + next; + } + if ( /^%install\b/i ) { + change_section("install"); + push @oldspec, $_; + next; + } + if ( /^%changelog\b/i ) { + change_section("changelog"); + # changelog comes always from *.changes. Skip what is in spec file + # at the moment. + next; + } + if (/^%files\b/i) { + change_section("files"); + $current_section = "files"; + } + if ( /^%/ ) { + if ( m/$section_tags_re/oi ) { + $_ =~ s/^(%\w+)/lc($1)/e; + change_section("header") if (! m/\s*%files/i && !m/\s*%build/i); + change_section("build") if m/\s*%build/i; + warn "changed to $current_section for $_\n" if $debug; + } + + push @oldspec, $_; + # multiline macros need an extra newline with old RPMs + if (/^%(\w[\w\d]+).*[^\\]$/) { + push @oldspec, "" if (defined($multiline_macros{$1})); + } + next; + } + if ($current_section eq "header") { + if ( /^Summary\b\s*:\s*(.*)/i ) { + $replace_hash{"XXXSUMMARY $current_package"} = sprintf("%-16s%s","Summary:", $1); + push @oldspec, "XXXSUMMARY $current_package"; + next; + } + if ( /^Group\b\s*:\s*(.*)/i ) { + $replace_hash{"XXXGROUP $current_package"} = sprintf("%-16s%s", "Group:", $1); + push @oldspec, "XXXGROUP $current_package"; + next; + } + if ( /^Vendor:/ || /^Distribution:/ || /^Packager:/ ) { + next; + } + if ( /^Name\s*:\s*(.*)/i ) { + my $orig_name = $1; + my $changed_name = $orig_name; + $changed_name =~ s/\Q$_\E/$definelist->{$_}/ for (sort { length($b) <=> length($a) } keys (%{$definelist})); + if ($changed_name eq $base_package) { + push @oldspec, sprintf("\n%-16s%s","Name:", $orig_name); + } else { + push @oldspec, sprintf("\n%-16s%s","Name:", $base_package); + } + $definelist->{"%name"} = $base_package if $ifhandler->{"disabled"} == 0; + $definelist->{"%{name}"} = $base_package if $ifhandler->{"disabled"} == 0; + warn ("line is $_, orig_name is $orig_name, base_package is $base_package\n") if $ifhandler->{"disabled"} == 0 && $debug; + next; + } + if ( /^BuildArchitectures\s*:/i ) { + $_ =~ s/^[^:]+:/BuildArch:/; + } + if ( /^Release\s*:\s*(.*)/i ) { + $pkg_release{$current_package} = $_; + $replace_hash{"XXXRELEASE $current_package"} = sprintf("%-16s%s","Release:", $1); + next; + } + if ( /^BuildRoot\s*:/i ) { + push @oldspec, "BuildRoot: %{_tmppath}/%{name}-%{version}-build"; + next; + } + if ( /^Copyright\s*:\s*(.*)/i || /^License\s*:\s*(.*)/i ) { + $replace_hash{"XXXLICENSE $current_package"} = sprintf("%-16s%s","License:", $1); + push @oldspec, "XXXLICENSE $current_package"; + next; + } + if ( /^Url\s*:\s*(.*)/i ) { + $replace_hash{"XXXURL $current_package"} = sprintf("%-16s%s","Url:", $1); + push @oldspec, "XXXURL $current_package"; + next; + } + if ( m/$global_tags_re\s*(.*)/oi ) { + my ($tag, $value) = ($1, $2); + $nosrc_result = 1 if ($tag =~ /(?:nosource|nopatch)/i); + push @oldspec, sprintf("%-16s%s", capitalize_case($tag) . ":", $value); + next; + } + if ( /^Version:/ ) { + warn "found Version, section = $current_section\n" if $debug; + $version{$current_package} = $_; + $version{$current_package} =~ s/^Version:\s*(.*)\s*/$1/; + $replace_hash{"XXXVERSION $current_package"} = sprintf("%-16s%s","Version:",$version{$current_package}); + push @oldspec, "XXXVERSION $current_package"; + push @oldspec, "XXXRELEASE $current_package"; + next; + } + } + if ( $current_section eq "description" ) { + my $target = $current_package; + $target .= "_$current_lang" if $current_lang; + $target .= "_disabled" if $ifhandler->{"disabled"}; + $replace_hash{"XXXDESCRIPTION $target"} .= "\n" if ( $replace_hash{"XXXDESCRIPTION $target"} ); + $replace_hash{"XXXDESCRIPTION $target"} .= $_; + next; + } + if ( $current_section ne "description" && $current_section ne "changelog" ) { + push @oldspec, $_; + } + } +} + +if ($ARGV[0] eq '--debug') { + $debug = 1; + shift @ARGV; +} + +my $specfile = shift ( @ARGV ); +if ( ! stat($specfile) ) { + die "$specfile is no file"; +} + + +my @specpath = split ('/' ,$specfile); +my $specbase = pop @specpath; +my $specdir = join ('/', @specpath); + +if ( $specdir eq "" ) { + $specdir = "."; +} + +my $xdefinelist; +my $seen_name = 0; +open ( SPE , "$specfile" ); +while ( ) { + chomp(); + if ( /^%define/ ) { + my @args = split (/\s+/,$_); + $_ =~ s/[\{\}\"]//g for (@args); + $args[2] =~ s/\Q$_\E/$xdefinelist->{$_}/ for (sort { length($b) <=> length($a) } keys (%{$xdefinelist})); + if ( $args[2] !~ /[\(\)\{\}\@\%\"\\]/ ) { + $xdefinelist->{"%".$args[1]} = $args[2]; + $xdefinelist->{"%{".$args[1]."}"} = $args[2]; + } + } + if ( /^\s*Name:/ ) { + next if $seen_name; + $seen_name = 1; + $base_package = $_; + $base_package =~ s/^\s*Name:\s*(\S*)\s*/$1/; + $base_package =~ s/\Q$_\E/$xdefinelist->{$_}/ for (sort { length($b) <=> length($a) } keys (%{$xdefinelist})); + if ($debug) { + warn "DEBUG: base_package = $base_package\n"; + warn Dumper($xdefinelist); + } + last; + } +} +close ( SPE ); + +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/\-[^\-]*$//; +} + +warn ("base_package is $base_package\n") if $debug; + +if ( ! stat ((glob("$specdir/$base_package*.spec"))[0] || "") ) { + $base_package = $specbase; + $base_package =~ s/\.spec$//; + $base_package =~ s/\-.*$//; +} + +read_and_parse_old_spec ( $specfile, $base_package ); + +for (@oldspec) { + next unless /^XXX/; + $please_replace{$_} = 1; +} + +my $thisyear = localtime->year() + 1900; + +unshift @copyrights, "# Copyright (c) $thisyear SUSE LINUX Products GmbH, Nuernberg, Germany."; + +my $copy_list = join("\n", @copyrights); +print <