aboutsummaryrefslogtreecommitdiff
path: root/src/simplaret
diff options
context:
space:
mode:
Diffstat (limited to 'src/simplaret')
-rwxr-xr-xsrc/simplaret112
1 files changed, 103 insertions, 9 deletions
diff --git a/src/simplaret b/src/simplaret
index cb676f9..3a1508e 100755
--- a/src/simplaret
+++ b/src/simplaret
@@ -439,7 +439,7 @@ function simplaret_search_and_delete {
if [ "`package_name $candidate`" == "`package_name $result`" ]; then
if [ "`package_version $candidate`" == "`package_version $result`" ] && \
[ "`package_build $candidate`" == "`package_build $result`" ]; then
- LAST_DONWLOADED_PACKAGE="$file"
+ LAST_DOWNLOADED_PACKAGE="$file"
if [ "$3" != "--silent" ]; then
echo Package $candidate already downloaded
# echo Package $candidate stored at `dirname $file`
@@ -495,7 +495,8 @@ function simplaret_get {
if [ "`package_name $candidate`" == "$1" ]; then
simplaret_repository_url
- # if repos_type == root and the package is a patch,
+ # if repos_type == root, the package is a patch and
+ # STORE_ROOT_PATCHES_ON_PATCHES_DIR config parameter is enabled
# save it on $PATCHES_DIR/root-$repository_name, so all patches
# are placed in the same tree
if [ "$repos_type" == "root" ] && \
@@ -505,16 +506,35 @@ function simplaret_get {
folder="$storage/$repository_name"
fi
+ # download the package
simplaret_download $repository_url $file $folder
+ if [ -f "$folder/$candidate.asc" ]; then
+ rm $folder/$candidate.asc
+ fi
+
+ if [ -f "$folder/$1.slack-required" ]; then
+ rm $folder/$1.slack-required
+ fi
+
+ # download the signature, if exist
+ if simplaret_check_url $repository_url/$file.asc; then
+ simplaret_download $repository_url $file.asc $folder
+ fi
+
+ # download slack-required, if exist
+ if simplaret_check_url $repository_url/`dirname $file`/$1.slack-required; then
+ simplaret_download $repository_url `dirname $file`/$1.slack-required $folder
+ fi
+
if [ ! -f "$folder/$candidate" ]; then
- LAST_DONWLOADED_PACKAGE="0"
+ LAST_DOWNLOADED_PACKAGE="0"
if [ "$2" != "--silent" ]; then
echo Error downloading $candidate from $repos_type repository $repository_url, please check your settings
fi
return 1
else
- LAST_DONWLOADED_PACKAGE="$folder/$candidate"
+ LAST_DOWNLOADED_PACKAGE="$folder/$candidate"
if [ "$2" != "--silent" ]; then
silent=""
echo Package $candidate stored at $folder
@@ -522,6 +542,9 @@ function simplaret_get {
# echo $folder/$candidate
silent="--silent"
fi
+ if [ -f "$folder/$candidate.asc" ] || [ "$SIGNATURE_CHECKING" == "1" ]; then
+ gpg --verify $folder/$candidate.asc $folder/$candidate
+ fi
simplaret_checksum $storage/$repository_name/CHECKSUMS.md5 $folder/$candidate $silent
return $?
fi
@@ -752,7 +775,7 @@ function simplaret_install {
# download and install a package
# usage: simplaret_install <package-name> [--skip-checks]
- local package root jail_arch jail_version
+ local package root jail_arch jail_version slack_required dep dependency
root="/$ROOT"
mkdir -p $root/var/log/setup/tmp
@@ -775,20 +798,35 @@ function simplaret_install {
# package="`simplaret_get $1 --silent`"
simplaret_get $1 --silent
- package="$LAST_DONWLOADED_PACKAGE"
+ package="$LAST_DOWNLOADED_PACKAGE"
if [ "$package" != "0" ] && [ ! -z "$package" ]; then
+ slack_required="`dirname $package`/$1.slack-required"
if [ -f "$package" ]; then
+
+ if [ -f "$slack_required" ] || [ "$DEPENDENCY_CHECKING" == "1" ]; then
+ # this routine checks for dependencies in package's slack-required
+ # procedure adapted from createpkg script
+ ( cat $slack_required | while read dep; do
+ if [ ! -z "$dep" ]; then
+ dependency="`echo $dep | awk '{ print $1 }'`"
+ simplaret_solve_dep $1 $dependency $root
+ fi
+ true
+ done )
+ fi
+
ROOT=$root upgradepkg --install-new $package
- LAST_DONWLOADED_PACKAGE="0"
+ LAST_DOWNLOADED_PACKAGE="0"
+
else
echo "error: could not install package $1: file not found"
- LAST_DONWLOADED_PACKAGE="0"
+ LAST_DOWNLOADED_PACKAGE="0"
return 1
fi
else
echo "error: could not install package $1"
- LAST_DONWLOADED_PACKAGE="0"
+ LAST_DOWNLOADED_PACKAGE="0"
return 1
fi
@@ -871,6 +909,53 @@ function simplaret_set_arch {
}
+function simplaret_check_url {
+
+ # check if a given url exist, use just with small files
+ # usage: simplaret_check_url <url>
+
+ if [ -z "$1" ]; then
+ return 1
+ fi
+
+ if [ ! -z "$CONNECT_TIMEOUT" ] || [ "$CONNECT_TIMEOUT" != "0" ]; then
+ curl_timeout="--connect-timeout $CONNECT_TIMEOUT"
+ fi
+
+ if [ "`curl $curl_timeout -I $1 2> /dev/null | head -n 1 | awk '{ print $2 }'`" == "200" ]; then
+ # server gave a 200 response, so the url exist
+ return 0
+ else
+ # the url is missing
+ return 1
+ fi
+
+}
+
+function simplaret_solve_dep {
+
+ # solve dependency for a package
+ # this function was adapted from createpkg script
+ # usage: simplaret_solve_dep <package-name> <package-depencency-name> [root-folder]
+
+ local installed check exit_code
+
+ local package="$1"
+ local pack="$2"
+ local root="/$3"
+
+ installed=`eval "ls $root/var/log/packages/ | egrep '^$pack-[^-]+-[^-]+-[^-]+$'"`
+ check=$?
+
+ if [ -z "$installed" ]; then
+ if [ $check -ne 0 ]; then
+ echo "$BASENAME: processing $1 dependency $pack"
+ SIMPLARET_CHILD=$SIMPLARET_CHILD simplaret --install $PACK
+ fi
+ fi
+
+}
+
if [ -z "$1" ]; then
simplaret_usage
exit 1
@@ -878,6 +963,15 @@ else
eval_config $BASENAME
fi
+# This is used to show how many children process we have
+if [ -z "$SIMPLARET_CHILD" ]; then
+ SIMPLARET_CHILD="1"
+else
+ let SIMPLARET_CHILD++
+fi
+
+BASENAME="`basename $0`[$SIMPLARET_CHILD]"
+
case $1 in
"--update" | "update") simplaret_update ;;
"--search" | "search") shift ; simplaret_search $* ;;