Class: Dr::BuildRoot
Instance Method Summary collapse
-
#initialize(env, arch, br_cache) ⇒ BuildRoot
constructor
A new instance of BuildRoot.
- #open ⇒ Object
Methods included from Logger
#log, log, set_logfile, set_verbosity, #tag
Constructor Details
#initialize(env, arch, br_cache) ⇒ BuildRoot
Returns a new instance of BuildRoot.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/dr/buildroot.rb', line 14 def initialize(env, arch, br_cache) @arch = arch if arch == "all" unless Dr::config.build_environments.has_key? env log :err, "Unkown build environment: #{env.to_s.fg "red"}" raise "Build environment not recognised" end @arch = Dr::config.build_environments[env][:arches][0] end @location = "#{br_cache}/#{env.to_s}-#{@arch}.tar.gz" @env = env @essential_pkgs = "sudo,vim,ca-certificates,fakeroot,build-essential," + "curl,devscripts,debhelper,git,bc,locales,equivs," + "pkg-config,libfile-fcntllock-perl" unless File.exists?(@location) setup @env, @arch end end |
Instance Method Details
#open ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/dr/buildroot.rb', line 36 def open Dir.mktmpdir do |tmp| log :info, "Preparing #{@env.to_s.fg "blue"} #{@arch.fg "orange"} build root" ShellCmd.new "sudo tar xz -C #{tmp} -f #{@location}", :tag => "tar" begin log :info, "Mounting the /proc file system" mnt_cmd = "sudo chroot #{tmp} mount -t proc none /proc" ShellCmd.new mnt_cmd, :tag => "mount" yield tmp ensure log :info, "Unmounting the /proc file system" umnt_cmd = "sudo chroot #{tmp} umount -f /proc" ShellCmd.new umnt_cmd, :tag => "umount" log :info, "Cleaning up the buildroot" ShellCmd.new "sudo rm -rf #{tmp}/*", :tag => "rm" end end end |