From 8164018d0940b8cc542cb5995a1e7c85187bbdb7 Mon Sep 17 00:00:00 2001 From: rhatto Date: Fri, 10 Nov 2006 22:32:38 +0000 Subject: start to apply changes from the huge TODO list git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@25 04377dda-e619-0410-9926-eae83683ac58 --- doc/CHANGELOG | 6 ++++++ lib/common.sh | 33 +++++++++++++++++++++++++++++++++ src/jail-upgrade | 16 ++++++++-------- src/simplaret | 22 +++++++++++++++++----- 4 files changed, 64 insertions(+), 13 deletions(-) diff --git a/doc/CHANGELOG b/doc/CHANGELOG index d473559..258dcc8 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -5,6 +5,12 @@ simplepkg changelog - fix in swaret upgrade method - 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. + 0.4.9pre6: createpkg: - fixes - now with slackbuild error handling diff --git a/lib/common.sh b/lib/common.sh index af31da3..5c9a4fa 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -55,6 +55,39 @@ function package_name { fi } +function package_version { + + # get VERSION from a package name + local file pack version + file="`basename $1`" + pack="`package_name $1`" + version="`echo $file | sed -e "s/^$pack//" | cut -d "-" -f 1`" + echo $version + +} + +function package_arch { + + # get ARCH from a package name + local file pack arch + file="`basename $1`" + pack="`package_name $1`" + arch="`echo $file | sed -e "s/^$pack//" | cut -d "-" -f 2`" + echo $arch + +} + +function package_build { + + # get BUILD from a package name + local file pack build + file="`basename $1`" + pack="`package_name $1`" + build="`echo $file | sed -e "s/^$pack//" | cut -d "-" -f 3`" + echo $build + +} + function install_packages { if [[ "$SIMPLARET_CLEAN" == "1" ]]; then diff --git a/src/jail-upgrade b/src/jail-upgrade index c33180c..df6e013 100755 --- a/src/jail-upgrade +++ b/src/jail-upgrade @@ -108,14 +108,14 @@ elif [ -d "$JAIL_ROOT/$1" ]; then else echo error: jail $JAIL_ROOT/$1 dont looks like a slackware system fi -# elif [ -f "$1" ]; then -# basename="`basename $1 tgz`" -# if [ "`basename $1 | sed -e "s/^$basename//"`" == "tgz" ]; then -# # TODO: -# # - descobrir a arquitetura do pacote -# # - atualizar nas jaulas de mesma arquitetura -# true -# fi + elif [ -f "$1" ]; then + basename="`basename $1 tgz`" + if [ "`basename $1 | sed -e "s/^$basename//"`" == "tgz" ]; then + arch="`package_arch $1`" + # TODO + # - atualizar nas jaulas de mesma arquitetura + true + fi else echo "error: jail $0 does not exist" exit 1 diff --git a/src/simplaret b/src/simplaret index cdcf430..797c2d6 100755 --- a/src/simplaret +++ b/src/simplaret @@ -1,6 +1,6 @@ #!/bin/bash # -# simplaret v0.1.1: simplepkg's package grabber +# simplaret v0.1.1: simplepkg's retrieval tool # feedback: rhatto at riseup.net | gpl # # Simplaret is free software; you can redistribute it and/or modify it under the @@ -24,9 +24,9 @@ # # config file repos.conf: # -# ROOT-i386="http://slack.sarava.org/packages/slackware" +# ROOT-i386="http://slack.sarava.org/packages/slackware/" # REPOS-i386-10.2="slack.sarava.org%http://slack.sarava.org/packages/slackware/slackware-10.2/" -# ROOT-x86_64="http://darkstar.ist.utl.pt/pub/slamd64/" +# ROOT-x86_64="http://mirror1.slackadelic.com/slamd64/" # REPOS-x86_64-10.2="slack.sarava.org%http://slack.sarava.org/packages/slamd64/slamd64-10.2/" # # usage: @@ -303,12 +303,24 @@ function simplaret_purge { function simplaret_get { + # TODO: with no parameters, update the existing packages at the local repo? + # support to --get package-version-arch-build.tgz or just half the name + # search for an already downloaded package for file in `find $STORAGE/$ARCH/$VERSION/ -name $1*tgz 2> /dev/null`; do candidate="`basename $file`" if [ "`package_name $candidate`" == "$1" ]; then - echo package $candidate already downloaded and stored at `dirname $file` - exit 0 + # check if has the same version and build number, otherwise erase the old one + for result in `simplaret_search `basename $file tgz` --silent`; do + if [ "`package_name $candidate`" == "`package_name $result`" ] && \ + [ "`package_version $candidate`" == "`package_version $result`" ] && \ + [ "`package_build $candidate`" == "`package_build $result`" ]; then + echo package $candidate already downloaded and stored at `dirname $file` + exit 0 + else + rm $file + fi + done fi done -- cgit v1.2.3