From 4f49be03ad9d031129ab6e8ef96f38892b79216a Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Fri, 14 Mar 2014 00:24:06 -0300 Subject: [PATCH] core: Make `lxc-template` optional [GH-254] --- CHANGELOG.md | 5 ++++- README.md | 2 +- boxes/common/package.sh | 1 - lib/vagrant-lxc.rb | 8 ++++++++ lib/vagrant-lxc/action/handle_box_metadata.rb | 7 ++++++- {boxes/common => scripts}/lxc-template | 0 6 files changed, 19 insertions(+), 4 deletions(-) rename {boxes/common => scripts}/lxc-template (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc0d131..581b13d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,9 @@ FEATURES: IMPROVEMENTS: - - Set container utsname to configured hostname by default [[GH-253]] + - `lxc-template` is now optional for base boxes and are bundled with the plugin, + allowing us to roll out updates without the need to rebuild boxes [[GH-254]] + - Set container's `utsname` to `config.vm.hostname` by default [[GH-253]] - Added libvirt dnsmasq leases file to the lookup paths [[GH-251]] - Improved compatibility with Vagrant 1.4 / 1.5 including the ability to use `rsync` and `nfs` shared folders to work around synced folders @@ -29,6 +31,7 @@ IMPROVEMENTS: - Warn in case `:group` or `:owner` are specified for synced folders [[GH-251]] - Acceptance specs are now powered by `vagrant-spec` [[GH-213]] +[GH-254]: https://github.com/fgrehm/vagrant-lxc/issues/254 [GH-196]: https://github.com/fgrehm/vagrant-lxc/issues/196 [GH-251]: https://github.com/fgrehm/vagrant-lxc/pull/251 [GH-253]: https://github.com/fgrehm/vagrant-lxc/pull/253 diff --git a/README.md b/README.md index dc8c757..8f3665f 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ will be coming along _soon_. ## Requirements -* [Vagrant 1.1+](http://downloads.vagrantup.com/) +* [Vagrant 1.1+](http://www.vagrantup.com/downloads.html) * lxc 0.7.5+ * redir (if you are planning to use port forwarding) * A [kernel != 3.5.0-17.28](https://github.com/fgrehm/vagrant-lxc/wiki/Troubleshooting#wiki-im-unable-to-restart-containers) diff --git a/boxes/common/package.sh b/boxes/common/package.sh index 853f653..943915e 100755 --- a/boxes/common/package.sh +++ b/boxes/common/package.sh @@ -23,7 +23,6 @@ popd &>>${LOG} # Prepare package contents log 'Preparing box package contents' -cp common/lxc-template ${WORKING_DIR} cp conf/${DISTRIBUTION} ${WORKING_DIR}/lxc-config cp conf/metadata.json ${WORKING_DIR} sed -i "s//${NOW}/" ${WORKING_DIR}/metadata.json diff --git a/lib/vagrant-lxc.rb b/lib/vagrant-lxc.rb index 7566c36..d1ad0f7 100644 --- a/lib/vagrant-lxc.rb +++ b/lib/vagrant-lxc.rb @@ -1,2 +1,10 @@ require "vagrant-lxc/version" require "vagrant-lxc/plugin" + +module Vagrant + module LXC + def self.source_root + @source_root ||= Pathname.new(File.dirname(__FILE__)).join('..').expand_path + end + end +end diff --git a/lib/vagrant-lxc/action/handle_box_metadata.rb b/lib/vagrant-lxc/action/handle_box_metadata.rb index fccc9b5..6d78800 100644 --- a/lib/vagrant-lxc/action/handle_box_metadata.rb +++ b/lib/vagrant-lxc/action/handle_box_metadata.rb @@ -42,7 +42,12 @@ module Vagrant end def template_src - @template_src ||= @box.directory.join('lxc-template').to_s + @template_src ||= + if (box_template = @box.directory.join('lxc-template')).exist? + box_template.to_s + else + Vagrant::LXC.source_root.join('scripts/lxc-template').to_s + end end def template_config_file diff --git a/boxes/common/lxc-template b/scripts/lxc-template similarity index 100% rename from boxes/common/lxc-template rename to scripts/lxc-template