class PackerFiles::Ubuntu::CD
Public Instance Methods
get_check_sum_pattern()
click to toggle source
Override method for getting checksums
# File lib/PackerFiles/OS/Ubuntu/CD.rb, line 21 def get_check_sum_pattern 'MD5SUMS' end
get_check_sum_type()
click to toggle source
Override method for checksum type
# File lib/PackerFiles/OS/Ubuntu/CD.rb, line 26 def get_check_sum_type 'md5' end
get_iso_name_pattern()
click to toggle source
Override method for getting the ISO name
# File lib/PackerFiles/OS/Ubuntu/CD.rb, line 16 def get_iso_name_pattern 'ubuntu-@release@-server-@arch@.iso' end
index_urls()
click to toggle source
Override method for getting index URLs. The Master index URLs are always checked first.
# File lib/PackerFiles/OS/Ubuntu/CD.rb, line 32 def index_urls master_index_urls + mirror_index_urls end
Private Instance Methods
master_index_urls()
click to toggle source
mirror_index_urls()
click to toggle source
The Index URLs from other Ubuntu
CD
mirrors. The CD
Mirrors
only support CD
images and not DVD Images.
# File lib/PackerFiles/OS/Ubuntu/CD.rb, line 47 def mirror_index_urls # Use nokogiri to parse the index page, to get all the URLs that contain # country name [as detected by AutoZone]. Unfortunately this code can only # be understood if HTML structure is visually inspected first. page = Nokogiri::HTML(open(@@index)) country = Utils::AutoZone.new.JSON['country'] # Get a list of nodes that match the country name (it is usually just one) nodes = page.css('tr.head').select {|n| n.text.include?(country)} return [] if nodes.empty? # Looking at the inner text yields the count of mirrors this country has. # That value is at array index 5, which maps to index value 4 (from zero) count = nodes.first.text.split("\n")[4].to_i # Now we have to walk through next siblings of nodes.first "n" times to # get all the mirror URLs mirrors = [] node = nodes.first count.times do |i| node = node.next_element urls = node.css('a').map { |aref| aref['href'] if !aref['href'].start_with?('/') } mirrors << urls end # Compact mirrors to remove nil values and add standard prefixes. mirrors.flatten.compact.map {|m| URI::join(m, '@release@/').to_s } end