Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Sep 2015 12:13:24 +0000 (UTC)
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r397963 - in head: . Keywords Mk/Scripts
Message-ID:  <201509261213.t8QCDOKs040876@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bapt
Date: Sat Sep 26 12:13:23 2015
New Revision: 397963
URL: https://svnweb.freebsd.org/changeset/ports/397963

Log:
  Extend @sample to accept arguments
  
  Maintainers can now use @sample sample_file target_file for all cases
  that does not fall into the usual @sample something.sample
  
  Reviewed by:	antoine
  Differential Revision:	https://reviews.freebsd.org/D3734

Modified:
  head/CHANGES
  head/Keywords/sample.ucl
  head/Mk/Scripts/functions.sh

Modified: head/CHANGES
==============================================================================
--- head/CHANGES	Sat Sep 26 11:56:16 2015	(r397962)
+++ head/CHANGES	Sat Sep 26 12:13:23 2015	(r397963)
@@ -10,7 +10,16 @@ in the release notes and/or placed into 
 
 All ports committers are allowed to commit to this file.
 
-20150926
+20150926:
+AUTHOR: bapt@FreeBSD.org
+
+  @sample now accept arguments, so it can now be used the following way:
+
+  @sample afile.sample
+  or
+  @sample path/to/example etc/target
+
+20150926:
 AUTHOR: bapt@FreeBSD.org
 
   New keywords are supported in pkg since 1.5.x:

Modified: head/Keywords/sample.ucl
==============================================================================
--- head/Keywords/sample.ucl	Sat Sep 26 11:56:16 2015	(r397962)
+++ head/Keywords/sample.ucl	Sat Sep 26 12:13:23 2015	(r397963)
@@ -3,6 +3,10 @@
 # MAINTAINER: portmgr@FreeBSD.org
 #
 # @sample etc/somefile.conf.sample
+# or
+# @sample file1 file2
+#
+# Where file1 is considered as a sample file and file2 the target file
 #
 # This will install the somefile.conf.sample and automatically copy to
 # somefile.conf if it doesn't exist. On deinstall it will remove the
@@ -14,24 +18,42 @@
 #  etc/pkgtools.conf.sample
 #  @exec [ -f %B/pkgtools.conf ] || cp %B/%f %B/pkgtools.conf
 
-actions: [file]
+actions: [file(1)]
+arguments: true
 post-install: <<EOD
-  case "%@" in
-  /*) sample_file="%@" ;;
-  *) sample_file="%D/%@" ;;
+  case "%1" in
+  /*) sample_file="%1" ;;
+  *) sample_file="%D/%1" ;;
   esac
   target_file="${sample_file%.sample}"
+  set -- %@
+  if [ $# -eq 2 ]; then
+      target_file=${2}
+  fi
+  case "${target_file}" in
+  /*) target_file="${target_file}" ;;
+  *) target_file="%D/${target_file}" ;;
+  esac
   if ! [ -f "${target_file}" ]; then
     /bin/cp -p "${sample_file}" "${target_file}" && \
       /bin/chmod u+w "${target_file}"
   fi
 EOD
 pre-deinstall: <<EOD
-  case "%@" in
-  /*) sample_file="%@" ;;
-  *) sample_file="%D/%@" ;;
+  case "%1" in
+  /*) sample_file="%1" ;;
+  *) sample_file="%D/%1" ;;
   esac
   target_file="${sample_file%.sample}"
+  set -- %@
+  if [ $# -eq 2 ]; then
+      set -- %@
+      target_file=${2}
+  fi
+  case "${target_file}" in
+  /*) target_file="${target_file}" ;;
+  *) target_file="%D/${target_file}" ;;
+  esac
   if cmp -s "${target_file}" "${sample_file}"; then
     rm -f "${target_file}"
   else

Modified: head/Mk/Scripts/functions.sh
==============================================================================
--- head/Mk/Scripts/functions.sh	Sat Sep 26 11:56:16 2015	(r397962)
+++ head/Mk/Scripts/functions.sh	Sat Sep 26 12:13:23 2015	(r397963)
@@ -82,17 +82,22 @@ parse_plist() {
 		@sample\ *)
 			set -- $line
 			shift
-			# Ignore the actual file if it is in stagedir
-			case "$@" in
-			/*)
-			echo "@comment ${@%.sample}"
-			echo "${comment}$@"
-			;;
-			*)
-			echo "@comment ${cwd}/${@%.sample}"
-			echo "${comment}${cwd}/$@"
-			;;
+			sample_file=$1
+			target_file=${1%.sample}
+			if [ $# -eq 2 ]; then
+				target_file=$2
+			fi
+			case "${sample_file}" in
+			/*) ;;
+			*) sample_file=${cwd}/${sample_file} ;;
 			esac
+			case "${target_file}" in
+			/*) ;;
+			*) target_file=${cwd}/${target_file} ;;
+			esac
+			# Ignore the actual file if it is in stagedir
+			echo "@comment ${target_file}"
+			echo "${comment}${sample_file}"
 		;;
 		# Handle [dir] Keywords
 		@fc\ *|@fcfontsdir\ *|@fontsdir\ *)



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