Changeset View
Changeset View
Standalone View
Standalone View
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 | ||||
mat: There is so much magic going on here.
What is `%@` ? What is `%S+` ? I looked at pkg-lua… | |||||
Done Inline ActionsI copied the gsub from the old review but a simple test on %# will be enough. I'll update the code. manu: I copied the gsub from the old review but a simple test on %# will be enough. I'll update the… | |||||
*) 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 | ||||
Done Inline ActionsThis is not what the script was doing before. The script copies the .sample to the destination file if the destination file does not exist. There is absolutely no comparison involved. There should be a pkg.fileexists or something. mat: This is not what the script was doing before.
The script copies the .sample to the destination… | |||||
Done Inline ActionsThis is exactly what it does too. manu: This is exactly what it does too.
Sure there is a "useless" cmp, I can see to add a fileexist… | |||||
/*) 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 -- %@ | |||||
if [ $# -eq 2 ]; then | EOS | ||||
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 |
There is so much magic going on here.
What is %@ ? What is %S+ ? I looked at pkg-lua-script(5) and it does not appear in it.