Update the @sample example to catch up with reality.
Reviewed by: brd, wblock Sponsored by: Absolight Differential Revision: https://reviews.freebsd.org/D3755
This commit is contained in:
parent
862b2b51c6
commit
15f7e94fd1
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/head/; revision=47467
1 changed files with 29 additions and 10 deletions
|
|
@ -881,7 +881,7 @@ EOD</programlisting>
|
|||
<title>Real Life Example, How <literal>@sample</literal>
|
||||
is Implemented</title>
|
||||
|
||||
<para>This keyword does three things, it adds the
|
||||
<para>This keyword does three things. It adds the first
|
||||
<replaceable>filename</replaceable> passed as an argument to
|
||||
<literal>@sample</literal> to the packing list, it adds to
|
||||
the <literal>post-install</literal> script instructions to
|
||||
|
|
@ -890,27 +890,46 @@ EOD</programlisting>
|
|||
<literal>post-deinstall</literal> instructions to remove the
|
||||
configuration file if it has not been modified.</para>
|
||||
|
||||
<programlisting>actions: [file]
|
||||
<programlisting>actions: [file(1)]
|
||||
arguments: true
|
||||
post-install: <<EOD
|
||||
case "%@" in
|
||||
/*) sample_file="%@" ;;
|
||||
*) sample_file="%D/%@" ;;
|
||||
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/cp -p "${sample_file}" "${target_file}" && \
|
||||
/bin/chmod u+w "${target_file}"
|
||||
fi
|
||||
EOD
|
||||
pre-deinstall: <<EOD
|
||||
case "%@" in
|
||||
/*) sample_file="%@" ;;
|
||||
*) sample_file="%D/%@" ;;
|
||||
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's no longer needed."
|
||||
echo "You may need to manually remove ${target_file} if it is no longer needed."
|
||||
fi
|
||||
EOD</programlisting>
|
||||
</example>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue