aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2007-01-05 03:58:36 +0000
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2007-01-05 03:58:36 +0000
commit99ace5d5b81660af343d1b76a7e2f5c236635013 (patch)
tree88d6007c6cc04ede576656e802bc0ac5c7504cb2 /src
parentfc9e1b993a9b17821a94f0de68a3b3e88fa54a65 (diff)
downloadsimplepkg-99ace5d5b81660af343d1b76a7e2f5c236635013.tar.gz
simplepkg-99ace5d5b81660af343d1b76a7e2f5c236635013.tar.bz2
simplaret: added --install
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@80 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'src')
-rwxr-xr-xsrc/simplaret64
1 files changed, 52 insertions, 12 deletions
diff --git a/src/simplaret b/src/simplaret
index 1cef677..9a7a64c 100755
--- a/src/simplaret
+++ b/src/simplaret
@@ -92,7 +92,7 @@ function simplaret_check_index {
function simplaret_download {
- # downloads a file from a repo to a folder
+ # download a file from a repo to a folder
# usage: simplaret <repository_url> <package> <destination-folder>
protocol="`echo $1 | cut -d : -f 1`"
@@ -379,6 +379,9 @@ function simplaret_purge {
function simplaret_get {
+ # get a package
+ # usage: simplaret_get <package-name> [--silent]
+
# prevent user to stay in $storage
cd
@@ -395,7 +398,10 @@ function simplaret_get {
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`
+ if [ "$2" != "--silent" ]; then
+ echo package $candidate already downloaded and stored at `dirname $file`
+ else echo $file
+ fi
return 0
else
rm $file
@@ -422,12 +428,17 @@ function simplaret_get {
simplaret_repository_url
simplaret_download $repository_url $file $storage/$repository_name
if [ ! -f "$storage/$repository_name/$candidate" ]; then
- echo error downloading $candidate from $repos_type repository $repository_url, please check your settings
+ if [ "$2" != "--silent" ]; then
+ echo error downloading $candidate from $repos_type repository $repository_url, please check your settings
+ fi
return 1
else
- echo package $candidate stored at $storage/$repository_name
- simplaret_checksum $storage/$repository_name/CHECKSUMS.md5 $storage/$repository_name/$candidate
- return 0
+ if [ "$2" != "--silent" ]; then
+ echo package $candidate stored at $storage/$repository_name
+ else echo $storage/$repository_name/$candidate
+ fi
+ simplaret_checksum $storage/$repository_name/CHECKSUMS.md5 $storage/$repository_name/$candidate --silent
+ return $?
fi
fi
@@ -548,11 +559,13 @@ function simplaret_get_patches {
function simplaret_checksum {
- # simplaret_checksum <md5file> <file-name>
+ # simplaret_checksum <md5file> <file-name> [--silent]
if [ ! -f "$1" ] || [ ! -f "$2" ]; then
- echo checksum error: file not found
- exit 1
+ if [ "$3" != "--silent" ]; then
+ echo checksum error: file not found
+ fi
+ return 1
fi
pack="`basename $2`"
@@ -560,11 +573,37 @@ function simplaret_checksum {
if [ -z "$checksum" ]; then
echo file $2 not in checksum $1
- exit 1
+ return 1
elif [ "$checksum" != "`md5sum $2 | awk '{ print $1 }'`" ]; then
- echo checksum mismatch for file `basename $file`
+ if [ "$3" != "--silent" ]; then
+ echo checksum mismatch for file `basename $file`
+ fi
+ return 1
else
- echo checksum ok for file `basename $file`
+ if [ "$3" != "--silent" ]; then
+ echo checksum ok for file `basename $file`
+ fi
+ return 0
+ fi
+
+}
+
+function simplaret_install {
+
+ # download and install a package
+ # TODO: dependency checking
+
+ local package root
+
+ if [ ! -x "$ROOT" ]; then
+ root="ROOT=/$ROOT"
+ else root=""
+ fi
+
+ package="`simplaret_get $1 --silent`"
+
+ if [ "$?" == "0" ]; then
+ $root upgradepkg --install-new $package
fi
}
@@ -626,6 +665,7 @@ case $1 in
--get) simplaret_get $2 ;;
--get-patches) simplaret_get_patches ;;
--purge) shift ; simplaret_purge $* ;;
+ --install) simplaret_install $2 ;;
--upgrade) simplaret_get_patches ; jail-upgrade ;;
*) simplaret_usage ;;
esac