From owner-freebsd-ports Thu Aug 12 4: 0:59 1999 Delivered-To: freebsd-ports@freebsd.org Received: from plab.ku.dk (plab.ku.dk [130.225.105.65]) by hub.freebsd.org (Postfix) with ESMTP id 3F88B15705; Thu, 12 Aug 1999 04:00:38 -0700 (PDT) (envelope-from tobez@plab.ku.dk) Received: from lion.plab.ku.dk (lion.plab.ku.dk [130.225.105.49]) by plab.ku.dk (8.9.1/8.9.1) with ESMTP id NAA13121; Thu, 12 Aug 1999 13:00:43 +0200 (CEST) Received: (from tobez@localhost) by lion.plab.ku.dk (8.9.3/8.9.3) id MAA57463; Thu, 12 Aug 1999 12:57:50 +0200 (CEST) (envelope-from tobez) Date: Thu, 12 Aug 1999 12:57:50 +0200 From: Anton Berezin To: Bill Fumerola Cc: Tim Vanderhoek , Satoshi - Ports Wraith - Asami , freebsd-ports@FreeBSD.ORG Subject: Re: ports/13030: Many ports use ``chown'' rather than ``/usr/sbin/chown'' in their Makefiles Message-ID: <19990812125750.B56987@lion.plab.ku.dk> References: <19990809083649.B97354@mad> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.4i In-Reply-To: ; from Bill Fumerola on Mon, Aug 09, 1999 at 09:02:47AM -0400 Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Mon, Aug 09, 1999 at 09:02:47AM -0400, Bill Fumerola wrote: > On Mon, 9 Aug 1999, Tim Vanderhoek wrote: > > > If you auto-generated the patch with a script, submitting that would > > be easier. The committer can make a simple modification to have the > > script checkout anything it changes. If you hand-edit the patches, > > then patches are better. > > I'll take anything, though I'll probably end up grep'ing myself. Okay. I am sorry for the delay. The revised version of a script is below the sig. The script is interactive, and I believe is more/less convenient to use - at least it does diff prints and asks for a confirmation. It is also easy to modify it to handle chmod, strip etc. cases if necessary. Cheers, -- Anton Berezin The Protein Laboratory, University of Copenhagen #! /usr/bin/perl -w use strict; $| = 1; # # it is easy to add support for chmod, strip etc. # it is easy to add an external pager for diff prints # it is easy to add some autocommit feature to this # # please tell me if you would # like any of this to be added # # Cheers # my $tmp = ($ENV{TMPDIR} || '/tmp') . "/chowned.Makefile"; chdir "/usr/ports" or die $!; unlink $tmp; die "cannot unlink $tmp" if -r $tmp; print "searching..."; open CHOWN, "grep -il chown */*/Makefile |" or die $!; while () { print "\n"; chomp( my $makefile = $_); open MK, "< $makefile" or die $!; open PATCHED, "> $tmp" or die $!; while () { # print lines without chown as is unless (/\bchown\b/) { print PATCHED; next; } # skip clever CHOWN assignments - they are unnecessary next if m%^\s*CHOWN\s*\??=\s*(?:/usr/sbin/)?chown\s*$%; # change all /usr/sbin/chown for ${CHOWN} s%/usr/sbin/chown%\${CHOWN}%g; # change all standalone chown for ${CHOWN} s%\bchown\b%\${CHOWN}%g; print PATCHED; } close PATCHED; close MK; my $diff = `diff -u $makefile $tmp`; if ($diff) { print "|||||||||| suggested patch for \"$makefile\":\n"; # patch the patch $diff =~ s%^--- (\S+)(.*?)\n\+{3} (\S+)(.*?)\n%--- $1.orig$2\n+++ $1$4\n%s; print $diff; my $aa = ''; until ($aa =~ /^[aAdDcC]$/) { print "|||||||||| \"$makefile\": A)ccept D)iscard C)ancel -> "; $aa = <>; } chomp $aa; last if lc $aa eq 'c'; next if lc $aa eq 'd'; rename $makefile, "$makefile.orig" or die $!; system( "/bin/cp", $tmp, $makefile); } else { # there was no difference, just tell this print "||||||||||| \"$makefile\" seems to be arleady alright.\n"; print "||||||||||| press enter -> "; scalar <>; } } close CHOWN; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message