/var/lib/sorcery/modules/url_handlers/url_svn_ssh

     1	#!/bin/bash
     2	#---------------------------------------------------------------------
     3	##
     4	##=head1 SYNOPSIS
     5	##
     6	## Url handler functions for parsing smgl specific subversion over ssh urls.
     7	##
     8	##=head1 SVN URL Format
     9	##
    10	## The sourcemage specific svn+ssh url is as follows:
    11	## specific format was invented:
    12	##
    13	##      svn_ssh://SVNURL:DIR_NAME
    14	##
    15	## The above url will download the latest version of the specified
    16	## module (i.e., the HEAD revision). To specify a specific revision,
    17	## the following format can be used:
    18	##
    19	##      svn://SVNURL:DIR_NAME:REVISION_TAG
    20	##
    21	## The SVNURL portion of the url will appear as a normal svn+ssh url
    22	## sans svn+ssh:// prefix.
    23	##
    24	## The DIR_NAME will be the tail element of the SOURCE_DIRECTORY.
    25	##
    26	## For more details, see the SVN manual at
    27	## http://svnbook.red-bean.com/svnbook/ch03s04.html
    28	## and url_svn.
    29	##
    30	##=head1 COPYRIGHT
    31	##
    32	## Copyright 2004 by the Source Mage Team
    33	## Copyright 2005 by the Source Mage Team
    34	##
    35	#---------------------------------------------------------------------
    36	
    37	#---------------------------------------------------------------------
    38	##=item url_svn_http_bucketize
    39	## @param url
    40	##
    41	## Outputs svn as that is the dl handler for svn_http:// urls
    42	#---------------------------------------------------------------------
    43	function url_svn_ssh_bucketize() {
    44	  echo svn
    45	}
    46	
    47	#---------------------------------------------------------------------
    48	##=item url_file_download <url>
    49	##
    50	## Parse the specified svn_ssh url.
    51	##
    52	## @Global URL
    53	## @Global SVN_ROOT
    54	## @Global SVN_MODULE
    55	## @Global SVN_TAG
    56	##
    57	#---------------------------------------------------------------------
    58	function url_svn_ssh_crack() {
    59	
    60	  URL=`url_strip_prefix "$1" svn_ssh`
    61	  SVN_ROOT=svn+ssh://`echo $URL | sed "s#\(^[^/]*[^:]*\):.*#\1#"`
    62	  local SVN_MODULE_TAG=`echo $URL | sed "s#^[^/]*[^:]*\(.*\)#\1#"`
    63	  SVN_MODULE=`echo $SVN_MODULE_TAG | cut -d : -f2`
    64	  local SVN_TAGNAME=`echo $SVN_MODULE_TAG | cut -d : -f3`
    65	  SVN_TAG=${SVN_TAGNAME:=HEAD}
    66	
    67	}
    68	
    69	#---------------------------------------------------------------------
    70	##=item url_svn_ssh_is_valid <url>
    71	##
    72	## Ensure that all the fields that should be parsed out from a url
    73	## do indeed exist
    74	#---------------------------------------------------------------------
    75	function url_svn_ssh_is_valid() {
    76	  url_svn_is_valid "$@"
    77	}
    78	
    79	#---------------------------------------------------------------------
    80	##=item url_svn_ssh_hostname <url>
    81	##
    82	## Get the hostname of the url
    83	##
    84	#---------------------------------------------------------------------
    85	function url_svn_ssh_hostname() {
    86	  echo $1|sed 's#^svn_ssh://\([^/:]*\)[/:].*$#\1#'
    87	}
    88	
    89	#---------------------------------------------------------------------
    90	##=item url_svn_ssh_netselect <url>
    91	##
    92	## Gets a netselect type output for the url
    93	##
    94	#---------------------------------------------------------------------
    95	function url_svn_ssh_netselect() {
    96	  local tmp_hostname url_speed each
    97	
    98	  for each in "$@" ; do
    99	    tmp_hostname=$(url_svn_ssh_hostname $each)
   100	    # since we had to pull the url apart to give netselect
   101	    # something it can understand we'll just pretend like
   102	    # multiple A records wont exist for this host...
   103	    url_speed=$(netselect -s 1 $tmp_hostname 2>/dev/null|awk '{print $1}')
   104	    [[ -n $url_speed ]] && echo "$url_speed $each"
   105	  done
   106	}
   107	
   108	#---------------------------------------------------------------------
   109	##=back
   110	##
   111	##=head1 LICENSE
   112	##
   113	## This software is free software; you can redistribute it and/or modify
   114	## it under the terms of the GNU General Public License as published by
   115	## the Free Software Foundation; either version 2 of the License, or
   116	## (at your option) any later version.
   117	##
   118	## This software is distributed in the hope that it will be useful,
   119	## but WITHOUT ANY WARRANTY; without even the implied warranty of
   120	## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   121	## GNU General Public License for more details.
   122	##
   123	## You should have received a copy of the GNU General Public License
   124	## along with this software; if not, write to the Free Software
   125	## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   126	##
   127	#---------------------------------------------------------------------