From owner-svn-ports-head@FreeBSD.ORG Sun Apr 20 09:29:22 2014 Return-Path: Delivered-To: svn-ports-head@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 1033) id 4C7D8CDD; Sun, 20 Apr 2014 09:29:22 +0000 (UTC) Date: Sun, 20 Apr 2014 09:29:22 +0000 From: Alexey Dokuchaev To: Adam Weinberger Subject: Re: Commit logs for 2014/04/11 Message-ID: <20140420092922.GA90642@FreeBSD.org> References: <20140412035900.3C695121E45@apnoea.adamw.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="EeQfGwPcQSOJBaQU" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Cc: svn-ports-head@freebsd.org, svn-ports-all@freebsd.org, ports-committers@freebsd.org, Bryan Drewery X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Apr 2014 09:29:22 -0000 --EeQfGwPcQSOJBaQU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, Apr 12, 2014 at 10:11:44AM -0400, Adam Weinberger wrote: > * Please, please don't mandate .sample. Plenty of of ports install Actually, it's not really ".sample". It's any six-letter word if I read the code correctly. > sample conf files with different extension. "-dist" is very common > for php ports, for example. Let @sample take two arguments. Like > @sample etc/pants.conf-dist pants.conf Why do we need the second argument? Can't we just use the rightmost extension? Proof of concept attached. ./danfe --EeQfGwPcQSOJBaQU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="sample.diff" Index: /usr/ports/Keywords/pkg_install.awk =================================================================== --- /usr/ports/Keywords/pkg_install.awk (revision 351320) +++ /usr/ports/Keywords/pkg_install.awk (working copy) @@ -15,9 +15,10 @@ # @comment end @sample somefile.conf.sample # $1 == "@sample" { - sample_file=$2 - # Take out .sample - target_file=substr(sample_file, 0, length(sample_file) - 7) + sample_file = $2 + # Take out the rightmost (last) extension + lastsep = match(sample_file, "[-.][^-.]+$") + target_file = substr(sample_file, 0, lastsep - 1) print "@comment begin " $0 print "@unexec if cmp -s '%D/" target_file "' '%D/" sample_file "'; then rm -f '%D/" target_file "'; fi" print sample_file --EeQfGwPcQSOJBaQU--