Skip to content

Commit 39639ec

Browse files
Merge pull request #900 from shubhamshinde360/PA-6324-windowsfips-2016
(PA-6324) Add windowsfips-2016-x64 to agent-runtime-main and agent-runtime-7.x
2 parents 7c72b3d + 939be69 commit 39639ec

File tree

9 files changed

+133
-6
lines changed

9 files changed

+133
-6
lines changed

configs/components/curl.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
elsif platform.is_windows?
2828
pkg.build_requires "runtime-#{settings[:runtime_project]}"
2929
pkg.environment "PATH", "$(shell cygpath -u #{settings[:gcc_bindir]}):$(PATH)"
30+
pkg.environment "NM" , "/usr/bin/nm" if platform.name =~ /windowsfips-2016/
3031
pkg.environment "CYGWIN", settings[:cygwin]
3132
elsif platform.is_aix? && platform.name != 'aix-7.1-ppc'
3233
pkg.environment "PKG_CONFIG_PATH", "/opt/puppetlabs/puppet/lib/pkgconfig"

configs/components/openssl-1.0.2.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
'no-ssl3',
130130
]
131131

132-
configure_flags += ['fips', "--with-fipsdir=#{settings[:prefix]}/usr/local/ssl/fips-2.0"] if platform.name =~ /windowsfips-2012r2/
132+
configure_flags += ['fips', "--with-fipsdir=#{settings[:prefix]}/usr/local/ssl/fips-2.0"] if platform.name =~ /windowsfips-/
133133

134134
# Individual projects may provide their own openssl configure flags:
135135
project_flags = settings[:openssl_extra_configure_flags] || []

configs/components/ruby-2.7.8.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@
141141
'windows-2012r2-x64',
142142
'windows-2012r2-x86',
143143
'windows-2019-x64',
144-
'windowsfips-2012r2-x64'
144+
'windowsfips-2012r2-x64',
145+
'windowsfips-2016-x64'
145146
]
146147

147148
unless without_dtrace.include? platform.name
@@ -170,6 +171,19 @@
170171
]
171172
end
172173

174+
if(platform.name =~ /windowsfips-2016/)
175+
# We need the below patch since during ruby build step for windowsfips-2016-x64 agent-runtime builds,
176+
# the rbconfig.rb file that gets generated contains '\r' trailing character in 'ruby_version' config.
177+
# We patch rbconfig.rb to remove the '\r' character.
178+
# This patch has to run after the build step since rbconfig.rb is generated during the build step.
179+
# This is sort of a hacky way to do this. We need to find why the '\r' character gets appended to
180+
# 'ruby_version' field in the future so that this patch can be removed - PA-6902.
181+
pkg.add_source("#{base}/rbconfig_win.patch")
182+
pkg.build do
183+
["TMP=/var/tmp /usr/bin/patch.exe --binary --strip=1 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../rbconfig_win.patch"]
184+
end
185+
end
186+
173187
#########
174188
# INSTALL
175189
#########

configs/components/ruby-3.2.5.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@
161161
'windows-2012r2-x64',
162162
'windows-2012r2-x86',
163163
'windows-2019-x64',
164-
'windowsfips-2012r2-x64'
164+
'windowsfips-2012r2-x64',
165+
'windowsfips-2016-x64'
165166
]
166167

167168
unless without_dtrace.include? platform.name
@@ -195,6 +196,19 @@
195196
]
196197
end
197198

199+
if(platform.name =~ /windowsfips-2016/)
200+
# We need the below patch since during ruby build step for windowsfips-2016-x64 agent-runtime builds,
201+
# the rbconfig.rb file that gets generated contains '\r' trailing character in 'ruby_version' config.
202+
# We patch rbconfig.rb to remove the '\r' character.
203+
# This patch has to run after the build step since rbconfig.rb is generated during the build step.
204+
# This is sort of a hacky way to do this. We need to find why the '\r' character gets appended to
205+
# 'ruby_version' field in the future so that this patch can be removed - PA-6902.
206+
pkg.add_source("#{base}/rbconfig_win.patch")
207+
pkg.build do
208+
["TMP=/var/tmp /usr/bin/patch.exe --binary --strip=1 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../rbconfig_win.patch"]
209+
end
210+
end
211+
198212
#########
199213
# INSTALL
200214
#########
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
platform "windowsfips-2016-x64" do |plat|
2+
plat.vmpooler_template 'win-2016-fips-x86_64'
3+
4+
plat.servicetype 'windows'
5+
visual_studio_version = '2017'
6+
visual_studio_sdk_version = 'win8.1'
7+
8+
# We need to ensure we install chocolatey prior to adding any nuget repos. Otherwise, everything will fall over
9+
plat.add_build_repository "https://artifactory.delivery.puppetlabs.net/artifactory/generic/buildsources/windows/chocolatey/install-chocolatey-1.4.0.ps1"
10+
plat.provision_with "C:/ProgramData/chocolatey/bin/choco.exe feature enable -n useFipsCompliantChecksums"
11+
12+
plat.add_build_repository "https://artifactory.delivery.puppetlabs.net/artifactory/api/nuget/nuget"
13+
14+
# C:\tools is likely added by mingw, however because we also want to use that
15+
# dir for vsdevcmd.bat we create it for safety
16+
plat.provision_with "mkdir -p C:/tools"
17+
# We don't want to install any packages from the chocolatey repo by accident
18+
plat.provision_with "C:/ProgramData/chocolatey/bin/choco.exe sources remove -name chocolatey"
19+
20+
packages = [
21+
"cmake",
22+
"pl-gdbm-#{self._platform.architecture}",
23+
"pl-iconv-#{self._platform.architecture}",
24+
"pl-libffi-#{self._platform.architecture}",
25+
"pl-pdcurses-#{self._platform.architecture}",
26+
"pl-toolchain-#{self._platform.architecture}",
27+
"pl-zlib-#{self._platform.architecture}",
28+
"mingw-w64 -version 5.2.0 -debug",
29+
]
30+
31+
packages.each do |name|
32+
plat.provision_with("C:/ProgramData/chocolatey/bin/choco.exe install -y --no-progress #{name}")
33+
end
34+
# We use cache-location in the following install because msvc has several long paths
35+
# if we do not update the cache location choco will fail because paths get too long
36+
plat.provision_with "C:/ProgramData/chocolatey/bin/choco.exe install msvc.#{visual_studio_version}-#{visual_studio_sdk_version}.sdk.en-us -y --cache-location=\"C:\\msvc\" --no-progress"
37+
# The following creates a batch file that will execute the vsdevcmd batch file located within visual studio.
38+
# We create the following batch file under C:\tools\vsdevcmd.bat so we can avoid using both the %ProgramFiles(x86)%
39+
# evironment var, as well as any spaces in the path when executing things with cygwin. This makes command execution
40+
# through cygwin much easier.
41+
#
42+
# Note that the unruly \'s in the following string escape the following sequence to literal chars: "\" and then \""
43+
plat.provision_with "touch C:/tools/vsdevcmd.bat && echo \"\\\"%ProgramFiles(x86)%\\Microsoft Visual Studio\\#{visual_studio_version}\\BuildTools\\Common7\\Tools\\vsdevcmd\\\"\" >> C:/tools/vsdevcmd.bat"
44+
45+
plat.install_build_dependencies_with "C:/ProgramData/chocolatey/bin/choco.exe install -y --no-progress"
46+
47+
plat.make "/usr/bin/make"
48+
plat.patch "TMP=/var/tmp /usr/bin/patch.exe --binary"
49+
50+
plat.platform_triple "x86_64-w64-mingw32"
51+
52+
plat.package_type "archive"
53+
plat.output_dir "windows"
54+
end

configs/projects/_shared-agent-components.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
elsif platform.name =~ /^redhatfips-.*/
2727
proj.component "openssl-1.1.1-fips"
2828
else
29-
proj.component "openssl-fips-2.0.16" if platform.name =~ /windowsfips-2012r2/ && proj.openssl_version =~ /1.0.2/
29+
proj.component "openssl-fips-2.0.16" if platform.name =~ /windowsfips-/ && proj.openssl_version =~ /1.0.2/
3030
proj.component "openssl-#{proj.openssl_version}"
3131
end
3232

configs/projects/_shared-agent-settings.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
proj.setting(:openssl_version, '3.0')
148148
elsif platform.name =~ /^redhatfips-/
149149
proj.setting(:openssl_version, '1.1.1-fips')
150-
elsif platform.name =~ /^windowsfips-2012r2/
150+
elsif platform.name =~ /^windowsfips-/
151151
proj.setting(:openssl_version, '1.0.2')
152152
else
153153
proj.setting(:openssl_version, '1.1.1')
@@ -168,7 +168,7 @@
168168
proj.setting(:cflags, "#{proj.cppflags}")
169169

170170
ldflags = "-L#{proj.tools_root}/lib -L#{proj.gcc_root}/lib -L#{proj.libdir} -Wl,--nxcompat"
171-
if platform.name !~ /windowsfips-2012r2/ || name != 'agent-runtime-7.x'
171+
if platform.name !~ /windowsfips-/ || name != 'agent-runtime-7.x'
172172
ldflags += ' -Wl,--dynamicbase'
173173
end
174174
proj.setting(:ldflags, ldflags)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/rbconfig.rb b/rbconfig.rb
2+
index de4f173..87459fe 100644
3+
--- a/rbconfig.rb
4+
+++ b/rbconfig.rb
5+
@@ -13,7 +13,7 @@ module RbConfig
6+
raise "ruby lib version (2.7.8) doesn't match executable version (#{RUBY_VERSION})"
7+
8+
# Ruby installed directory.
9+
- TOPDIR = File.dirname(__FILE__).chomp!("/lib/ruby/2.7.0\r/x64-mingw32")
10+
+ TOPDIR = File.dirname(__FILE__).chomp!("/lib/ruby/2.7.0/x64-mingw32")
11+
# DESTDIR on make install.
12+
DESTDIR = TOPDIR && TOPDIR[/\A[a-z]:/i] || '' unless defined? DESTDIR
13+
# The hash configurations stored.
14+
@@ -54,7 +54,7 @@ module RbConfig
15+
CONFIG["sitedir"] = "$(rubylibprefix)/site_ruby"
16+
CONFIG["rubyarchdir"] = "$(rubylibdir)/$(arch)"
17+
CONFIG["rubylibdir"] = "$(rubylibprefix)/$(ruby_version)"
18+
- CONFIG["ruby_version"] = "2.7.0\r"
19+
+ CONFIG["ruby_version"] = "2.7.0"
20+
CONFIG["sitearch"] = "x64-msvcrt"
21+
CONFIG["arch"] = "x64-mingw32"
22+
CONFIG["sitearchincludedir"] = "$(includedir)/$(sitearch)"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/rbconfig.rb b/rbconfig.rb
2+
index 592dd52..a994b0a 100644
3+
--- a/rbconfig.rb
4+
+++ b/rbconfig.rb
5+
@@ -13,7 +13,7 @@ module RbConfig
6+
raise "ruby lib version (3.2.5) doesn't match executable version (#{RUBY_VERSION})"
7+
8+
# Ruby installed directory.
9+
- TOPDIR = File.dirname(__FILE__).chomp!("/lib/ruby/3.2.0\r/x64-mingw32")
10+
+ TOPDIR = File.dirname(__FILE__).chomp!("/lib/ruby/3.2.0/x64-mingw32")
11+
# DESTDIR on make install.
12+
DESTDIR = TOPDIR && TOPDIR[/\A[a-z]:/i] || '' unless defined? DESTDIR
13+
# The hash configurations stored.
14+
@@ -55,7 +55,7 @@ module RbConfig
15+
CONFIG["sitedir"] = "$(rubylibprefix)/site_ruby"
16+
CONFIG["rubyarchdir"] = "$(rubylibdir)/$(arch)"
17+
CONFIG["rubylibdir"] = "$(rubylibprefix)/$(ruby_version)"
18+
- CONFIG["ruby_version"] = "3.2.0\r"
19+
+ CONFIG["ruby_version"] = "3.2.0"
20+
CONFIG["sitearch"] = "x64-msvcrt"
21+
CONFIG["arch"] = "x64-mingw32"
22+
CONFIG["sitearchincludedir"] = "$(includedir)/$(sitearch)"

0 commit comments

Comments
 (0)