template-control - A script to expand out template package control scripts in InstallPackage
check-pkg [-hvqsE] [-e ext] [-p directory] [-M master]
Supported options are:
-v option if it was also
given.
. prepended to it.
The default is template.
InstallPackage.
/usr/local/lib/pkg-tools/master.template
This script handles template files for package control scripts. The author of this
script has built up a set of functions which can be used to all sorts of neat
things within package control scripts. Things like automating the addition or removal
of entries from files /etc/syslog.conf, even if said files use RCS. However this
set of functions is an evolving system which means that you have to provide to the
package control scripts. There are a number of different ways of doing this:
sh code similar to:
eval "`cat /usr/local/lib/pkg-tools/package-functions.sh`"
This will work quite well, however the file must exist for the package to be
correctly installed. This would mean having a package with just the above file
within it which all other packages would then depend on. This would work, but it
would mean that if the above file was removed then packages could not be installed
or removed; preinstall and preremove package control scripts would probably
have to be put into place for every package to ensure that the file was in place
before letting the package be installed or removed.
Personally I prefer the templating system, although you should've probably guessed that from the fact that this command exists in the first place.
The script works by searching the package control directory - by default InstallPackage -
for any template files. These files have a file extension of template by default.
Each template file is loaded in turn and combined with the master template file which is
held at /usr/local/lib/pkg-tools/master.template
This expansion takes the form of the loading each file in turn and the replacement of
the string %%%MASTER_TEMPLATE%%% with the contents of the master template file. There
are a number of variables which must by present in the sh code of the package
control scripts for this to work.
The expanded file is written into a file which has a name related to the template file
name - essentially it is the same name, but with the template file extension stripped
away. Thus InstallPackage/postinstall.template would end up as the more useful
InstallPackage/postinstall
As mentioned above there are several variables which have to be present for the master template file to work; please see the
master_template(4) manual page for more details.
Simon Burr <simes@bpfh.net>
Copyright (c) 2003, Simon Burr <simes@bpfh.net> All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.