From c625913afb9d89e0c1b1046f01b823a01fac6394 Mon Sep 17 00:00:00 2001 From: alexeypetrushin Date: Sat, 12 Feb 2011 13:49:12 +0300 Subject: [PATCH] small updates --- lib/vos/box/marks.rb | 29 +++++++++++++---------------- lib/vos/drivers/ssh.rb | 1 - lib/vos/helpers/ubuntu.rb | 16 +++++++++++----- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/lib/vos/box/marks.rb b/lib/vos/box/marks.rb index b8ce90b..6b64197 100644 --- a/lib/vos/box/marks.rb +++ b/lib/vos/box/marks.rb @@ -1,30 +1,27 @@ module Vos class Box module Marks - def mark key - ensure_mark_requrements! - file("#{marks_dir}/#{key}").create! + def mark key + marks_dir.file(key).create + marks_cache.clear end def has_mark? key - ensure_mark_requrements! - entry["#{marks_dir}/#{key}"].exist? + marks_cache.include? key.to_s end def clear_marks - bash "rm -r #{marks_dir}" + marks_dir.destroy + marks_cache.clear end - + + def marks_dir + dir "/etc/vos/marks" + end + protected - def marks_dir - home "/.marks" - end - - def ensure_mark_requrements! - unless @ensure_mark_requrements - self.dir(marks_dir).create - @ensure_mark_requrements = true - end + def marks_cache + @marks_cache ||= marks_dir.files.collect{|file| file.name} end end end diff --git a/lib/vos/drivers/ssh.rb b/lib/vos/drivers/ssh.rb index 1461a1b..41a365d 100644 --- a/lib/vos/drivers/ssh.rb +++ b/lib/vos/drivers/ssh.rb @@ -128,7 +128,6 @@ def hacked_exec!(ssh, command, merge_stdout_and_stderr = false, &block) end channel.wait - [stdout_data, stderr_data, exit_code, exit_signal] end end diff --git a/lib/vos/helpers/ubuntu.rb b/lib/vos/helpers/ubuntu.rb index cc9f589..bd74675 100644 --- a/lib/vos/helpers/ubuntu.rb +++ b/lib/vos/helpers/ubuntu.rb @@ -5,7 +5,7 @@ def default_env {:DEBIAN_FRONTEND => 'noninteractive'} end def wrap_cmd env_str, cmd - %(. #{env_file.path} && #{env_str}#{' && ' unless env_str.empty?}#{cmd}) + %(source #{env_file.path} && #{env_str}#{' && ' unless env_str.empty?}#{cmd}) end def env_file @@ -36,12 +36,18 @@ def reload_env module Vfs class File def append_to_environment_of box, reload = true - raise "#{box} must be an Vos::Box" unless file.is_a? Vos::Box + raise "#{box} must be an Vos::Box" unless box.is_a? Vos::Box - copy_to! box.dir('/etc/profile_ext').file(name) + remote_file = box.dir('/etc/profile_ext').file(name) + copy_to! remote_file - require_clause = "source #{remote_file.path}" - box.env_file.append "\n#{require_clause}\n" unless env_file.content.include? require_clause + require_clause = <<-BASH + +# #{name} +source #{remote_file.path} + BASH + + box.env_file.append require_clause unless box.env_file.content.include? require_clause box.reload_env if reload end