svn commit: r47467 - head/en_US.ISO8859-1/books/porters-handbook/plist

Mathieu Arnold mat at FreeBSD.org
Thu Oct 1 14:34:27 UTC 2015


Author: mat
Date: Thu Oct  1 14:34:26 2015
New Revision: 47467
URL: https://svnweb.freebsd.org/changeset/doc/47467

Log:
  Update the @sample example to catch up with reality.
  
  Reviewed by:	brd, wblock
  Sponsored by:	Absolight
  Differential Revision:	https://reviews.freebsd.org/D3755

Modified:
  head/en_US.ISO8859-1/books/porters-handbook/plist/chapter.xml

Modified: head/en_US.ISO8859-1/books/porters-handbook/plist/chapter.xml
==============================================================================
--- head/en_US.ISO8859-1/books/porters-handbook/plist/chapter.xml	Thu Oct  1 14:34:20 2015	(r47466)
+++ head/en_US.ISO8859-1/books/porters-handbook/plist/chapter.xml	Thu Oct  1 14:34:26 2015	(r47467)
@@ -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>


More information about the svn-doc-all mailing list