Skip to content

Commit

Permalink
small updates
Browse files Browse the repository at this point in the history
  • Loading branch information
al6x committed Feb 12, 2011
1 parent 19529a4 commit c625913
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
29 changes: 13 additions & 16 deletions lib/vos/box/marks.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion lib/vos/drivers/ssh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 11 additions & 5 deletions lib/vos/helpers/ubuntu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c625913

Please sign in to comment.