On Mon, May 13, 2019 at 07:37:36AM +0100, Stuart Henderson wrote:
> As far as plists go, unless the port only supports py2 or only supports py3,
> it ought to generate the plist with FLAVOR=python3 and then prefix any lines
> ending in ${MODPY_PYCACHE}/ with ${MODPY_COMMENT}.

I think kmos@ explained this to me correctly, but if someone wants to
write down the why this needs to happen again I'll happily add it as a
comment to this magic.

Comments, OK?

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 17:03:48 
-0000
@@ -48,6 +48,38 @@ sub get_ver_info
        return 1;
 }
 
+sub make_plist
+{
+       my ($self, @args) = @_;
+
+       my $flavored3 = $self->{FLAVORS} && $self->{FLAVORS} =~ /\bpython3\b/;
+       local $ENV{FLAVOR} = 'python3' if $flavored3;
+
+       my $ret = $self->SUPER::make_plist(@args);
+
+       if ( $flavored3 && -e 'pkg/PLIST' ) {
+               open my $ifh, '<', 'pkg/PLIST'
+                   or die "Unable to open PLIST: $!";
+               open my $ofh, '>', 'pkg/PLIST.new'
+                   or die "Unable to open PLIST.new: $!";
+
+               while ( my $line = readline $ifh ) {
+                       $line = '${MODPY_COMMENT}' . $line
+                           if $line =~ m<\$\{MODPY_PYCACHE\}/?$>
+                           and $line !~ m<^\$\{MODPY_COMMENT\}>;
+                       print $ofh $line;
+               }
+
+               close $ifh;
+               close $ofh;
+
+               rename 'pkg/PLIST.new', 'pkg/PLIST'
+                   or die "Unable to rename new PLIST: $!";
+       }
+
+       return $ret;
+}
+
 sub name_new_port
 {
        my ( $self, $di ) = @_;

Reply via email to