Skip to content
Browse files

Added support for symfony 1.x lib in shared directory.

I prefer to link to symfony lib instead of keeping it in the repository.
This commit introduces two new tasks:
* shared:symfony:download downloads symfony framework and stores it in shared
* symfony:create_lib_symlink creates a lib/vendor/symfony symlink to sources in shared

Download is called after deploy:setup to ensure that symfony is
accessible during the deploy.

Symlink is created before finalizing the update as it is needed
for every symfony task.

No task is automatically run unless use_shared_symfony is set to true.
By default it's false.

As there is no symfony in the repository we cannot guess the version and
have to ask it. Default is provided.
  • Loading branch information...
1 parent 1cd0f3b commit 423265cccce10b2abfe3ed6ea47c759966568bbc @jakzal jakzal committed with Apr 24, 2011
Showing with 40 additions and 0 deletions.
  1. +40 −0 lib/symfony1.rb
View
40 lib/symfony1.rb
@@ -19,6 +19,10 @@
# Symfony lib path
set(:symfony_lib) { guess_symfony_lib }
+# Shared symfony lib
+set :use_shared_symfony, false
+set :symfony_version, "1.4.11"
+
def guess_symfony_orm
databases = YAML::load(IO.read('config/databases.yml'))
@@ -130,6 +134,15 @@ def load_database_config(data, env)
run "#{php_bin} #{latest_release}/symfony cache:clear"
end
+ desc "Creates symbolic link to symfony lib in shared"
+ task :create_lib_symlink do
+ prompt_with_default(:version, symfony_version)
+ symlink_path = "#{latest_release}/lib/vendor/symfony"
+
+ run "if [ ! -d #{shared_path}/symfony-#{version} ]; then exit 1; fi;"
+ run "ln -nfs #{shared_path}/symfony-#{version} #{symlink_path};"
+ end
+
namespace :configure do
desc "Configure database DSN"
task :database do
@@ -578,6 +591,33 @@ def load_database_config(data, env)
upload("web/uploads", "#{shared_path}/web", :via => :scp, :recursive => true)
end
end
+
+ namespace :symfony do
+ desc "Downloads symfony framework to shared directory"
+ task :download do
+ prompt_with_default(:version, symfony_version)
+
+ run <<-CMD
+ if [ ! -d #{shared_path}/symfony-#{version} ]; then
+ wget -q http://www.symfony-project.org/get/symfony-#{version}.tgz -O- | tar -zxf - -C #{shared_path};
+ fi
+ CMD
+ end
+ end
+end
+
+# After setup
+after "deploy:setup" do
+ if use_shared_symfony
+ shared.symfony.download
+ end
+end
+
+# Before finalizing update
+before "deploy:finalize_update" do
+ if use_shared_symfony
+ symfony.create_lib_symlink
+ end
end
# After finalizing update:

0 comments on commit 423265c

Please sign in to comment.
Something went wrong with that request. Please try again.