]> gitweb.fluxo.info Git - simplepkg.git/commitdiff
changing template location procedures
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Thu, 8 Feb 2007 23:58:09 +0000 (23:58 +0000)
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Thu, 8 Feb 2007 23:58:09 +0000 (23:58 +0000)
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@163 04377dda-e619-0410-9926-eae83683ac58

conf/simplepkg.conf.new
doc/CHANGELOG
lib/common.sh
src/jail-update
src/mkjail
src/templatepkg
templates/mplayer.metapkg [deleted file]

index 29be9fafd41f5fce12427fa068fb9607cb96863c..f590feb391ce465b42da1714ad9e8d6a2e0c256a 100644 (file)
@@ -94,3 +94,6 @@ CONSIDER_ALL_PACKAGES_AS_PATCHES="0"
 # stored in the same tree.
 STORE_ROOT_PATCHES_ON_PATCHES_DIR="0"
 
+# Where your templates will be located
+TEMPLATE_FOLDER="/etc/simplepkg/templates"
+
index f4cbce3282cd605492c3011e81c3ddd8c3ba56a2..c64e5fc9ee7a4556fadc1c3c45404f7ddb76d754 100644 (file)
@@ -7,6 +7,11 @@ simplepkg changelog
               - SIGNATURE_CHECKING
             - signature checking
             - dependency checking through slack-required
+            mkjail:
+            - templates now can be stored either on
+               - /etc/simplepkg/template_name.template
+               - /etc/simplepkg/templates/template_name.template
+               - /etc/simplepkg/templates/template_name/template_name.template
 
 0.4.9pre18-23: simplaret:
                - enhanced http retrieval: curl support
index 2b78c107f38699cdf6ca0b00f0535f2a09758e8a..5b8246966e39996de7f5331b579a8af65a05bd59 100644 (file)
@@ -198,6 +198,10 @@ function eval_config {
     FTP_TOOL="`eval_parameter FTP_TOOL curl`"
     HTTP_TOOL="`eval_parameter HTTP_TOOL curl`"
     CONNECT_TIMEOUT="`eval_parameter CONNECT_TIMEOUT 0`"
+    TEMPLATE_FOLDER="`eval_parameter TEMPLATE_BASE /etc/simplepkg/templates`"
+
+    # TODO: also add this stuff in simplepkg.conf.new
+    # TEMPLATE_STORAGE_STYLE
 
     SIMPLARET_CLEAN="`eval_boolean_parameter SIMPLARET_CLEAN 1`"
     SIMPLARET_DELETE_DOWN="`eval_boolean_parameter SIMPLARET_DELETE_DOWN 1`"
@@ -307,3 +311,51 @@ function default_arch {
 
 }
 
+function search_default_template {
+
+  if [ -f "$BASE_CONF/templates/default.template" ]; then
+    TEMPLATE_BASE="$BASE_CONF/templates/default"
+    echo $BASENAME: using default template
+  elif [ -f "$BASE_CONF/default.template" ]; then
+    TEMPLATE_BASE="$BASE_CONF/default"
+    echo $BASENAME using default template
+  else
+    echo $BASENAME: error: default template not found
+    echo $BASENAME: please create a template using templatepkg
+    return 1
+  fi
+}
+
+function search_template {
+
+  # determine the template to be used
+  # usage: <search-template> <template-name> [--new]
+
+  #
+  # templates can be stored either on
+  #
+  # - $BASE_CONF/template_name.template
+  # - $BASE_CONF/templates/template_name.template
+  # - $BASE_CONF/templates/template_name/template_name.template
+  #
+
+  if [ -f "$BASE_CONF/$1.template" ]; then
+    TEMPLATE_BASE="$BASE_CONF/$1"
+  elif [ -f "$BASE_CONF/templates/$1.template" ]; then
+    TEMPLATE_BASE="$BASE_CONF/templates/$1"
+  elif [ -f "$BASE_CONF/templates/$1/$1.template" ]; then
+    TEMPLATE_BASE="$BASE_CONF/templates/$1/$1"
+  else
+    if [ "$2" == "--new" ]; then
+      # we need to return the path for a new template
+      # TODO: set a path for the new template
+      # TODO: TEMPLATE_STORAGE_STYLE
+      true
+    else
+      echo $BASENAME: template $1 not found
+      search_default_template
+    fi
+  fi
+
+}
+
index f6635b505e52549e695e527bb5cb725f932e9daa..07d1d1bc3d24dcd8d734721e73d28ff530f913da 100755 (executable)
@@ -25,6 +25,8 @@ else
   exit 1
 fi
 
+# TODO: get the correct template folder
+
 if [ -f $JAIL_LIST ]; then
   for jailpath in `cat $JAIL_LIST`; do
     jail="`basename $jailpath`"
index 49c6c8a346b123409564c8d25a86cab6df4e7406..0f9834da5027409aa02bcbd0d8e65fd5f4c343d0 100755 (executable)
 #
 
 COMMON="/usr/libexec/simplepkg/common.sh"
+BASENAME="`basename $0`"
 
 function usage {
-  echo "usage: [ROOT=/otherroot] `basename $0` <jail-name> [template]"
+  echo "usage: [ARCH=arch] [VERSION=version] [ROOT=/otherroot] $BASENAME <jail-name> [template]"
   exit 1
 }
 
@@ -38,47 +39,47 @@ else
   eval_config `basename $0` -u
 fi
 
-if [[ ! -z "$2" && -f "$BASE_CONF/$2.template" ]]; then
-  TEMPLATE="$BASE_CONF/$2.template"
-elif [[ ! -z "$2" && ! -f "$BASE_CONF/$2.template" ]]; then
-  echo template $2 not found, using default template
-  TEMPLATE="$BASE_CONF/default.template"
-elif [[ -z "$2" && -f "$BASE_CONF/default.template" ]]; then
-  TEMPLATE="$BASE_CONF/default.template"
-  echo using default template
+if [ ! -z "$2" ]; then
+  search_template $2
+  result="$?"
 else
-  echo `basename $0` error: no templates found
-  echo please create a template using templatepkg
+  result="$?"
+  search_default_template
+fi
+
+if [ "$result" != "0" ]; then
   exit 1
 fi
 
+TEMPLATE="$TEMPLATE_BASE.template"
+
 if [ ! -d "$JAIL_ROOT/$server" ]; then
   mkdir -p $JAIL_ROOT/$server
 else
   if [ ! -z "`ls $JAIL_ROOT/$server | grep -v 'lost+found'`" ]; then
-    echo error: folder $JAIL_ROOT/$server already exists and seens to be not empty
-    echo probably the jail $1 already exists
+    echo $BASENAME: error: folder $JAIL_ROOT/$server already exists and seens to be not empty
+    echo $BASENAME: probably the jail $1 already exists
     exit 1
   fi
 fi
 
-echo "instaling packages into $JAIL_ROOT/$server using $TEMPLATE..."
+echo "$BASENAME: instaling packages into $JAIL_ROOT/$server using $TEMPLATE..."
 install_packages
 
-TEMPLATE="`echo $TEMPLATE | sed -e 's/\.template$//'`"
-echo "copying template files..."
-if [ -d "$TEMPLATE.d" ]; then 
-  rsync -av $TEMPLATE.d/ $JAIL_ROOT/$server/
+echo "$BASENAME: copying template files..."
+if [ -d "$TEMPLATE_BASE.d" ]; then 
+  rsync -av $TEMPLATE_BASE.d/ $JAIL_ROOT/$server/
 fi
 
-echo "executing template scripts..."
+echo "$BASENAME: executing template scripts..."
 if [ -d "$TEMPLATE.s" ]; then
   for script in `ls $TEMPLATE.s/`; do
-    if [ -x "$TEMPLATE.s/$script" ]; then
-      exec $TEMPLATE.s/$script $JAIL_ROOT $server
+    if [ -x "$TEMPLATE_BASE.s/$script" ]; then
+      exec $TEMPLATE_BASE.s/$script $JAIL_ROOT $server
     fi
   done
 fi
 
-echo "$JAIL_ROOT/$server" >> $JAIL_LIST
-echo "done creating $server jail"
+echo $JAIL_ROOT/$server >> $JAIL_LIST
+echo $BASENAME: done creating $server jail
+
index 9c1f8bce4c64687c0aa8558545181971dc746a0d..dc0323cb7e48733822038c9dfd17875b50115dff 100755 (executable)
@@ -19,6 +19,7 @@
 #
 
 COMMON="/usr/libexec/simplepkg/common.sh"
+BASENAME="`basename $0`"
 
 if [ -f "$COMMON" ]; then
   source $COMMON
@@ -31,24 +32,26 @@ fi
 APPEND="0"
 if [[ ! -z "$3" && "$1" == "-a" ]]; then
   ROOT="$3"
-  TEMPLATE="$BASE_CONF/$2.template"
+  search_template $2 --new
   APPEND="1"
 elif [[ ! -z "$2" && "$1" == "-a" ]]; then
   ROOT="/"
-  TEMPLATE="$BASE_CONF/$2.template"
+  search_template $2 --new
   APPEND="1"
 elif [[ ! -z "$2" ]]; then
   ROOT="$2"
-  TEMPLATE="$BASE_CONF/$1.template"
+  search_template $1 --new
 elif [[ ! -z "$1" ]]; then
-  TEMPLATE="$BASE_CONF/$1.template"
+  search_template $1 --new
   ROOT="/"
 else
-  echo "usage: `basename $0` [-a] <template> [root-dir]"
-  echo -e "\t-a: append packages into <$BASE_CONF/template.template>"
+  echo "usage: $BASENAME [-a] <template> [root-dir]"
+  echo -e "\t-a: append packages into a template"
   exit 1
 fi
 
+TEMPLATE="$BASE_TEMPLATE.template"
+
 if [ ! -d "$ROOT/var/log/packages" ]; then
   echo $ROOT/var/log/packages: directory not found
   exit 1
diff --git a/templates/mplayer.metapkg b/templates/mplayer.metapkg
deleted file mode 100644 (file)
index 90d2ff3..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-libmad
-esound
-glib
-libogg
-libvorbis
-libungif
-gtk
-arts
-audiofile
-sdl
-gdk-pixbuf
-cdparanoia
-lame
-essential