/var/lib/sorcery/modules/dl_handlers/dl_bzr

     1	#!/bin/bash
     2	#---------------------------------------------------------------------
     3	##
     4	##=head1 COPYRIGHT
     5	##
     6	## Copyright 2004 by the Source Mage Team
     7	##
     8	##=head1 FUNCTIONS
     9	##
    10	##=over 4
    11	##
    12	#---------------------------------------------------------------------
    13	
    14	
    15	#---------------------------------------------------------------------
    16	##=item dl_bzr_get <url>
    17	##
    18	## Fetch the specified bzr url.
    19	##
    20	## This handler only supports tree downloads.
    21	##
    22	#---------------------------------------------------------------------
    23	function dl_bzr_get() {
    24	  dl_command_check bzr || 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 url rc=0
    32	
    33	  [[ $target ]] &&
    34	  dl_connect || return 255
    35	
    36	  for url in $url_list; do
    37	    local URL BZR_ROOT BZR_DIRECTORY BZR_BRANCH
    38	    url_crack "$url" "$hints"
    39	    if [[ -z $BZR_DIRECTORY ]]
    40	    then
    41	      BZR_DIRECTORY=${target}
    42	    fi
    43	    if test -d $BZR_DIRECTORY; then
    44	      message "${MESSAGE_COLOR}Updating...${DEFAULT_COLOR}"
    45	      ( cd $BZR_DIRECTORY &&
    46		echo bzr update &&
    47		bzr update )
    48	      rc=$?
    49	      eval "$dl_target=\"$BZR_DIRECTORY\""
    50	    else
    51	      message "${MESSAGE_COLOR}Doing a lightweight checkout...${DEFAULT_COLOR}"
    52	      echo bzr checkout --lightweight $BZR_ROOT $BZR_DIRECTORY
    53	      bzr checkout --lightweight $BZR_ROOT $BZR_DIRECTORY
    54	      rc=$?
    55	      eval "$dl_target=\"$BZR_DIRECTORY\""
    56	    fi
    57	    [[ $rc == 0 ]] && break
    58	  done
    59	  dl_disconnect
    60	
    61	  eval "$dl_type=\"tree\""
    62	  return $rc
    63	}
    64	
    65	#---------------------------------------------------------------------
    66	##=back
    67	##
    68	##=head1 LICENSE
    69	##
    70	## This software is free software; you can redistribute it and/or modify
    71	## it under the terms of the GNU General Public License as published by
    72	## the Free Software Foundation; either version 2 of the License, or
    73	## (at your option) any later version.
    74	##
    75	## This software is distributed in the hope that it will be useful,
    76	## but WITHOUT ANY WARRANTY; without even the implied warranty of
    77	## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    78	## GNU General Public License for more details.
    79	##
    80	## You should have received a copy of the GNU General Public License
    81	## along with this software; if not, write to the Free Software
    82	## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    83	##
    84	#---------------------------------------------------------------------