English German (de_DE)
These keywords contains a man:sh[1] script to be executed before or after installation, deinstallation, or upgrade of the package. In addition to the usual `@exec %_foo_` placeholders described in <<plist-keywords-base-exec>>, there is a new one, `%@`, which represents the argument of the keyword.
Custom Keyword Examples
Example of a `@dirrmtryecho` Keyword
This keyword does two things, it adds a `@dirrmtry _directory_` line to the packing list, and echoes the fact that the directory is removed when deinstalling the package.
actions: [dirrmtry]
post-deinstall: <<EOD
echo "Directory %D/%@ removed."
EOD
Real Life Example, How `@sample` is Implemented
This keyword does three things. It adds the first _filename_ passed as an argument to `@sample` to the packing list, it adds to the `post-install` script instructions to copy the sample to the actual configuration file if it does not already exist, and it adds to the `post-deinstall` instructions to remove the configuration file if it has not been modified.
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}" && \
/bin/chmod u+w "${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