Changeset 82
- Timestamp:
- 06/19/07 17:53:52 (2 years ago)
- Files:
-
- branches/1-7-stable/lib/deprec/recipes/svn.rb (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1-7-stable/lib/deprec/recipes/svn.rb
r73 r82 1 1 require 'fileutils' 2 require 'uri' 2 3 3 4 Capistrano.configuration(:must_exist).load do … … 10 11 # however the SVN docs convinced me it's probably overkill. 11 12 # http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.serverconfig.pathbasedauthz 13 # 12 14 set :scm_group, 'scm' 13 15 14 set :svn_root, '/usr/local/svn' 16 # The following values define the svn repository to work with. 17 # If any are undefined but :repository is set, we'll extract the 18 # necessary values from it, otherwise we'll prompt the user. 19 # 20 # An example of :repository entries are: 21 # 22 # set :repository, 'svn+ssh://scm.deprecated.org/var/svn/deprec/trunk' 23 # set :repository, 'file:///tmp/svn/deprec/trunk' 24 # 25 # I've only used svn+ssh but it shouldn't be hard to get the file scheme working. 26 # 27 set (:svn_scheme) do 28 repository ? URI.parse(repository).scheme : 'svn+ssh' 29 end 15 30 31 set (:scm_host) do 32 if repository 33 URI.parse(repository).host || 'localhost' 34 elsif ENV['HOSTS'] 35 svn_host = ENV['HOSTS'] 36 else 37 Capistrano::CLI.password_prompt('svn host: ') 38 end 39 end 40 41 # This is the actual path in the svn repos where we'll check our project into 42 set (:repos_path) do 43 repository ? URI.parse(repository).path : Capistrano::CLI.password_prompt('svn repos path: ') 44 end 45 46 # We'll calculate this based on the repos_path. It's used when initializing the repository 47 set (:repos_root) do 48 (repository ? URI.parse(repository).path : repos_path).sub(/\/(trunk|tags|branches)$/, '') 49 end 16 50 51 # XXX sudo apt-get install swig python-dev 52 # XXX requires apache already installed... 17 53 desc "install Subversion version control system" 18 task : install_svndo54 task :svn_install do 19 55 # svn 1.4 server improves on 1.3 and is backwards compatible with 1.3 clients 20 56 # http://subversion.tigris.org/svn_1.4_releasenotes.html … … 23 59 # http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.reposadmin.basics.backends 24 60 # 25 version = 'subversion-1.4.3' 61 # NOTE: we're bulding the python bindings for trac 62 # ./subversion/bindings/swig/INSTALL 63 # 64 version = 'subversion-1.4.4' 26 65 set :src_package, { 27 66 :file => version + '.tar.gz', 28 :md5sum => ' 6b991b63e3e1f69670c9e15708e40176 subversion-1.4.3.tar.gz',67 :md5sum => '702655defa418bab8f683f6268b4fd30 subversion-1.4.4.tar.gz', 29 68 :dir => version, 30 69 :url => "http://subversion.tigris.org/downloads/#{version}.tar.gz", … … 36 75 --with-apr=/usr/local/apache2 37 76 --with-apr-util=/usr/local/apache2 77 PYTHON=/usr/bin/python 38 78 ; 39 79 ).reject{|arg| arg.match '#'}.join(' ') , # DRY this up 40 80 :make => 'make;', 41 :install => 'make install;' 81 :install => 'make install;', 82 :post_install => ' 83 make swig-py; 84 make install-swig-py; 85 echo /usr/local/lib/svn-python > /usr/lib/python2.4/site-packages/subversion.pth; 86 ' 42 87 } 43 apt.install( {:base => %w(libneon25 libneon25-dev)}, :stable ) 88 enable_universe 89 apt.install( {:base => %w(libneon25 libneon25-dev swig python-dev)}, :stable ) 44 90 deprec.download_src(src_package, src_dir) 45 91 deprec.install_from_src(src_package, src_dir) 46 92 end 47 93 48 desc "create a repository and import a project" 49 task :svn_create_repos, :roles => :scm do 50 svn_repos ||= "#{svn_root}/#{application}" 94 task :scm_setup do # deprecated 95 svn_import_project 96 end 97 98 desc "Create subversion repository and import project into it" 99 task :svn_import_project, :roles => scm do 100 svn_create_repos 101 svn_import 102 end 103 104 desc "Create a subversion repository" 105 task :svn_create_repos, :roles => scm do 51 106 deprec.groupadd(scm_group) 52 107 deprec.add_user_to_group(user, scm_group) 53 deprec.mkdir(svn_root, :mode => '0755')54 deprec.mkdir( svn_repos, :mode => '2775', :group => scm_group)55 sudo "svnadmin verify #{ svn_repos} > /dev/null 2>&1 || sudo svnadmin create #{svn_repos}"56 sudo "chmod -R g+w #{ svn_repos}"108 # deprec.mkdir(svn_root, :mode => '0755') 109 deprec.mkdir(repos_root, :mode => '2775', :group => scm_group) 110 sudo "svnadmin verify #{repos_root} > /dev/null 2>&1 || sudo svnadmin create #{repos_root}" 111 sudo "chmod -R g+w #{repos_root}" 57 112 end 58 59 # XXX check through and test the next two [mike]60 113 61 # from Bradley Taylors RailsMachine gem 62 desc "Import code into svn repository." 63 task :svn_import do 114 # Adapted from code in Bradley Taylors RailsMachine gem 115 desc "Import project into subversion repository." 116 task :svn_import, :roles => scm do 117 repository ||= "#{svn_scheme}://#{scm_host == 'localhost' ? '/' : scm_host}/#{repos_path}" 64 118 new_path = "../#{application}" 65 119 tags = repository.sub("trunk", "tags") … … 76 130 system "svn co #{repository} #{application}" 77 131 Dir.chdir application 78 puts "removing log directory contents from svn" 79 system "svn remove log/*" 80 puts "ignoring log directory" 81 system "svn propset svn:ignore '*.log' log/" 82 system "svn update log/" 83 puts "removing tmp directory from svn" 84 system "svn remove tmp/" 85 puts "ignoring tmp directory" 86 system "svn propset svn:ignore '*' tmp/" 87 system "svn update tmp/" 88 puts "committing changes" 89 system "svn commit -m 'Removed and ignored log files and tmp'" 132 svn_remove_log_and_tmp 90 133 puts "Your repository is: #{repository}" 91 134 end 92 135 93 # from Bradley Taylors RailsMachine gem136 # Lifted from Bradley Taylors RailsMachine gem 94 137 desc "remove and ignore log files and tmp from subversion" 95 138 task :svn_remove_log_and_tmp do
