class Chef::Resource::AptUpdate

Constants

APT_CONF_DIR
STAMP_DIR

Public Instance Methods

apt_up_to_date?() click to toggle source

Determines whether we need to run `apt-get update`

@return [Boolean]

# File lib/chef/resource/apt_update.rb, line 65
def apt_up_to_date?
  ::File.exist?("#{STAMP_DIR}/update-success-stamp") &&
    ::File.mtime("#{STAMP_DIR}/update-success-stamp") > Time.now - new_resource.frequency
end
do_update() click to toggle source
# File lib/chef/resource/apt_update.rb, line 70
def do_update
  [STAMP_DIR, APT_CONF_DIR].each do |d|
    directory d do
      recursive true
    end
  end

  file "#{APT_CONF_DIR}/15update-stamp" do
    content "APT::Update::Post-Invoke-Success {\"touch #{STAMP_DIR}/update-success-stamp 2>/dev/null || true\";};\n"
    action :create_if_missing
  end

  execute "apt-get -q update" do
    command [ "apt-get", "-q", "update" ]
    default_env true
  end
end