mirror of
https://git.FreeBSD.org/ports.git
synced 2024-12-17 03:25:46 +00:00
e682d8cb62
It is up to the package to decide the mode of the config files Reported by: garga
62 lines
1.5 KiB
Plaintext
62 lines
1.5 KiB
Plaintext
# $FreeBSD$
|
|
#
|
|
# 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
|
|
# 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(1)]
|
|
arguments: true
|
|
post-install: <<EOD
|
|
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}"
|
|
fi
|
|
EOD
|
|
pre-deinstall: <<EOD
|
|
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
|
|
echo "You may need to manually remove ${target_file} if it is no longer needed."
|
|
fi
|
|
EOD
|