On Mon, May 13, 2019 at 11:49:02PM +0200, Charlene Wendling wrote:
> On Mon, 13 May 2019 13:46:46 -0700
> Andrew Hewus Fresh <[email protected]> wrote:
> > This should make portgen(1) recognize the EXTRACT_CASES in
> > bsd.port.mk(5) and set EXTRACT_SUFX correctly.
> > I didn't adjust Ruby handling because I don't really understand how
> > the ruby gems things work, but it appears all ruby modules are just
> > gems and so nothing to set.
> > I do feel a little bad about not documenting how to write a new
> > PortGen::Port subclass, but not completely sure where those docs
> > should live.
> > Anyway, Comments, OKs?
> I tested against various Perl and Python ports that have EXTRACT_SUFX:
> it works well (but many of them moved to tar.gz with updated versions).
> OK cwen@ but there is a typo:
Good catch. I also tested it with various Python ports that use different
extensions. (which is tar.gz, zip, and tar.bz2).
OK kmos@ (also with the typo fix).
--Kurt
> > Index: infrastructure/lib/OpenBSD/PortGen/Port.pm
> > ===================================================================
> > RCS file: /cvs/ports/infrastructure/lib/OpenBSD/PortGen/Port.pm,v
> > retrieving revision 1.15
> > diff -u -p -r1.15 Port.pm
> > --- infrastructure/lib/OpenBSD/PortGen/Port.pm 13 May 2019
> > 01:30:05 -0000 1.15 +++
> > infrastructure/lib/OpenBSD/PortGen/Port.pm 13 May 2019
> > 20:37:31 -0000 @@ -132,6 +132,40 @@ sub set_pkgname
> > { $self->{PKGNAME} = $pkgname; }
> >
> > +sub pick_distfile
> > +{
> > + my ( $self, @files ) = @_;
> > +
> > + my ($distname, $ext);
> > + foreach my $filename (@files) {
> > + # from EXTRACT_CASES
> > + ($distname, $ext) = $filename =~ /^(.*)(\.(?:
> > + tar\.xz | tar\.lzma
> > + | tar.lz
> ^ here
> > + | zip
> > + | tar\.bz2 | tbz2 | tbz
> > + | shar\.gz | shar\.Z | sh\.Z | sh\.gz
> > + | shar | shar\.sh
> > + | tar
> > + | tar\.gz | tgz
> > + ))$/xms;
> > +
> > + # These are our preferred suffixes
> > + if ( $ext eq '.tar.gz' ) {
> > + $ext = '';
> > + last;
> > + }
> > + elsif ( $ext eq '.tgz' or $ext eq '.tar' ) {
> > + last;
> > + }
> > + }
> > +
> > + $self->add_notice("Failed to pick a distname from @files")
> > unless $distname; +
> > + $self->set_other( EXTRACT_SUFX => $ext ) if $ext;
> > + return $self->set_distname($distname);
> > +}
> > +
> > sub set_distname
> > {
> > my ( $self, $distname ) = @_;
> > Index: infrastructure/lib/OpenBSD/PortGen/Port/CPAN.pm
> > ===================================================================
> > RCS file: /cvs/ports/infrastructure/lib/OpenBSD/PortGen/Port/CPAN.pm,v
> > retrieving revision 1.7
> > diff -u -p -r1.7 CPAN.pm
> > --- infrastructure/lib/OpenBSD/PortGen/Port/CPAN.pm 11 May
> > 2019 19:36:27 -0000 1.7 +++
> > infrastructure/lib/OpenBSD/PortGen/Port/CPAN.pm 13 May 2019
> > 20:37:31 -0000 @@ -182,7 +182,7 @@ sub fill_in_makefile my ( $self,
> > $di, $vi ) = @_;
> > $self->set_comment( $di->{abstract} );
> > - $self->set_distname( $di->{name} );
> > + $self->pick_distfile( $di->{archive} );
> > $self->set_license(
> > $di->{metadata}->{license}[0] eq 'unknown'
> > ? ''
> > @@ -192,12 +192,6 @@ sub fill_in_makefile
> >
> > $self->set_other( 'CPAN_AUTHOR', $di->{author} )
> > if $self->needs_author($di);
> > -
> > - my ($sufx) = $di->{archive} =~ /(\.[\.A-Za-z]+)$/;
> > -
> > - if ( defined $sufx and $sufx ne '.tar.gz' ) {
> > - $self->set_other( 'EXTRACT_SUFX', $sufx );
> > - }
> > }
> >
> > sub postextract
> > Index: infrastructure/lib/OpenBSD/PortGen/Port/PyPI.pm
> > ===================================================================
> > RCS file: /cvs/ports/infrastructure/lib/OpenBSD/PortGen/Port/PyPI.pm,v
> > retrieving revision 1.12
> > diff -u -p -r1.12 PyPI.pm
> > --- infrastructure/lib/OpenBSD/PortGen/Port/PyPI.pm 12 May
> > 2019 20:23:33 -0000 1.12 +++
> > infrastructure/lib/OpenBSD/PortGen/Port/PyPI.pm 13 May 2019
> > 20:37:31 -0000 @@ -68,9 +100,22 @@ sub fill_in_makefile
> > $self->set_other( 'MODPY_PI', 'Yes' );
> > $self->set_other( 'MODPY_SETUPTOOLS', 'Yes' );
> > $self->set_comment( $di->{info}{summary} );
> > - $self->set_other( 'MODPY_EGG_VERSION', $di->{info}
> > {version} );
> > - $self->set_distname( "$di->{info}{name}" . '-$
> > {MODPY_EGG_VERSION}' );
> > - my $pkgname = $di->{info}->{name};
> > +
> > + my $pkgname = $di->{info}->{name};
> > + my $version = $di->{info}->{version};
> > + my $distname = $self->pick_distfile(
> > + map { $_->{filename} } @{ $di->{urls} || [] } );
> > +
> > + $self->add_notice("distname $distname does not match pkgname
> > $pkgname")
> > + unless $distname !~ /^\Q$pkgname/;
> > +
> > + $self->set_other( 'MODPY_EGG_VERSION', $version );
> > + $distname =~ s/-\Q$version\E$/-\$\{MODPY_EGG_VERSION\}/
> > + or $self->add_notice("Didn't set distname version to \$
> > {MODPY_EGG_VERSION}"); +
> > + $self->set_distname($distname);
> > +
> > + # TODO: These assume the PKGNAME is the DISTNAME
> > my $to_lower = $pkgname =~ /\p{Upper}/ ? ':L' : '';
> > if ($pkgname =~ /^python-/) {
> > $self->set_pkgname("\$
> > {DISTNAME:S/^python-/py-/$to_lower}"); @@ -78,6 +123,7 @@ sub
> > fill_in_makefile elsif ($pkgname !~ /^py-/) {
> > $self->set_pkgname("py-\${DISTNAME$to_lower}");
> > }
> > +
> > $self->set_modules('lang/python');
> > $self->set_other( 'HOMEPAGE', $di->{info}{home_page} );
> > $self->set_license( $di->{info}{license} );
>