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:
Mathieu Arnold 2015-10-01 14:34:26 +00:00
parent 862b2b51c6
commit 15f7e94fd1
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=47467

View file

@ -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: &lt;&lt;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}" &amp;&amp; \
/bin/chmod u+w "${target_file}"
fi
EOD
pre-deinstall: &lt;&lt;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>