1 # $FreeBSD: head/Keywords/sample.ucl 417335 2016-06-22 21:44:25Z bapt $
3 # MAINTAINER: portmgr@FreeBSD.org
5 # @sample etc/somefile.conf.sample
9 # Where file1 is considered as a sample file and file2 the target file
11 # This will install the somefile.conf.sample and automatically copy to
12 # somefile.conf if it doesn't exist. On deinstall it will remove the
13 # somefile.conf if it still matches the sample, otherwise it is
16 # This replaces the old pattern:
17 # @unexec if cmp -s %D/etc/pkgtools.conf %D/etc/pkgtools.conf.sample; then rm -f %D/etc/pkgtools.conf; fi
18 # etc/pkgtools.conf.sample
19 # @exec [ -f %B/pkgtools.conf ] || cp %B/%f %B/pkgtools.conf
25 /*) sample_file="%1" ;;
26 *) sample_file="%D/%1" ;;
28 target_file="${sample_file%.sample}"
33 case "${target_file}" in
34 /*) target_file="${target_file}" ;;
35 *) target_file="%D/${target_file}" ;;
37 if ! [ -f "${target_file}" ]; then
38 /bin/cp -p "${sample_file}" "${target_file}"
43 /*) sample_file="%1" ;;
44 *) sample_file="%D/%1" ;;
46 target_file="${sample_file%.sample}"
52 case "${target_file}" in
53 /*) target_file="${target_file}" ;;
54 *) target_file="%D/${target_file}" ;;
56 if cmp -s "${target_file}" "${sample_file}"; then
57 rm -f "${target_file}"
59 echo "You may need to manually remove ${target_file} if it is no longer needed."