[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35
test branch
puppet-dev at googlegroups.com
Wed Jul 14 10:34:22 UTC 2010
The following commit has been merged in the upstream branch:
commit 6a928940a43001f62cbd62d6c760c7d287bad855
Author: David Schmitt <david at dasz.at>
Date: Mon May 17 14:38:41 2010 +0200
Avoid trying to symlink() on windows
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index 6d71abc..04a6765 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -30,8 +30,8 @@ Puppet::Type.newtype(:file) do
validate do |value|
# accept various path syntaxes: lone slash, posix, win32, unc
- unless value =~ /^\/$/ or value =~ /^\/[^\/]/ or value =~ /^.:\// or value =~ /^\/\/[^\/]+\/[^\/]+/
- fail Puppet::Error,"File paths must be fully qualified, not '#{value}'"
+ unless (Puppet.features.posix? and (value =~ /^\/$/ or value =~ /^\/[^\/]/)) or (Puppet.features.win32? and (value =~ /^.:\// or value =~ /^\/\/[^\/]+\/[^\/]+/))
+ fail Puppet::Error, "File paths must be fully qualified, not '#{value}'"
end
end
diff --git a/lib/puppet/type/file/target.rb b/lib/puppet/type/file/target.rb
index fe547e4..6987328 100644
--- a/lib/puppet/type/file/target.rb
+++ b/lib/puppet/type/file/target.rb
@@ -23,6 +23,8 @@ module Puppet
# Create our link.
def mklink
+ raise Puppet::Error, "Cannot symlink on Win32" if Puppet.features.win32?
+
target = self.should
# Clean up any existing objects. The argument is just for logging,
diff --git a/spec/unit/type/file.rb b/spec/unit/type/file.rb
index 4ce6275..548fc1b 100755
--- a/spec/unit/type/file.rb
+++ b/spec/unit/type/file.rb
@@ -5,6 +5,8 @@ require File.dirname(__FILE__) + '/../../spec_helper'
describe Puppet::Type.type(:file) do
before do
Puppet.settings.stubs(:use)
+ @real_posix = Puppet.features.posix?
+ Puppet.features.stubs("posix?").returns(true)
@path = Tempfile.new("puppetspec")
pathname = @path.path
@@ -151,127 +153,181 @@ describe Puppet::Type.type(:file) do
end
describe "when using POSIX filenames" do
- it "should autorequire its parent directory" do
- file = Puppet::Type::File.new(:path => "/foo/bar")
- dir = Puppet::Type::File.new(:path => "/foo")
- @catalog.add_resource file
- @catalog.add_resource dir
- reqs = file.autorequire
- reqs[0].source.must == dir
- reqs[0].target.must == file
- end
+ describe "on POSIX systems" do
+ before do
+ Puppet.features.stubs(:posix?).returns(true)
+ Puppet.features.stubs(:win32?).returns(false)
+ end
- it "should not autorequire its parent dir if its parent dir is itself" do
- file = Puppet::Type::File.new(:path => "/")
- @catalog.add_resource file
- file.autorequire.should be_empty
- end
+ it "should autorequire its parent directory" do
+ file = Puppet::Type::File.new(:path => "/foo/bar")
+ dir = Puppet::Type::File.new(:path => "/foo")
+ @catalog.add_resource file
+ @catalog.add_resource dir
+ reqs = file.autorequire
+ reqs[0].source.must == dir
+ reqs[0].target.must == file
+ end
- it "should remove trailing slashes" do
- file = Puppet::Type::File.new(:path => "/foo/bar/baz/")
- file[:path].should == "/foo/bar/baz"
- end
+ it "should not autorequire its parent dir if its parent dir is itself" do
+ file = Puppet::Type::File.new(:path => "/")
+ @catalog.add_resource file
+ file.autorequire.should be_empty
+ end
- it "should remove double slashes" do
- file = Puppet::Type::File.new(:path => "/foo/bar//baz")
- file[:path].should == "/foo/bar/baz"
- end
+ it "should remove trailing slashes" do
+ file = Puppet::Type::File.new(:path => "/foo/bar/baz/")
+ file[:path].should == "/foo/bar/baz"
+ end
- it "should remove trailing double slashes" do
- file = Puppet::Type::File.new(:path => "/foo/bar/baz//")
- file[:path].should == "/foo/bar/baz"
+ it "should remove double slashes" do
+ file = Puppet::Type::File.new(:path => "/foo/bar//baz")
+ file[:path].should == "/foo/bar/baz"
+ end
+
+ it "should remove trailing double slashes" do
+ file = Puppet::Type::File.new(:path => "/foo/bar/baz//")
+ file[:path].should == "/foo/bar/baz"
+ end
+
+ it "should leave a single slash alone" do
+ file = Puppet::Type::File.new(:path => "/")
+ file[:path].should == "/"
+ end
end
+
+ describe "on Win32 systems" do
+ before do
+ Puppet.features.stubs(:posix?).returns(false)
+ Puppet.features.stubs(:win32?).returns(true)
+ end
- it "should leave a single slash alone" do
- file = Puppet::Type::File.new(:path => "/")
- file[:path].should == "/"
+ it "should refuse to work" do
+ lambda { Puppet::Type::File.new(:path => "/foo/bar") }.should raise_error(Puppet::Error)
+ end
end
end
describe "when using Win32 filenames" do
- it "should autorequire its parent directory" do
- file = Puppet::Type::File.new(:path => "X:/foo/bar")
- dir = Puppet::Type::File.new(:path => "X:/foo")
- @catalog.add_resource file
- @catalog.add_resource dir
- reqs = file.autorequire
- reqs[0].source.must == dir
- reqs[0].target.must == file
- end
+ describe "on Win32 systems" do
+ before do
+ Puppet.features.stubs(:posix?).returns(false)
+ Puppet.features.stubs(:win32?).returns(true)
+ end
- it "should not autorequire its parent dir if its parent dir is itself" do
- file = Puppet::Type::File.new(:path => "X:/")
- @catalog.add_resource file
- file.autorequire.should be_empty
- end
+ it "should autorequire its parent directory" do
+ file = Puppet::Type::File.new(:path => "X:/foo/bar")
+ dir = Puppet::Type::File.new(:path => "X:/foo")
+ @catalog.add_resource file
+ @catalog.add_resource dir
+ reqs = file.autorequire
+ reqs[0].source.must == dir
+ reqs[0].target.must == file
+ end
- it "should remove trailing slashes" do
- file = Puppet::Type::File.new(:path => "X:/foo/bar/baz/")
- file[:path].should == "X:/foo/bar/baz"
- end
+ it "should not autorequire its parent dir if its parent dir is itself" do
+ file = Puppet::Type::File.new(:path => "X:/")
+ @catalog.add_resource file
+ file.autorequire.should be_empty
+ end
- it "should remove double slashes" do
- file = Puppet::Type::File.new(:path => "X:/foo/bar//baz")
- file[:path].should == "X:/foo/bar/baz"
- end
+ it "should remove trailing slashes" do
+ file = Puppet::Type::File.new(:path => "X:/foo/bar/baz/")
+ file[:path].should == "X:/foo/bar/baz"
+ end
- it "should remove trailing double slashes" do
- file = Puppet::Type::File.new(:path => "X:/foo/bar/baz//")
- file[:path].should == "X:/foo/bar/baz"
- end
+ it "should remove double slashes" do
+ file = Puppet::Type::File.new(:path => "X:/foo/bar//baz")
+ file[:path].should == "X:/foo/bar/baz"
+ end
+
+ it "should remove trailing double slashes" do
+ file = Puppet::Type::File.new(:path => "X:/foo/bar/baz//")
+ file[:path].should == "X:/foo/bar/baz"
+ end
+
+ it "should leave a drive letter with a slash alone" do
+ file = Puppet::Type::File.new(:path => "X:/")
+ file[:path].should == "X:/"
+ end
- it "should leave a drive letter with a slash alone" do
- file = Puppet::Type::File.new(:path => "X:/")
- file[:path].should == "X:/"
+ it "should add a slash to a drive letter" do
+ file = Puppet::Type::File.new(:path => "X:")
+ file[:path].should == "X:/"
+ end
end
- it "should add a slash to a drive letter" do
- file = Puppet::Type::File.new(:path => "X:")
- file[:path].should == "X:/"
+ describe "on POSIX systems" do
+ before do
+ Puppet.features.stubs(:posix?).returns(true)
+ Puppet.features.stubs(:win32?).returns(false)
+ end
+
+ it "should refuse to work" do
+ lambda { Puppet::Type::File.new(:path => "X:/foo/bar") }.should raise_error(Puppet::Error)
+ end
end
end
describe "when using UNC filenames" do
- it "should autorequire its parent directory" do
- file = Puppet::Type::File.new(:path => "//server/foo/bar")
- dir = Puppet::Type::File.new(:path => "//server/foo")
- @catalog.add_resource file
- @catalog.add_resource dir
- reqs = file.autorequire
- reqs[0].source.must == dir
- reqs[0].target.must == file
- end
+ describe "on Win32 systems" do
+ before do
+ Puppet.features.stubs(:posix?).returns(false)
+ Puppet.features.stubs(:win32?).returns(true)
+ end
- it "should not autorequire its parent dir if its parent dir is itself" do
- file = Puppet::Type::File.new(:path => "//server/foo")
- @catalog.add_resource file
- puts file.autorequire
- file.autorequire.should be_empty
- end
+ it "should autorequire its parent directory" do
+ file = Puppet::Type::File.new(:path => "//server/foo/bar")
+ dir = Puppet::Type::File.new(:path => "//server/foo")
+ @catalog.add_resource file
+ @catalog.add_resource dir
+ reqs = file.autorequire
+ reqs[0].source.must == dir
+ reqs[0].target.must == file
+ end
- it "should remove trailing slashes" do
- file = Puppet::Type::File.new(:path => "//server/foo/bar/baz/")
- file[:path].should == "//server/foo/bar/baz"
- end
+ it "should not autorequire its parent dir if its parent dir is itself" do
+ file = Puppet::Type::File.new(:path => "//server/foo")
+ @catalog.add_resource file
+ puts file.autorequire
+ file.autorequire.should be_empty
+ end
- it "should remove double slashes" do
- file = Puppet::Type::File.new(:path => "//server/foo/bar//baz")
- file[:path].should == "//server/foo/bar/baz"
- end
+ it "should remove trailing slashes" do
+ file = Puppet::Type::File.new(:path => "//server/foo/bar/baz/")
+ file[:path].should == "//server/foo/bar/baz"
+ end
- it "should remove trailing double slashes" do
- file = Puppet::Type::File.new(:path => "//server/foo/bar/baz//")
- file[:path].should == "//server/foo/bar/baz"
- end
+ it "should remove double slashes" do
+ file = Puppet::Type::File.new(:path => "//server/foo/bar//baz")
+ file[:path].should == "//server/foo/bar/baz"
+ end
+
+ it "should remove trailing double slashes" do
+ file = Puppet::Type::File.new(:path => "//server/foo/bar/baz//")
+ file[:path].should == "//server/foo/bar/baz"
+ end
- it "should remove a trailing slash from a sharename" do
- file = Puppet::Type::File.new(:path => "//server/foo/")
- file[:path].should == "//server/foo"
+ it "should remove a trailing slash from a sharename" do
+ file = Puppet::Type::File.new(:path => "//server/foo/")
+ file[:path].should == "//server/foo"
+ end
+
+ it "should not modify a sharename" do
+ file = Puppet::Type::File.new(:path => "//server/foo")
+ file[:path].should == "//server/foo"
+ end
end
- it "should not modify a sharename" do
- file = Puppet::Type::File.new(:path => "//server/foo")
- file[:path].should == "//server/foo"
+ describe "on POSIX systems" do
+ before do
+ Puppet.features.stubs(:posix?).returns(true)
+ Puppet.features.stubs(:win32?).returns(false)
+ end
+
+ it "should refuse to work" do
+ lambda { Puppet::Type::File.new(:path => "X:/foo/bar") }.should raise_error(Puppet::Error)
+ end
end
end
@@ -310,37 +366,54 @@ describe Puppet::Type.type(:file) do
include PuppetTest
require 'tempfile'
- before do
- @basedir = tempfile
- Dir.mkdir(@basedir)
- @file = File.join(@basedir, "file")
- @link = File.join(@basedir, "link")
+ if @real_posix
+ describe "on POSIX systems" do
+ before do
+ @basedir = tempfile
+ Dir.mkdir(@basedir)
+ @file = File.join(@basedir, "file")
+ @link = File.join(@basedir, "link")
+
+ File.open(@file, "w", 0644) { |f| f.puts "yayness"; f.flush }
+ File.symlink(@file, @link)
+
+ @resource = Puppet::Type.type(:file).new(
+ :path => @link,
+ :mode => "755"
+ )
+ @catalog.add_resource @resource
+ end
- File.open(@file, "w", 0644) { |f| f.puts "yayness"; f.flush }
- File.symlink(@file, @link)
+ after do
+ remove_tmp_files
+ end
- @resource = Puppet::Type.type(:file).new(
- :path => @link,
- :mode => "755"
- )
- @catalog.add_resource @resource
- end
+ it "should default to managing the link" do
+ @catalog.apply
+ # I convert them to strings so they display correctly if there's an error.
+ ("%o" % (File.stat(@file).mode & 007777)).should == "%o" % 0644
+ end
- after do
- remove_tmp_files
- end
+ it "should be able to follow links" do
+ @resource[:links] = :follow
+ @catalog.apply
- it "should default to managing the link" do
- @catalog.apply
- # I convert them to strings so they display correctly if there's an error.
- ("%o" % (File.stat(@file).mode & 007777)).should == "%o" % 0644
+ ("%o" % (File.stat(@file).mode & 007777)).should == "%o" % 0755
+ end
+ end
+ else # @real_posix
+ # should recode tests using expectations instead of using the filesystem
end
+
+ describe "on Win32 systems" do
+ before do
+ Puppet.features.stubs(:posix?).returns(false)
+ Puppet.features.stubs(:win32?).returns(true)
+ end
- it "should be able to follow links" do
- @resource[:links] = :follow
- @catalog.apply
-
- ("%o" % (File.stat(@file).mode & 007777)).should == "%o" % 0755
+ it "should refuse to work with links" do
+ lambda { Puppet::Type.type(:file).new(:path => @link, :mode => "755") }.should raise_error(Puppet::Error)
+ end
end
end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list