/var/lib/sorcery/modules/dl_handlers/dl_tla

     1	#!/bin/bash
     2	## ----------------------------------------------------------------------------
     3	##
     4	##=head1 SYNOPSIS
     5	##
     6	## Url handler functions for grabbing tla urls.
     7	##
     8	##
     9	##=head1 COPYRIGHT
    10	##
    11	## Copyright 2005 the SourceMage Team
    12	##
    13	## ----------------------------------------------------------------------------
    14	
    15	# -----------------------------------------------------------------------------
    16	##=item dl_get_tla <url>
    17	##
    18	## Fetch the specified tla url.
    19	##
    20	## This handler only supports tree downloads.
    21	##
    22	# -----------------------------------------------------------------------------
    23	function dl_tla_get() {
    24	  dl_command_check tla || return 254
    25	
    26	  local target=$1
    27	  local url_list=$2
    28	  local hints=$3
    29	  local dl_target=$4
    30	  local dl_type=$5
    31	  local rc=1 url
    32	
    33	  [[ $target ]] &&
    34	  dl_connect || return 255
    35	
    36	  for url in $url_list; do
    37	    local URL TLA_ARCHIVE TLA_LOCATION TLA_REVISION
    38	
    39	    if ! tla archives | grep -q "\<$TLA_ARCHIVE\>"; then
    40	      tla register-archive $TLA_ARCHIVE $TLA_LOCATION || {
    41	        message "${PROBLEM_COLOR}Error registering archive${DEFAULT_COLOR}"
    42	        continue
    43	      }
    44	    else
    45	      debug "archive $TLA_ARCHIVE is already registered"
    46	    fi
    47	    if test -d $target; then
    48	      pushd $target &>/dev/null &&
    49	      message "${MESSAGE_COLOR}Running tla update...${DEFAULT_COLOR}"
    50	      tla update $TLA_ARCHIVE/$TLA_REVISION &&
    51	      tla register-archive -d $TLA_ARCHIVE $TLA_LOCATION &&
    52	      popd || {
    53	        message "${PROBLEM_COLOR}Error updating cached archive${DEFAULT_COLOR}"
    54	        tla register-archive -d $TLA_ARCHIVE $TLA_LOCATION &>/dev/null
    55	        continue
    56	      }
    57	    else
    58	      message "${MESSAGE_COLOR}Running tla get...${DEFAULT_COLOR}"
    59	      tla get -A $TLA_ARCHIVE $TLA_REVISION $target &&
    60	      tla register-archive -d $TLA_ARCHIVE $TLA_LOCATION || {
    61	        message "${PROBLEM_COLOR}Error checking out archive${DEFAULT_COLOR}"
    62	        continue
    63	      }
    64	    fi
    65	    rc=0
    66	    break
    67	  done
    68	
    69	  dl_disconnect
    70	
    71	  eval "$dl_target=\"$target\""
    72	  eval "$dl_type=\"tree\""
    73	  return $rc
    74	}
    75	
    76	
    77	
    78	#---------------------------------------------------------------------
    79	##=back
    80	##
    81	##=head1 LICENSE
    82	##
    83	## This software is free software; you can redistribute it and/or modify
    84	## it under the terms of the GNU General Public License as published by
    85	## the Free Software Foundation; either version 2 of the License, or
    86	## (at your option) any later version.
    87	##
    88	## This software is distributed in the hope that it will be useful,
    89	## but WITHOUT ANY WARRANTY; without even the implied warranty of
    90	## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    91	## GNU General Public License for more details.
    92	##
    93	## You should have received a copy of the GNU General Public License
    94	## along with this software; if not, write to the Free Software
    95	## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    96	##
    97	#---------------------------------------------------------------------