aboutsummaryrefslogtreecommitdiff
path: root/Keywords
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2015-09-26 12:13:23 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2015-09-26 12:13:23 +0000
commit5adc8a9faaebe0a180ed8a3d10fc3e17dde7d29c (patch)
tree3e4a83167a13b89c9d0efeeaa6e5b0f5487d84e9 /Keywords
parentce1853bf021623ab004669e0073c29ab6a83994f (diff)
downloadports-5adc8a9faaebe0a180ed8a3d10fc3e17dde7d29c.tar.gz
ports-5adc8a9faaebe0a180ed8a3d10fc3e17dde7d29c.zip
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
Notes
Notes: svn path=/head/; revision=397963
Diffstat (limited to 'Keywords')
-rw-r--r--Keywords/sample.ucl36
1 files changed, 29 insertions, 7 deletions
diff --git a/Keywords/sample.ucl b/Keywords/sample.ucl
index 834788cbc418..7ca2df923753 100644
--- a/Keywords/sample.ucl
+++ b/Keywords/sample.ucl
@@ -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