\HeaderA{createPackage}{Create a Package Directory from a Template}{createPackage}
\keyword{programming}{createPackage}
\begin{Description}\relax
Create a package directory from a template, with symbol-value substitution
\end{Description}
\begin{Usage}
\begin{verbatim}
createPackage(pkgname, destinationDir, originDir, symbolValues, unlink=FALSE, quiet=FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{pkgname}] Character. The name of the package to be written.
\item[\code{destinationDir}] Character. The path to a directory where the
package is to be written.
\item[\code{originDir}] Character. The path to a directory that contains
the template package. Usually, this will contain a file named
\code{DESCRIPTION}, and subdirectories \code{R}, \code{man},
\code{data}. In all files and filenames, symbols will be replaced
by their respective values, see the parameter \code{symbolValues}.
\item[\code{symbolValues}] Named list of character strings. The symbol-to-value
mapping. See
\code{\LinkA{copySubstitute}{copySubstitute}} for details.
\item[\code{unlink}] Logical. If \code{TRUE}, and \code{destinationDir}
already contains a file or directory with the name \code{pkgname},
try to unlink (remove) it.
\item[\code{quiet}] Logical. If \code{TRUE}, do not print information
messages.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The intended use of this function is for the automated mass
production of data packages, such as the microarray annotation,
CDF, and probe sequence packages.

No syntactic or other checking of the package is performed. For this,
use R CMD check.

The symbols \code{@PKGNAME@} and \code{@DATE@} are automatically
defined with the values of \code{pkgname} and \code{date()}, respectively.
\end{Details}
\begin{Value}
The function returns a \code{list} with one element
\code{pkgdir}: the path to the package.
\end{Value}
\begin{Author}\relax
Wolfgang Huber \url{http://www.dkfz.de/mga/whuber}
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{copySubstitute}{copySubstitute}},
the reference manual \emph{Writing R extensions}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
  sym  = list(AUTHOR = "Hesiod", VERSION = "1.0",
         TITLE = "the nine muses",
         FORMAT = "Character vector containg the names of the 9 muses.")

  res  = createPackage("muses",
           destinationDir = tempdir(),
           originDir      = system.file("Code", package="Biobase"),
           symbolValues   = sym,
           unlink = TRUE, quiet = FALSE)

  muses = c("Calliope", "Clio", "Erato", "Euterpe", "Melpomene",
            "Polyhymnia", "Terpsichore", "Thalia", "Urania")

  dir.create(file.path(res$pkgdir, "data"))

  save(muses, file = file.path(res$pkgdir, "data", "muses.rda"))

  res$pkgdir
\end{ExampleCode}
\end{Examples}

