aboutsummaryrefslogtreecommitdiff
path: root/src/templatepkg
diff options
context:
space:
mode:
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2007-02-11 14:29:54 +0000
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2007-02-11 14:29:54 +0000
commitf9a8dfcd51e481a49355d94a3e74f2762519378f (patch)
tree948f0382081bd2eb8b1b5458a9661b67a090e795 /src/templatepkg
parentfef31cbc9988ead081aaec587222b44ed524b6fd (diff)
downloadsimplepkg-f9a8dfcd51e481a49355d94a3e74f2762519378f.tar.gz
simplepkg-f9a8dfcd51e481a49355d94a3e74f2762519378f.tar.bz2
changed repository layout to trunk/, tags/ and branches/ scheme
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@181 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'src/templatepkg')
-rwxr-xr-xsrc/templatepkg220
1 files changed, 0 insertions, 220 deletions
diff --git a/src/templatepkg b/src/templatepkg
deleted file mode 100755
index 1382759..0000000
--- a/src/templatepkg
+++ /dev/null
@@ -1,220 +0,0 @@
-#!/bin/bash
-#
-# templatepkg v0.3: template maintenance script from simplepkg suite
-#
-# feedback: rhatto at riseup.net | gpl
-#
-# Templatepkg is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or any later version.
-#
-# Templatepkg is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-# Place - Suite 330, Boston, MA 02111-1307, USA
-#
-
-COMMON="/usr/libexec/simplepkg/common.sh"
-BASENAME="`basename $0`"
-
-if [ -f "$COMMON" ]; then
- source $COMMON
- eval_config `basename $0`
-else
- echo "error: file $COMMON found, check your `basename $0` installation"
- exit 1
-fi
-
-function usage {
-
- echo "usage: $BASENAME <option> <template> [arguments]"
- echo "options:"
- echo ""
- echo " -c | --create: create a template from a jail;"
- echo " -u | --update: update a template from a jail."
- echo ""
- echo " -c and -u are equivalent and their arguments are:"
- echo ""
- echo " $BASENAME -u <template> [jail-root]"
- echo ""
- echo " -a | --add: add files into a template; arguments for -a are:"
- echo ""
- echo " $BASENAME -a <template> <file-name> [jail-root]"
- echo ""
- echo " file-name: the file or directory to be added"
- echo " jail-root: the jail under file-name is located"
- echo ""
- echo " -d | --delete: delete files or folders from a template; arguments are:"
- echo ""
- echo " $BASENAME -d <template> <file-name>"
- echo ""
- echo " in all cases (-c, -u and -a), jail-root defaults to /, if ommited"
- echo ""
- exit 1
-
-}
-
-function template_update {
-
- # update the template package list
-
- if [ ! -d "$ROOT/var/log/packages" ]; then
- echo $ROOT/var/log/packages: directory not found
- exit 1
- fi
-
- for package in `ls -1 $ROOT/var/log/packages/`; do
- pack=`package_name $package`
- if [ -f $TEMPLATE ]; then
- if ! `grep -v -e "^#" $TEMPLATE | cut -d : -f 1 | grep -q -e "^$pack\$"`; then
- package_name $package >> $TEMPLATE
- fi
- else
- package_name $package >> $TEMPLATE
- fi
- done
-
- # check if each package from the template is installed
- grep -v -e "^#" $TEMPLATE | cut -d : -f 1 | while read pack; do
-
- if [ ! -z "$pack" ]; then
- unset found
- for candidate in `ls $ROOT/var/log/packages/$pack* 2> /dev/null`; do
- candidate="`package_name $candidate`"
- if [ "$pack" == "$candidate" ]; then
- found="1"
- break
- fi
- done
- if [ "$found" != "1" ]; then
- # remove a non-installed package from the template
- sed "/^$pack$/d" $TEMPLATE | sed "/^$pack $/d" | sed "/^$pack:*/d" > $TEMPLATE.tmp
- cat $TEMPLATE.tmp > $TEMPLATE
- rm -f $TEMPLATE.tmp
- fi
- fi
-
- done
-
-}
-
-function template_add {
-
- # add a file in a template
- # usage: template_add <jail-root> <file>
-
- local info_commit
-
- mkdir -p $TEMPLATE_BASE.d
-
- if [ -z "$1" ] || [ -z "$2" ]; then
- return 1
- fi
-
- jail="/$1"
- file="$2"
-
- if [ -a "$TEMPLATE_BASE.d/$file" ]; then
- if [ -d "$TEMPLATE_BASE.d/$file" ]; then
-
- echo $BASENAME: folder $file already on $TEMPLATE_BASE.d, checking for contents
-
- cd $jail
- for candidate in `find $file`; do
- if [ ! -a "$TEMPLATE_BASE.d/$candidate" ]; then
- mkdir -p $TEMPLATE_BASE.d/`dirname $candidate`
- cp -a $jail/$candidate $TEMPLATE_BASE.d/$candidate
- if [ "$TEMPLATES_UNDER_SVN" == "1" ]; then
- ( cd $TEMPLATE_BASE.d && svn add $candidate )
- info_commit="yes"
- fi
- fi
- done
-
- if [ "$info_commit" == "yes" ]; then
- echo $BASENAME: please run jail-commit to add files under $file into the svn repository
- fi
-
- else
- echo $BASENAME: file $file already on $TEMPLATE_BASE.d
- exti 1
- fi
- else
- if [ -a "$jail/$file" ]; then
-
- mkdir -p $TEMPLATE_BASE.d/`dirname $file`/
- destination="`echo $TEMPLATE_BASE.d/$file | sed -e 's/\/$//'`"
- cp -a $jail/$file $destination
- if [ "$TEMPLATES_UNDER_SVN" == "1" ]; then
- ( cd $TEMPLATE_BASE.d && svn add $file )
- echo $BASENAME: please run jail-commit to add $file into the svn repository
- true
- fi
-
- else
- echo $BASENAME: $jail/$file: file not found
- exit 1
- fi
- fi
-
-}
-
-# command line parsing
-
-if [ -z "$2" ]; then
- usage
-fi
-
-search_template $2 --new
-TEMPLATE="$TEMPLATE_BASE.template"
-
-if [ "$1" == "-u" ] || [ "$1" == "--update" ] || \
- [ "$1" == "-c" ] || [ "$1" == "--create" ]; then
-
- if [ -z "$3" ]; then
- ROOT="/"
- else
- ROOT="/$3"
- fi
-
- template_update
-
-elif [ "$1" == "-a" ] || [ "$1" == "--add" ]; then
-
- if [ -z "$3" ]; then
- usage
- else
- if [ -z "$4" ]; then
- ROOT="/"
- else
- ROOT="$4"
- fi
- fi
-
- template_add $ROOT $3
-
-elif [ "$1" == "-d" ] || [ "$1" == "--delete" ]; then
-
- if [ -z "$3" ]; then
- usage
- else
-
- if [ -a "$TEMPLATE_BASE.d/$3" ]; then
- if [ "$TEMPLATES_UNDER_SVN" == "1" ]; then
- cd $TEMPLATE_BASE
- svn del --force ./$3 || rm -rf ./$3
- echo $BASENAME: please run jail-commit to del $3 in the svn repository
- else
- rm -rf $TEMPLATE_BASE.d/$3
- fi
- fi
-
- fi
-
-else
- usage
-fi
-