diff options
Diffstat (limited to 'trunk')
-rw-r--r-- | trunk/lib/common.sh | 52 | ||||
-rwxr-xr-x | trunk/src/simplaret | 56 |
2 files changed, 39 insertions, 69 deletions
diff --git a/trunk/lib/common.sh b/trunk/lib/common.sh index f83e761..658c66d 100644 --- a/trunk/lib/common.sh +++ b/trunk/lib/common.sh @@ -1,30 +1,19 @@ #!/bin/bash # # common.sh: common functions for simplepkg -# feedback: rhatto at riseup.net | gpl +# feedback: rhatto at riseup.net # -# Uses some functions from pkgtools, which license is: +# common.sh is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or any later version. # -# Copyright 1999 Patrick Volkerding, Moorhead, Minnesota, USA -# Copyright 2001, 2002, 2003 Slackware Linux, Inc., Concord, California, USA -# All rights reserved. +# common.sh is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. # -# Redistribution and use of this script, with or without modification, is -# permitted provided that the following conditions are met: -# -# 1. Redistributions of this script must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 59 Temple +# Place - Suite 330, Boston, MA 02111-1307, USA # BASE_CONF="/etc/simplepkg" @@ -38,26 +27,7 @@ SIMPLARET="simplaret" function package_name { - STRING=`basename $1 .tgz` - # Check for old style package name with one segment: - if [ "`echo $STRING | cut -f 1 -d -`" = "`echo $STRING | cut -f 2 -d -`" ]; then - echo $STRING - else # has more than one dash delimited segment - # Count number of segments: - INDEX=1 - while [ ! "`echo $STRING | cut -f $INDEX -d -`" = "" ]; do - INDEX=`expr $INDEX + 1` - done - INDEX=`expr $INDEX - 1` # don't include the null value - # If we don't have four segments, return the old-style (or out of spec) package name: - if [ "$INDEX" = "2" -o "$INDEX" = "3" ]; then - echo $STRING - else # we have four or more segments, so we'll consider this a new-style name: - NAME=`expr $INDEX - 3` - NAME="`echo $STRING | cut -f 1-$NAME -d -`" - echo $NAME - fi - fi + echo "`basename $1 .tgz`" | sed -e 's/-[^-]*-[^-]*-[^-]*$//' } diff --git a/trunk/src/simplaret b/trunk/src/simplaret index 54b8f0e..29e3b75 100755 --- a/trunk/src/simplaret +++ b/trunk/src/simplaret @@ -691,36 +691,36 @@ function simplaret_search_and_process_patch { local package_version package_build installed_version pack local installed_build repos_type get is_patch package_match - # get the repository type - repos_type="`echo $sugested | cut -d , -f 2`" + # get just the file and package name + sugested_filename="`echo $sugested | cut -d , -f 1`" + sugested_pack="`package_name $sugested_filename`" - # get just the file name - sugested="`echo $sugested | cut -d , -f 1`" + # search if its installed in the jail + if grep -q -e "^$sugested_pack$" $PACKAGES_TMP; then + + # get the repository type + repos_type="`echo $sugested | cut -d , -f 2`" - if echo $sugested | grep -q "patches"; then - is_patch="yes" - else - is_patch="no" - fi + if echo $sugested | grep -q "patches"; then + is_patch="yes" + else + is_patch="no" + fi - # now split the file name into pieces - package_version="`package_version $sugested`" - package_build="`package_build $sugested`" - sugested="`package_name $sugested`" + # now split the file name into pieces + package_version="`package_version $sugested_filename`" + package_build="`package_build $sugested_filename`" - # check if the patch was already downloaded - if echo "$DOWNLOADED_PATCHES" | grep -q " $ARCH:$VERSION:$sugested "; then - if [ "$IS_UPGRADE" != "1" ]; then - echo Package $sugested already downloaded - # echo "Jail $root needs package $sugested (already downloaded, skipping)" - return + # check if the patch was already downloaded + if echo "$DOWNLOADED_PATCHES" | grep -q " $ARCH:$VERSION:$sugested_pack "; then + if [ "$IS_UPGRADE" != "1" ]; then + echo Package $sugested_pack already downloaded + # echo "Jail $root needs package $sugested_pack (already downloaded, skipping)" + return + fi fi - fi - # search if its installed in the jail - if grep -q -e "^$sugested$" $PACKAGES_TMP; then - - pack="`echo $sugested | sed -e 's/\+/\\\+/'`" + pack="`echo $sugested_pack | sed -e 's/\+/\\\+/'`" installed=`eval "ls $root/var/log/packages/ | egrep -E '^$pack-[^-]+-[^-]+-[^-]+$'"` installed_version="`package_version $installed.tgz`" installed_build="`package_build $installed.tgz`" @@ -760,15 +760,15 @@ function simplaret_search_and_process_patch { if [ "$get" == "yes" ]; then if [ "$IS_UPGRADE" == "1" ]; then if [ "$package_match" == "no" ]; then - simplaret_install $sugested + simplaret_install $sugested_pack else - simplaret_get $sugested + simplaret_get $sugested_pack fi else - simplaret_get $sugested + simplaret_get $sugested_pack fi if [ "$?" == "0" ]; then - DOWNLOADED_PATCHES="$DOWNLOADED_PATCHES $ARCH:$VERSION:$sugested " # the ending space is important + DOWNLOADED_PATCHES="$DOWNLOADED_PATCHES $ARCH:$VERSION:$sugested_pack " # the ending space is important fi fi |