From 9ed605710d1acdb16a12b47a2c83474cebd5c819 Mon Sep 17 00:00:00 2001 From: rhatto Date: Thu, 18 Jan 2007 01:54:06 +0000 Subject: lots of changes git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@108 04377dda-e619-0410-9926-eae83683ac58 --- conf/simplepkg.conf.new | 27 +++++++---- doc/CHANGELOG | 12 +++-- lib/common.sh | 124 +++++++++++++++++++++++++++++++++--------------- simplepkg.SlackBuild | 2 +- src/mkjail | 16 ------- src/simplaret | 91 ++++++++++------------------------- 6 files changed, 138 insertions(+), 134 deletions(-) diff --git a/conf/simplepkg.conf.new b/conf/simplepkg.conf.new index fa93a30..53c4d5a 100644 --- a/conf/simplepkg.conf.new +++ b/conf/simplepkg.conf.new @@ -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 diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 28bfe1b..0ebd749 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -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 diff --git a/lib/common.sh b/lib/common.sh index 0749dd4..d5e84c8 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -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 [-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 } diff --git a/simplepkg.SlackBuild b/simplepkg.SlackBuild index 8c41aac..54fcd7c 100755 --- a/simplepkg.SlackBuild +++ b/simplepkg.SlackBuild @@ -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" diff --git a/src/mkjail b/src/mkjail index 509bde3..49c6c8a 100755 --- a/src/mkjail +++ b/src/mkjail @@ -16,22 +16,6 @@ # 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" diff --git a/src/simplaret b/src/simplaret index c47e093..fd5a8b3 100755 --- a/src/simplaret +++ b/src/simplaret @@ -16,10 +16,16 @@ # 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`