Module: Apt::Ubuntu
- Defined in:
- lib/repo_conf_generators/apt_conf_generators.rb
Constant Summary collapse
- SUPPORTED_REPOS =
['hardy', 'intrepid', 'jaunty', 'karmic', 'lucid', 'maverick', 'precise', 'quantal']
Class Method Summary collapse
-
.abstract_generate(params) ⇒ Object
INTERNAL FUNCTIONS #######################################################.
- .path_to_sources_list ⇒ Object
Class Method Details
.abstract_generate(params) ⇒ Object
INTERNAL FUNCTIONS #######################################################
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/repo_conf_generators/apt_conf_generators.rb', line 54 def self.abstract_generate(params) return unless ::RightScale::Platform.linux? && ::RightScale::Platform.ubuntu? opts = { :enabled => true, :frozen_date => "latest"} opts.merge!(params) raise ArgumentError.new("missing parameters to generate file!") unless opts[:repo_filename] && opts[:repo_name] && opts[:base_urls] && opts[:frozen_date] && opts[:enabled] return unless opts[:enabled] target = opts[:codename].downcase codename = ::RightScale::Platform.codename.downcase raise ::RightScale::Exceptions::PlatformError, "Unsupported Ubuntu release #{codename}" unless SUPPORTED_REPOS.include?(codename) raise ::RightScale::Exceptions::PlatformError, "Wrong release; repo is for #{target}, we are #{codename}" unless target == codename FileUtils.mkdir_p(Apt::Ubuntu::path_to_sources_list) if opts[:frozen_date] != 'latest' x = Date.parse(opts[:frozen_date]).to_s x.gsub!(/-/,"/") opts[:frozen_date] = x end mirror_list = opts[:base_urls].map do |bu| bu +='/' unless bu[-1..-1] == '/' # ensure the base url is terminated with a '/' bu + opts[:frozen_date] end config_body = "" mirror_list.each do |mirror_url| config_body += "deb \#{mirror_url} \#{codename} main restricted multiverse universe\ndeb \#{mirror_url} \#{codename}-updates main restricted multiverse universe\ndeb \#{mirror_url} \#{codename}-security main restricted multiverse universe\n\n" end target_filename = "#{Apt::Ubuntu::path_to_sources_list}/#{opts[:repo_filename]}.sources.list" FileUtils.rm_f(target_filename) if File.exists?(target_filename) File.open(target_filename,'w') { |f| f.write(config_body) } FileUtils.mv("/etc/apt/sources.list", "/etc/apt/sources.list.ORIG") if File.exists?("/etc/apt/sources.list") mirror_list end |
.path_to_sources_list ⇒ Object
49 50 51 |
# File 'lib/repo_conf_generators/apt_conf_generators.rb', line 49 def self.path_to_sources_list "/etc/apt/sources.list.d" end |