Changeset View
Changeset View
Standalone View
Standalone View
head/Keywords/sample.ucl
Show All 14 Lines | |||||
# | # | ||||
# 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(1)] | actions: [file(1)] | ||||
arguments: true | arguments: true | ||||
post-install: <<EOD | post-install-lua: <<EOS | ||||
case "%1" in | sample_file = pkg.prefixed_path("%1") | ||||
/*) sample_file="%1" ;; | if "%#" == 2 then | ||||
*) sample_file="%D/%1" ;; | target_file = pkg.prefixed_path("%1") | ||||
esac | else | ||||
target_file="${sample_file%.sample}" | target_file = string.gsub(sample_file,'%.sample$', "") | ||||
set -- %@ | end | ||||
if [ $# -eq 2 ]; then | if not pkg.stat(target_file) then | ||||
target_file=${2} | pkg.copy(sample_file, target_file) | ||||
fi | end | ||||
case "${target_file}" in | EOS | ||||
/*) target_file="${target_file}" ;; | |||||
*) target_file="%D/${target_file}" ;; | pre-deinstall-lua: <<EOS | ||||
esac | sample_file = pkg.prefixed_path("%1") | ||||
if ! [ -f "${target_file}" ]; then | if "%#" == 2 then | ||||
/bin/cp -p "${sample_file}" "${target_file}" | target_file = pkg.prefixed_path("%1") | ||||
fi | else | ||||
EOD | target_file = string.gsub(sample_file,'%.sample$', "") | ||||
pre-deinstall: <<EOD | end | ||||
case "%1" in | if pkg.filecmp(sample_file, target_file) == 0 then | ||||
/*) sample_file="%1" ;; | os.remove(target_file) | ||||
*) sample_file="%D/%1" ;; | else | ||||
esac | pkg.print_msg("You may need to manually remove " .. target_file .. " if it is no longer needed.") | ||||
target_file="${sample_file%.sample}" | end | ||||
set -- %@ | EOS | ||||
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}" | |||||
elif [ -e "${target_file}" ] ; then | |||||
echo "You may need to manually remove ${target_file} if it is no longer needed." | |||||
fi | |||||
EOD |