diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-09-26 12:13:23 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-09-26 12:13:23 +0000 |
commit | 5adc8a9faaebe0a180ed8a3d10fc3e17dde7d29c (patch) | |
tree | 3e4a83167a13b89c9d0efeeaa6e5b0f5487d84e9 /Keywords | |
parent | ce1853bf021623ab004669e0073c29ab6a83994f (diff) | |
download | ports-5adc8a9faaebe0a180ed8a3d10fc3e17dde7d29c.tar.gz ports-5adc8a9faaebe0a180ed8a3d10fc3e17dde7d29c.zip |
Notes
Diffstat (limited to 'Keywords')
-rw-r--r-- | Keywords/sample.ucl | 36 |
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 |