#!@PERL@ -w # -*- perl -*- # # $NetBSD: check-cvs-diff,v 1.7 2022/11/19 13:16:00 mef Exp $ # # Copyright (c) 2014 The NetBSD Foundation, Inc. # # This code was originally contributed to the NetBSD Foundation, Inc. # by Makoto Fujiwara . # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # 3. Neither the name of author nor the names of its contributors may # be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND # CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # read output of (cd /usr/pkgsrc; cvs diff -u ) and check if # py* and ruby* strings are left in buildlink3.mk. # They are then modified to Variable representation. #" use strict; use Getopt::Std; our(@ARGV); my (%opts); my($my_name) = $0; $my_name =~ s#(.*)/##; sub usage(){ print <){ # Looking for the +++ filename line in cvs diff (supposed to use 'cvs diff -u') $file_to_edit = ''; if ( /^\+\+\+ (\S+)/) { $file_to_edit = $1; } if ( $file_to_edit && -f $file_to_edit ) { if ( $file_to_edit =~ /Makefile$/ ) { $Makefile++;} elsif ( $file_to_edit =~ /buildlink3.mk$/ ) { $buildlink3++; # print __LINE__, ' ', $file_to_edit,"\n"; my ($new_file) = $file_to_edit. '.new'; my ($edit) = 0; open(NEW, "> $new_file" ) || print STDERR "Problem opening file $new_file: $! \n"; open(EDIT, $file_to_edit ) || print STDERR "Problem opening file $file_to_edit: $! \n"; while() { if ( /^BUILDLINK.*py27/ ) { $_=~ s/py27/\${PYPKGPREFIX}/ ; $edit++;} if ( /^BUILDLINK.*py3[0-9]*/ ) { $_=~ s/py3[0-9]*/\${PYPKGPREFIX}/ ; print STDERR " py3[0-9]* found at $file_to_edit\n"; ; $edit++;} if ( /^BUILDLINK.*ruby[0-9][0-9]*/ ) { $_=~ s/ruby[0-9][0-9]*/\${RUBY_PKGPREFIX}/ ; $edit++;} print NEW $_; } close(EDIT); close(NEW); if ($edit) { unlink $file_to_edit; rename $new_file, $file_to_edit; $mod++;} else { $stay++; unlink $new_file; }; } else { $other++; print STDERR " (other) ", $file_to_edit,"\n"} } } close(CVS_DIFF); printf STDERR "Makefile: %4d\n", $Makefile; printf STDERR "buildlink3.mk: %4d\n", $buildlink3; printf STDERR " Modified: %4d\n", $mod; printf STDERR " Untouched: %4d\n", $stay; printf STDERR "Other: %4d\n", $other; } main(); exit;