/var/lib/sorcery/modules/url_handlers/url_git_local

     1	#!/bin/bash
     2	#---------------------------------------------------------------------
     3	##
     4	##=head1 SYNOPSIS
     5	##
     6	## Url handler functions for downloading from local git urls
     7	##
     8	##=head1 DESCRIPTION
     9	##
    10	## This file contains functions for downloading and verifying
    11	## local git urls.  This file uses the "git" 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_git_local_crack <url>
    25	##
    26	## Parse the specified git url.
    27	##
    28	## @Global URL
    29	## @Global GIT_ROOT
    30	## @Global GIT_DIRECTORY
    31	## @Global GIT_TAG
    32	##
    33	#---------------------------------------------------------------------
    34	function url_git_local_crack() {
    35	
    36	  URL=`url_strip_prefix "$1" git_local`
    37	  GIT_ROOT=`echo $URL | sed "s#\(^[^/]*[^:]*\):.*#\1#"`
    38	  local GIT_DIRECTORY_TAG=`echo $URL | sed "s#^[^/]*[^:]*\(.*\)#\1#"`
    39	  GIT_DIRECTORY=`echo $GIT_DIRECTORY_TAG | cut -d : -f2`
    40	  local GIT_TAGNAME=`echo $GIT_DIRECTORY_TAG | cut -d : -f3`
    41	  GIT_TAG=${GIT_TAGNAME:=master}
    42	
    43	}
    44	
    45	#---------------------------------------------------------------------
    46	##=item url_git_local_bucketize <url>
    47	##
    48	## echoes the download handler - git
    49	##
    50	#---------------------------------------------------------------------
    51	function url_git_local_bucketize() {
    52	  echo git
    53	}
    54	
    55	#---------------------------------------------------------------------
    56	##=item url_git_local_verify <url>
    57	##
    58	## Verifies the specified git url.  Returns true if the url exists
    59	## OR if the url is an empty string.
    60	##
    61	#---------------------------------------------------------------------
    62	function url_git_local_verify() {
    63	  local  URL GIT_ROOT GIT_DIRECTORY GIT_TAG item
    64	  url_git_local_crack $1
    65	  for item in URL GIT_ROOT; do
    66	    if ! [[ ${!item} ]] ; then
    67	      return 1
    68	    fi
    69	  done
    70	}
    71	
    72	#---------------------------------------------------------------------
    73	##=item url_<prefix>_hostname <url>
    74	##
    75	## Gets the hostname out of the url
    76	#---------------------------------------------------------------------
    77	function url_git_local_hostname() {
    78	  echo $1|sed 's:^.*//\([^/]*\).*$:\1:'
    79	}
    80	
    81	#---------------------------------------------------------------------
    82	##=back
    83	##
    84	##=head1 LICENSE
    85	##
    86	## This software is free software; you can redistribute it and/or modify
    87	## it under the terms of the GNU General Public License as published by
    88	## the Free Software Foundation; either version 2 of the License, or
    89	## (at your option) any later version.
    90	##
    91	## This software is distributed in the hope that it will be useful,
    92	## but WITHOUT ANY WARRANTY; without even the implied warranty of
    93	## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    94	## GNU General Public License for more details.
    95	##
    96	## You should have received a copy of the GNU General Public License
    97	## along with this software; if not, write to the Free Software
    98	## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    99	##
   100	#---------------------------------------------------------------------