Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package cpanspec for openSUSE:Factory checked in at 2021-05-10 15:38:50 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/cpanspec (Old) and /work/SRC/openSUSE:Factory/.cpanspec.new.2988 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "cpanspec" Mon May 10 15:38:50 2021 rev:43 rq:891849 version:1.81.01.1620405353.7ed9076 Changes: -------- --- /work/SRC/openSUSE:Factory/cpanspec/cpanspec.changes 2020-12-08 13:26:07.110778828 +0100 +++ /work/SRC/openSUSE:Factory/.cpanspec.new.2988/cpanspec.changes 2021-05-10 15:41:23.417083837 +0200 @@ -1,0 +2,11 @@ +Fri May 7 16:36:50 UTC 2021 - Tina M??ller <[email protected]> + +- Update to 1.81.01 + * Also read from META.json + * Read 'dynamic_config' and 'provides' from META files + * Move Intrusive.pm into its own subprocess + * Add --debug option + * Add statistics output + * Add batch processing script for testing changes on a number of packages + +------------------------------------------------------------------- Old: ---- cpanspec-1.80.01.1604908251.c47daae.obscpio New: ---- cpanspec-1.81.01.1620405353.7ed9076.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ cpanspec.spec ++++++ --- /var/tmp/diff_new_pack.7VfEC8/_old 2021-05-10 15:41:23.893081977 +0200 +++ /var/tmp/diff_new_pack.7VfEC8/_new 2021-05-10 15:41:23.897081961 +0200 @@ -1,7 +1,7 @@ # # spec file for package cpanspec # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ %define cpan_name cpanspec Name: cpanspec -Version: 1.80.01.1604908251.c47daae +Version: 1.81.01.1620405353.7ed9076 Release: 0 Summary: Generate a SUSE spec file for a CPAN module License: Artistic-1.0 OR GPL-1.0-or-later ++++++ _service ++++++ --- /var/tmp/diff_new_pack.7VfEC8/_old 2021-05-10 15:41:23.929081837 +0200 +++ /var/tmp/diff_new_pack.7VfEC8/_new 2021-05-10 15:41:23.929081837 +0200 @@ -1,6 +1,6 @@ <services> <service name="obs_scm" mode="disabled"> - <param name="versionprefix">1.80.01</param> + <param name="versionprefix">1.81.01</param> <param name="url">git://github.com/openSUSE/cpanspec</param> <param name="scm">git</param> <param name="changesgenerate">enable</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.7VfEC8/_old 2021-05-10 15:41:23.945081774 +0200 +++ /var/tmp/diff_new_pack.7VfEC8/_new 2021-05-10 15:41:23.949081758 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">git://github.com/openSUSE/cpanspec</param> - <param name="changesrevision">c47daae0b848b2a976f791a754bef9f7740d98ea</param> + <param name="changesrevision">7ed9076bb6e249082bab6d5b6a66eed7f33e8703</param> </service> </servicedata> ++++++ cpanspec-1.80.01.1604908251.c47daae.obscpio -> cpanspec-1.81.01.1620405353.7ed9076.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cpanspec-1.80.01.1604908251.c47daae/Changes new/cpanspec-1.81.01.1620405353.7ed9076/Changes --- old/cpanspec-1.80.01.1604908251.c47daae/Changes 2020-11-09 08:50:51.000000000 +0100 +++ new/cpanspec-1.81.01.1620405353.7ed9076/Changes 2021-05-07 18:35:53.000000000 +0200 @@ -1,8 +1,28 @@ +1.81.01 2021-05-07 18:32:43+02:00 + +* Also read from META.json +* Read 'dynamic_config' and 'provides' from META files +* Move Intrusive.pm into its own subprocess +* Add --debug option +* Add statistics output +* Add batch processing script for testing changes on a number of packages + +1.80.01 + +* support opensuse patch comments (PATCH-FIX-UPSTREAM) +* add misc block, e.g. for subpackages + 1.79.1 * new release for openSUSE, changes see in git repository https://github.com/openSUSE/cpanspec +* smaller bug-fixes +* add add_doc and skip_doc to allow changing docs handling +* ignore some more unwanted files in doc handling +* fix package requires +* reduce changelog space wasting, document option --old-file +* update copyrights -1.78.5 +1.78.5 * convert from Build.PL to Makefile.PL 1.78 2009-01-16 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cpanspec-1.80.01.1604908251.c47daae/Dockerfile new/cpanspec-1.81.01.1620405353.7ed9076/Dockerfile --- old/cpanspec-1.80.01.1604908251.c47daae/Dockerfile 1970-01-01 01:00:00.000000000 +0100 +++ new/cpanspec-1.81.01.1620405353.7ed9076/Dockerfile 2021-05-07 18:35:53.000000000 +0200 @@ -0,0 +1,38 @@ +FROM opensuse/leap:15.2 + +RUN zypper refresh \ + && zypper install -y \ + osc \ + perl \ + perl-YAML-LibYAML \ + perl-XML-Simple \ + perl-Parse-CPAN-Packages \ + procmail \ + wget \ + vim \ + git \ + perl-Text-Autoformat \ + perl-YAML \ + perl-Pod-POM \ + perl-libwww-perl \ + perl-Class-Accessor-Chained \ + perl-Perl-PrereqScanner \ + perl-Algorithm-Diff \ + perl-Module-Build-Tiny \ + perl-ExtUtils-Depends \ + perl-ExtUtils-PkgConfig \ + obs-service-format_spec_file \ + && true + + +RUN cd /tmp && wget http://www.cpan.org/modules/02packages.details.txt.gz + +ENV LANG=en_US.UTF-8 \ + LC_CTYPE="en_US.UTF-8" \ + LC_NUMERIC="en_US.UTF-8" \ + LC_TIME="en_US.UTF-8" \ + LC_COLLATE="en_US.UTF-8" + + +# perl /cpanspec/cpanspec -v -f --skip-changes --pkgdetails /tmp/02packages.details.txt.gz tarball + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cpanspec-1.80.01.1604908251.c47daae/bin/batch.pl new/cpanspec-1.81.01.1620405353.7ed9076/bin/batch.pl --- old/cpanspec-1.80.01.1604908251.c47daae/bin/batch.pl 1970-01-01 01:00:00.000000000 +0100 +++ new/cpanspec-1.81.01.1620405353.7ed9076/bin/batch.pl 2021-05-07 18:35:53.000000000 +0200 @@ -0,0 +1,82 @@ +#!/usr/bin/perl +use strict; +use warnings; +use 5.010; +use Data::Dumper; +use Getopt::Long; + +GetOptions( + "debug" => \my $debug, + "dry" => \my $dry, + "help|h" => \my $help, +) # flag +or die "Error in command line arguments"; + +if ($help) { + print <<'EOM'; +Usage: + batch.pl /path/to/packages 0 50 # process the first 51 packages +EOM + exit; +} + +my ($dir, $from, $to) = @ARGV; +$from ||= 0; +$to ||= $from; + +my @skip = qw/ + perl-AcePerl + perl-Acme-MetaSyntactic + perl-Acme-Ook + perl-Algorithm-Munkres + perl-Alien-LibGumbo + perl-Alien-SVN + perl-Alien-Tidyp + perl-Apache-AuthNetLDAP + perl-Apache-Filter + perl-Apache-SessionX + perl-Apache-Gallery + perl-App-ProcIops + perl-App-Nopaste + perl-App-SVN-Bisect + perl-App-gcal + perl-Array-Dissect + perl-Audio-CD + perl-Authen-SASL-Cyrus + perl-BIND-Conf_Parser + perl-BSXML + perl-Boost-Geometry-Utils + perl-Class-Accessor-Chained + Class-Multimethods + perl-Crypt-HSXKPasswd + perl-Crypt-Rot13 +/; +my %skip; +@skip{ @skip } = (); + +opendir my $dh, $dir or die $!; +my @pkgs = sort grep { + -d "$dir/$_" && m/^perl-/ + and not exists $skip{ $_ } +} readdir $dh; +closedir $dh; + +my $count = @pkgs; +say "Total: $count"; + +my $opt_debug = $debug ? '--debug' : ''; +for my $i ($from .. $to) { + my $pkg = $pkgs[ $i ]; + chdir $dir; + say "=========== ($i) $pkg"; + next if $dry; + chdir $pkg; + my $mod = $pkg; + $mod =~ s/^perl-//; + my @glob = glob("$mod*"); + my $cmd = qq{cpanspec $opt_debug -v -f --skip-changes --pkgdetails /tmp/02packages.details.txt.gz @glob 2>&1}; + say "Cmd: $cmd"; + my $out = qx{$cmd}; + say $out; + +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cpanspec-1.80.01.1604908251.c47daae/bin/intrusive.pl new/cpanspec-1.81.01.1620405353.7ed9076/bin/intrusive.pl --- old/cpanspec-1.80.01.1604908251.c47daae/bin/intrusive.pl 1970-01-01 01:00:00.000000000 +0100 +++ new/cpanspec-1.81.01.1620405353.7ed9076/bin/intrusive.pl 2021-05-07 18:35:53.000000000 +0200 @@ -0,0 +1,26 @@ +#!/usr/bin/perl +use strict; +use warnings; +use 5.010; +use JSON::PP; +use File::Basename qw/ dirname /; +my $bin = dirname(__FILE__); +require "$bin/../lib/Intrusive.pm"; + +my $coder = JSON::PP->new->utf8->pretty->canonical; + +my ($path) = @ARGV; + +# Makefile.PL etc. might print things to STDOUT, temporary redirect +# to STDERR +open my $orig, ">&", STDOUT; +open STDOUT, ">&STDERR"; + +my $deps = Intrusive->new->dist_dir($path)->find_modules; + +# restore STDOUT +open STDOUT, ">&", $orig; + +my $json = $coder->encode({%$deps}); +print $json; + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cpanspec-1.80.01.1604908251.c47daae/cpanspec new/cpanspec-1.81.01.1620405353.7ed9076/cpanspec --- old/cpanspec-1.80.01.1604908251.c47daae/cpanspec 2020-11-09 08:50:51.000000000 +0100 +++ new/cpanspec-1.81.01.1620405353.7ed9076/cpanspec 2021-05-07 18:35:53.000000000 +0200 @@ -187,9 +187,11 @@ use strict; use warnings; +use 5.010; our $NAME = "cpanspec"; -our $VERSION = '1.80.01'; +our $VERSION = '1.81.01'; +my $script = __FILE__; use Cwd; BEGIN { @@ -218,11 +220,17 @@ use Parse::CPAN::Packages; use File::Temp; use File::Path qw(rmtree); -use Intrusive; use Perl::PrereqScanner; +use Encode qw/ decode_utf8 /; +use Encode::Guess; +use JSON::PP (); require Carp; +my $url="https://metacpan.org/release/\%{cpan_name}"; +my $bin = Cwd::abs_path(dirname($script)); +my $coder = JSON::PP->new->utf8; + our %opt; our $help = 0; @@ -248,6 +256,7 @@ our $old_file; our $config = {}; our $cpan = $ENV{'CPAN'} || 'https://cpan.metacpan.org'; +my $debug; our $home = $ENV{'HOME'} || (getpwuid($<))[7]; die "Can't locate home directory. Please define \$HOME.\n" @@ -456,14 +465,18 @@ return $ret; } -sub readfile($) { +sub readfile { + my ($filename, $encoding) = @_; + $encoding //= ''; local $/ = undef; - my $filename = shift; die "empty filename" unless length($filename); - open FILE, $basedir . $filename or return undef; - binmode FILE; - my $string = <FILE>; - close FILE; + open my $fh, "<", $basedir . $filename or return undef; + binmode $fh; + my $string = <$fh>; + if ($encoding eq 'guess') { + $string = decode_latin_or_utf8($string); + } + close $fh; return $string; } @@ -535,9 +548,8 @@ return $description = undef; } -sub get_summary($$) { - my $cont = shift; - my $mod = shift; +sub get_summary { + my ($summary, $cont, $mod) = @_; my $parser = Pod::POM->new; # extract pod; the file may contain no pod, that's ok @@ -552,7 +564,7 @@ $pom =~ /^[^-]+ -* (.*)$/m; # return... - return $summary = $1 if $pom; + return "$1" if $1; } return $summary; } @@ -764,6 +776,7 @@ 'version' => \&print_version, 'prefer-macros|m' => \$macros, 'pkgdetails=s' => \$pkgdetails, + 'debug' => \$debug, ) or pod2usage({-exitval => 1, -verbose => 0}); pod2usage({-exitval => 0, -verbose => 1}) if ($help); @@ -791,13 +804,15 @@ } my @args = @ARGV; my @processed = (); +local $Data::Dumper::Sortkeys = 1; for my $ofile (@args) { my $type = undef; my $download = undef; + my $summary; ($file, $name, $source, $version) = (undef, undef, undef, undef); - ($content, $summary, $description, $author, $license) = (undef, undef, undef, undef, undef); + ($content, $description, $author, $license) = (undef, undef, undef, undef); if ($ofile =~ /^(?:.*\/)?(.+)-(?:v\.?)?([^-]+)\.(tar)\.(?:gz|bz2)$/i) { $file = $ofile; @@ -871,6 +886,7 @@ push(@archive_files, $archive->memberNames()); } + my %stats; my @files = (); my $bogus = 0; my $execs = 0; @@ -879,6 +895,7 @@ @archive_files = sort @archive_files; my $changesfile; foreach my $entry (@archive_files) { + my $version0=$version; $version0=~s/0*$/0*/; # pathnames may not contain as many trailing zeros if ( @@ -901,7 +918,7 @@ my $candidate = lc $entry; if (!$changes && ($candidate =~ m/^changes/ || $candidate =~ m/^changelog/ || $candidate =~ m/^history/)) { $changesfile = $entry; - $changes = readfile("$path/$entry"); + $changes = readfile("$path/$entry", 'guess'); } if (-x "$basedir$path/$entry" && -f "$basedir$path/$entry") { @@ -918,8 +935,6 @@ next; } - my $url="https://metacpan.org/release/\%{cpan_name}"; - get_source($name) if(!defined $source && -d dirname($pkgdetails)); $content = get_content( @@ -935,7 +950,7 @@ get_description($content) || get_description($content, 'OVERVIEW'); } - get_summary($content,$module) if (!defined($summary)); + $summary = get_summary($summary, $content, $module) unless defined $summary; get_author($content) if (!defined($author)); @@ -946,12 +961,12 @@ push(@skipdoc, $r); } - sub doskip($) { + my $doskip = sub { for my $s (@skipdoc) { return 1 if $_ =~ /$s/; } return 0; - } + }; my @doc=sort { $a cmp $b } grep { !/\// @@ -986,7 +1001,7 @@ and $_ ne "install.sh" and !/\.tar\./ and !/~$/ - and !doskip($_) + and !$doskip->($_) } @files; my %adddoc; @@ -1076,45 +1091,93 @@ $license = undef; my $scripts = 0; - my (%build_requires, %requires, %recommends, %possible_build_requires); - my ($yml, $meta); - if (grep /^META\.yml$/, @files and $yml = readfile("$path/META.yml")) { - # Basic idea borrowed from Module::Depends. - my $meta; - eval { $meta = Load($yml); }; + my (%build_requires, %requires, %recommends); + my %provides; + my $metayaml = -e "$basedir/$path/META.yml" ? 1 : ''; + my $metajson = -e "$basedir/$path/META.json" ? 1 : ''; + my $dynamic = 1; + my $got_prereqs = 0; + + if ($metajson) { + open my $fh, '<', "$basedir/$path/META.json" or die $!; + my $json = do { local $/; <$fh> }; + close $fh; + $metajson = eval { $coder->decode($json) }; + if ($@) { + warn "Error decoding META.json, ignoring ($@)"; + $stats{metajson} = 'error'; + } + else { + $stats{metajson} = 1; + if (exists $metajson->{dynamic_config} and not $metajson->{dynamic_config}) { + $dynamic = 0; + } + + my ($prov, $build, $run, $rec) = prereqs_from_metajson($metajson); + if (keys %$prov) { + @provides{ keys %$prov } = values %$prov; + } + if ($build) { + %build_requires = %$build; + %requires = %$run; + %recommends = %$rec; + $got_prereqs = 1; + if ($debug) { + warn __PACKAGE__.':'.__LINE__.$".Data::Dumper->Dump([\%build_requires], ['build_requires']); + warn __PACKAGE__.':'.__LINE__.$".Data::Dumper->Dump([\%requires], ['requires']); + warn __PACKAGE__.':'.__LINE__.$".Data::Dumper->Dump([\%recommends], ['recommends']); + } + } + $stats{license}->{metajson} = $metajson->{license}; + if ($metajson->{abstract}) { + $stats{abstract}->{metajson} = $metajson->{abstract}; + } + } + } + + if ($metayaml) { + my $yml = readfile("$path/META.yml"); + my $meta = eval { Load($yml); }; if ($@) { warn "Error parsing $path/META.yml: $@"; + $stats{metayaml} = 'error'; goto SKIP; } + $stats{metayaml} = 1; + if (exists $meta->{dynamic_config} and not $meta->{dynamic_config}) { + $dynamic = 0; + } if ($meta->{abstract} && $meta->{abstract} ne 'unknown') { my $abstract = $meta->{abstract}; - $summary = $abstract if (!defined($summary)); + $stats{abstract}->{metayaml} = $abstract; + $summary = $abstract unless defined $summary; } - %build_requires = %{$meta->{build_requires}} if ($meta->{build_requires}); - if ($meta->{configure_requires}) { - while (my ($key, $value) = each(%{$meta->{configure_requires}})) { - if (defined $build_requires{$key}) { - next if version->parse($build_requires{$key}) > version->parse($value); - } - $build_requires{$key} = $value; - } + my ($prov, $build, $run, $rec) = prereqs_from_metayaml($meta); + if (not %provides and keys %$prov) { + @provides{ keys %$prov } = values %$prov; } - if ($meta->{test_requires}) { - while (my ($key, $value) = each(%{$meta->{test_requires}})) { - $build_requires{$key} = $value; + + if (not $got_prereqs and $build) { + %build_requires = %$build; + %requires = %$run; + %recommends = %$rec; + $got_prereqs = 1; + if ($debug) { + warn __PACKAGE__.':'.__LINE__.$".Data::Dumper->Dump([\%build_requires], ['build_requires']); + warn __PACKAGE__.':'.__LINE__.$".Data::Dumper->Dump([\%requires], ['requires']); + warn __PACKAGE__.':'.__LINE__.$".Data::Dumper->Dump([\%recommends], ['recommends']); } } - - %requires = %{$meta->{requires}} if ($meta->{requires}); - %recommends = %{$meta->{recommends}} if ($meta->{recommends}); + $stats{got_prereqs} = $got_prereqs; # did we get static dependencies? # FIXME - I'm not sure this is sufficient... if ($meta->{script_files} or $meta->{scripts}) { $scripts = 1; } + $stats{license}->{metayaml} = $meta->{license}; if ($meta->{license}) { # This list of licenses is from the Module::Build::API # docs, cross referenced with the list of licenses in @@ -1168,6 +1231,8 @@ } SKIP: } + $stats{dynamic} = $dynamic; + $debug and warn __PACKAGE__.':'.__LINE__.$".Data::Dumper->Dump([\$dynamic], ['dynamic']); if (!defined($license)) { get_license($content); @@ -1187,8 +1252,10 @@ } $license = "CHECK($perllicense)" if (!$license); + $stats{license}->{spec} = $license; $description = $summary if (!defined($description)); + $stats{summary} = $summary; $summary =~ s,\.$,,; $summary =~ s,^[aA] ,,; @@ -1220,54 +1287,45 @@ } } else { - $build_requires{'ExtUtils::MakeMaker'} = 0; + $build_requires{'ExtUtils::MakeMaker'} ||= 0; } - my $deps = Intrusive->new->dist_dir($basedir . $path)->find_modules; - my %lrequires = %{$deps->requires}; - foreach my $dep (keys(%lrequires)) { - $requires{$dep} = $lrequires{$dep}; + if ($got_prereqs and not $dynamic) { + $debug and warn "Got prereqs, no need to run Makefile.PL/Build.PL"; } - %lrequires = %{$deps->build_requires}; - foreach my $dep (keys(%lrequires)) { - if (defined $build_requires{$dep}) { - next if version->parse($build_requires{$dep}) > version->parse($lrequires{$dep}); + else { + # Basic idea borrowed from Module::Depends. + my $intrusive = qq{perl $bin/bin/intrusive.pl $basedir$path}; + my $jsondeps = qx{$intrusive}; + my $deps = eval { $coder->decode($jsondeps) }; + unless ($deps) { + warn "JSON: >>$jsondeps<<"; + die $@; } - $build_requires{$dep} = $lrequires{$dep}; - } - - my %packages = (); - - my $scanner = Perl::PrereqScanner->new; - foreach my $test (grep /\.(pm|t|PL|pl)/, @files) { - my $doc = PPI::Document->new($basedir . $path . "/" . $test); - - next unless ($doc); - - # Get the name of the main package - my $pkg = $doc->find_first('PPI::Statement::Package'); - if ($pkg) { - $packages{$pkg->namespace} = 1; + my %lrequires = %{ $deps->{requires} }; + foreach my $dep (keys(%lrequires)) { + $requires{$dep} = $lrequires{$dep}; } - - my $scan; # = eval { $scanner->scan_ppi_document($doc)->as_string_hash; }; - next unless $scan; - my %scanneddeps = %$scan; - foreach my $dep (keys(%scanneddeps)) { - my $ndep = $scanneddeps{$dep}; - unless ($build_requires{$dep} && version->parse($build_requires{$dep}) > version->parse($ndep)) { - $possible_build_requires{$dep} = $scanneddeps{$dep}; + %lrequires = %{ $deps->{build_requires} }; + foreach my $dep (keys(%lrequires)) { + if (defined $build_requires{$dep}) { + next if version->parse($build_requires{$dep}) > version->parse($lrequires{$dep}); } + $build_requires{$dep} = $lrequires{$dep}; } } - foreach my $pkg (keys %packages) { delete $build_requires{$pkg} } + $stats{provides} = keys %provides; + dump_statistics($module, $version, \%stats); + unless (%provides) { + verbose("No 'provides' info in meta, parsing code.\n"); + %provides = parse_provides($basedir . $path, \@files); + } + delete @build_requires{ keys %provides }; my %hdoc; - if (@doc) { - foreach my $d (@doc) { - $hdoc{$d} = 1; - } + foreach my $d (@doc) { + $hdoc{$d} = 1; } rmtree($basedir); @@ -1297,6 +1355,7 @@ my $version_string = '%{version}'; print $spec <<END; +%define cpan_name $name Name: $prefix$name Version: $rpm_version Release: $release @@ -1325,10 +1384,8 @@ print $spec "License: $license\n"; } print $spec <<END; -%define cpan_name $name Summary: $summary Url: $url -Group: Development/Libraries/Perl END my $sfile = basename($ofile); $sfile =~ s/$name/\%{cpan_name}/; @@ -1375,7 +1432,6 @@ else { printf $spec "%-16s%s\n", "BuildArch:", "noarch" if $noarch; } - print $spec "BuildRoot: \%{_tmppath}/\%{name}-\%{version}-build\n"; printf $spec "%-16s%s\n", "BuildRequires:", "perl"; printf $spec "%-16s%s\n", "BuildRequires:", "perl-macros"; @@ -1386,9 +1442,6 @@ } my @treqs = sort(keys(%build_requires)); - foreach my $dep (sort(keys(%possible_build_requires))) { - push(@treqs, $dep) if (!defined $build_requires{$dep}); - } for my $dep (@treqs) { my $iscore = 0; eval { $iscore = is_in_core($dep, $build_requires{$dep}); }; @@ -1476,19 +1529,42 @@ $description \%prep -\%setup -q@{[($noprefix ? "" : " -n $buildpath")]} +END + + my $all_patch_args_same = 1; + my $common_patch_args = undef; + if ($config->{patches}) { + for my $p (sort keys %{$config->{patches}}) { + my $args = $config->{patches}->{$p} || undef; + $args =~ s/ ?PATCH-FIX.*// if defined($args); + if (!defined($common_patch_args) && defined($args)) { + $common_patch_args = $args; + } + $all_patch_args_same = ($args // '') eq ($common_patch_args // ''); + last if !$all_patch_args_same; + } + } + + my $autosetup_arg = (!$config->{patches} || $all_patch_args_same) ? (defined($common_patch_args) ? " $common_patch_args" : "") : " -N"; + print $spec <<END; +\%autosetup @{[($noprefix ? "" : " -n $buildpath")]}$autosetup_arg END if ($execs) { print $spec qq{find . -type f ! -path "*/t/*" ! -name "*.pl" ! -path "*/bin/*" ! -path "*/script/*" ! -name "configure" -print0 | xargs -0 chmod 644\n}; } - if ($config->{patches}) { + if ($config->{patches} && !$all_patch_args_same) { my $counter = 0; for my $p (sort keys %{$config->{patches}}) { - my $args = $config->{patches}->{$p} || ''; - $args =~ s/ ?PATCH-FIX.*//; - print $spec "%patch$counter $args\n"; + + my $args = $config->{patches}->{$p} || undef; + if (defined($args)) { + $args =~ s/ ?PATCH-FIX.*//; + print $spec "%patch$counter $args\n"; + } else { + print $spec "%patch$counter\n"; + } $counter++; } } @@ -1556,7 +1632,7 @@ if ($compat and !$noarch); print $spec <<END; -$cmdmake \%{?_smp_mflags} +\%make_build END } @@ -1628,7 +1704,6 @@ } print $spec "\%files -f \%{name}.files\n"; - print $spec "\%defattr(-,root,root,755)\n"; if (%hdoc) { my (@ldoc, @hdoc); @@ -1683,6 +1758,7 @@ my $changes_diff; my ($tfh, $tmpfile) = File::Temp::tempfile; + binmode $tfh, ':encoding(UTF-8)'; my $cltxt = ""; if (-f $changelogfile) { @@ -1690,6 +1766,7 @@ $cltxt .= $txt; if ($old_file && $changes) { my $old_changes = extract_old_changes($old_file, $changesfile); + $old_changes = decode_latin_or_utf8($old_changes); $old_changes =~ s,\r\n,\n,g; $cltxt .= diff_changes($old_changes, $changes) if $old_changes; } @@ -1713,8 +1790,114 @@ $cltxt =~ s/\n+$/\n/; # drop multi-lines at the end, osc adds one again print $tfh $cltxt; system("osc vc -F $tmpfile $basename.changes") if !$skip; + die "osc vc failed with $?" if $?; close($tfh); } } +sub prereqs_from_metayaml { + my ($meta) = @_; + my (%provides, %build_requires, %requires, %recommends); + + if ($meta->{provides}) { + for my $pkg (keys %{ $meta->{provides} || {} }) { + $provides{ $pkg } = 1; + } + } + + %build_requires = %{$meta->{build_requires}} if ($meta->{build_requires}); + if ($meta->{configure_requires}) { + while (my ($key, $value) = each(%{$meta->{configure_requires}})) { + if (defined $build_requires{$key}) { + next if version->parse($build_requires{$key}) > version->parse($value); + } + $build_requires{$key} = $value; + } + } + if ($meta->{test_requires}) { + while (my ($key, $value) = each(%{$meta->{test_requires}})) { + $build_requires{$key} = $value; + } + } + + %requires = %{$meta->{requires}} if ($meta->{requires}); + %recommends = %{$meta->{recommends}} if ($meta->{recommends}); + return (\%provides) + if (not %build_requires and not %requires and not %recommends); + return (\%provides, \%build_requires, \%requires, \%recommends); +} + +sub prereqs_from_metajson { + my ($metajson) = @_; + my (%provides, %build, %run, %rec); + if ($metajson->{provides}) { + for my $pkg (keys %{ $metajson->{provides} || {} }) { + $provides{ $pkg } = 1; + } + } + + my $prereqs = $metajson->{prereqs}; + return (\%provides) unless keys %$prereqs; + + for my $phase (qw/ build configure test /) { + if (my $build = $prereqs->{ $phase }) { + my $req = $build->{requires} || {}; + for my $module (sort keys %$req) { + next if exists $build{ $module } and + version->parse($build{ $module }) > version->parse( $req->{ $module }); + $build{ $module } = $req->{ $module }; + } + } + } + for my $phase (qw/ runtime /) { + if (my $build = $prereqs->{ $phase }) { + my $req = $build->{requires} || {}; + @run{ keys %$req } = values %$req; + my $rec = $build->{recommends} || {}; + @rec{ keys %$rec } = values %$rec; + } + } + return (\%provides, \%build, \%run, \%rec); +} + +sub parse_provides { + my ($path, $files) = @_; + my %provides; + my $scanner = Perl::PrereqScanner->new; + foreach my $test (grep /\.(pm|t|PL|pl)/, @$files) { + my $doc = PPI::Document->new($path . "/" . $test); + + next unless ($doc); + + # Get the name of the main package + my $pkg = $doc->find_first('PPI::Statement::Package'); + if ($pkg) { + $provides{$pkg->namespace} = 1; + } + + } + return %provides; +} + +sub decode_latin_or_utf8 { + my ($string) = @_; + my $enc = guess_encoding($string, qw/ utf8 latin1 /); + unless (ref $enc) { + return decode_utf8 $string; + } + #my $name = $enc->name; + $string = $enc->decode($string); + return $string; +} + +sub dump_statistics { + my ($module, $version, $stats) = @_; + $stats->{name} = $module; + $stats->{version} = $version; + my $yaml = YAML::XS::Dump($stats); + $yaml =~ s/^/# STATS # /mg; + $yaml = "# STATS # # $module, $version\n$yaml"; + verbose($yaml); +} + # vi: set ai et: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cpanspec-1.80.01.1604908251.c47daae/cpanspec.yml new/cpanspec-1.81.01.1620405353.7ed9076/cpanspec.yml --- old/cpanspec-1.80.01.1604908251.c47daae/cpanspec.yml 2020-11-09 08:50:51.000000000 +0100 +++ new/cpanspec-1.81.01.1620405353.7ed9076/cpanspec.yml 2021-05-07 18:35:53.000000000 +0200 @@ -10,6 +10,7 @@ #patches: # foo.patch: -p1 # bar.patch: +# baz.patch: PATCH-FIX-OPENSUSE #preamble: |- # BuildRequires: gcc-c++ #post_prep: |- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cpanspec-1.80.01.1604908251.c47daae/lib/CPAN2OBS.pm new/cpanspec-1.81.01.1620405353.7ed9076/lib/CPAN2OBS.pm --- old/cpanspec-1.80.01.1604908251.c47daae/lib/CPAN2OBS.pm 2020-11-09 08:50:51.000000000 +0100 +++ new/cpanspec-1.81.01.1620405353.7ed9076/lib/CPAN2OBS.pm 2021-05-07 18:35:53.000000000 +0200 @@ -527,10 +527,13 @@ my $cmd = sprintf "timeout 180 perl $cpanspec -v -f --pkgdetails %s --skip-changes %s > cpanspec.error 2>&1", "$data/02packages.details.txt.gz", $tar; + debug("CMD $cmd"); if (system $cmd or not -f $spec) { info("Error executing cpanspec"); + system("cat cpanspec.error"); } else { + system("cat cpanspec.error"); $error = 0; unlink "cpanspec.error"; } @@ -668,7 +671,7 @@ copy("$Bin/../cpanspec.yml", "$checkout/cpanspec.yml") unless -f "cpanspec.yml"; { my $cmd = sprintf - "timeout 900 perl $cpanspec -f --pkgdetails %s --old-file %s %s > cpanspec.error 2>&1", + "timeout 900 perl $cpanspec -v -f --pkgdetails %s --old-file %s %s > cpanspec.error 2>&1", "$data/02packages.details.txt.gz", ".osc/$old_tar", $tar; debug("CMD $cmd"); if (system $cmd or not -f $spec) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cpanspec-1.80.01.1604908251.c47daae/lib/Intrusive.pm new/cpanspec-1.81.01.1620405353.7ed9076/lib/Intrusive.pm --- old/cpanspec-1.80.01.1604908251.c47daae/lib/Intrusive.pm 2020-11-09 08:50:51.000000000 +0100 +++ new/cpanspec-1.81.01.1620405353.7ed9076/lib/Intrusive.pm 2021-05-07 18:35:53.000000000 +0200 @@ -72,6 +72,9 @@ my $WriteMakefile = sub { my %args = @_; $self->requires( $args{PREREQ_PM} || {} ); + my %br = %{ $args{TEST_REQUIRES} || {} }; + %br = (%br, %{ $args{BUILD_REQUIRES} }) if $args{BUILD_REQUIRES}; + $self->build_requires( \%br ); 1; }; local *main::WriteMakefile; ++++++ cpanspec.obsinfo ++++++ --- /var/tmp/diff_new_pack.7VfEC8/_old 2021-05-10 15:41:24.057081336 +0200 +++ /var/tmp/diff_new_pack.7VfEC8/_new 2021-05-10 15:41:24.057081336 +0200 @@ -1,5 +1,5 @@ name: cpanspec -version: 1.80.01.1604908251.c47daae -mtime: 1604908251 -commit: c47daae0b848b2a976f791a754bef9f7740d98ea +version: 1.81.01.1620405353.7ed9076 +mtime: 1620405353 +commit: 7ed9076bb6e249082bab6d5b6a66eed7f33e8703
