aboutsummaryrefslogtreecommitdiff
path: root/trunk/src
diff options
context:
space:
mode:
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2007-02-11 22:07:34 +0000
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2007-02-11 22:07:34 +0000
commit50570901c1743d507dd4ca347b161786cab608f0 (patch)
tree7215b09cd71c05c14bde594ef499a522a0c94812 /trunk/src
parentc6df3969c725f6a102a0d4ae9d8a7265eba48c85 (diff)
downloadsimplepkg-50570901c1743d507dd4ca347b161786cab608f0.tar.gz
simplepkg-50570901c1743d507dd4ca347b161786cab608f0.tar.bz2
templatepkg: now -c is different from -u
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@186 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'trunk/src')
-rwxr-xr-xtrunk/src/jail-commit6
-rwxr-xr-xtrunk/src/templatepkg103
2 files changed, 86 insertions, 23 deletions
diff --git a/trunk/src/jail-commit b/trunk/src/jail-commit
index d6e18f3..656d568 100755
--- a/trunk/src/jail-commit
+++ b/trunk/src/jail-commit
@@ -36,8 +36,7 @@ function template_merge {
return 1
fi
- rm -f $TEMPLATE_BASE.perms
- touch $TEMPLATE_BASE.perms
+ echo "" > $TEMPLATE_BASE.perms
cd $TEMPLATE_BASE.d
for file in `find`; do
@@ -57,8 +56,7 @@ function template_merge {
function template_svn_commit {
- if [ "$TEMPLATES_UNDER_SVN" == "1" ] && \
- [ "$TEMPLATE_STORAGE_STYLE" == "own-folder" ]; then
+ if use_svn; then
cd `basedir $TEMPLATE_BASE`
svn commit -m "changes for `date`"
fi
diff --git a/trunk/src/templatepkg b/trunk/src/templatepkg
index 0a48406..914f1aa 100755
--- a/trunk/src/templatepkg
+++ b/trunk/src/templatepkg
@@ -33,10 +33,11 @@ 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 " -c | --create: create a template from a jail; arguments are:"
echo ""
- echo " -c and -u are equivalent and their arguments are:"
+ echo " $BASENAME -u <template> [jail-root]"
+ echo ""
+ echo " -u | --update: update a template from a jail; arguments are:"
echo ""
echo " $BASENAME -u <template> [jail-root]"
echo ""
@@ -61,10 +62,66 @@ function usage {
}
+function template_create {
+
+ # create a new template
+ # TODO: usar svn add $TEMPLATE_BASE ao inves de svn mkdir, etc?
+
+ local template_base
+
+ if [ ! -d "$TEMPLATE_BASE" ]; then
+ if use_svn && [ -d "`dirname $TEMPLATE_BASE`/.svn" ]; then
+ cd `dirname $TEMPLATE_BASE`
+ svn mkdir $TEMPLATE_BASE
+ else
+ mkdir -p $TEMPLATE_BASE
+ fi
+ fi
+
+ touch $TEMPLATE.perms
+ touch $TEMPLATE.template
+
+ if use_svn && [ -d "$TEMPLATE_BASE/.svn" ]; then
+
+ cd $TEMPLATE_BASE
+
+ if ! svn_check $TEMPLATE.d; then
+ svn mkdir $TEMPLATE.d
+ fi
+
+ if ! svn_check $TEMPLATE.s; then
+ svn mkdir $TEMPLATE.s
+ fi
+
+ if ! svn_check $TEMPLATE.template; then
+ svn add $TEMPLATE.template
+ fi
+
+ if ! svn_check $TEMPLATE.perms; then
+ svn add $TEMPLATE.perms
+ fi
+
+ else
+ mkdir $TEMPLATE.{d,s}
+ fi
+
+ template_update
+
+}
+
function template_update {
# update the template package list
+ components="$TEMPLATE.template $TEMPLATE.perms $TEMPLATE.d $TEMPLATE.s"
+ for component in $components; do
+ if [ ! -a "$component" ]; then
+ echo $BASENAME: template component not found: $component
+ echo $BASENAME: please run $BASENAME -c before update a template
+ exit 1
+ fi
+ done
+
if [ ! -d "$ROOT/var/log/packages" ]; then
echo $ROOT/var/log/packages: directory not found
exit 1
@@ -131,7 +188,7 @@ function template_add {
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
+ if use_svn; then
( cd $TEMPLATE_BASE.d && svn add $candidate )
info_commit="yes"
fi
@@ -152,7 +209,7 @@ function template_add {
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
+ if use_svn; then
( cd $TEMPLATE_BASE.d && svn add $file )
echo $BASENAME: please run jail-commit to add $file into the svn repository
true
@@ -166,6 +223,19 @@ function template_add {
}
+function setroot {
+
+ # set ROOT variable
+ # usage: setroot <value1> <value2>
+
+ if [ -z "$1" ]; then
+ ROOT="/"
+ else
+ ROOT="$1"
+ fi
+
+}
+
# command line parsing
if [ -z "$2" ]; then
@@ -175,15 +245,14 @@ fi
search_template $2 --new
TEMPLATE="$TEMPLATE_BASE.template"
-if [ "$1" == "-u" ] || [ "$1" == "--update" ] || \
- [ "$1" == "-c" ] || [ "$1" == "--create" ]; then
+if [ "$1" == "-u" ] || [ "$1" == "--update" ]; then
- if [ -z "$3" ]; then
- ROOT="/"
- else
- ROOT="/$3"
- fi
+ setroot $3
+ template_create
+
+elif [ "$1" == "-c" ] || [ "$1" == "--create" ]; then
+ setroot $3
template_update
elif [ "$1" == "-a" ] || [ "$1" == "--add" ]; then
@@ -191,11 +260,7 @@ elif [ "$1" == "-a" ] || [ "$1" == "--add" ]; then
if [ -z "$3" ]; then
usage
else
- if [ -z "$4" ]; then
- ROOT="/"
- else
- ROOT="$4"
- fi
+ setroot $4
fi
template_add $ROOT $3
@@ -207,7 +272,7 @@ elif [ "$1" == "-d" ] || [ "$1" == "--delete" ]; then
else
if [ -a "$TEMPLATE_BASE.d/$3" ]; then
- if [ "$TEMPLATES_UNDER_SVN" == "1" ]; then
+ if use_svn; then
cd $TEMPLATE_BASE
svn del --force ./$3 || rm -rf ./$3
echo $BASENAME: please run jail-commit to del $3 in the svn repository
@@ -220,7 +285,7 @@ elif [ "$1" == "-d" ] || [ "$1" == "--delete" ]; then
elif [ "$1" == "-s" ] || [ "$1" == "--sync" ]; then
- if [ "$TEMPLATES_UNDER_SVN" == "1" ]; then
+ if use_svn; then
if [ -d "$TEMPLATE_BASE.d/.svn" ]; then
( cd $TEMPLATE_BASE.d && svn update )
true