1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-05 01:55:52 +00:00
freebsd-ports/Keywords/sample.ucl
Bryan Drewery 581b88c885 @sample: chmod u+w to ensure user may write to it.
PR:		193209
Submitted by:	ohauer
With hat:	portmgr
2014-10-03 18:33:32 +00:00

41 lines
1.1 KiB
Plaintext

# $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: <<EOD
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}" && \
/bin/chmod u+w "${target_file}"
fi
EOD
pre-deinstall: <<EOD
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}"
else
echo "You may need to manually remove ${target_file} if it's no longer needed."
fi
EOD