From 22bdf059ebfc9ec380e11a2b1128e666ceec602d Mon Sep 17 00:00:00 2001 From: rhatto Date: Tue, 14 Nov 2006 00:02:10 +0000 Subject: jail-upgrade: introducing function check_for_upgrade git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@27 04377dda-e619-0410-9926-eae83683ac58 --- src/jail-upgrade | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 2 deletions(-) (limited to 'src/jail-upgrade') diff --git a/src/jail-upgrade b/src/jail-upgrade index c879bfa..a5803d0 100755 --- a/src/jail-upgrade +++ b/src/jail-upgrade @@ -24,18 +24,25 @@ function swaret_jail_upgrade { if [ ! -d "$PATCHES_DIR" ]; then for file in `find $PATCHES_DIR -name *tgz`; do + pack=`package_name $file` for installed in `ls $1/var/log/packages/$pack* 2> /dev/null`; do if [[ $pack == `package_name $installed.tgz` ]]; then if [[ "`basename $installed`" != "`basename $file .tgz`" ]]; then + ROOT=$1 upgradepkg $file - UPGRADED="$UPGRADED $pack" + upgraded $pack + fi fi done + done fi + # clear the upgraded package list + unset UPGRADED + } function simplaret_jail_upgrade { @@ -51,15 +58,19 @@ function simplaret_jail_upgrade { if [ -d "$PATCHES_DIR/$ARCH/$VERSION" ]; then for file in `find $PATCHES_DIR/$ARCH/$VERSION -name *tgz`; do + pack=`package_name $file` for installed in `ls $1/var/log/packages/$pack* 2> /dev/null`; do if [[ "$pack" == "`package_name $installed.tgz`" ]]; then if [[ "`basename $installed`" != "`basename $file .tgz`" ]]; then + ROOT=$1 upgradepkg $file - UPGRADED="$UPGRADED $pack" + upgraded $pack + fi fi done + done else echo error: cant upgrade for arch $ARCH and version $VERSION on $1: no such patch dir $PATCHES_DIR/$ARCH/$VERSION @@ -69,12 +80,77 @@ function simplaret_jail_upgrade { [ "$CONSIDER_ALL_PACKAGES_AS_PATCHES" == "1" ]; then # TODO: search all packages in the repositories # 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 + + pack=`package_name $file` + for installed in `ls $1/var/log/packages/$pack* 2> /dev/null`; do + if [[ "$pack" == "`package_name $installed.tgz`" ]]; then + if [[ "`basename $installed`" != "`basename $file .tgz`" ]]; then + + # the package is installed + if ! echo $UPGRADED | grep -q $pack; then + # the package isnt already applied + if [ "`package_version $file`" != "`package_version $installed.tgz`" ] || + [ "`package_build $file`" != "`package_build $installed.tgz`" ]; then + # the stored package has a different version or build number + # from the installed one; then we upgrade it + ROOT=$1 upgradepkg $file + upgraded $pack + fi + fi + + fi + fi + done + + done + fi true fi + # clear the upgraded package list + unset UPGRADED + +} + +function check_for_upgrade { + + # check if package $1 is installed in the $2 root environment + # and should be upgraded + local pack found file + + found="0" + file="$1" + pack="`package_name $file`" + + if [ -d "$2/var/log/packages/" ] && [ ! -z "$file" ]; then + for installed in `ls $2/var/log/packages/$pack* 2> /dev/null`; do + if [[ "$pack" == "`package_name $installed.tgz`" ]]; then + if [[ "`basename $installed`" != "`basename $file .tgz`" ]]; then + found="1" + fi + fi + done + fi + + # if the package is installed, return true, otherwise false + if [ "$found" == "0" ]; then + return 1 + elif [ "$found" == "1" ]; then + return 0 + fi + +} + +function upgraded { + + UPGRADED="$UPGRADED $1 " + } if [ -f "$COMMON" ]; then -- cgit v1.2.3