[#120] support external downloads storage; remove links for hidden platforms
This commit is contained in:
parent
59d8f5e1dd
commit
632eeb8e5f
|
@ -78,9 +78,8 @@ module BuildListsHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def container_url(full_path = true, build_list = @build_list)
|
def container_url(full_path = true, build_list = @build_list)
|
||||||
p = ''
|
p = full_path ? APP_CONFIG['downloads_url'].dup : "http://#{request.host_with_port}/downloads"
|
||||||
p << "http://#{request.host_with_port}" if full_path
|
p << "/#{build_list.save_to_platform.name}/container/#{build_list.id}"
|
||||||
p << "/downloads/#{build_list.save_to_platform.name}/container/#{build_list.id}"
|
|
||||||
p << "/#{build_list.arch.name}/#{build_list.save_to_repository.name}/release" if full_path && build_list.build_for_platform.distrib_type == 'mdv'
|
p << "/#{build_list.arch.name}/#{build_list.save_to_repository.name}/release" if full_path && build_list.build_for_platform.distrib_type == 'mdv'
|
||||||
p.html_safe
|
p.html_safe
|
||||||
end
|
end
|
||||||
|
|
|
@ -412,10 +412,10 @@ class BuildList < ActiveRecord::Base
|
||||||
repos |= ['146'] if build_for_platform_id == 376
|
repos |= ['146'] if build_for_platform_id == 376
|
||||||
include_repos_hash = {}.tap do |h|
|
include_repos_hash = {}.tap do |h|
|
||||||
Repository.where(:id => (repos | (extra_repositories || [])) ).each do |repo|
|
Repository.where(:id => (repos | (extra_repositories || [])) ).each do |repo|
|
||||||
path = repo.platform.public_downloads_url(nil, arch.name, repo.name)
|
path = repo.platform.public_downloads_url(arch.name, repo.name)
|
||||||
# path.gsub!(/^http:\/\/(0\.0\.0\.0|localhost)\:[\d]+/, 'https://abf.rosalinux.ru') unless Rails.env.production?
|
# path.gsub!(/^http:\/\/(0\.0\.0\.0|localhost)\:[\d]+/, 'https://abf.rosalinux.ru') unless Rails.env.production?
|
||||||
# Path looks like:
|
# Path looks like:
|
||||||
# http://abf.rosalinux.ru/downloads/rosa-server2012/repository/x86_64/base/
|
# http://abf-downloads.rosalinux.ru/downloads/rosa-server2012/repository/x86_64/base/
|
||||||
# so, we should append:
|
# so, we should append:
|
||||||
# - release
|
# - release
|
||||||
# - updates
|
# - updates
|
||||||
|
@ -425,7 +425,7 @@ class BuildList < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
host = EventLog.current_controller.request.host_with_port rescue ::Rosa::Application.config.action_mailer.default_url_options[:host]
|
host = EventLog.current_controller.request.host_with_port rescue ::Rosa::Application.config.action_mailer.default_url_options[:host]
|
||||||
BuildList.where(:id => extra_build_lists).each do |bl|
|
BuildList.where(:id => extra_build_lists).each do |bl|
|
||||||
path = "http://#{host}/downloads/#{bl.save_to_platform.name}/container/"
|
path = "#{APP_CONFIG['downloads_url']}/#{bl.save_to_platform.name}/container/"
|
||||||
path << "#{bl.id}/#{bl.arch.name}/#{bl.save_to_repository.name}/release"
|
path << "#{bl.id}/#{bl.arch.name}/#{bl.save_to_repository.name}/release"
|
||||||
include_repos_hash["container_#{bl.id}"] = path
|
include_repos_hash["container_#{bl.id}"] = path
|
||||||
end
|
end
|
||||||
|
|
|
@ -57,20 +57,17 @@ class Platform < ActiveRecord::Base
|
||||||
|
|
||||||
def urpmi_list(host = nil, pair = nil, add_commands = true, repository_name = 'main')
|
def urpmi_list(host = nil, pair = nil, add_commands = true, repository_name = 'main')
|
||||||
host ||= default_host
|
host ||= default_host
|
||||||
blank_pair = {:login => 'login', :pass => 'password'}
|
|
||||||
pair = blank_pair if pair.blank?
|
|
||||||
urpmi_commands = ActiveSupport::OrderedHash.new
|
urpmi_commands = ActiveSupport::OrderedHash.new
|
||||||
|
|
||||||
# TODO: rename method or create separate methods for mdv and rhel
|
# TODO: rename method or create separate methods for mdv and rhel
|
||||||
# Platform.main.opened.where(:distrib_type => APP_CONFIG['distr_types'].first).each do |pl|
|
# Platform.main.opened.where(:distrib_type => APP_CONFIG['distr_types'].first).each do |pl|
|
||||||
Platform.main.opened.each do |pl|
|
Platform.main.opened.each do |pl|
|
||||||
urpmi_commands[pl.name] = {}
|
urpmi_commands[pl.name] = {}
|
||||||
local_pair = pl.id != self.id ? blank_pair : pair
|
# FIXME should support restricting access to the hidden platform
|
||||||
head = hidden? ? "http://#{local_pair[:login]}@#{local_pair[:pass]}:#{host}/private/" : "http://#{host}/downloads/"
|
|
||||||
Arch.all.each do |arch|
|
Arch.all.each do |arch|
|
||||||
tail = "/#{arch.name}/#{repository_name}/release"
|
tail = "/#{arch.name}/#{repository_name}/release"
|
||||||
command = add_commands ? "urpmi.addmedia #{name} " : ''
|
command = add_commands ? "urpmi.addmedia #{name} " : ''
|
||||||
command << "#{head}#{name}/repository/#{pl.name}#{tail}"
|
command << "#{APP_CONFIG['downloads_url']}#{name}/repository/#{pl.name}#{tail}"
|
||||||
urpmi_commands[pl.name][arch.name] = command
|
urpmi_commands[pl.name][arch.name] = command
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -94,21 +91,8 @@ class Platform < ActiveRecord::Base
|
||||||
Rails.root.join("public", "downloads", name)
|
Rails.root.join("public", "downloads", name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def prefix_url(pub, options = {})
|
def public_downloads_url(arch = nil, repo = nil, suffix = nil)
|
||||||
options[:host] ||= default_host
|
"#{APP_CONFIG['downloads_url']}/#{name}/repository/".tap do |url|
|
||||||
pub ? "http://#{options[:host]}/downloads" : "http://#{options[:login]}:#{options[:password]}@#{options[:host]}/private"
|
|
||||||
end
|
|
||||||
|
|
||||||
def public_downloads_url(host = nil, arch = nil, repo = nil, suffix = nil)
|
|
||||||
downloads_url prefix_url(true, :host => host), arch, repo, suffix
|
|
||||||
end
|
|
||||||
|
|
||||||
def private_downloads_url(login, password, host = nil, arch = nil, repo = nil, suffix = nil)
|
|
||||||
downloads_url prefix_url(false, :host => host, :login => login, :password => password), arch, repo, suffix
|
|
||||||
end
|
|
||||||
|
|
||||||
def downloads_url(prefix, arch = nil, repo = nil, suffix = nil)
|
|
||||||
"#{prefix}/#{name}/repository/".tap do |url|
|
|
||||||
url << "#{arch}/" if arch.present?
|
url << "#{arch}/" if arch.present?
|
||||||
url << "#{repo}/" if repo.present?
|
url << "#{repo}/" if repo.present?
|
||||||
url << "#{suffix}/" if suffix.present?
|
url << "#{suffix}/" if suffix.present?
|
||||||
|
|
|
@ -120,7 +120,7 @@ class ProductBuildList < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def container_path
|
def container_path
|
||||||
"/downloads/#{product.platform.name}/product/#{id}/"
|
"#{APP_CONFIG['downloads_url']}/#{product.platform.name}/product/#{id}/"
|
||||||
end
|
end
|
||||||
|
|
||||||
def event_log_message
|
def event_log_message
|
||||||
|
|
|
@ -21,7 +21,7 @@ common: &common
|
||||||
facebook:
|
facebook:
|
||||||
id: 'APP_ID'
|
id: 'APP_ID'
|
||||||
secret: 'APP_SECRET'
|
secret: 'APP_SECRET'
|
||||||
|
downloads_url: 'http://abf-downloads.rosalinux.ru/'
|
||||||
wiki_formats:
|
wiki_formats:
|
||||||
markdown: "Markdown"
|
markdown: "Markdown"
|
||||||
textile: "Textile"
|
textile: "Textile"
|
||||||
|
|
Loading…
Reference in New Issue