Class: Pandler::Chroot

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Chroot

Returns a new instance of Chroot.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/pandler/chroot.rb', line 7

def initialize(args = {})
  @base_dir = args[:base_dir] || File.expand_path("pandler")
  @root_dir = args[:root_dir] || File.join(base_dir, "root")
  @yumrepo  = args[:yumrepo]  || "file://" + File.join(base_dir, "yumrepo")

  @mounts = [
     { :type => 'proc',   :path => '/proc' },
     { :type => 'sysfs',  :path => '/sys' },
     { :type => 'tmpfs',  :path => '/dev/shm' },
     { :type => 'devpts', :path => '/dev/pts',
                          :options => "gid=#{Etc.getgrnam("tty").gid},mode=0620,ptmxmode=0666,newinstance" },
  ]
end

Instance Attribute Details

#base_dirObject (readonly)

Returns the value of attribute base_dir.



5
6
7
# File 'lib/pandler/chroot.rb', line 5

def base_dir
  @base_dir
end

#mountsObject (readonly)

Returns the value of attribute mounts.



5
6
7
# File 'lib/pandler/chroot.rb', line 5

def mounts
  @mounts
end

#root_dirObject (readonly)

Returns the value of attribute root_dir.



5
6
7
# File 'lib/pandler/chroot.rb', line 5

def root_dir
  @root_dir
end

#yumrepoObject (readonly)

Returns the value of attribute yumrepo.



5
6
7
# File 'lib/pandler/chroot.rb', line 5

def yumrepo
  @yumrepo
end

Instance Method Details

#cleanObject



46
47
48
49
# File 'lib/pandler/chroot.rb', line 46

def clean
  umount_all
  FileUtils.remove_entry_secure root_dir
end

#execute(*cmd) ⇒ Object



42
43
44
# File 'lib/pandler/chroot.rb', line 42

def execute(*cmd)
  chroot_run_cmd(*cmd)
end

#initObject



25
26
27
28
29
30
31
# File 'lib/pandler/chroot.rb', line 25

def init
  setup_dirs
  setup_files
  setup_devs
  mount_all
  true
end

#install(*pkgs) ⇒ Object



33
34
35
36
# File 'lib/pandler/chroot.rb', line 33

def install(*pkgs)
  yum_install(*pkgs)
  rpm_erase_exclude(*pkgs)
end

#installed_pkgsObject



38
39
40
# File 'lib/pandler/chroot.rb', line 38

def installed_pkgs
  rpm_qa
end

#listObject



51
52
53
# File 'lib/pandler/chroot.rb', line 51

def list
  rpm_qa
end

#real_path(path) ⇒ Object



21
22
23
# File 'lib/pandler/chroot.rb', line 21

def real_path(path)
  File.join(root_dir, path)
end