Opened 10 years ago

Last modified 3 months ago

#44654 new enhancement

cpan2port improvements

Reported by: mojca (Mojca Miklavec) Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: contrib Version:
Keywords: Cc: drkp (Dan Ports), ryandesign (Ryan Carsten Schmidt), cooljeanius (Eric Gallager), kurthindenburg (Kurt Hindenburg), pixilla (Bradley Giesbrecht)
Port: cpan2port

Description

  • try to figure out if there is some desired order of keys (perl5.branches/perl5.setup/licence/maintainer/...)
  • properly implement if {${perl5.major} != ""} { and put dependencies inside the block
  • description is often missing, but META.yml usually contains abstract: that could be used
  • sort dependencies alphabetically
  • something seems to be wrong with dependencies, see cpan2port -t Mouse for example:
    build_requires:
      Test::Exception: 0
      Test::Exception::LessClever: 0
      Test::Fatal: 0
      Test::LeakTrace: 0
      Test::More: 0.88
      Test::Output: 0
      Test::Requires: 0
      Try::Tiny: 0
    configure_requires:
      CPAN::Meta: 0
      CPAN::Meta::Prereqs: 0
      Devel::PPPort: 3.19
      ExtUtils::ParseXS: 3.22
      Module::Build: 0.4005
      Module::Build::XSUtil: 0
    requires:
      Scalar::Util: 1.14
      XSLoader: 0.02
      perl: 5.008005
    

But it generates:

    depends_build-append \
                    port:p5${perl5.major}-test-exception \
                    port:p5${perl5.major}-test-exception-lessclever \
                    port:p5${perl5.major}-test-fatal \
                    port:p5${perl5.major}-test-leaktrace \
                    port:p5${perl5.major}-test-output \
                    port:p5${perl5.major}-test-requires \
                    port:p5${perl5.major}-try-tiny

In particular Module::Build::XSUtil and everything else from configure_requires is missing, as well as runtime dependencies.

Attachments (2)

cpan2port.diff (3.3 KB) - added by mojca (Mojca Miklavec) 10 years ago.
some patches addressing alignment of dependencies only
cpan2port-uniq-deps.diff (3.5 KB) - added by pixilla (Bradley Giesbrecht) 10 years ago.

Download all attachments as: .zip

Change History (9)

Changed 10 years ago by mojca (Mojca Miklavec)

Attachment: cpan2port.diff added

some patches addressing alignment of dependencies only

comment:1 Changed 10 years ago by pixilla (Bradley Giesbrecht)

cpan2port should remove duplicate dependencies:

$ cpan2port -t Net::Works
...
$ grep moo perl/p5-net-works/Portfile 
                    port:p5${perl5.major}-moo \
                    port:p5${perl5.major}-moo \
                    port:p5${perl5.major}-moo \

Changed 10 years ago by pixilla (Bradley Giesbrecht)

Attachment: cpan2port-uniq-deps.diff added

comment:2 Changed 10 years ago by pixilla (Bradley Giesbrecht)

My patch makes deps unique. Beware, I have very limited perl experience but my test results with Net::Works is what I was looking for.

comment:3 Changed 10 years ago by kurthindenburg (Kurt Hindenburg)

Cc: khindenburg@… added

Cc Me!

comment:4 Changed 10 years ago by mojca (Mojca Miklavec)

Cc: pixilla@… added

I committed the changes in r129562 since nobody objected.

(The commit message is wrong about removal of 5.8 because 5.8 5.10 5.12 5.14 was already removed earlier and my version of the file was just outdated.)

Remaining issues (other than the need of testing):

  • determine the licence automatically, at least for the most common types
  • description is often missing, but META.yml usually contains abstract: that could be used (I don't know how to extract that)
  • try to figure out if there is some desired order of keys (perl5.branches/perl5.setup/licence/maintainer/...)
  • sometimes one ends up with weird dependencies, see the above exaple of cpan2port -t Mouse
Last edited 10 years ago by mojca (Mojca Miklavec) (previous) (diff)

comment:5 Changed 10 years ago by mojca (Mojca Miklavec)

I added another sort into

$depends_build = join(" \\\n".(' 'x20), sort(@depends_build))."\n";

Maybe the first sort could go away (or this one could be moved elsewhere), but I'm not sure how to properly fix the code.

We could probably remove sort from here at least (I just noticed that I added that sort myself, but I added it at the wrong location):

  • cpan2port

     
    242242             my @depends_build = Huggy::uniq map {
    243243                 MSG::warn "$$info{name} build_requires $_";
    244244                 'port:'.Huggy::from_port $_
    245              } sort(keys %{ $dep_ref });
     245             } keys %{ $dep_ref };
    246246             if (@depends_build) {
    247247                 unshift(@depends_build, '    depends_build-append');
    248248                 $depends_build = join(" \\\n".(' 'x20), sort(@depends_build))."\n";
     
    252252             my @depends_lib = Huggy::uniq map {
    253253                 MSG::warn "$$info{name} requires $_";
    254254                 'port:'.Huggy::from_port $_
    255              } sort(keys %{ $dep_ref });
     255             } keys %{ $dep_ref };
    256256             if (@depends_lib) {
    257257                 unshift(@depends_lib, '    depends_lib-append');
    258258                 $depends_lib = join(" \\\n".(' 'x20), sort(@depends_lib))."\n";
Last edited 10 years ago by mojca (Mojca Miklavec) (previous) (diff)

comment:6 Changed 10 years ago by mojca (Mojca Miklavec)

Another issue worth inspecting: trying to guess when to use perl5.use_module_build with p5-module-build-tiny instead of p5-module-build. See:

comment:7 Changed 3 months ago by mf2k (Frank Schima)

Cc: mf2k removed
Note: See TracTickets for help on using tickets.