aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2006-11-14 17:24:00 +0000
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2006-11-14 17:24:00 +0000
commit36e4c24f5b35dd2f1860c2746b5517b1000ea3d4 (patch)
tree922263c7bee570ef3b5fee455506849f7f28ef83
parent540c8f09dc282b0dbf770d1cd52be1cab23247ca (diff)
downloadsimplepkg-36e4c24f5b35dd2f1860c2746b5517b1000ea3d4.tar.gz
simplepkg-36e4c24f5b35dd2f1860c2746b5517b1000ea3d4.tar.bz2
jail-upgrade now coded to work as expected, hope there's no bugs
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@30 04377dda-e619-0410-9926-eae83683ac58
-rw-r--r--doc/CHANGELOG15
-rwxr-xr-xsrc/jail-upgrade93
2 files changed, 39 insertions, 69 deletions
diff --git a/doc/CHANGELOG b/doc/CHANGELOG
index 258dcc8..a8b5b85 100644
--- a/doc/CHANGELOG
+++ b/doc/CHANGELOG
@@ -1,15 +1,16 @@
simplepkg changelog
-------------------
-0.4.9pre7: jail-upgrade:
- - fix in swaret upgrade method
+0.5pre1: jail-upgrade:
+ - added option CONSIDER_ALL_PACKAGES_AS_PATCHES
+ - merged swaret and simplaret upgrade procedures
- act recursively on patches' folder
- simplaret:
- - for --get, check if an already existing package
- in the local repository has the same version and
- build number, otherwise erase the old and download
- the new one.
+ simplaret:
+ - for --get, check if an already existing package
+ in the local repository has the same version and
+ build number, otherwise erase the old and download
+ the new one.
0.4.9pre6: createpkg:
- fixes
diff --git a/src/jail-upgrade b/src/jail-upgrade
index 6383cf5..c44f32d 100755
--- a/src/jail-upgrade
+++ b/src/jail-upgrade
@@ -18,63 +18,33 @@
COMMON="/usr/libexec/simplepkg/common.sh"
-# TODO: merge upgrade functions
+function jail_upgrade {
-function swaret_jail_upgrade {
+ local patches_dir storage_dir
echo upgrading jail $1...
- if [ ! -d "$PATCHES_DIR" ]; then
- for file in `find $PATCHES_DIR -name *tgz`; do
- pack=`package_name $file`
- if check_for_upgrade $file $1; then
- ROOT=$1 upgradepkg $file
- upgraded $pack
- fi
- done
- fi
+ if [ "$SIMPLARET" == "simplaret" ]; then
- if [ "$CONSIDER_ALL_PACKAGES_AS_PATCHES" == "YES" ] ||
- [ "$CONSIDER_ALL_PACKAGES_AS_PATCHES" == "1" ]; then
- # this option does the following:
- # search all packages in the repositories and apply a patch if:
- # - the package is installed
- # - it hasnt already applied
- # - has a different version from the current installed
- # - has a different build number from the current installed
- if [ -d "$STORAGE" ]; then
- for file in `find $STORAGE -name *tgz`; do
- pack=`package_name $file`
- if check_for_upgrade $file $1; then
- # the package is installed
- if ! echo $UPGRADED | grep -q $pack; then
- # it hasnt already applied
- ROOT=$1 upgradepkg $file
- upgraded $pack
- fi
- fi
- done
- fi
- fi
-
- # clear the upgraded package list
- unset UPGRADED
+ VERSION="`cat $1/etc/slackware-version | awk '{ print $2 }' | sed -e 's/.0$//'`"
+ ARCH="`cat $1/etc/slackware-version | awk '{ print $3 }' | sed -e 's/(//' -e 's/)//'`"
-}
+ if [ -z "$ARCH" ]; then
+ ARCH="i386"
+ fi
-function simplaret_jail_upgrade {
+ patches_dir="$PATCHES_DIR/$ARCH/$VERSION"
+ storage_dir="$STORAGE/$ARCH/$VERSION"
- echo upgrading jail $1...
+ elif [ "$SIMPLARET" == "swaret" ]; then
- VERSION="`cat $1/etc/slackware-version | awk '{ print $2 }' | sed -e 's/.0$//'`"
- ARCH="`cat $1/etc/slackware-version | awk '{ print $3 }' | sed -e 's/(//' -e 's/)//'`"
+ patches_dir="$PACTHES_DIR"
+ storage_dir="$STORAGE"
- if [ -z "$ARCH" ]; then
- ARCH="i386"
fi
- if [ -d "$PATCHES_DIR/$ARCH/$VERSION" ]; then
- for file in `find $PATCHES_DIR/$ARCH/$VERSION -name *tgz`; do
+ if [ -d "$patches_dir" ]; then
+ for file in `find $patches_dir -name *tgz`; do
pack=`package_name $file`
if check_for_upgrade $file $1; then
ROOT=$1 upgradepkg $file
@@ -82,19 +52,22 @@ function simplaret_jail_upgrade {
fi
done
else
- echo error: cant upgrade for arch $ARCH and version $VERSION on $1: no such patch dir $PATCHES_DIR/$ARCH/$VERSION
+ if [ "$SIMPLARET" == "simplaret" ]; then
+ echo error: cant upgrade for arch $ARCH and version $VERSION on $1: no such patch dir $patches_dir
+ elif [ "$SIMPLARET" == "swaret" ]; then
+ echo error: cant upgrade on $1: no such patch dir $patches_dir
+ fi
+ return
fi
+ # optionally, search all packages in the repositories and apply a patch if:
+ # - the package is installed in the jail
+ # - it hasn't already applied in the jail
+ # - has different version or build from the current installed package
if [ "$CONSIDER_ALL_PACKAGES_AS_PATCHES" == "YES" ] ||
[ "$CONSIDER_ALL_PACKAGES_AS_PATCHES" == "1" ]; then
- # this option does the following:
- # search all packages in the repositories and apply a patch if:
- # - the package is installed
- # - it hasnt already applied
- # - has a different version from the current installed
- # - has a different build number from the current installed
- if [ -d "$STORAGE/$ARCH/$VERSION" ]; then
- for file in `find $STORAGE/$ARCH/$VERSION -name *tgz`; do
+ if [ -d "$storage_dir" ]; then
+ for file in `find $storage_dir -name *tgz`; do
pack=`package_name $file`
if check_for_upgrade $file $1; then
# the package is installed
@@ -164,11 +137,7 @@ if [ ! -z "$PATCHES" ]; then
fi
fi
-if [ "$SIMPLARET" == "simplaret" ]; then
- upgrade_method="simplaret_jail_upgrade"
-elif [ "$SIMPLARET" == "swaret" ]; then
- upgrade_method="swaret_jail_upgrade"
-else
+if [ "$SIMPLARET" != "simplaret" ] || [ "$SIMPLARET" == "swaret" ]; then
echo invalid value $SIMPLARET for SIMPLARET, please check your $CONF
exit 1
fi
@@ -177,16 +146,16 @@ UPGRADED=""
if [ -z "$1" ]; then
if [ -d "/var/log/packages" ]; then
- $upgrade_method /
+ jail_upgrade /
fi
for vserver in `ls $JAIL_ROOT`; do
if [ -d "$JAIL_ROOT/$vserver/var/log/packages" ]; then
- $upgrade_method $JAIL_ROOT/$vserver
+ jail_upgrade $JAIL_ROOT/$vserver
fi
done
elif [ -d "$JAIL_ROOT/$1" ]; then
if [ -d "$JAIL_ROOT/$1/var/log/packages" ]; then
- $upgrade_method $JAIL_ROOT/$1
+ jail_upgrade $JAIL_ROOT/$1
else
echo error: jail $JAIL_ROOT/$1 dont looks like a slackware system
fi