class Proxy::Omaha::Release
Attributes
track[RW]
version[RW]
Public Class Methods
new(options)
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 11 def initialize(options) @track = options.fetch(:track).to_s @version = Gem::Version.new(options.fetch(:version)) end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 40 def <=>(other) return unless self.class === other version.<=>(other.version) end
==(other)
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 45 def ==(other) self.class === other && track == other.track && version == other.version end
create()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 32 def create logger.debug "Creating #{track} #{version}" return false unless create_path return false unless download return false unless create_metadata true end
create_metadata()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 64 def create_metadata metadata_provider.store(Metadata.new( :track => track, :release => version.to_s, :size => File.size(updatefile), :sha1_b64 => Digest::SHA1.file(updatefile).base64digest, :sha256_b64 => Digest::SHA256.file(updatefile).base64digest, )) true rescue false end
create_path()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 77 def create_path FileUtils.mkdir_p(path) true rescue false end
download()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 53 def download sources.map do |url| file = URI.parse(url).path.split('/').last dst = File.join(path, file) logger.debug "Downloading file #{url} to #{dst}" task = ::Proxy::Omaha::HttpDownload.new(url, dst) task.start task end.each(&:join).map(&:result).all? end
exists?()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 24 def exists? File.directory?(path) end
expected_files()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 97 def expected_files sources.map { |source| File.basename(source) } end
expected_files_exist?()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 101 def expected_files_exist? expected_files.map {|file| File.file?(File.join(path, file)) }.all? end
metadata()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 20 def metadata metadata_provider.get(track, release) end
path()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 16 def path @path ||= File.join(Proxy::Omaha::Plugin.settings.contentpath, track, version.to_s) end
purge()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 105 def purge FileUtils.rm(Dir.glob(File.join(path, '*')), :force => true) FileUtils.remove_dir(path) true rescue false end
sources()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 88 def sources upstream = "https://#{track}.release.core-os.net/amd64-usr/#{version}" [ "#{upstream}/coreos_production_pxe.vmlinuz", "#{upstream}/coreos_production_pxe_image.cpio.gz", "https://update.release.core-os.net/amd64-usr/#{version}/update.gz" ] end
to_s()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 49 def to_s version.to_s end
updatefile()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 84 def updatefile File.join(path, 'update.gz') end
valid?()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 28 def valid? expected_files_exist? end
Private Instance Methods
metadata_provider()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 115 def metadata_provider MetadataProvider.new( :contentpath => Proxy::Omaha::Plugin.settings.contentpath ) end