OSDN Git Service

Import apt version 2.0.0
[metasearch/grid-chef-repo.git] / cookbooks / apt / recipes / default.rb
1 #
2 # Cookbook Name:: apt
3 # Recipe:: default
4 #
5 # Copyright 2008-2011, Opscode, Inc.
6 # Copyright 2009, Bryan McLellan <btm@loftninjas.org>
7 #
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 #     http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 #
20
21 # Run apt-get update to create the stamp file
22 execute "apt-get-update" do
23   command "apt-get update"
24   ignore_failure true
25   not_if do ::File.exists?('/var/lib/apt/periodic/update-success-stamp') end
26 end
27
28 # For other recipes to call to force an update
29 execute "apt-get update" do
30   command "apt-get update"
31   ignore_failure true
32   action :nothing
33 end
34
35 # Automatically remove packages that are no longer needed for dependencies
36 execute "apt-get autoremove" do
37   command "apt-get -y autoremove"
38   action :nothing
39 end
40
41 # Automatically remove .deb files for packages no longer on your system
42 execute "apt-get autoclean" do
43   command "apt-get -y autoclean"
44   action :nothing
45 end
46
47 # provides /var/lib/apt/periodic/update-success-stamp on apt-get update
48 package "update-notifier-common" do
49   notifies :run, 'execute[apt-get-update]', :immediately
50 end
51
52 execute "apt-get-update-periodic" do
53   command "apt-get update"
54   ignore_failure true
55   only_if do
56     ::File.exists?('/var/lib/apt/periodic/update-success-stamp') &&
57     ::File.mtime('/var/lib/apt/periodic/update-success-stamp') < Time.now - 86400
58   end
59 end
60
61 %w{/var/cache/local /var/cache/local/preseeding}.each do |dirname|
62   directory dirname do
63     owner "root"
64     group "root"
65     mode  00755
66     action :create
67   end
68 end