aboutsummaryrefslogtreecommitdiffstats
path: root/Keywords
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2015-09-26 20:13:23 +0800
committerbapt <bapt@FreeBSD.org>2015-09-26 20:13:23 +0800
commit90a5834466ddfbc6d2e6aa7289414fe376fd2832 (patch)
tree3e4a83167a13b89c9d0efeeaa6e5b0f5487d84e9 /Keywords
parent9111fbcf07f46dec3c2f410c5990019ff2ae72df (diff)
downloadfreebsd-ports-gnome-90a5834466ddfbc6d2e6aa7289414fe376fd2832.tar.gz
freebsd-ports-gnome-90a5834466ddfbc6d2e6aa7289414fe376fd2832.tar.zst
freebsd-ports-gnome-90a5834466ddfbc6d2e6aa7289414fe376fd2832.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
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