Module: Apt::RightScale
- Defined in:
- lib/repo_conf_generators/rightscale_conf_generators.rb
Constant Summary collapse
- SUPPORTED_REPOS =
['lucid', 'precise']
Class Method Summary collapse
-
.abstract_generate(params) ⇒ Object
INTERNAL FUNCTIONS #######################################################.
- .path_to_sources_list ⇒ Object
- .rightscale_gpgkey_imported? ⇒ Boolean
Class Method Details
.abstract_generate(params) ⇒ Object
INTERNAL FUNCTIONS #######################################################
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/repo_conf_generators/rightscale_conf_generators.rb', line 196 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::RightScale::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 += <<END deb #{mirror_url} #{codename} main END end target_filename = "#{Apt::RightScale::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") unless Apt::RightScale::rightscale_gpgkey_imported? gpgfile = File.("../rightscale_key.pub", __FILE__) Apt::execute("apt-key add #{gpgfile}") end mirror_list end |
.path_to_sources_list ⇒ Object
182 183 184 |
# File 'lib/repo_conf_generators/rightscale_conf_generators.rb', line 182 def self.path_to_sources_list "/etc/apt/sources.list.d" end |