From c50c7959f9fc1b3f5c9531fe8419a80f1f70433d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 10 Feb 2012 18:14:51 -0800 Subject: [PATCH] Convert lineendings for the other guests as well --- lib/vagrant/guest/arch.rb | 15 +++++++++++++-- lib/vagrant/guest/debian.rb | 10 ++++++++-- lib/vagrant/guest/gentoo.rb | 10 ++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/lib/vagrant/guest/arch.rb b/lib/vagrant/guest/arch.rb index bc9bad649..2c027ebdc 100644 --- a/lib/vagrant/guest/arch.rb +++ b/lib/vagrant/guest/arch.rb @@ -1,9 +1,16 @@ require 'set' require 'tempfile' +require 'vagrant/util/line_ending_helpers' +require 'vagrant/util/template_renderer' + module Vagrant module Guest class Arch < Linux + # Make the TemplateRenderer top-level + include Vagrant::Util + include Vagrant::Util::LineEndingHelpers + def change_host_name(name) # Only do this if the hostname is not already set if !vm.channel.test("sudo hostname | grep '#{name}'") @@ -23,8 +30,12 @@ module Vagrant entries = [] networks.each do |network| interfaces.add(network[:interface]) - entries << TemplateRenderer.render("guests/arch/network_#{network[:type]}", - :options => network) + entry = TemplateRenderer.render("guests/arch/network_#{network[:type]}", + :options => network) + + # Convert to proper line endings + entry = dos_to_unix(entry) + entries << entry end # Perform the careful dance necessary to reconfigure diff --git a/lib/vagrant/guest/debian.rb b/lib/vagrant/guest/debian.rb index ca7158349..7789ac847 100644 --- a/lib/vagrant/guest/debian.rb +++ b/lib/vagrant/guest/debian.rb @@ -1,6 +1,7 @@ require 'set' require 'tempfile' +require 'vagrant/util/line_ending_helpers' require 'vagrant/util/template_renderer' module Vagrant @@ -8,6 +9,7 @@ module Vagrant class Debian < Linux # Make the TemplateRenderer top-level include Vagrant::Util + include Vagrant::Util::LineEndingHelpers def configure_networks(networks) # First, remove any previous network modifications @@ -22,8 +24,12 @@ module Vagrant entries = [] networks.each do |network| interfaces.add(network[:interface]) - entries << TemplateRenderer.render("guests/debian/network_#{network[:type]}", - :options => network) + entry = TemplateRenderer.render("guests/debian/network_#{network[:type]}", + :options => network) + + # Convert line endings properly and save + entry = dos_to_unix(entry) + entries << entry end # Perform the careful dance necessary to reconfigure diff --git a/lib/vagrant/guest/gentoo.rb b/lib/vagrant/guest/gentoo.rb index a5af9abb0..67f47ef54 100644 --- a/lib/vagrant/guest/gentoo.rb +++ b/lib/vagrant/guest/gentoo.rb @@ -1,8 +1,15 @@ require 'tempfile' +require 'vagrant/util/line_ending_helpers' +require 'vagrant/util/template_renderer' + module Vagrant module Guest class Gentoo < Linux + # Make the TemplateRenderer top-level + include Vagrant::Util + include Vagrant::Util::LineEndingHelpers + def configure_networks(networks) # Remove any previous host only network additions to the interface file vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces") @@ -13,6 +20,9 @@ module Vagrant entry = TemplateRenderer.render("guests/gentoo/network_#{network[:type]}", :options => network) + # Convert to proper lineendings + entry = dos_to_unix(entry) + # Upload the entry to a temporary location temp = Tempfile.new("vagrant") temp.write(entry)