vagrant-lxc 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/Gemfile +3 -6
- data/Gemfile.lock +25 -25
- data/README.md +44 -32
- data/boxes/common/cleanup +7 -0
- data/boxes/common/install-babushka +15 -0
- data/boxes/{ubuntu → common}/install-chef +0 -0
- data/boxes/{ubuntu → common}/install-puppet +1 -1
- data/boxes/debian/download +156 -0
- data/boxes/debian/lxc-template +363 -0
- data/boxes/debian/metadata.json.template +9 -0
- data/boxes/ubuntu/download +11 -0
- data/boxes/ubuntu/lxc-template +14 -23
- data/development/Vagrantfile +69 -95
- data/development/lxc-configs/sid +37 -0
- data/development/lxc-configs/squeeze +37 -0
- data/development/lxc-configs/wheezy +37 -0
- data/development/shell-provisioning/upgrade-kernel +2 -2
- data/development/site.pp +3 -0
- data/example/Vagrantfile +15 -1
- data/lib/vagrant-lxc/action.rb +3 -1
- data/lib/vagrant-lxc/action/forced_halt.rb +1 -3
- data/lib/vagrant-lxc/action/remove_temporary_files.rb +23 -0
- data/lib/vagrant-lxc/driver.rb +3 -3
- data/lib/vagrant-lxc/driver/cli.rb +20 -2
- data/lib/vagrant-lxc/version.rb +1 -1
- data/spec/Vagrantfile +10 -19
- data/spec/acceptance/sanity_check_spec.rb +11 -2
- data/spec/acceptance/support/test_ui.rb +1 -1
- data/spec/unit/driver/cli_spec.rb +5 -6
- data/spec/unit/driver_spec.rb +10 -2
- data/tasks/boxes.rake +136 -36
- metadata +13 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c50dc38cceb25885011a091ace53495f0992bb45
|
4
|
+
data.tar.gz: d9e0c2cb8b70ff4a170d1744f438ffffcdaca199
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a71590125708f5bdb688a46fc5e6d282e3acb49c9045946becb261a856b7f6a23b29b2bef25370c8d6bc9de23f765cf27f2e3e6a2e6442fe030dde5d8442fc31
|
7
|
+
data.tar.gz: 380309703b319c8eb6e91be92a8e2e1a09f28164d1076753667253ea9eb1a9b2b36ec11cffec8a1667d886cb32395ef2f5f44eab51c216e3a1e5bb66539cc45f
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,22 @@
|
|
1
|
+
## [0.?.?](https://github.com/fgrehm/vagrant-lxc/compare/v0.3.3...master)
|
2
|
+
|
3
|
+
FEATURES:
|
4
|
+
|
5
|
+
- Support for building Debian boxes (tks to @Val)
|
6
|
+
- Support for installing babushka on base boxes (tks to @Val)
|
7
|
+
|
8
|
+
IMPROVEMENTS:
|
9
|
+
|
10
|
+
- Remove `/tmp` files after the machine has been successfully shut down [#68][]
|
11
|
+
- Clean up base boxes files after they've been configured, resulting in smaller packages
|
12
|
+
- Bump development dependency to Vagrant 1.2+ series
|
13
|
+
|
1
14
|
## [0.3.3](https://github.com/fgrehm/vagrant-lxc/compare/v0.3.2...v0.3.3) (April 23, 2013)
|
2
15
|
|
3
16
|
BUG FIXES:
|
4
17
|
|
5
18
|
- Properly kill `redir` child processes [#59][]
|
19
|
+
- Use `uname -m` on base Ubuntu lxc-template [#53][]
|
6
20
|
|
7
21
|
IMPROVEMENTS:
|
8
22
|
|
data/Gemfile
CHANGED
@@ -3,14 +3,11 @@ source 'https://rubygems.org'
|
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
group :development do
|
6
|
-
#
|
7
|
-
|
8
|
-
|
9
|
-
gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git', tag: 'v1.1.5'
|
6
|
+
# TODO: Lock to 1.2.3 once it is out with this fix: https://github.com/mitchellh/vagrant/pull/1685
|
7
|
+
gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git'
|
8
|
+
gem 'vagrant-cachier'
|
10
9
|
gem 'guard'
|
11
10
|
gem 'guard-rspec'
|
12
|
-
gem 'guard-bundler'
|
13
|
-
gem 'guard-ctags-bundler'
|
14
11
|
gem 'rb-inotify'
|
15
12
|
end
|
16
13
|
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
GIT
|
2
2
|
remote: https://github.com/mitchellh/vagrant.git
|
3
|
-
revision:
|
4
|
-
tag: v1.1.5
|
3
|
+
revision: ccfd321ef98dc5c12b180cc3a26f12d870c0eff5
|
5
4
|
specs:
|
6
|
-
vagrant (1.
|
5
|
+
vagrant (1.2.3.dev)
|
7
6
|
childprocess (~> 0.3.7)
|
8
7
|
erubis (~> 2.7.0)
|
9
8
|
i18n (~> 0.6.0)
|
@@ -15,7 +14,7 @@ GIT
|
|
15
14
|
PATH
|
16
15
|
remote: .
|
17
16
|
specs:
|
18
|
-
vagrant-lxc (0.3.
|
17
|
+
vagrant-lxc (0.3.4)
|
19
18
|
|
20
19
|
GEM
|
21
20
|
remote: https://rubygems.org/
|
@@ -24,48 +23,49 @@ GEM
|
|
24
23
|
ffi (~> 1.0, >= 1.0.11)
|
25
24
|
coderay (1.0.9)
|
26
25
|
colorize (0.5.8)
|
27
|
-
coveralls (0.6.
|
26
|
+
coveralls (0.6.7)
|
28
27
|
colorize
|
29
28
|
multi_json (~> 1.3)
|
30
29
|
rest-client
|
31
30
|
simplecov (>= 0.7)
|
32
31
|
thor
|
33
|
-
diff-lcs (1.2.
|
32
|
+
diff-lcs (1.2.4)
|
34
33
|
erubis (2.7.0)
|
35
|
-
ffi (1.
|
34
|
+
ffi (1.8.1)
|
36
35
|
formatador (0.2.4)
|
37
|
-
guard (1.
|
36
|
+
guard (1.8.0)
|
38
37
|
formatador (>= 0.2.4)
|
39
|
-
listen (>= 0.
|
38
|
+
listen (>= 1.0.0)
|
40
39
|
lumberjack (>= 1.0.2)
|
41
40
|
pry (>= 0.9.10)
|
42
41
|
thor (>= 0.14.6)
|
43
|
-
guard-
|
44
|
-
|
45
|
-
|
46
|
-
guard-ctags-bundler (0.1.6)
|
47
|
-
guard (>= 1.1)
|
48
|
-
guard-rspec (2.5.2)
|
49
|
-
guard (>= 1.1)
|
50
|
-
rspec (~> 2.11)
|
42
|
+
guard-rspec (2.6.0)
|
43
|
+
guard (>= 1.8)
|
44
|
+
rspec (~> 2.13)
|
51
45
|
i18n (0.6.4)
|
52
46
|
json (1.7.7)
|
53
|
-
listen (0.
|
47
|
+
listen (1.0.3)
|
48
|
+
rb-fsevent (>= 0.9.3)
|
49
|
+
rb-inotify (>= 0.9)
|
50
|
+
rb-kqueue (>= 0.2)
|
54
51
|
log4r (1.1.10)
|
55
52
|
lumberjack (1.0.3)
|
56
53
|
method_source (0.8.1)
|
57
|
-
mime-types (1.
|
58
|
-
multi_json (1.7.
|
54
|
+
mime-types (1.23)
|
55
|
+
multi_json (1.7.3)
|
59
56
|
net-scp (1.1.0)
|
60
57
|
net-ssh (>= 2.6.5)
|
61
|
-
net-ssh (2.6.
|
62
|
-
pry (0.9.12)
|
58
|
+
net-ssh (2.6.7)
|
59
|
+
pry (0.9.12.1)
|
63
60
|
coderay (~> 1.0.5)
|
64
61
|
method_source (~> 0.8)
|
65
62
|
slop (~> 3.4)
|
66
63
|
rake (10.0.4)
|
64
|
+
rb-fsevent (0.9.3)
|
67
65
|
rb-inotify (0.9.0)
|
68
66
|
ffi (>= 0.5.0)
|
67
|
+
rb-kqueue (0.2.0)
|
68
|
+
ffi (>= 0.5.0)
|
69
69
|
rest-client (1.6.7)
|
70
70
|
mime-types (>= 1.16)
|
71
71
|
rspec (2.13.0)
|
@@ -77,7 +77,7 @@ GEM
|
|
77
77
|
diff-lcs (>= 1.1.3, < 2.0)
|
78
78
|
rspec-fire (1.1.3)
|
79
79
|
rspec (~> 2.11)
|
80
|
-
rspec-mocks (2.13.
|
80
|
+
rspec-mocks (2.13.1)
|
81
81
|
rspec-spies (2.1.4)
|
82
82
|
rspec (~> 2.0)
|
83
83
|
simplecov (0.7.1)
|
@@ -86,6 +86,7 @@ GEM
|
|
86
86
|
simplecov-html (0.7.1)
|
87
87
|
slop (3.4.4)
|
88
88
|
thor (0.18.1)
|
89
|
+
vagrant-cachier (0.0.2)
|
89
90
|
|
90
91
|
PLATFORMS
|
91
92
|
ruby
|
@@ -93,8 +94,6 @@ PLATFORMS
|
|
93
94
|
DEPENDENCIES
|
94
95
|
coveralls
|
95
96
|
guard
|
96
|
-
guard-bundler
|
97
|
-
guard-ctags-bundler
|
98
97
|
guard-rspec
|
99
98
|
rake
|
100
99
|
rb-inotify
|
@@ -102,4 +101,5 @@ DEPENDENCIES
|
|
102
101
|
rspec-fire
|
103
102
|
rspec-spies
|
104
103
|
vagrant!
|
104
|
+
vagrant-cachier
|
105
105
|
vagrant-lxc!
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
Linux Containers support for Vagrant 1.1+
|
4
4
|
|
5
|
+
Check out this [blog post](http://fabiorehm.com/blog/2013/04/28/lxc-provider-for-vagrant)
|
6
|
+
to see the plugin in action and find out more about it.
|
5
7
|
|
6
8
|
## Dependencies
|
7
9
|
|
@@ -21,42 +23,19 @@ sudo dpkg -i /tmp/vagrant.deb
|
|
21
23
|
```
|
22
24
|
|
23
25
|
|
24
|
-
## What is currently supported?
|
25
|
-
|
26
|
-
Pretty much everything you need from Vagrant:
|
27
|
-
|
28
|
-
* Vagrant's `up`, `halt`, `reload`, `destroy`, `ssh` and `package` commands (box packaging is kind of experimental)
|
29
|
-
* Shared folders
|
30
|
-
* Provisioning
|
31
|
-
* Setting container's host name
|
32
|
-
* Port forwarding
|
33
|
-
|
34
|
-
*Please refer to the [closed issues](https://github.com/fgrehm/vagrant-lxc/issues?labels=&milestone=&page=1&state=closed)
|
35
|
-
and the [changelog](CHANGELOG.md) for most up to date information.*
|
36
|
-
|
37
|
-
|
38
|
-
## Current limitations
|
39
|
-
|
40
|
-
* Does not detect forwarded ports collision, right now you are responsible for taking care of that
|
41
|
-
* A hell lot of `sudo`s (this will probably be like this until [user namespaces](http://s3hh.wordpress.com/2013/02/12/user-namespaces-lxc-meeting/) are supported)
|
42
|
-
* [Does not tell you if dependencies are not met](https://github.com/fgrehm/vagrant-lxc/issues/11)
|
43
|
-
(will probably just throw up some random error)
|
44
|
-
* + bunch of other [core features](https://github.com/fgrehm/vagrant-lxc/issues?labels=core&milestone=&page=1&state=open)
|
45
|
-
and some known [bugs](https://github.com/fgrehm/vagrant-lxc/issues?labels=bug&page=1&state=open)
|
46
|
-
|
47
|
-
|
48
26
|
## Installation
|
49
27
|
|
50
28
|
```
|
51
29
|
vagrant plugin install vagrant-lxc
|
52
30
|
```
|
53
31
|
|
32
|
+
|
54
33
|
## Usage
|
55
34
|
|
56
35
|
After installing, add a [base box](#available-boxes) using any name you want, for example:
|
57
36
|
|
58
37
|
```
|
59
|
-
vagrant box add lxc-quantal64 http://dl.dropbox.com/u/13510779/lxc-quantal-amd64-2013-
|
38
|
+
vagrant box add lxc-quantal64 http://dl.dropbox.com/u/13510779/lxc-quantal-amd64-2013-05-06.box
|
60
39
|
```
|
61
40
|
|
62
41
|
Make a Vagrantfile that looks like the following, filling in your information where necessary:
|
@@ -76,7 +55,8 @@ Vagrant.configure("2") do |config|
|
|
76
55
|
end
|
77
56
|
```
|
78
57
|
|
79
|
-
And finally run `vagrant up --provider=lxc`.
|
58
|
+
And finally run `vagrant up --provider=lxc`. If you are using Vagrant 1.2+ you can
|
59
|
+
also set `VAGRANT_DEFAULT_PROVIDER` environmental variable to `lxc`.
|
80
60
|
|
81
61
|
If you are on a mac or window host and still want to try this plugin out, you
|
82
62
|
can use the [same Vagrant VirtualBox machine I use for development](#using-virtualbox-for-development).
|
@@ -85,20 +65,28 @@ can use the [same Vagrant VirtualBox machine I use for development](#using-virtu
|
|
85
65
|
|
86
66
|
| LINK | DESCRIPTION |
|
87
67
|
| --- | --- |
|
88
|
-
| [lxc-raring-amd64-2013-
|
89
|
-
| [lxc-quantal-amd64-2013-
|
90
|
-
| [lxc-precise-amd64-2013-
|
68
|
+
| [lxc-raring-amd64-2013-05-08.box](http://dl.dropbox.com/u/13510779/lxc-raring-amd64-2013-05-08.box) | Ubuntu 13.04 Raring x86_64 (Puppet 3.1.1) |
|
69
|
+
| [lxc-quantal-amd64-2013-05-08.box](http://dl.dropbox.com/u/13510779/lxc-quantal-amd64-2013-05-08.box) | Ubuntu 12.10 Quantal x86_64 (Puppet 3.1.1 & Chef 11.4.0) |
|
70
|
+
| [lxc-precise-amd64-2013-05-08.box](http://dl.dropbox.com/u/13510779/lxc-precise-amd64-2013-05-08.box) | Ubuntu 12.04 Precise x86_64 (Puppet 3.1.1 & Chef 11.4.0) |
|
71
|
+
| [lxc-sid-amd64-2013-05-08.box](http://dl.dropbox.com/u/13510779/lxc-sid-amd64-2013-05-08.box) | Debian Sid (Puppet 3.1.1) |
|
72
|
+
| [lxc-wheezy-amd64-2013-05-08.box](http://dl.dropbox.com/u/13510779/lxc-wheezy-amd64-2013-05-08.box) | Debian Wheezy (Puppet 3.1.1) |
|
73
|
+
| [lxc-squeeze-amd64-2013-05-08.box](http://dl.dropbox.com/u/13510779/lxc-squeeze-amd64-2013-05-08.box) | Debian Squeeze (Puppet 3.1.1) |
|
91
74
|
|
92
75
|
*Please note that I'm currently using only the quantal x86_64 on a daily basis,
|
93
76
|
and I've only done some basic testing with the others*
|
94
77
|
|
95
|
-
|
96
|
-
|
78
|
+
There is a set of [rake tasks](tasks/boxes.rake) that you can use to build base
|
79
|
+
boxes as needed. By default it won't include any provisioning tool and you can
|
80
|
+
pick the one you want by providing some environment variables.
|
81
|
+
|
82
|
+
For example:
|
97
83
|
|
98
84
|
```
|
99
|
-
CHEF=
|
85
|
+
CHEF=1 rake boxes:ubuntu:build:precise64
|
100
86
|
```
|
101
87
|
|
88
|
+
Will build a Ubuntu Precise x86_64 box with chef pre-installed.
|
89
|
+
|
102
90
|
### Storing container's rootfs on a separate partition
|
103
91
|
|
104
92
|
Before the 0.3.0 version of this plugin, there used to be a support for specifying
|
@@ -112,6 +100,30 @@ NFS shared folders are not supported and will behave as a "normal" shared folder
|
|
112
100
|
so we can share the same Vagrantfile with VBox environments.
|
113
101
|
|
114
102
|
|
103
|
+
## What is currently supported?
|
104
|
+
|
105
|
+
Pretty much everything you need from Vagrant:
|
106
|
+
|
107
|
+
* Vagrant's `up`, `halt`, `reload`, `destroy`, `ssh` and `package` commands (box packaging is kind of experimental)
|
108
|
+
* Shared folders
|
109
|
+
* Provisioning
|
110
|
+
* Setting container's host name
|
111
|
+
* Port forwarding
|
112
|
+
|
113
|
+
*Please refer to the [closed issues](https://github.com/fgrehm/vagrant-lxc/issues?labels=&milestone=&page=1&state=closed)
|
114
|
+
and the [changelog](CHANGELOG.md) for most up to date information.*
|
115
|
+
|
116
|
+
|
117
|
+
## Current limitations
|
118
|
+
|
119
|
+
* Does not detect forwarded ports collision, right now you are responsible for taking care of that
|
120
|
+
* A hell lot of `sudo`s (this will probably be like this until [user namespaces](http://s3hh.wordpress.com/2013/02/12/user-namespaces-lxc-meeting/) are supported)
|
121
|
+
* [Does not tell you if dependencies are not met](https://github.com/fgrehm/vagrant-lxc/issues/11)
|
122
|
+
(will probably just throw up some random error)
|
123
|
+
* + bunch of other [core features](https://github.com/fgrehm/vagrant-lxc/issues?labels=core&milestone=&page=1&state=open)
|
124
|
+
and some known [bugs](https://github.com/fgrehm/vagrant-lxc/issues?labels=bug&page=1&state=open)
|
125
|
+
|
126
|
+
|
115
127
|
## Development
|
116
128
|
|
117
129
|
If want to develop from your physical machine, just sing that same old song:
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
cache=`readlink -f .`
|
4
|
+
rootfs="${cache}/rootfs"
|
5
|
+
|
6
|
+
echo "installing babushka"
|
7
|
+
cat > $rootfs/tmp/install-babushka.sh << EOF
|
8
|
+
#!/bin/sh
|
9
|
+
curl -L https://babushka.me/up | sudo bash < /dev/null
|
10
|
+
|
11
|
+
EOF
|
12
|
+
chmod +x $rootfs/tmp/install-babushka.sh
|
13
|
+
chroot $rootfs /tmp/install-babushka.sh
|
14
|
+
|
15
|
+
rm -rf $rootfs/tmp/*
|
File without changes
|
@@ -7,6 +7,6 @@ echo "installing puppet"
|
|
7
7
|
wget http://apt.puppetlabs.com/puppetlabs-release-stable.deb -O "${rootfs}/tmp/puppetlabs-release-stable.deb"
|
8
8
|
chroot $rootfs dpkg -i "/tmp/puppetlabs-release-stable.deb"
|
9
9
|
chroot $rootfs apt-get update
|
10
|
-
chroot $rootfs apt-get install puppet -y
|
10
|
+
chroot $rootfs apt-get install puppet -y --force-yes
|
11
11
|
|
12
12
|
rm -rf $rootfs/tmp/*
|
@@ -0,0 +1,156 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# This is the code extracted from /usr/share/lxc/templates/lxc-debian
|
4
|
+
# that comes with Ubuntu 13.04 which is responsible for downloading the
|
5
|
+
# rootfs files / packages
|
6
|
+
|
7
|
+
set -e
|
8
|
+
|
9
|
+
suggest_flush()
|
10
|
+
{
|
11
|
+
echo <<EOF
|
12
|
+
Container upgrade failed. The container cache may be out of date,
|
13
|
+
in which case flushing the case (see -F in the hep output) may help.
|
14
|
+
EOF
|
15
|
+
}
|
16
|
+
|
17
|
+
cleanup()
|
18
|
+
{
|
19
|
+
rm -rf $cache/partial
|
20
|
+
rm -rf $cache/rootfs
|
21
|
+
}
|
22
|
+
|
23
|
+
write_sourceslist()
|
24
|
+
{
|
25
|
+
rootfs=$1
|
26
|
+
arch=$2
|
27
|
+
release=$3
|
28
|
+
|
29
|
+
MIRROR=${MIRROR:-http://ftp.debian.org/debian}
|
30
|
+
SECURITY_MIRROR=${SECURITY_MIRROR:-http://security.debian.org/debian-security}
|
31
|
+
|
32
|
+
|
33
|
+
if [ 'sid' == "${release}" -o 'unstable' == "${release}" ]; then
|
34
|
+
cat <<EOF > ${rootfs}/etc/apt/sources.list
|
35
|
+
# ${release}
|
36
|
+
#------------------------------------------------------------------------------
|
37
|
+
deb ${MIRROR} ${release} main contrib non-free
|
38
|
+
EOF
|
39
|
+
else
|
40
|
+
cat <<EOF > ${rootfs}/etc/apt/sources.list
|
41
|
+
# ${release}
|
42
|
+
#------------------------------------------------------------------------------
|
43
|
+
deb ${MIRROR} ${release} main contrib non-free
|
44
|
+
|
45
|
+
# ${release} security
|
46
|
+
#------------------------------------------------------------------------------
|
47
|
+
deb ${SECURITY_MIRROR} ${release}/updates main contrib non-free
|
48
|
+
|
49
|
+
# ${release} updates
|
50
|
+
#------------------------------------------------------------------------------
|
51
|
+
deb ${MIRROR} ${release}-updates main contrib non-free
|
52
|
+
|
53
|
+
# ${release} proposed updates
|
54
|
+
#------------------------------------------------------------------------------
|
55
|
+
deb ${MIRROR} ${release}-proposed-updates main contrib non-free
|
56
|
+
EOF
|
57
|
+
fi
|
58
|
+
}
|
59
|
+
|
60
|
+
download_debian()
|
61
|
+
{
|
62
|
+
cache=$1
|
63
|
+
arch=$2
|
64
|
+
release=$3
|
65
|
+
|
66
|
+
packages=\
|
67
|
+
sudo,\
|
68
|
+
ifupdown,\
|
69
|
+
locales,\
|
70
|
+
libui-dialog-perl,\
|
71
|
+
dialog,\
|
72
|
+
isc-dhcp-client,\
|
73
|
+
netbase,\
|
74
|
+
net-tools,\
|
75
|
+
iproute,\
|
76
|
+
openssh-server,\
|
77
|
+
vim,\
|
78
|
+
jed,\
|
79
|
+
jed-extra,\
|
80
|
+
ssh,\
|
81
|
+
curl,\
|
82
|
+
wget,\
|
83
|
+
bash-completion,\
|
84
|
+
manpages,\
|
85
|
+
man-db,\
|
86
|
+
psmisc,\
|
87
|
+
bind9-host,\
|
88
|
+
telnet,\
|
89
|
+
mtr-tiny,\
|
90
|
+
iputils-ping,\
|
91
|
+
ca-certificates
|
92
|
+
|
93
|
+
if [ ! -z "${ADDITIONAL_PACKAGES}" ]; then
|
94
|
+
packages=${ADDITIONAL_PACKAGES},${packages}
|
95
|
+
fi
|
96
|
+
|
97
|
+
echo "installing packages: ${packages}"
|
98
|
+
|
99
|
+
trap cleanup EXIT SIGHUP SIGINT SIGTERM
|
100
|
+
# check the mini debian was not already downloaded
|
101
|
+
partial=${cache}/partial
|
102
|
+
mkdir -p ${partial}
|
103
|
+
if [ $? -ne 0 ]; then
|
104
|
+
echo "Failed to create '${partial}' directory"
|
105
|
+
return 1
|
106
|
+
fi
|
107
|
+
|
108
|
+
# download a mini debian into a cache
|
109
|
+
echo "Downloading debian ${release} minimal ..."
|
110
|
+
debootstrap \
|
111
|
+
--variant=minbase \
|
112
|
+
--verbose \
|
113
|
+
--components=main,contrib,non-free \
|
114
|
+
--arch=${arch} \
|
115
|
+
--include=${packages} ${release} ${partial} ${MIRROR}
|
116
|
+
|
117
|
+
if [ $? -ne 0 ]; then
|
118
|
+
echo 'Failed to download the rootfs, aborting.'
|
119
|
+
return 1
|
120
|
+
fi
|
121
|
+
|
122
|
+
echo 'Installing updates'
|
123
|
+
write_sourceslist ${partial} ${arch} ${release}
|
124
|
+
|
125
|
+
chroot ${partial} apt-get update
|
126
|
+
if [ $? -ne 0 ]; then
|
127
|
+
echo 'Failed to update the apt cache'
|
128
|
+
return 1
|
129
|
+
fi
|
130
|
+
|
131
|
+
lxc-unshare -s MOUNT -- chroot ${partial} \
|
132
|
+
apt-get dist-upgrade -y || { suggest_flush; false; }
|
133
|
+
|
134
|
+
chroot ${partial} apt-get clean
|
135
|
+
|
136
|
+
mv ${partial} ${cache}/rootfs
|
137
|
+
trap EXIT
|
138
|
+
trap SIGINT
|
139
|
+
trap SIGTERM
|
140
|
+
trap SIGHUP
|
141
|
+
echo 'Download complete'
|
142
|
+
return 0
|
143
|
+
}
|
144
|
+
|
145
|
+
declare cache=`readlink -f .` \
|
146
|
+
arch=$1 \
|
147
|
+
release=$2
|
148
|
+
|
149
|
+
if [ -d ${cache}/rootfs ]; then
|
150
|
+
echo <<EOF
|
151
|
+
The rootfs cache has been built already, please remove it if you want to update
|
152
|
+
EOF
|
153
|
+
exit 1
|
154
|
+
fi
|
155
|
+
|
156
|
+
download_debian ${cache} ${arch} ${release}
|