def self.locate_directories(source_root_or_location_configuration_file = nil)
source_root_or_location_configuration_file ||= find_location_configuration_file
root_or_file = @source_root = source_root_or_location_configuration_file
if root_or_file && File.file?(root_or_file)
filename = root_or_file
options = parse_ini_file(filename)
@natively_packaged = get_bool_option(filename, options, 'natively_packaged')
REQUIRED_LOCATIONS_INI_FIELDS.each do |field|
value = get_option(filename, options, field.to_s)
value.freeze unless value.nil?
instance_variable_set("@#{field}", value)
end
OPTIONAL_LOCATIONS_INI_FIELDS.each do |field|
value = get_option(filename, options, field.to_s, false)
value.freeze unless value.nil?
instance_variable_set("@#{field}", value)
end
if natively_packaged?
@native_packaging_method = get_option(filename, options, 'native_packaging_method')
ORIGINALLY_PACKAGED_LOCATIONS_INI_FIELDS.each do |field|
instance_variable_set("@#{field}", nil)
end
end
else
@source_root = File.dirname(File.dirname(FILE_LOCATION))
@natively_packaged = false
@bin_dir = "#{@source_root}/bin".freeze
@agents_dir = "#{@source_root}/buildout/agents".freeze
@lib_dir = "#{@source_root}/buildout".freeze
@helper_scripts_dir = "#{@source_root}/helper-scripts".freeze
@resources_dir = "#{@source_root}/resources".freeze
@include_dir = "#{@source_root}/ext".freeze
@doc_dir = "#{@source_root}/doc".freeze
@ruby_libdir = File.dirname(FILE_LOCATION).freeze
@node_libdir = "#{@source_root}/node_lib".freeze
@apache2_module_path = "#{@source_root}/buildout/apache2/mod_passenger.so".freeze
@ruby_extension_source_dir = "#{@source_root}/ext/ruby".freeze
@nginx_module_source_dir = "#{@source_root}/ext/nginx".freeze
@download_cache_dir = "#{@source_root}/download_cache".freeze
@build_system_dir = @source_root.dup.freeze
@buildout_dir = "#{@source_root}/buildout".freeze
@apache2_module_source_dir = @source_root.dup.freeze
REQUIRED_LOCATIONS_INI_FIELDS.each do |field|
if instance_variable_get("@#{field}").nil?
raise "BUG: @#{field} not set"
end
end
end
end