Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Apr 2014 09:29:22 +0000
From:      Alexey Dokuchaev <danfe@FreeBSD.org>
To:        Adam Weinberger <adamw@adamw.org>
Cc:        svn-ports-head@freebsd.org, svn-ports-all@freebsd.org, ports-committers@freebsd.org, Bryan Drewery <bdrewery@freebsd.org>
Subject:   Re: Commit logs for 2014/04/11
Message-ID:  <20140420092922.GA90642@FreeBSD.org>
In-Reply-To: <EA3162FC-904F-4209-81D8-67CDADA357A2@adamw.org>
References:  <20140412035900.3C695121E45@apnoea.adamw.org> <EA3162FC-904F-4209-81D8-67CDADA357A2@adamw.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140420092922.GA90642>