class Proxy::Omaha::Release
Attributes
architecture[RW]
digests[W]
distribution[RW]
track[RW]
version[RW]
Public Class Methods
new(options)
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 14 def initialize(options) @distribution = options.fetch(:distribution) @track = options.fetch(:track).to_s @architecture = options.fetch(:architecture) @version = Gem::Version.new(options.fetch(:version)) end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 67 def <=>(other) return unless self.class === other version.<=>(other.version) end
==(other)
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 72 def ==(other) self.class === other && track == other.track && version == other.version && architecture == other.architecture end
base_path()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 21 def base_path @base_path ||= File.join(Proxy::Omaha::Plugin.settings.contentpath, track, architecture) end
complete?()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 158 def complete? missing_files.empty? end
create()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 48 def create logger.debug "Creating #{track} #{version} #{architecture}" 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 92 def create_metadata metadata_provider.store(Metadata.new( :track => track, :release => version.to_s, :architecture => architecture, :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 106 def create_path FileUtils.mkdir_p(path) true rescue false end
current?()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 56 def current? return false unless File.symlink?(current_path) File.readlink(current_path) == path end
current_path()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 29 def current_path @current_path ||= File.join(base_path, 'current') end
digest_files()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 154 def digest_files Dir.glob(File.join(path, '*.DIGESTS')).map { |file| File.basename(file) } end
digests()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 174 def digests @digests ||= load_digests! end
download()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 80 def download sources.map do |url| file = URI.parse(url).path.split('/').last next if file_exists?(file) dst = File.join(path, file) logger.debug "Downloading file #{url} to #{dst}" task = ::Proxy::Omaha::HttpDownload.new(url, dst) task.start task end.compact.each(&:join).map(&:result).all? end
existing_files()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 146 def existing_files Dir.glob(File.join(path, '*')).map { |file| File.basename(file) } end
exists?()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 37 def exists? File.directory?(path) end
expected_files()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 142 def expected_files sources.map { |source| File.basename(source) } end
file_exists?(file)
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 162 def file_exists?(file) File.file?(File.join(path, file)) end
file_urls(base_url)
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 207 def file_urls(base_url) existing_files.map do |file| [base_url, 'omahareleases', track, architecture, self, file].join('/') end end
load_digests!()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 178 def load_digests! self.digests = {} digest_files.each do |digest_file| file = File.basename(digest_file, '.DIGESTS') File.readlines(File.join(path, digest_file)).each do |line| next unless line =~ /^\w+[ ]+\S+$/ hexdigest = line.split(/[ ]+/).first self.digests[file] ||= [] self.digests[file] << hexdigest end end self.digests end
mark_as_current!()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 61 def mark_as_current! return true if current? File.unlink(current_path) if File.symlink?(current_path) FileUtils.ln_s(path, current_path) end
metadata()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 33 def metadata metadata_provider.get(track, release, architecture) end
missing_files()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 150 def missing_files expected_files - existing_files end
path()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 25 def path @path ||= File.join(base_path, version.to_s) end
purge()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 166 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 121 def sources upstream = distribution.upstream(track, architecture, version) update_upstream = distribution.update_upstream(architecture, version) prefix = distribution.prefix [ "#{upstream}/#{prefix}_production_pxe.vmlinuz", "#{upstream}/#{prefix}_production_pxe.DIGESTS", "#{upstream}/#{prefix}_production_image.bin.bz2", "#{upstream}/#{prefix}_production_image.bin.bz2.sig", "#{upstream}/#{prefix}_production_image.bin.bz2.DIGESTS", "#{upstream}/#{prefix}_production_pxe_image.cpio.gz", "#{upstream}/#{prefix}_production_pxe_image.cpio.gz.DIGESTS", "#{upstream}/#{prefix}_production_vmware_raw_image.bin.bz2", "#{upstream}/#{prefix}_production_vmware_raw_image.bin.bz2.sig", "#{upstream}/#{prefix}_production_vmware_raw_image.bin.bz2.DIGESTS", "#{upstream}/version.txt", "#{upstream}/version.txt.DIGESTS", "#{update_upstream}/#{update_filename}" ] end
to_h()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 192 def to_h { :name => to_s, :current => current?, :architecture => architecture, :track => track, :complete => complete?, :files => existing_files } end
to_json()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 203 def to_json to_h.to_json end
to_s()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 76 def to_s version.to_s end
update_filename()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 113 def update_filename distribution.update_filename end
updatefile()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 117 def updatefile File.join(path, update_filename) end
valid?()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 41 def valid? existing_files.select { |file| file !~ /\.(DIGESTS|sig)$/ }.map do |file| next unless digests[file] digests[file].include?(Digest::MD5.file(File.join(path, file)).hexdigest) end.compact.all? end
Private Instance Methods
metadata_provider()
click to toggle source
# File lib/smart_proxy_omaha/release.rb, line 215 def metadata_provider MetadataProvider.new( :contentpath => Proxy::Omaha::Plugin.settings.contentpath ) end