vagrant-apt_cache 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/Gemfile +2 -0
- data/LICENSE +22 -0
- data/README.md +30 -0
- data/Rakefile +2 -0
- data/lib/vagrant-apt_cache.rb +7 -0
- data/lib/vagrant-apt_cache/middleware.rb +36 -0
- data/lib/vagrant-apt_cache/register_shared_folder.rb +35 -0
- data/lib/vagrant-apt_cache/version.rb +5 -0
- data/lib/vagrant_init.rb +1 -0
- data/vagrant-apt_cache.gemspec +20 -0
- metadata +58 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Andrew Vit
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Vagrant apt-cache
|
2
|
+
|
3
|
+
Share a common package cache among all VM instances. This gem will share a directory from the host to the `/var/cache/apt` on guest VMs to avoid downloading already-downloaded packages when building VMs.
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'vagrant-apt_cache'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install vagrant-apt_cache
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
No configuration is currently provided. This gem is autoloaded by Vagrant.
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
|
26
|
+
1. Fork it
|
27
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
28
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
29
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
30
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module AptCache
|
3
|
+
|
4
|
+
class Middleware
|
5
|
+
def initialize(app, env, options={})
|
6
|
+
@app = app
|
7
|
+
@env = env
|
8
|
+
@options = options
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
@env = env
|
13
|
+
|
14
|
+
if is_apt_managed?
|
15
|
+
Vagrant::AptCache::RegisterSharedFolder.new(@env[:vm]).run
|
16
|
+
end
|
17
|
+
|
18
|
+
@app.call(env)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def guest
|
24
|
+
@env[:vm].guest
|
25
|
+
end
|
26
|
+
|
27
|
+
def is_apt_managed?
|
28
|
+
[
|
29
|
+
Vagrant::Guest::Debian,
|
30
|
+
Vagrant::Guest::Ubuntu
|
31
|
+
].any? { |deb_distro| guest.is_a? deb_distro }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module AptCache
|
3
|
+
|
4
|
+
class RegisterSharedFolder
|
5
|
+
def initialize(vm, options={})
|
6
|
+
@vm = vm
|
7
|
+
@options = options
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
config_vm.share_folder("v-apt-cache",
|
12
|
+
guest_apt_cache_dir, host_apt_cache_dir)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def config_vm
|
18
|
+
@vm.config.vm
|
19
|
+
end
|
20
|
+
|
21
|
+
def guest_apt_cache_dir
|
22
|
+
"/var/cache/apt/archives"
|
23
|
+
end
|
24
|
+
|
25
|
+
def host_apt_cache_dir
|
26
|
+
prefix = File.expand_path(Vagrant::Environment::DEFAULT_HOME)
|
27
|
+
cache_dir = File.join(prefix, 'cache', 'apt', @vm.box.name)
|
28
|
+
partial_dir = File.join(cache_dir, 'partial')
|
29
|
+
FileUtils.mkdir_p(partial_dir) unless File.exists? partial_dir
|
30
|
+
cache_dir
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
data/lib/vagrant_init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'vagrant-apt_cache'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/vagrant-apt_cache/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Andrew Vit"]
|
6
|
+
gem.email = ["andrew@avit.ca"]
|
7
|
+
gem.description = <<-DESC
|
8
|
+
Shares the /var/cache/apt/ folder for Ubuntu/Debian instances by storing
|
9
|
+
already-downloaded packages on the host.
|
10
|
+
DESC
|
11
|
+
gem.summary = %q{Share apt-cache among vagrant VMs of the same box type}
|
12
|
+
gem.homepage = "http://github.com/avit/vagrant-apt_cache"
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($\)
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.name = "vagrant-apt_cache"
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.version = Vagrant::AptCache::VERSION
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-apt_cache
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Andrew Vit
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-14 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: ! " Shares the /var/cache/apt/ folder for Ubuntu/Debian instances
|
15
|
+
by storing\n already-downloaded packages on the host.\n"
|
16
|
+
email:
|
17
|
+
- andrew@avit.ca
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- Gemfile
|
24
|
+
- LICENSE
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- lib/vagrant-apt_cache.rb
|
28
|
+
- lib/vagrant-apt_cache/middleware.rb
|
29
|
+
- lib/vagrant-apt_cache/register_shared_folder.rb
|
30
|
+
- lib/vagrant-apt_cache/version.rb
|
31
|
+
- lib/vagrant_init.rb
|
32
|
+
- vagrant-apt_cache.gemspec
|
33
|
+
homepage: http://github.com/avit/vagrant-apt_cache
|
34
|
+
licenses: []
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
requirements: []
|
52
|
+
rubyforge_project:
|
53
|
+
rubygems_version: 1.8.24
|
54
|
+
signing_key:
|
55
|
+
specification_version: 3
|
56
|
+
summary: Share apt-cache among vagrant VMs of the same box type
|
57
|
+
test_files: []
|
58
|
+
has_rdoc:
|