puppetlabs/puppet_for_the_win — pull request #68 by joshcooper (2014-07-11 19:47:41+00:00)
Title: (PE-4699) Ensure PEVERSION constant is defined

Previously, the windows rake task was transforming lib/puppet/version.rb from:

if File.readable? PEBuildFile and !File.zero? PEBuildFile
PEVERSION = File.new(PEBuildFile).gets.chomp
PUPPETVERSION = "3.6.2 (Puppet Enterprise #{PEVERSION})"
elsif File.readable? PEVersionFile and !File.zero? PEVersionFile
PEVERSION = File.new(PEVersionFile).gets.chomp
PUPPETVERSION = "3.6.2 (Puppet Enterprise #{PEVERSION})"
else
PUPPETVERSION = '3.6.2'
end

to

if File.readable? PEBuildFile and !File.zero? PEBuildFile
PEVERSION = File.new(PEBuildFile).gets.chomp
PUPPETVERSION = "3.6.2 (Puppet Enterprise #{PEVERSION}) (Puppet Enterprise 3.3.0-rc2-409-gb3a28f9)"
elsif File.readable? PEVersionFile and !File.zero? PEVersionFile
PEVERSION = File.new(PEVersionFile).gets.chomp
PUPPETVERSION = "3.6.2 (Puppet Enterprise #{PEVERSION}) (Puppet Enterprise 3.3.0-rc2-409-gb3a28f9)"
else
PUPPETVERSION = '3.6.2 (Puppet Enterprise 3.3.0-rc2-409-gb3a28f9)'
end

Note that (Puppet Enterprise ..) is repeated twice for two of the
cases. This fortunately is not a problem, because the PEBuildFile and
PEVersion file are under '/opt/puppet' and don't exist on Windows.

Also note that PEVERSION is missing in the else case. This is problem
because the PE PMT requires the constant to be defined.

This commit changes the transformation to:

if File.readable? PEBuildFile and !File.zero? PEBuildFile
PEVERSION = File.new(PEBuildFile).gets.chomp
PUPPETVERSION = "3.6.2 (Puppet Enterprise 3.3.0)"
elsif File.readable? PEVersionFile and !File.zero? PEVersionFile
PEVERSION = File.new(PEVersionFile).gets.chomp
PUPPETVERSION = "3.6.2 (Puppet Enterprise 3.3.0)"
else
PEVERSION = '3.3.0'
PUPPETVERSION = '3.6.2 (Puppet Enterprise 3.3.0)'
end

After this change PE PMT is working correctly

C:\Windows\system32>puppet --version
3.6.2 (Puppet Enterprise 3.3.0)

C:\Windows\system32>puppet module install puppetlabs/registry
Notice: Preparing to install into C:/ProgramData/PuppetLabs/puppet/etc/modules ...
Notice: Created target directory C:/ProgramData/PuppetLabs/puppet/etc/modules
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Found at least one version of puppetlabs-registry compatible with PE (3.3.0);
Notice: Skipping versions which don't express PE compatibility. To install
the most recent version of the module regardless of compatibility
with PE, use the '--ignore-requirements' flag.
Notice: Found at least one version of puppetlabs-stdlib compatible with PE (3.3.0);
Notice: Skipping versions which don't express PE compatibility. To install
the most recent version of the module regardless of compatibility
with PE, use the '--ignore-requirements' flag.
Notice: Installing -- do not interrupt ...
C:/ProgramData/PuppetLabs/puppet/etc/modules
└─┬ puppetlabs-registry (v1.0.1)
└── puppetlabs-stdlib (v4.2.2)