aboutsummaryrefslogtreecommitdiff
path: root/trunk/src/templatepkg
diff options
context:
space:
mode:
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2007-04-05 23:14:35 +0000
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2007-04-05 23:14:35 +0000
commit9e11a804a8604fa8e379fe8f342aa8135d042faa (patch)
tree944fdf29a2956014dc49c08ed33a507fe7eda477 /trunk/src/templatepkg
parenteed8f5ad968c3af4562075763689b1009ebf71e9 (diff)
downloadsimplepkg-9e11a804a8604fa8e379fe8f342aa8135d042faa.tar.gz
simplepkg-9e11a804a8604fa8e379fe8f342aa8135d042faa.tar.bz2
templatepkg: added -t and -p
jail-update: added --help jail-commit: added --help and --all git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@268 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'trunk/src/templatepkg')
-rwxr-xr-xtrunk/src/templatepkg91
1 files changed, 90 insertions, 1 deletions
diff --git a/trunk/src/templatepkg b/trunk/src/templatepkg
index 912f591..858911d 100755
--- a/trunk/src/templatepkg
+++ b/trunk/src/templatepkg
@@ -72,6 +72,14 @@ function usage {
echo ""
echo " $BASENAME -l [template-name]"
echo ""
+ echo " -p | --post-install: add or edit post-installation scripts:"
+ echo ""
+ echo " $BASENAME -p <template-name> <script-name>"
+ echo ""
+ echo " -t | --template-edit: edit template package list:"
+ echo ""
+ echo " $BASENAME -t <template-name>"
+ echo ""
echo " -h | --help: display this summary."
echo ""
echo " for -c, -u and -a jail-root defaults to / if ommited"
@@ -491,9 +499,14 @@ function template_remove {
basedir="`dirname $TEMPLATE_BASE`"
template="`basename $basedir`"
+ if [ ! -d "$basedir" ]; then
+ echo $BASENAME: template $template does not exist
+ exit 1
+ fi
+
if use_svn && [ -d "$basedir/.svn" ]; then
cd $BASE_CONF/templates
- svn del $template
+ svn del --force $template
if [ "$?" != "0" ]; then
echo $BASENAME: error deleting template $template
else
@@ -529,6 +542,72 @@ function template_list {
}
+function template_post_install_edit {
+
+ # add or edit a post-installation script
+ # usage: template_post_install_edit <script-name>
+
+ if [ -z "$1" ]; then
+ echo $BASENAME: no template specified
+ exit 1
+ elif echo $1 | grep -q "/"; then
+ echo $BASENAME: error: invalid script name $1
+ fi
+
+ if [ -f "$TEMPLATE_BASE.s/$1" ]; then
+ sha1sum="`sha1sum $TEMPLATE_BASE.s/$1`"
+ if [ ! -z "$EDITOR" ]; then
+ $EDITOR $TEMPLATE_BASE.s/$1
+ else
+ vi $TEMPLATE_BASE.s/$1
+ fi
+ if [ "$sha1sum" != "`sha1sum $TEMPLATE_BASE.s/$1`" ]; then
+ echo $BASENAME: please run jail-commit to send changes to the repository
+ fi
+ else
+
+ if [ -d "$TEMPLATE_BASE.s" ]; then
+
+ touch $TEMPLATE_BASE.s/$1
+ chmod +x $TEMPLATE_BASE.s/$1
+
+ if [ -d "$TEMPLATE_BASE.s/.svn" ]; then
+ cd $TEMPLATE_BASE.s
+ svn add $1
+ echo "$BASENAME: please run jail-commit to send the script to the repository"
+ fi
+
+ echo "$BASENAME: script created; run templatepkg -p `basename $TEMPLATE_BASE` $1 again to edit it"
+
+ else
+ echo $BASENAME: folder not found: $TEMPLATE_BASE.s
+ fi
+
+ fi
+
+}
+
+function template_edit {
+
+ # edit a template package list
+ # usage: template_edit
+
+ if [ -f "$TEMPLATE_BASE.template" ]; then
+ sha1sum="`sha1sum $TEMPLATE_BASE.template`"
+ if [ ! -z "$EDITOR" ]; then
+ $EDITOR $TEMPLATE_BASE.template
+ else
+ vi $TEMPLATE_BASE.template
+ fi
+ if [ "$sha1sum" != "`sha1sum $TEMPLATE_BASE.template`" ]; then
+ echo $BASENAME: please run jail-commit to send changes to the repository
+ fi
+ else
+ echo $BASENAME: file not found: $TEMPLATE_BASE.template
+ fi
+
+}
+
function require {
# requires a string
@@ -630,6 +709,16 @@ elif [ "$1" == "-l" ] || [ "$1" == "--list" ]; then
template_list $2
+elif [ "$1" == "-p" ] || [ "$1" == "--post-install" ]; then
+
+ require $3
+ template_post_install_edit $3
+
+elif [ "$1" == "-t" ] || [ "$1" == "--template-edit" ]; then
+
+ require $2
+ template_edit
+
elif [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
usage