Class: Pandler::Yumrepo

Inherits:
Object
  • Object
show all
Defined in:
lib/pandler/yumrepo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Yumrepo

Returns a new instance of Yumrepo.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/pandler/yumrepo.rb', line 19

def initialize(args = {})
  @base_dir      = args[:base_dir]      || File.expand_path("pandler")
  @repo_dir      = args[:repo_dir]      || File.join(base_dir, "yumrepo")
  @yumfile_path  = args[:yumfile_path]  || File.expand_path("Yumfile")
  @lockfile_path = args[:lockfile_path] || yumfile_path + ".lock"

  @cache_dir     = File.join(base_dir, "yumcache")
  @yum_log       = File.join(@cache_dir, "/var/lib/yum/pandler.log")
  FileUtils.mkdir_p base_dir
  FileUtils.mkdir_p repo_dir
  FileUtils.mkdir_p @cache_dir

  @yumfile   = Pandler::Yumfile.new(yumfile_path)
  @lockfile  = read_lockfile
end

Instance Attribute Details

#base_dirObject (readonly)

Returns the value of attribute base_dir.



18
19
20
# File 'lib/pandler/yumrepo.rb', line 18

def base_dir
  @base_dir
end

#lockfile_pathObject (readonly)

Returns the value of attribute lockfile_path.



18
19
20
# File 'lib/pandler/yumrepo.rb', line 18

def lockfile_path
  @lockfile_path
end

#repo_dirObject (readonly)

Returns the value of attribute repo_dir.



18
19
20
# File 'lib/pandler/yumrepo.rb', line 18

def repo_dir
  @repo_dir
end

#yumfile_pathObject (readonly)

Returns the value of attribute yumfile_path.



18
19
20
# File 'lib/pandler/yumrepo.rb', line 18

def yumfile_path
  @yumfile_path
end

Instance Method Details

#createrepoObject



35
36
37
38
39
40
41
42
# File 'lib/pandler/yumrepo.rb', line 35

def createrepo
  setup_dirs
  setup_files
  yum_download
  write_lockfile
  symlink_pkgs
  run_cmd("createrepo", "-v", repo_dir)
end

#install_pkgsObject



44
45
46
# File 'lib/pandler/yumrepo.rb', line 44

def install_pkgs
  specs.sort_by { |package, spec| spec["name"] }.map { |package, spec| package }
end

#specsObject



48
49
50
# File 'lib/pandler/yumrepo.rb', line 48

def specs
  @specs
end