Class: Pandler::Chroot
- Inherits:
-
Object
- Object
- Pandler::Chroot
- Defined in:
- lib/pandler/chroot.rb
Instance Attribute Summary collapse
-
#base_dir ⇒ Object
readonly
Returns the value of attribute base_dir.
-
#mounts ⇒ Object
readonly
Returns the value of attribute mounts.
-
#root_dir ⇒ Object
readonly
Returns the value of attribute root_dir.
-
#yumrepo ⇒ Object
readonly
Returns the value of attribute yumrepo.
Instance Method Summary collapse
- #clean ⇒ Object
- #execute(*cmd) ⇒ Object
- #init ⇒ Object
-
#initialize(args = {}) ⇒ Chroot
constructor
A new instance of Chroot.
- #install(*pkgs) ⇒ Object
- #installed_pkgs ⇒ Object
- #list ⇒ Object
- #real_path(path) ⇒ Object
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.("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_dir ⇒ Object (readonly)
Returns the value of attribute base_dir.
5 6 7 |
# File 'lib/pandler/chroot.rb', line 5 def base_dir @base_dir end |
#mounts ⇒ Object (readonly)
Returns the value of attribute mounts.
5 6 7 |
# File 'lib/pandler/chroot.rb', line 5 def mounts @mounts end |
#root_dir ⇒ Object (readonly)
Returns the value of attribute root_dir.
5 6 7 |
# File 'lib/pandler/chroot.rb', line 5 def root_dir @root_dir end |
#yumrepo ⇒ Object (readonly)
Returns the value of attribute yumrepo.
5 6 7 |
# File 'lib/pandler/chroot.rb', line 5 def yumrepo @yumrepo end |
Instance Method Details
#clean ⇒ Object
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 |
#init ⇒ Object
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_pkgs ⇒ Object
38 39 40 |
# File 'lib/pandler/chroot.rb', line 38 def installed_pkgs rpm_qa end |
#list ⇒ Object
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 |