nixpkgs/pkgs/applications/version-management/redmine/2002_FHS_through_env_vars.patch

101 lines
4.9 KiB
Diff
Raw Normal View History

2014-10-07 09:52:45 +01:00
Description: FHS through env vars
Forwarded: not-needed
Author: Jérémy Lal <kapouer@melix.org>
Last-Update: 2013-09-28
--- redmine.orig/app/models/attachment.rb
+++ redmine/app/models/attachment.rb
@@ -46,10 +46,10 @@ class Attachment < ActiveRecord::Base
"LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id"}
cattr_accessor :storage_path
- @@storage_path = Redmine::Configuration['attachments_storage_path'] || File.join(Rails.root, "files")
+ @@storage_path = Redmine::Configuration['attachments_storage_path'] || ENV['RAILS_VAR'] ? File.join(ENV['RAILS_VAR'], "files") : File.join(Rails.root, "files")
cattr_accessor :thumbnails_storage_path
- @@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
+ @@thumbnails_storage_path = ENV['RAILS_TMP'] ? File.join(ENV['RAILS_TMP'], "thumbnails") : File.join(Rails.root, "tmp", "thumbnails")
before_save :files_to_final_location
after_destroy :delete_from_disk
--- redmine.orig/lib/redmine/configuration.rb
+++ redmine/lib/redmine/configuration.rb
@@ -32,7 +32,7 @@ module Redmine
# * <tt>:file</tt>: the configuration file to load (default: config/configuration.yml)
# * <tt>:env</tt>: the environment to load the configuration for (default: Rails.env)
def load(options={})
- filename = options[:file] || File.join(Rails.root, 'config', 'configuration.yml')
+ filename = options[:file] || ENV['RAILS_ETC'] ? File.join(ENV['RAILS_ETC'], 'configuration.yml') : File.join(Rails.root, 'config', 'configuration.yml')
env = options[:env] || Rails.env
@config = @defaults.dup
@@ -103,7 +103,7 @@ module Redmine
end
def load_deprecated_email_configuration(env)
- deprecated_email_conf = File.join(Rails.root, 'config', 'email.yml')
+ deprecated_email_conf = ENV['RAILS_ETC'] ? File.join(ENV['RAILS_ETC'], 'email.yml') : File.join(Rails.root, 'config', 'email.yml')
if File.file?(deprecated_email_conf)
warn "Storing outgoing emails configuration in config/email.yml is deprecated. You should now store it in config/configuration.yml using the email_delivery setting."
@config.merge!({'email_delivery' => load_from_yaml(deprecated_email_conf, env)})
--- redmine.orig/lib/redmine/export/pdf.rb
+++ redmine/lib/redmine/export/pdf.rb
@@ -38,7 +38,7 @@ module Redmine
attr_accessor :footer_date
def initialize(lang, orientation='P')
- @@k_path_cache = Rails.root.join('tmp', 'pdf')
+ @@k_path_cache = ENV['RAILS_TMP'] ? File.join(ENV['RAILS_TMP'], 'pdf') : Rails.root.join('tmp', 'pdf')
FileUtils.mkdir_p @@k_path_cache unless File::exist?(@@k_path_cache)
set_language_if_valid lang
pdf_encoding = l(:general_pdf_encoding).upcase
--- redmine.orig/config/application.rb
+++ redmine/config/application.rb
@@ -52,8 +63,21 @@ module RedmineApp
# Do not include all helpers
config.action_controller.include_all_helpers = false
+ # move tmp directory to RAILS_TMP
+ config.paths['tmp'] = ENV['RAILS_TMP']
+
config.session_store :cookie_store, :key => '_redmine_session'
+ # log path
+ config.paths['log'] = File.join(ENV['RAILS_LOG'], "#{Rails.env}.log") unless !ENV['RAILS_LOG']
+
+ config.paths['public'] = ENV['RAILS_PUBLIC'] unless !ENV['RAILS_PUBLIC']
+
+ config.cache_store = :file_store, File.join(ENV['RAILS_TMP'], "cache")
+
+ # Set Active Record's database.yml path
+ config.paths['config/database'] = File.join(ENV['RAILS_ETC'], 'database.yml') unless !ENV['RAILS_ETC']
+
if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
instance_eval File.read(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
end
--- redmine.orig/lib/plugins/rfpdf/lib/tcpdf.rb
+++ redmine/lib/plugins/rfpdf/lib/tcpdf.rb
@@ -89,10 +89,10 @@ class TCPDF
@@k_small_ratio = 2/3.0
cattr_accessor :k_path_cache
- @@k_path_cache = Rails.root.join('tmp')
+ @@k_path_cache = ENV['RAILS_TMP'] ? ENV['RAILS_TMP'] : Rails.root.join('tmp')
cattr_accessor :k_path_url_cache
- @@k_path_url_cache = Rails.root.join('tmp')
+ @@k_path_url_cache = ENV['RAILS_TMP'] ? ENV['RAILS_TMP'] : Rails.root.join('tmp')
attr_accessor :barcode
--- redmine.orig/lib/redmine/scm/adapters/abstract_adapter.rb
+++ redmine/lib/redmine/scm/adapters/abstract_adapter.rb
@@ -222,7 +222,7 @@ module Redmine
if @stderr_log_file.nil?
writable = false
path = Redmine::Configuration['scm_stderr_log_file'].presence
- path ||= Rails.root.join("log/#{Rails.env}.scm.stderr.log").to_s
+ path ||= ENV['RAILS_LOG'] ? File.join(ENV['RAILS_LOG'], "#{Rails.env}.scm.stderr.log").to_s : Rails.root.join("log/#{Rails.env}.scm.stderr.log").to_s
if File.exists?(path)
if File.file?(path) && File.writable?(path)
writable = true