aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--conf/repos.conf.new1
-rw-r--r--conf/simplepkg.conf.new7
-rwxr-xr-xsrc/simplaret290
3 files changed, 129 insertions, 169 deletions
diff --git a/conf/repos.conf.new b/conf/repos.conf.new
index 9da9f67..9ecfab9 100644
--- a/conf/repos.conf.new
+++ b/conf/repos.conf.new
@@ -5,6 +5,7 @@
# root repositories
ROOT-i386="tds%http://slackware.mirrors.tds.net/pub/slackware/"
ROOT-i386="sarava%http://slack.sarava.org/slackware/"
+ROOT-x86_64="sarava%http://slack.sarava.org/slamd64/"
ROOT-x86_64="slackadelic%http://mirror1.slackadelic.com/slamd64/"
ROOT-x86_64="heanet%http://ftp.heanet.ie/pub/slamd64/"
diff --git a/conf/simplepkg.conf.new b/conf/simplepkg.conf.new
index 50db875..5d01f59 100644
--- a/conf/simplepkg.conf.new
+++ b/conf/simplepkg.conf.new
@@ -11,12 +11,15 @@ DEFAULT_ARCH="i386"
DEFAULT_VERSION="10.2"
STORAGE="/var/simplaret/packages"
PASSIVE_FTP="1"
+ROOT_PRIORITY="patches slackware extra testing pasture" # ROOT repository package priority
# Enabling this option, jail-upgrade will look at your
# standard repositories for new packages; if it find a package
# with different version of your current installed package and
# also this package isnt in the packages folder, then the new
-# package is apllied; if in doubt, just say no or leave blank.
-# Otherwise set it either to "yes" or "1"
+# package is applied; if in doubt, just say no or leave blank.
+# Otherwise set it either to "yes" or "1" and remember that if
+# enables this feature can cause problems if you use more than
+# one REPOS definition for each ARCH and VERSION.
CONSIDER_ALL_PACKAGES_AS_PATCHES="0"
diff --git a/src/simplaret b/src/simplaret
index 37f768a..b7c6216 100755
--- a/src/simplaret
+++ b/src/simplaret
@@ -15,30 +15,8 @@
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place - Suite 330, Boston, MA 02111-1307, USA
#
-# config file simplepkg.conf:
-#
-# DEFAULT_ARCH="i386"
-# DEFAULT=VERSION="10.2"
-# STORAGE="/storage/packages"
-# PASSIVE_FTP="1"
-#
-# config file repos.conf:
-#
-# ROOT-i386="sarava%http://slack.sarava.org/packages/slackware/"
-# REPOS-i386-10.2="sarava%http://slack.sarava.org/packages/slackware/slackware-10.2/"
-# ROOT-x86_64="slackadelic%http://mirror1.slackadelic.com/slamd64/"
-# REPOS-x86_64-10.2="sarava%http://slack.sarava.org/packages/slamd64/slamd64-10.2/"
-#
-# usage:
-#
-# --update: downloads package list for each package
-# --search: search for packages
-# --get [-a]: donwload a package
-# --get-pacthes: download patches
-# --upgrade: download and aplly patches
-# --purge [-w N]: purge package cache
-#
+DEFAULT_VERSION="11.0"
SIMPLARET_CONF="/etc/simplepkg/simplepkg.conf"
REPOS_CONF="/etc/simplepkg/repos.conf"
COMMON="/usr/libexec/simplepkg/common.sh"
@@ -47,42 +25,36 @@ FILELIST="FILELIST.TXT CHECKSUMS.md5"
function simplaret_usage {
echo "usage: [ARCH=otherarch] [VERSION=otherversion] `basename $0` <OPTION> package-name"
- echo -e "\t OPTIONS: --update, --search, --get, --get-patches"
+ echo -e "\t OPTIONS: --update, --upgrade, --search, --get, --get-patches, --purge"
exit 1
}
-function simplaret_eval_config {
+function simplaret_eval_parameter {
- if grep -qe "^DEFAULT_ARCH=" $SIMPLARET_CONF; then
- DEFAULT_ARCH="`grep -e "^DEFAULT_ARCH=" $SIMPLARET_CONF | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | cut -d "#" -f 1`"
- else
- DEFAULT_ARCH="i386"
- fi
+ # usage: eval $1 parameter from $SIMPLARET_CONF
+ # return the evaluated parameter if available or $2 $3 ... $n
- if grep -qe "^DEFAULT_VERSION=" $SIMPLARET_CONF; then
- DEFAULT_VERSION="`grep -e "^DEFAULT_VERSION=" $SIMPLARET_CONF | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | cut -d "#" -f 1`"
+ if grep -qe "^$1=" $SIMPLARET_CONF; then
+ grep -e "^$1=" $SIMPLARET_CONF | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | cut -d "#" -f 1
else
- DEFAULT_VERSION="11.0"
+ shift
+ echo $*
fi
- if grep -qe "^STORAGE=" $SIMPLARET_CONF; then
- STORAGE="`grep -e "^STORAGE=" $SIMPLARET_CONF | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | cut -d "#" -f 1`"
- else
- STORAGE="/var/simplaret"
- fi
+}
- if grep -qe "^PASSIVE_FTP=" $SIMPLARET_CONF; then
- PASSIVE_FTP="`grep -e "^PASSIVE_FTP=" $SIMPLARET_CONF | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | cut -d "#" -f 1`"
- else
- PASSIVE_FTP="0"
- fi
+function simplaret_eval_config {
- if grep -qe "^WARNING=" $SIMPLARET_CONF; then
- WARNING="`grep -e "^WARNING=" $SIMPLARET_CONF | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | cut -d "#" -f 1`"
- else
- WARNING="0"
- fi
+ # simplaret config file evaluation
+
+ DEFAULT_ARCH="`simplaret_eval_parameter DEFAULT_ARCH i386`"
+ DEFAULT_VERSION="`simplaret_eval_parameter DEFAULT_VERSION $DEFAULT_VERSION`"
+ STORAGE="`simplaret_eval_parameter STORAGE /var/simplaret/packages`"
+ PATCHES_DIR="`simplaret_eval_parameter PATCHES_DIR /var/simplaret/patches`"
+ PASSIVE_FTP="`simplaret_eval_parameter PASSIVE_FTP 0`"
+ WARNING="`simplaret_eval_parameter WARNING 0`"
+ ROOT_PRIORITY="`simplaret_eval_parameter ROOT_PRIORITY patches slackware extra testing pasture`"
}
@@ -142,176 +114,159 @@ function simplaret_download {
}
-function simplaret_repos {
-
- # return all REPOS definitions for some ARCH and VERSION
- grep -e "^REPOS-$ARCH-$VERSION=" $REPOS_CONF | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | cut -d "#" -f 1
+function simplaret_repository {
-}
+ # return a repository definition from $REPOS_CONF file
+ # usage: simplaret_repository [root|repos|noarch|patches]
-function simplaret_repos_name {
+ local definition
- if echo $repos | grep -qe %; then
- repos_name="`echo $repos | cut -d % -f 1`"
- if [ -z "$repos_name" ]; then
- echo you should set a name for the repository $repos for arch $ARCH and version $VERSION
- echo please correct your $REPOS_CONF so this repository definition looks like this:
- echo REPOS-$ARCH-$VERSION=\"repository-name%repository-url\"
- exit 1
- fi
+ if [ -z "$1" ]; then
+ definition="ROOT"
else
- echo you should set a name for the repository $repos for arch $ARCH and version $VERSION
- echo please correct your $REPOS_CONF so this repository definition looks like this:
- echo REPOS-$ARCH-$VERSION=\"repository-name%$repos_url\"
- exit 1
+ definition="`echo $1 | tr '[:lower:]' '[:upper:]'`"
+ fi
+
+ if [ "$definition" == "REPOS" ] || [ "$definition" == "PATCHES" ]; then
+ definition="$definition-$ARCH-$VERSION"
+ elif [ "$definition" == "ROOT" ]; then
+ definition="$definition-$ARCH"
fi
+ grep -e "^$definition=" $REPOS_CONF | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | cut -d "#" -f 1
+
}
-function simplaret_repos_url {
+function simplaret_repository_name {
- if echo $repos | grep -qe %; then
- repos_url="`echo $repos | cut -d % -f 2`"
- if [ -z "$repos_url" ]; then
- echo you should set a url for the repository $repos for arch $ARCH and version $VERSION
- echo please correct your $REPOS_CONF so this repository definition looks like this:
- echo REPOS-$ARCH-$VERSION=\"repository-name%repository-url\"
+ # return a repository name according the value of $repository
+
+ if [ -z "$repository" ]; then
+ false
+ elif echo $repository | grep -qe %; then
+ repository_name="`echo $repository | cut -d % -f 1`"
+ if [ -z "$repository_name" ]; then
+ echo you should set a name for the repository $repository
+ echo please correct your $REPOS_CONF
exit 1
fi
else
- echo you should set a url for the repository $repos for arch $ARCH and version $VERSION
- echo please correct your $REPOS_CONF so this repository definition looks like this:
- echo REPOS-$ARCH-$VERSION=\"repository-name%repository-url\"
+ echo you should set a name for the repository $repository
+ echo please correct your $REPOS_CONF
exit 1
fi
}
-function simplaret_root {
+function simplaret_repository_url {
- # return all ROOT definitions for some ARCH and VERSION
- grep -e "^ROOT-$ARCH=" $REPOS_CONF | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | cut -d "#" -f 1
+ # return a repository url according the value of $repository
-}
-
-function simplaret_root_url {
-
- if echo $repos | grep -qe %; then
- root_url="`echo $root | cut -d % -f 2`"
+ if echo $repository | grep -qe %; then
+ repository_url="`echo $repository | cut -d % -f 2`"
if [ -z "$repos_url" ]; then
- echo you should set a url for the repository $root for arch $ARCH
- echo please correct your $REPOS_CONF so this repository definition looks like this:
- echo ROOT-$ARCH=\"repository-name%repository-url\"
+ echo you should set a url for the repository $repository
+ echo please correct your $REPOS_CONF
exit 1
fi
else
- echo you should set a url for the repository $root for arch $ARCH
- echo please correct your $REPOS_CONF so this repository definition looks like this:
- echo ROOT-$ARCH=\"repository-name%repository-url\"
+ echo you should set a url for the repository $repository
+ echo please correct your $REPOS_CONF
exit 1
fi
}
-function simplaret_patches {
-
- # return all REPOS definitions for some ARCH and VERSION
- grep -e "^PATCHES-$ARCH-$VERSION=" $REPOS_CONF | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | cut -d "#" -f 1
-
-}
-
function simplaret_update {
- echo updating package information for arch $ARCH and version $VERSION...
-
- # TODO: new repos scheme
-
- if [ ! -d "$STORAGE/$ARCH/$VERSION" ]; then
- mkdir -p $STORAGE/$ARCH/$VERSION
- else
- simplaret_backup_index $STORAGE/$ARCH/$VERSION
- fi
+ local storage
- for root in `simplaret_root`; do
+ echo updating package information for arch $ARCH and version $VERSION...
- simplaret_root_url
- simplaret_get_index "$root_url/$DISTRO_FOLDER/$extra_folder" $STORAGE/$ARCH/$VERSION
- simplaret_check_index $STORAGE/$ARCH/$VERSION
+ for repos_type in patches root repos noarch; do
+ for repository in `simplaret_repository $repos_type`; do
- done
+ simplaret_repository_name
+ simplaret_repository_url
- for repos in `simplaret_repos`; do
+ storage="$STORAGE/$ARCH/$VERSION/$repos_type"
+ if [ "$repos_type" == "noarch" ]; then
+ storage="$STORAGE/noarch"
+ elif [ "$repos_type" == "patches" ]; then
+ storage="$PATCHES_DIR/$ARCH/$VERSION"
+ elif [ "$repost_type" == "root" ]; then
+ repository_url="$repository_url/$DISTRO_FOLDER/$EXTRA_FOLDER"
+ fi
- simplaret_repos_name
- simplaret_repos_url
+ if [ ! -d "$storage/$repository_name" ]; then
+ mkdir -p $storage/$repository_name
+ else
+ simplaret_backup_index $storage/$repository_name
+ fi
- if [ ! -d "$STORAGE/$ARCH/$VERSION/$repos_name" ]; then
- mkdir -p $STORAGE/$ARCH/$VERSION/$repos_name
- else
- simplaret_backup_index $STORAGE/$ARCH/$VERSION/$repos_name
- fi
+ simplaret_get_index $repository_url $storage/$repository_name
+ simplaret_check_index $storage/$repository_name
- simplaret_get_index $repos_url $STORAGE/$ARCH/$VERSION/$repos_name
- simplaret_check_index $STORAGE/$ARCH/$VERSION/$repos_name
+ unset repository_name repository_url repository_protocol
- unset repos_name repos_url repos_protocol
-
+ done
done
}
function simplaret_search {
- # first search in ROOT repositories
- # TODO ...
+ # TODO: ROOT_PRIORITY
- if [ ! -f "$STORAGE/$ARCH/$VERSION/FILELIST.TXT" ]; then
- if [ "$WARNING" != "0" ] || [ ! -z "$SILENT" ]; then
- echo warning: no file list for root repository on arch $ARCH version $VERSION, please do a simplaret --update
- fi
- else
- for file in `grep $1 $STORAGE/$ARCH/$VERSION/FILELIST.TXT | awk '{ print $8 }' | grep -e ".tgz$"`; do
- if echo $file | grep -q "patches"; then
- patch="(patch)"
- fi
- if [ "$2" == "-silent" ]; then
- echo `basename $file`
- else
- echo root repos, arch: $ARCH, version: $VERSION: `basename $file` $patch
- fi
- unset patch
- done
- fi
+ local name
- # then search in the REPOS repositories
+ for repos_type in patches root repos noarch; do
- for repos in `simplaret_repos`; do
+ name="`echo $repos_type | tr '[:lower:]' '[:upper:]'`"
- simplaret_repos_name
+ storage="$STORAGE/$ARCH/$VERSION/$repos_type"
+ if [ "$repos_type" == "noarch" ]; then
+ storage="$STORAGE/noarch"
+ elif [ "$repos_type" == "patches" ]; then
+ storage="$PATCHES_DIR/$ARCH/$VERSION"
+ fi
- if [ ! -f "$STORAGE/$ARCH/$VERSION/$repos_name/FILELIST.TXT" ]; then
- if [ "$WARNING" != "0" ] || [ ! -z "$SILENT" ]; then
- echo warning: no file list for $repos_name repository on arch $ARCH version $VERSION, please do a simplaret --update
- fi
- else
- for file in `grep $1 $STORAGE/$ARCH/$VERSION/$repos_name/FILELIST.TXT | awk '{ print $8 }' | grep -e ".tgz$"`; do
- if echo $file | grep -q "patches"; then
- patch="(patch)"
- fi
- if [ "$2" == "-silent" ]; then
- echo `basename $file`
- else
- echo $repos_name, arch: $ARCH, version: $VERSION: `basename $file` $patch
+ for repository in `simplaret_repository $repos_type`; do
+
+ simplaret_repository_name
+
+ if [ ! -f "$storage/$repository_name/FILELIST.TXT" ]; then
+ if [ "$WARNING" != "0" ] || [ ! -z "$SILENT" ]; then
+ echo warning: no file list for $repository_name repository $repository_name on arch $ARCH version $VERSION
+ echo please do a simplaret --update
fi
- done
- fi
+ else
+ for file in `grep $1 $storage/$repository_name/FILELIST.TXT | awk '{ print $8 }' | grep -e ".tgz$"`; do
+ if echo $file | grep -q "/patches/"; then
+ patch="(patch)"
+ fi
+ if [ "$2" == "-silent" ]; then
+ echo `basename $file`
+ else
+ if [ "$repos_type" == "noarch" ]; then
+ echo $name repository $repository_name: `basename $file` $patch
+ else
+ echo $name repository $repository_name, arch: $ARCH, version: $VERSION: `basename $file` $patch
+ fi
+ fi
+ unset patch
+ done
+ fi
+ done
done
}
function simplaret_purge {
+ # TODO: new repo format
+
if [ "$2" == "-w" ] && [ ! -z "$3" ]; then
if [ -z "$SILENT" ]; then
echo purging all packages older than $3 weeks for arch $ARCH and version $VERSION
@@ -347,16 +302,17 @@ 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
+ # etc
# 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
# 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`" ] && \
+ 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
+ [ "`package_build $candidate`" == "`package_build $result`" ]; then
echo package $candidate already downloaded and stored at `dirname $file`
exit 0
else
@@ -376,7 +332,7 @@ function simplaret_get {
candidate="`basename $file`"
if [ "`package_name $candidate`" == "$1" ]; then
simplaret_root_url
- simplaret_download $root_url/$DISTRO_FOLDER/$extra_folder $file $STORAGE/$ARCH/$VERSION
+ simplaret_download $root_url/$DISTRO_FOLDER/$EXTRA_FOLDER $file $STORAGE/$ARCH/$VERSION
if [ ! -f "$STORAGE/$ARCH/$VERSION/$candidate" ]; then
echo error downloading $candidate from root repository $root_url, please check your settings
exit 1
@@ -390,7 +346,7 @@ function simplaret_get {
fi
# then search for the package in contrib repos
- for repos in `simplaret_repos`; do
+ for repos in `simplaret_repository repos`; do
simplaret_repos_name
simplaret_repos_url
if [ ! -f "$STORAGE/$ARCH/$VERSION/$repos_name/FILELIST.TXT" ]; then
@@ -505,7 +461,7 @@ if [ "$ARCH" == "i386" ]; then
DISTRO="slackware"
DISTRO_FOLDER="$DISTRO-$VERSION"
elif [ "$ARCH" == "x86_64" ]; then
- # extra_folder="tree"
+ # EXTRA_FOLDER="tree"
DISTRO="slamd64"
DISTRO_FOLDER="$DISTRO-$VERSION"
elif [ "$ARCH" == "s390" ]; then