/var/lib/sorcery/modules/url_handlers/url_bzr

     1	#!/bin/bash
     2	#---------------------------------------------------------------------
     3	##
     4	##=head1 SYNOPSIS
     5	##
     6	## Url handler functions for downloading bzr urls
     7	##
     8	##=head1 DESCRIPTION
     9	##
    10	## This file contains functions for downloading and verifying
    11	## bzr urls.  This file uses the "bzr" program.
    12	##
    13	##=head1 COPYRIGHT
    14	##
    15	## Copyright 2002 by the Source Mage Team
    16	##
    17	##=head1 FUNCTIONS
    18	##
    19	##=over 4
    20	##
    21	#---------------------------------------------------------------------
    22	
    23	#---------------------------------------------------------------------
    24	##=item url_bzr_crack <url>
    25	##
    26	## Parse the specified bzr url.
    27	##
    28	## @Global URL
    29	## @Global BZR_ROOT
    30	## @Global BZR_DIRECTORY
    31	##
    32	#---------------------------------------------------------------------
    33	function url_bzr_crack() {
    34	  URL=$(url_strip_prefix "$1" bzr)
    35	  BZR_ROOT=bzr://$(echo $URL | cut -d: -f1)
    36	  BZR_DIRECTORY=$(echo $URL | cut -d: -f2)
    37	}
    38	
    39	#---------------------------------------------------------------------
    40	##=item url_bzr_bucketize <url>
    41	##
    42	## echoes the download handler - bzr
    43	##
    44	#---------------------------------------------------------------------
    45	function url_bzr_bucketize() {
    46	  echo bzr
    47	}
    48	
    49	#---------------------------------------------------------------------
    50	##=item url_bzr_verify <url>
    51	##
    52	## Verifies the specified bzr url.  Returns true if the url exists
    53	## OR if the url is an empty string.
    54	##
    55	#---------------------------------------------------------------------
    56	function url_bzr_verify() {
    57	  local URL BZR_ROOT item
    58	  url_bzr_crack $1
    59	  for item in URL BZR_ROOT; do
    60	    if ! [[ ${!item} ]] ; then
    61	      return 1
    62	    fi
    63	  done
    64	}
    65	
    66	#---------------------------------------------------------------------
    67	##=item url_<prefix>_hostname <url>
    68	##
    69	## Gets the hostname out of the url
    70	#---------------------------------------------------------------------
    71	function url_bzr_hostname() {
    72	  echo $1|sed 's:^.*//\([^/]*\).*$:\1:'
    73	}
    74	
    75	#---------------------------------------------------------------------
    76	##=item url_bzr_netselect <url>
    77	##
    78	## Gets a netselect type output for the url
    79	##
    80	#---------------------------------------------------------------------
    81	function url_bzr_netselect() {
    82	  local tmp_hostname url_speed each
    83	
    84	  for each in "$@" ; do
    85	    tmp_hostname=$(url_bzr_hostname $each)
    86	    # since we had to pull the url apart to give netselect
    87	    # something it can understand we'll just pretend like
    88	    # multiple A records wont exist for this host...
    89	    url_speed=$(netselect -s 1 $tmp_hostname 2>/dev/null|awk '{print $1}')
    90	    [[ -n $url_speed ]] && echo "$url_speed $each"
    91	  done
    92	}
    93	
    94	
    95	#---------------------------------------------------------------------
    96	##=back
    97	##
    98	##=head1 LICENSE
    99	##
   100	## This software is free software; you can redistribute it and/or modify
   101	## it under the terms of the GNU General Public License as published by
   102	## the Free Software Foundation; either version 2 of the License, or
   103	## (at your option) any later version.
   104	##
   105	## This software is distributed in the hope that it will be useful,
   106	## but WITHOUT ANY WARRANTY; without even the implied warranty of
   107	## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   108	## GNU General Public License for more details.
   109	##
   110	## You should have received a copy of the GNU General Public License
   111	## along with this software; if not, write to the Free Software
   112	## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   113	##
   114	#---------------------------------------------------------------------