freebsd-ports/Keywords/sample.yaml
Antoine Brodin 26222800aa - Make it possible to use sample keyword with a full path
- Prefer @dirrmtry over @unexec rmdir in makeplist

Differential Revision:	https://reviews.freebsd.org/D705
Reviewed by:	bapt
With hat:	portmgr
2014-09-01 17:06:19 +00:00

35 lines
986 B
YAML

# $FreeBSD$
#
# MAINTAINER: portmgr@FreeBSD.org
#
# @sample etc/somefile.conf.sample
#
# 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 still matches the sample, otherwise it is
# kept.
#
# 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
# etc/pkgtools.conf.sample
# @exec [ -f %B/pkgtools.conf ] || cp %B/%f %B/pkgtools.conf
actions: [file]
post-install: |
case "%@" in
/*) sample_file="%@" ;;
*) sample_file="%D/%@" ;;
esac
target_file="${sample_file%.sample}"
if ! [ -f "${target_file}" ]; then
/bin/cp -p "${sample_file}" "${target_file}"
fi
pre-deinstall: |
case "%@" in
/*) sample_file="%@" ;;
*) sample_file="%D/%@" ;;
esac
target_file="${sample_file%.sample}"
if cmp -s "${target_file}" "${sample_file}"; then
rm -f "${target_file}"
fi