diff options
| author | rhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58> | 2007-01-23 13:16:19 +0000 | 
|---|---|---|
| committer | rhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58> | 2007-01-23 13:16:19 +0000 | 
| commit | 640fab565d59163048976a215188aa90ce0f5fcb (patch) | |
| tree | b4cf0885988e33ba581d0749e00d4e1596528847 /src/simplaret | |
| parent | 7d475294da550148c62373bb3e0b87614208ef0b (diff) | |
| download | simplepkg-640fab565d59163048976a215188aa90ce0f5fcb.tar.gz simplepkg-640fab565d59163048976a215188aa90ce0f5fcb.tar.bz2  | |
simplaret: added ncftpget and timeout support, small changes
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@113 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'src/simplaret')
| -rwxr-xr-x | src/simplaret | 36 | 
1 files changed, 28 insertions, 8 deletions
diff --git a/src/simplaret b/src/simplaret index 97627d6..b77322e 100755 --- a/src/simplaret +++ b/src/simplaret @@ -16,19 +16,20 @@  #  Place - Suite 330, Boston, MA 02111-1307, USA  # +BASERNAME="`basename $0`"  REPOS_CONF="/etc/simplepkg/repos.conf"  COMMON="/usr/libexec/simplepkg/common.sh"  if [ -f "$COMMON" ]; then    source $COMMON  else -  echo "error: file $COMMON found, check your `basename $0` installation" +  echo "error: file $COMMON found, check your $BASENAME installation"    exit 1  fi  function simplaret_usage { -  echo "usage: [ARCH=otherarch] [VERSION=otherversion] `basename $0` <OPTION> package-name" +  echo "usage: [ARCH=otherarch] [VERSION=otherversion] $BASENAME <OPTION> package-name"    echo -e "\t OPTIONS: --update, --upgrade, --search, --get, --get-patches, --purge, --remove"    exit 1 @@ -70,19 +71,37 @@ function simplaret_download {    # download a file from a repo to a folder    # usage: simplaret <repository_url> <package> <destination-folder> +  local protocol +  local wget_timeout wget_passive_ftp +  local ncftpget_timeout ncftpget_passive_ftp +    protocol="`echo $1 | cut -d : -f 1`"    if [ ! -d "$3" ]; then      mkdir -p $3    fi +  if [ ! -z "$CONNECT_TIMEOUT" ] || [ "$CONNECT_TIMEOUT" != "0" ]; then +    wget_timeout="--timeout $CONNECT_TIMEOUT" +    ncftpget_timeout="-t $CONNECT_TIMEOUT" +  fi +    if [ "$protocol" == "http" ]; then -    (cd $3 && wget $1/$2) +    (cd $3 && wget $wget_timeout $1/$2)    elif [ "$protocol" == "ftp" ]; then      if [ "$PASSIVE_FTP" == "1" ]; then -      passive_ftp="--passive-ftp" +      wget_passive_ftp="--passive-ftp" +      ncftpget_passive_ftp="-F"      fi  -    (cd $3 && wget $passive_ftp $1/$2) +    if [ "$FTP_TOOL" == "ncftpget" ]; then +      (cd $3 && ncftpget $ncftpget_timeout $ncftpget_passive_ftp $1/$2) +    elif [ "$FTP_TOOL" == "wget" ]; then +      (cd $3 && wget $wget_timeout $wget_passive_ftp $1/$2) +    else +      echo $BASENAME: error: invalid value for config variable FTP_TOOL: $FTP_TOOL +      echo $BASENAME: please check your config file $CONF +      exit 1 +    fi    elif [ "$protocol" == "file" ]; then      url="`echo $1 | sed -e 's/file:\/\///'`"      cp $url/$2 $3 2> /dev/null @@ -348,7 +367,7 @@ function simplaret_purge {      simplaret_set_storage_folder      for file in `find $storage/ $mtime 2> /dev/null`; do -      for extension in tgz asc meta; do +      for extension in tgz asc meta txt; do          if echo $file | grep -qe ".$extension$"; then            rm $file          fi @@ -486,6 +505,7 @@ function simplaret_search_and_download_patch {    # check if the patch was already downloaded    if echo "$DOWNLOADED_PATCHES" | grep -q " $ARCH:$VERSION:$sugested "; then +    echo "jail $root needs package $sugested, but it's already downloaded, skipping donwload"      return    fi @@ -681,7 +701,7 @@ function simplaret_install {  function simplaret_distro_folder { -  # sets the distro folder +  # set the distro folder    if [ "$ARCH" == "i386" ]; then      DISTRO="slackware" @@ -713,7 +733,7 @@ if [ -z "$1" ]; then    simplaret_usage    exit 1  else -  eval_config `basename $0` +  eval_config $BASENAME  fi  case $1 in  | 
