This patch lets us remove the FLAVORS if we're updating a port that is moving from supporting python 2 and 3 to only supporting one of them, it should also better handle removing the MODPY_VERSION in the very unlikely case that a python 3 only port adds python 2 support.
Also able to simplify things as we ended up switching to copying everything except stuff we know we don't want. Noticed by kmos@ when trying out py-nose that does this Comments, OK? Index: infrastructure/lib/OpenBSD/PortGen/Port.pm =================================================================== RCS file: /cvs/ports/infrastructure/lib/OpenBSD/PortGen/Port.pm,v retrieving revision 1.16 diff -u -p -r1.16 Port.pm --- infrastructure/lib/OpenBSD/PortGen/Port.pm 14 May 2019 15:00:01 -0000 1.16 +++ infrastructure/lib/OpenBSD/PortGen/Port.pm 14 May 2019 16:44:49 -0000 @@ -312,6 +312,9 @@ sub write_makefile my @template = $self->parse_makefile("Makefile.orig"); my %copy_values; + # Decisions elsewhere might effect which values to copy from the template + my %dont_copy = %{ delete $configs{dont_copy} || {} }; + if (@template) { %copy_values = map { $_->{key} => 1 } grep { $_->{name} ne 'REVISION' } @@ -380,17 +383,10 @@ sub write_makefile } # If we didn't get a value, copy from the template - # if we know we should and if so, also copy: - # * MULTI_PACKAGES until we understand them - # * any _DEPENDS that we didn't find - # * plus any MODPY_* variables if ( not $value and %copy_values ) { - my $name = $line->{name}; - my $copy = - $copy_values{$key} - || $name =~ /_DEPENDS$/ - || $name =~ /^MODPY_/; - $value = $line->{value} if $copy; + $value = $line->{value} + if $copy_values{$key} + and not $dont_copy{$key}; } next unless defined $value; Index: infrastructure/lib/OpenBSD/PortGen/Port/PyPI.pm =================================================================== RCS file: /cvs/ports/infrastructure/lib/OpenBSD/PortGen/Port/PyPI.pm,v retrieving revision 1.13 diff -u -p -r1.13 PyPI.pm --- infrastructure/lib/OpenBSD/PortGen/Port/PyPI.pm 14 May 2019 15:00:01 -0000 1.13 +++ infrastructure/lib/OpenBSD/PortGen/Port/PyPI.pm 14 May 2019 16:44:49 -0000 @@ -106,10 +106,12 @@ sub fill_in_makefile if ( @versions > 1 ) { shift @versions; # remove default, lowest + $self->{dont_copy}{MODPY_VERSION} = 1; $self->set_other( 'FLAVORS', "python$_" ) for @versions; $self->set_other( 'FLAVOR', '' ); } elsif ( @versions && $versions[0] != 2 ) { + $self->{dont_copy}{$_} = 1 for qw( FLAVORS FLAVOR ); $self->set_other( MODPY_VERSION => "\${MODPY_DEFAULT_VERSION_$_}" ) for @versions;