]> gitweb.fluxo.info Git - simplepkg.git/commitdiff
lots of changes
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Thu, 18 Jan 2007 01:54:06 +0000 (01:54 +0000)
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Thu, 18 Jan 2007 01:54:06 +0000 (01:54 +0000)
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@108 04377dda-e619-0410-9926-eae83683ac58

conf/simplepkg.conf.new
doc/CHANGELOG
lib/common.sh
simplepkg.SlackBuild
src/mkjail
src/simplaret

index fa93a308d4d6e980c9d88fbe695b50d2621e2cce..53c4d5ac0aa525bba2abbe2a0b60a9c36bca69e6 100644 (file)
@@ -17,21 +17,29 @@ JAIL_ROOT="/vservers"
 # just change to swaret if you know what you're doing
 SIMPLARET="simplaret"
 
-# whether to clean package cache before installation
+# whether mkjail should clean the package cache before installation
+# to enable it, set to "1" or "yes"
 SIMPLARET_CLEAN="1"
 
-# whether clean package cache after the installation
+# whether mkjail should clean the package cache after the installation
+# to enable it, set to "1" or "yes"
 SIMPLARET_DELETE_DOWN="1"
 
-# whether issue an simplaret --update before install the jail
-SIMPLARET_UPDATE="0"
+# whether mkjail should issue a simplaret --update before install the jail
+# to enable it, set to "1" or "yes"
+SIMPLARET_UPDATE="1"
 
-# delete packages older than N weeks from the cache
-SIMPLARET_PURGE_WEEKS="3"
+# wheter delete also patches when simplaret --purge is called
+# to enable it, set to "1" or "yes"
+SIMPLARET_PURGE_PATCHES="0"
 
 # whether delete each package rigth after its installation
+# to enable it, set to "1" or "yes"
 SIMPLARET_DELETE_DURING="0"
 
+# delete packages older than N weeks from the cache
+SIMPLARET_PURGE_WEEKS="3"
+
 # where patches are placed
 PATCHES_DIR="/var/simplaret/patches"
 
@@ -39,14 +47,15 @@ PATCHES_DIR="/var/simplaret/patches"
 STORAGE="/var/simplaret/packages"
 
 # whether to use passive ftp transfers
+# to enable it, set to "1" or "yes"
 PASSIVE_FTP="1"
 
 # ROOT repository package priority
 ROOT_PRIORITY="patches slackware extra testing pasture"
 
-# Enabling this option (i.e, setting to 1), simplaret will donwload even
-# already applied patches, a good option when you plan to keep local
-# copies of all needed patches for your system
+# Enabling this option (i.e, setting to "1" or "yes"), simplaret will
+# donwload even # already applied patches, a good option when you plan
+# to keep local copies of all needed patches for your system
 DOWNLOAD_EVEN_APPLIED_PATCHES="0"
 
 # Enabling this option, jail-upgrade will look at your
index 28bfe1b5c6b61bba6dc1fbec97202c841c223828..0ebd749523a18ae58431f8197f2df46f75212064 100644 (file)
@@ -1,7 +1,15 @@
 simplepkg changelog
 -------------------
 
-0.4.10pre1: repos: added patches/ metafile creation
+0.4.9pre8: createpkg: bugfix
+           common.sh:
+             - enhanced config file evaluation
+             - fixed function default_arch
+           simplaret:
+             - config evaluation via common.sh
+             - new config parameter SIMPLARET_PURGE_PATCHES
+0.4.9pre7: repos: added patches/ metafile creation
             jail-upgrade:
              - added option CONSIDER_ALL_PACKAGES_AS_PATCHES
              - merged swaret and simplaret upgrade procedures
@@ -25,8 +33,6 @@ simplepkg changelog
               - new config parameter DOWNLOAD_EVEN_APPLIED_PATCHES
              createpkg: lots of changes...
 
-0.4.9: released 0.4.9pre6 as 0.4.9
-
 0.4.9pre6: createpkg:
              - fixes
              - now with slackbuild error handling
index 0749dd4387c1cb0cf553c5ec6dda4b8ce5f215d7..d5e84c83749c67e7363fc428d5f2d2fd40d25751 100644 (file)
@@ -103,10 +103,13 @@ function install_packages {
   for pack in `cat $TEMPLATE | grep -v -e "^#" | cut -d : -f 1`; do
 
     package_downloaded="0"
+
     if [ "$SIMPLARET" == "simplaret" ]; then
       extrafolder="$ARCH/$VERSION/"
+      extraoptions=""
     else
       unset extrafolder
+      extraoptions="-a"
     fi
 
     # first search the package in the patches folder
@@ -131,7 +134,7 @@ function install_packages {
 
     # if the package wasnt found, try to donwload it
     if [[ "$package_downloaded" != "1" ]]; then
-      ARCH=$ARCH VERSION=$VERSION $SIMPLARET --get $pack -a
+      ARCH=$ARCH VERSION=$VERSION $SIMPLARET --get $pack $extraoptions
 
       # it can be stored at the patches folder
       for file in `find $PATCHES_DIR/$extrafolder -name $pack*tgz`; do
@@ -201,35 +204,87 @@ function remove_packages {
 
 }
 
-function eval_config {
+function eval_parameter {
 
-  if [ -f "$CONF" ]; then
-    source $CONF
+  # usage: eval $1 parameter from $CONF
+  # return the evaluated parameter if available or $2 $3 ... $n
+
+  if grep -qe "^$1=" $CONF; then
+    grep -e "^$1=" $CONF | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | awk '{ print $1 }'
   else
-    echo $1 error: config file $CONFIG not found
-    exit 1
+    shift
+    echo $*
   fi
 
-  if [ -z "$SIMPLARET" ]; then
-    SIMPLARET="simplaret"
-  fi
+}
 
-  if [ -z "$STORAGE" ]; then
-    if [ -d "/var/$SIMPLARET" ]; then
-      STORAGE="/var/$SIMPLARET"
-    else
-      echo error: please adjust value for STORAGE at $CONF
-      exit 1
-    fi
+function eval_boolean_parameter {
+
+  # get a boolean parameter from the configuration
+
+  local value
+
+  # get the value
+  value="`eval_parameter $1 $2`"
+
+  # force case insensitiveness
+  value="`echo $value | tr '[:upper:]' '[:lower:]'`"
+
+  # convert it to wheter 0 or 1
+  if [ "$value" == "yes" ] || [ "$value" == "1" ]; then
+    echo 1
+  else
+    echo 0
   fi
 
-  if [ ! -z "$ROOT" ]; then
-    JAIL_ROOT="$ROOT"
-  elif [ -z "$JAIL_ROOT" ]; then
-    echo error: please adjust value for JAIL_ROOT at $CONF
+}
+
+function eval_config {
+
+  # simplepkg config file evaluation
+  # usage: eval_config <program-name> [-u]
+
+  if [ -f "$CONF" ]; then
+
+    SIMPLARET="`eval_parameter SIMPLARET simplaret`"
+    STORAGE="`eval_parameter STORAGE /var/simplaret/packages`"
+    JAIL_ROOT="`eval_parameter JAIL_ROOT /vservers`"
+    PATCHES_DIR="`eval_parameter PATCHES_DIR /var/simplaret/patches`"
+    ROOT_PRIORITY="`eval_parameter ROOT_PRIORITY patches slackware extra testing pasture`"
+    SIMPLARET_PURGE_WEEKS="`eval_parameter SIMPLARET_PURGE_WEEKS 0`"
+
+    SIMPLARET_CLEAN="`eval_boolean_parameter SIMPLARET_CLEAN 1`"
+    SIMPLARET_DELETE_DOWN="`eval_boolean_parameter SIMPLARET_DELETE_DOWN 1`"
+    SIMPLARET_UPDATE="`eval_boolean_parameter SIMPLARET_UPDATE 0`"
+    SIMPLARET_DELETE_DURING="`eval_boolean_parameter SIMPLARET_DELETE_DURING 0`"
+    SIMPLARET_PURGE_PATCHES="`eval_boolean_parameter SIMPLARET_PURGE_PATCHES 0`"
+    CONSIDER_ALL_PACKAGES_AS_PATCHES="`eval_boolean_parameter CONSIDER_ALL_PACKAGES_AS_PATCHES 0`"
+    DOWNLOAD_EVEN_APPLIED_PATCHES="`eval_boolean_parameter DOWNLOAD_EVEN_APPLIED_PATCHES 0`"
+    PASSIVE_FTP="`eval_boolean_parameter PASSIVE_FTP 0`"
+    WARNING="`eval_boolean_parameter WARNING 0`"
+    
+    DEFAULT_ARCH="`eval_parameter DEFAULT_ARCH $(default_arch)`"
+    DEFAULT_VERSION="`eval_parameter DEFAULT_VERSION $(default_version)`"
+
+    # Enabling this option, jail-upgrade will look at your
+    # standard repositories for new packages; if it find a package
+    # with different version of your current installed package and
+    # also this package isnt in the packages folder, then the new
+    # package is apllied; if in doubt, just say no or leave blank.
+    CONSIDER_ALL_PACKAGES_AS_PATCHES="`eval_boolean_parameter CONSIDER_ALL_PACKAGES_AS_PATCHES 0`"
+
+    # now we place "patches" on the top of ROOT_PRIORITY
+    ROOT_PRIORITY="patches `echo $ROOT_PRIORITY | sed -e 's/patches//'`"
+
+  else
+    echo $1 error: config file $CONFIG not found
     exit 1
   fi
 
+  if [ ! -d "$STORAGE" ]; then
+    mkdir -p $STORAGE
+  else
+
   if [ -z "$ARCH" ]; then
     ARCH="$DEFAULT_ARCH" 
   fi
@@ -239,8 +294,8 @@ function eval_config {
   fi
 
   if which $SIMPLARET &> /dev/null; then
-    if [[ "$SIMPLARET_UPDATE" == "1" ]]; then
-      if [[ "$2" == "-u" ]]; then
+    if [ "$SIMPLARET_UPDATE" == "1" ]; then
+      if [ "$2" == "-u" ]; then
         echo "updating package database..."
         ARCH=$ARCH VERSION=$VERSION $SIMPLARET --update
       fi
@@ -249,21 +304,6 @@ function eval_config {
     echo "$SIMPLARET not found, please install it before run $0"
   fi
 
-  if [ -z "$PATCHES_DIR" ]; then
-    echo error: please adjust a value for PATCHES_DIR at $CONF
-  fi
-
-  CONSIDER_ALL_PACKAGES_AS_PATCHES="`echo $CONSIDER_ALL_PACKAGES_AS_PATCHES | tr '[:lower:]' '[:upper:]'`"
-  if [ "$CONSIDER_ALL_PACKAGES_AS_PATCHES" != "YES" ] && \
-     [ "$CONSIDER_ALL_PACKAGES_AS_PATCHES" != "1" ]; then
-     # Enabling this option, jail-upgrade will look at your
-     # standard repositories for new packages; if it find a package
-     # with different version of your current installed package and
-     # also this package isnt in the packages folder, then the new
-     # package is apllied; if in doubt, just say no or leave blank.
-     CONSIDER_ALL_PACKAGES_AS_PATCHES="0"
-  fi
-
 }
 
 function default_version {
@@ -276,7 +316,15 @@ function default_version {
 function default_arch {
 
   # get arch from /etc/slackware-version
-  cat $1/etc/slackware-version | awk '{ print $3 }' | sed -e 's/(//' -e 's/)//'
+
+  local arch
+  arch="`cat $1/etc/slackware-version | awk '{ print $3 }' | sed -e 's/(//' -e 's/)//'`"
+
+  if [ -z "$arch" ]; then
+    echo i386
+  else
+    echo $arch
+  fi
 
 }
 
index 8c41aac8bf2c4074209c4374800b25642840e2b4..54fcd7c45999293de16e485bc1a216f9fc80446e 100755 (executable)
@@ -6,7 +6,7 @@
 PACKAGE="simplepkg"
 PACK_DIR="package-$PACKAGE"
 BUILD=${BUILD:=1rha}
-VERSION="0.4.9pre7"
+VERSION="0.4.9pre8"
 ARCH="noarch"
 LIBEXEC="/usr/libexec/$PACKAGE"
 BINDIR="/usr/bin"
index 509bde3c66a05c98c4f5e15343b18bd0e0edf438..49c6c8a346b123409564c8d25a86cab6df4e7406 100755 (executable)
 #  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 #  Place - Suite 330, Boston, MA 02111-1307, USA
 #
-# Under the config file, adjust this to where your things live, for example:
-#
-# JAIL_ROOT="/vservers"               # default folder where jails lives
-# STORAGE="/var/simplaret"            # place where simplaret host its packages
-# SIMPLARET_CLEAN="1"                 # delete downloaded packages before installation
-# SIMPLARET_DELETE_DOWN="1"           # delete donwloaded packages after installation
-# SIMPLARET_DELETE_DURING="1"         # delete each package rigth after its installation
-# SIMPLARET_UPDATE="0"                # simplaret --update before get the packages
-# SIMPLARET_PURGE_WEEKS="N"           # purge cached packages older than N weeks
-# PATCHES_DIR=/var/simplaret/patches" # where your patches lives
-#
-# todo: - list of packages that could not be installed
-#       - use swaret just for network mirrors
-#       - installation order
-#       - optionally execute chroot-upgrade after installation
-#
 
 COMMON="/usr/libexec/simplepkg/common.sh"
 
index c47e093650b470445635ab7228528a8e5c12b2b7..fd5a8b3d72b9e4708e049b2ac952ac59ff391416 100755 (executable)
 #  Place - Suite 330, Boston, MA 02111-1307, USA
 #
 
-SIMPLARET_CONF="/etc/simplepkg/simplepkg.conf"
 REPOS_CONF="/etc/simplepkg/repos.conf"
 COMMON="/usr/libexec/simplepkg/common.sh"
 
+if [ -f "$COMMON" ]; then
+  source $COMMON
+else
+  echo "error: file $COMMON found, check your `basename $0` installation"
+  exit 1
+fi
+
 function simplaret_usage {
 
   echo "usage: [ARCH=otherarch] [VERSION=otherversion] `basename $0` <OPTION> package-name"
@@ -28,44 +34,6 @@ function simplaret_usage {
 
 }
 
-function simplaret_eval_parameter {
-
-  # usage: eval $1 parameter from $SIMPLARET_CONF
-  # return the evaluated parameter if available or $2 $3 ... $n
-
-  if grep -qe "^$1=" $SIMPLARET_CONF; then
-    grep -e "^$1=" $SIMPLARET_CONF | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | awk '{ print $1 }'
-  else
-    shift
-    echo $*
-  fi
-
-}
-
-function simplaret_eval_config {
-
-  # simplaret config file evaluation
-
-  DEFAULT_ARCH="`simplaret_eval_parameter DEFAULT_ARCH $(default_arch)`"
-  DEFAULT_VERSION="`simplaret_eval_parameter DEFAULT_VERSION $(default_version)`"
-  STORAGE="`simplaret_eval_parameter STORAGE /var/simplaret/packages`"
-  PATCHES_DIR="`simplaret_eval_parameter PATCHES_DIR /var/simplaret/patches`"
-  PASSIVE_FTP="`simplaret_eval_parameter PASSIVE_FTP 0`"
-  WARNING="`simplaret_eval_parameter WARNING 0`"
-  ROOT_PRIORITY="`simplaret_eval_parameter ROOT_PRIORITY patches slackware extra testing pasture`"
-  SIMPLARET_PURGE_WEEKS="`simplaret_eval_parameter SIMPLARET_PURGE_WEEKS 0`"
-  CONSIDER_ALL_PACKAGES_AS_PATCHES="`simplaret_eval_parameter CONSIDER_ALL_PACKAGES_AS_PATCHES 0`"
-  DOWNLOAD_EVEN_APPLIED_PATCHES="`simplaret_eval_parameter DOWNLOAD_EVEN_APPLIED_PATCHES 0`"
-
-  # now we place "patches" on the top of ROOT_PRIORITY
-  ROOT_PRIORITY="patches `echo $ROOT_PRIORITY | sed -e 's/patches//'`" 
-
-  # force case insensitiveness
-  CONSIDER_ALL_PACKAGES_AS_PATCHES="`echo $CONSIDER_ALL_PACKAGES_AS_PATCHES | tr '[:upper:]' '[:lower:]'`"
-  DOWNLOAD_EVEN_APPLIED_PATCHES="`echo $DOWNLOAD_EVEN_APPLIED_PATCHES | tr '[:upper:]' '[:lower:]'`"
-
-}
-
 function simplaret_get_index {
 
   for file in `simplaret_metafiles`; do
@@ -345,7 +313,10 @@ function simplaret_search {
 
 function simplaret_purge {
 
-  local mtime mtime_message
+  # purge simplaret package cache
+  # usage: simplaret_purge [-w N]
+
+  local mtime mtime_message which and_patches
 
   if [ "$2" == "-w" ] && [ ! -z "$3" ]; then
     mtime="-mtime +`echo "$3*7" | bc -l`"
@@ -358,13 +329,21 @@ function simplaret_purge {
     mtime_mesage=""
   fi
 
+  which="root repos noarch"
+  and_patches=""
+
+  if [ "$SIMPLARET_PURGE_PATCHES" == "1" ]; then
+    which="patches $which"
+    and_patches="including patches"
+  fi
+
   if [ -z "$SILENT" ]; then
     echo purging all packages $mtime_message for:
-    echo - arch $ARCH and version $VERSION, including patches
+    echo - arch $ARCH and version $VERSION $and_patches
     echo - noarch folder
   fi
 
-  for repos_type in patches root repos noarch; do
+  for repos_type in $which; do
 
     simplaret_set_storage_folder
 
@@ -529,7 +508,7 @@ function simplaret_search_and_download_patch {
     if [ "$package_installed" == "1" ]; then
       if [ "$repos_type" == "patches" ]; then
 
-        if [ "$DOWNLOAD_EVEN_APPLIED_PATCHES" == "1" ] || [ "$DOWNLOAD_EVEN_APPLIED_PATCHES" == "yes" ]; then
+        if [ "$DOWNLOAD_EVEN_APPLIED_PATCHES" == "1" ]; then
           get="yes"
         elif  [ "$package_version" != "$installed_version" ] || [ "$package_build" != "$installed_build" ]; then
           get="yes"
@@ -537,7 +516,7 @@ function simplaret_search_and_download_patch {
 
       elif [ "$repos_type" == "root" ] && [ "$is_patch" == "yes" ]; then
 
-        if [ "$DOWNLOAD_EVEN_APPLIED_PATCHES" == "1" ] || [ "$DOWNLOAD_EVEN_APPLIED_PATCHES" == "yes" ]; then
+        if [ "$DOWNLOAD_EVEN_APPLIED_PATCHES" == "1" ]; then
           get="yes"
         elif  [ "$package_version" != "$installed_version" ] || [ "$package_build" != "$installed_build" ]; then
           get="yes"
@@ -607,7 +586,7 @@ function simplaret_get_jail_patches {
   done
 
   # grab patches from every other places
-  if [ "$CONSIDER_ALL_PACKAGES_AS_PATCHES" == "1" ] || [ "$CONSIDER_ALL_PACKAGES_AS_PATCHES" == "yes" ]; then
+  if [ "$CONSIDER_ALL_PACKAGES_AS_PATCHES" == "1" ]; then
 
     # old behaviour was just one loop:
     # for sugested in `simplaret_search --formatted | grep -v patches`; do
@@ -680,8 +659,6 @@ function simplaret_checksum {
 function simplaret_install {
 
   # download and install a package
-  # TODO: dependency checking
-  # TODO: also check if repository arch version matches target jail arch and version
 
   local package root
 
@@ -732,31 +709,11 @@ function simplaret_distro_folder {
 
 }
 
-if [ -f "$COMMON" ]; then
-  source $COMMON
-else
-  echo "error: file $COMMON found, check your `basename $0` installation"
-  exit 1
-fi
-
 if [ -z "$1" ]; then
   simplaret_usage
   exit 1
 else
   eval_config `basename $0`
-  simplaret_eval_config
-fi
-
-if [ ! -d "$STORAGE" ]; then
-  mkdir -p $STORAGE
-fi
-
-if [ -z "$ARCH" ]; then
-  ARCH="$DEFAULT_ARCH"
-fi
-
-if [ -z "$VERSION" ]; then
-  VERSION="$DEFAULT_VERSION"
 fi
 
 case $1 in