aboutsummaryrefslogtreecommitdiff
path: root/Keywords/sample.ucl
diff options
context:
space:
mode:
authorEmmanuel Vadot <manu@FreeBSD.org>2020-10-01 18:32:29 +0000
committerEmmanuel Vadot <manu@FreeBSD.org>2020-10-01 18:32:29 +0000
commit18ad3a1d26423fbd0378e74268ae50c2c8053d2d (patch)
tree23981cd3f7c7669df1cf8b525db595ee4bdbf6a9 /Keywords/sample.ucl
parent8ef3eb76a8252fbb06aa11268aefceae61352893 (diff)
downloadports-18ad3a1d26423fbd0378e74268ae50c2c8053d2d.tar.gz
ports-18ad3a1d26423fbd0378e74268ae50c2c8053d2d.zip
Notes
Diffstat (limited to 'Keywords/sample.ucl')
-rw-r--r--Keywords/sample.ucl64
1 files changed, 25 insertions, 39 deletions
diff --git a/Keywords/sample.ucl b/Keywords/sample.ucl
index 9fb7c626c2cb..4f9b388e3d87 100644
--- a/Keywords/sample.ucl
+++ b/Keywords/sample.ucl
@@ -20,42 +20,28 @@
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}"
- elif [ -e "${target_file}" ] ; then
- echo "You may need to manually remove ${target_file} if it is no longer needed."
- fi
-EOD
+post-install-lua: <<EOS
+ sample_file = pkg.prefixed_path("%1")
+ if "%#" == 2 then
+ target_file = pkg.prefixed_path("%1")
+ else
+ target_file = string.gsub(sample_file,'%.sample$', "")
+ end
+ if not pkg.stat(target_file) then
+ pkg.copy(sample_file, target_file)
+ end
+EOS
+
+pre-deinstall-lua: <<EOS
+ sample_file = pkg.prefixed_path("%1")
+ if "%#" == 2 then
+ target_file = pkg.prefixed_path("%1")
+ else
+ target_file = string.gsub(sample_file,'%.sample$', "")
+ end
+ if pkg.filecmp(sample_file, target_file) == 0 then
+ os.remove(target_file)
+ else
+ pkg.print_msg("You may need to manually remove " .. target_file .. " if it is no longer needed.")
+ end
+EOS