Changeset View
Changeset View
Standalone View
Standalone View
Keywords/sample.ucl
# $FreeBSD$ | # $FreeBSD$ | ||||
# | # | ||||
# MAINTAINER: portmgr@FreeBSD.org | # MAINTAINER: portmgr@FreeBSD.org | ||||
# | # | ||||
# @sample etc/somefile.conf.sample | # @sample etc/somefile.conf.sample | ||||
# | # | ||||
# This will install the somefile.conf.sample and automatically copy to | # This will install the somefile.conf.sample and automatically copy to | ||||
# somefile.conf if it doesn't exist. On deinstall it will remove the | # somefile.conf if it doesn't exist. On deinstall it will remove the | ||||
# somefile.conf if it still matches the sample, otherwise it is | # somefile.conf if it still matches the sample, otherwise it is | ||||
# kept. | # kept. | ||||
# | # | ||||
# This replaces the old pattern: | # This replaces the old pattern: | ||||
# @unexec if cmp -s %D/etc/pkgtools.conf %D/etc/pkgtools.conf.sample; then rm -f %D/etc/pkgtools.conf; fi | # @unexec if cmp -s %D/etc/pkgtools.conf %D/etc/pkgtools.conf.sample; then rm -f %D/etc/pkgtools.conf; fi | ||||
# etc/pkgtools.conf.sample | # etc/pkgtools.conf.sample | ||||
# @exec [ -f %B/pkgtools.conf ] || cp %B/%f %B/pkgtools.conf | # @exec [ -f %B/pkgtools.conf ] || cp %B/%f %B/pkgtools.conf | ||||
actions: [file] | actions: [file(1)] | ||||
arguments: true | |||||
post-install: <<EOD | post-install: <<EOD | ||||
case "%@" in | set -x | ||||
/*) sample_file="%@" ;; | case "%1" in | ||||
*) sample_file="%D/%@" ;; | /*) sample_file="%1" ;; | ||||
*) sample_file="%D/%1" ;; | |||||
esac | esac | ||||
target_file="${sample_file%.sample}" | 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 | if ! [ -f "${target_file}" ]; then | ||||
/bin/cp -p "${sample_file}" "${target_file}" && \ | /bin/cp -p "${sample_file}" "${target_file}" && \ | ||||
/bin/chmod u+w "${target_file}" | /bin/chmod u+w "${target_file}" | ||||
fi | fi | ||||
EOD | EOD | ||||
pre-deinstall: <<EOD | pre-deinstall: <<EOD | ||||
case "%@" in | case "%1" in | ||||
/*) sample_file="%@" ;; | /*) sample_file="%1" ;; | ||||
*) sample_file="%D/%@" ;; | *) sample_file="%D/%1" ;; | ||||
esac | esac | ||||
target_file="${sample_file%.sample}" | 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 | if cmp -s "${target_file}" "${sample_file}"; then | ||||
rm -f "${target_file}" | rm -f "${target_file}" | ||||
else | else | ||||
echo "You may need to manually remove ${target_file} if it's no longer needed." | echo "You may need to manually remove ${target_file} if it's no longer needed." | ||||
fi | fi | ||||
EOD | EOD |