Class: Gonzui::DebAptGet

Inherits:
AbstractAptGet show all
Defined in:
lib/gonzui/apt.rb

Instance Attribute Summary

Attributes included from TemporaryDirectoryUtil

#temporary_directory

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractAptGet

#add_cleaning_proc, #clean, #extract, #initialize, #run_apt_get

Methods included from TemporaryDirectoryUtil

#clean_temporary_directory, #prepare_temporary_directory, #set_temporary_directory

Methods included from Util

assert, assert_equal, assert_equal_all, assert_non_nil, assert_not_reached, benchmark, command_exist?, commify, eprintf, format_bytes, program_name, protect_from_signals, require_command, set_verbosity, shell_escape, unix?, vprintf, windows?, wprintf

Constructor Details

This class inherits a constructor from Gonzui::AbstractAptGet

Class Method Details

.apt_typeObject



102
103
104
# File 'lib/gonzui/apt.rb', line 102

def self.apt_type
  :deb
end

Instance Method Details

#contains_single_tarball?(directory) ⇒ Boolean

Returns:

  • (Boolean)


133
134
135
136
137
138
# File 'lib/gonzui/apt.rb', line 133

def contains_single_tarball?(directory)
  entries = Dir.entries_without_dots(directory)
  entries.delete("debian")
  entries.delete("CVS") # some packages have it
  entries.length == 1 and Extractor.supported_file?(entries.first)
end

#extract_packageObject



140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/gonzui/apt.rb', line 140

def extract_package
  remove_deb_files
  source_directory = find_deb_source_directory
  if contains_single_tarball?(source_directory)
    archive_file_name = find_archive(source_directory)
    extractor = Extractor.new(@config, archive_file_name)
    add_cleaning_proc(lambda{ extractor.clean_temporary_directory })
    return extractor.extract
  else
    return source_directory
  end
end

#find_archive(directory) ⇒ Object



106
107
108
109
110
111
112
# File 'lib/gonzui/apt.rb', line 106

def find_archive(directory)
  Dir.entries_without_dots(directory).map {|entry|
    File.join(directory, entry)
  }.find {|file_name|
    Extractor.supported_file?(file_name)
  }
end

#find_deb_source_directoryObject

Raises:



114
115
116
117
118
119
120
121
122
123
124
# File 'lib/gonzui/apt.rb', line 114

def find_deb_source_directory
  entries  = Dir.entries_without_dots(self.temporary_directory)
  directory = entries.map {|entry|
    File.join(self.temporary_directory, entry)
  }.find {|path|
    File.directory?(path)
  }
  raise AptGetError.new("#{@package_name}: source directory not found") if
    directory.nil?
  return directory
end

#remove_deb_filesObject



126
127
128
129
130
131
# File 'lib/gonzui/apt.rb', line 126

def remove_deb_files
  Dir.entries(self.temporary_directory).each {|entry|
    file_name = File.join(self.temporary_directory, entry)
    File.unlink(file_name) if File.file?(file_name)
  }
end