Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support windows provision and helper script #42

Open
wants to merge 28 commits into
base: latest
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ca6fbd7
Initial work to install base packages from a file
j-rivero Jun 6, 2023
cfaaabd
Fix windows code
j-rivero Jun 7, 2023
f67ef9c
fully qualifies recipe
j-rivero Jun 7, 2023
3fd22a2
Restrict docker to linux
j-rivero Jun 7, 2023
542f882
Add more packages to provisioning
j-rivero Jun 7, 2023
67e5969
Install berks + python
j-rivero Jun 7, 2023
591e251
Install pip directly no with chef
j-rivero Jun 7, 2023
0b36cef
Try to avoid berkshelf installation
j-rivero Jun 7, 2023
dbd85af
Exact ruby version
j-rivero Jun 7, 2023
574c9f1
Added 1.4.4 poise/python cookbook
j-rivero Jun 9, 2023
faac0b6
Use python_package to install vcs and colcon
j-rivero Jun 9, 2023
3f11545
Remove python
j-rivero Jun 12, 2023
3ee57f4
Add vcpkg patches
j-rivero Jun 12, 2023
095236e
Move python install to its own recipes from ros2-cookbooks
j-rivero Jun 13, 2023
1d8b505
Reuse visual studio from ros2
j-rivero Jun 13, 2023
4c34ba0
Install chef from choco
j-rivero Jun 13, 2023
8628c06
Update bootstrap
j-rivero Jun 13, 2023
320e7de
Fix version
j-rivero Jun 13, 2023
e30673e
Patch for python.exe installer
j-rivero Jun 14, 2023
cd91a8b
Patch for selecting community in visual_studio
j-rivero Jun 14, 2023
8a84047
Move vcpkg installation to a file
j-rivero Jun 14, 2023
bd88bbb
Fixes to ruby syntax
j-rivero Jun 14, 2023
d24baf4
Add custom osrf-vcpkg dir
j-rivero Jun 14, 2023
a4a6e0f
Need atlmfc package from vcpkg that requires support
j-rivero Jun 15, 2023
2eeedc2
Use cuda installer
j-rivero Jun 15, 2023
8e66534
Add README for the helper script
j-rivero Jun 20, 2023
53c39d5
Update bootstrap-windows-base-packages.ps1
j-rivero Jun 20, 2023
fa12a6b
Need to include cmake in PATH
j-rivero Jun 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions files/vcpkg-patches/msys.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
To solve: microsoft/vcpkg#30546.

From 1fb05211dbf8af15745b44d9d760e07ccf2797d1 Mon Sep 17 00:00:00 2001
From: Mengna-Li <[email protected]>
Date: Thu, 30 Mar 2023 10:15:17 +0000
Subject: [PATCH] update runtime version

---
scripts/cmake/vcpkg_acquire_msys.cmake | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/cmake/vcpkg_acquire_msys.cmake b/scripts/cmake/vcpkg_acquire_msys.cmake
index 8b0b3d931d74e..67441df14b549 100644
--- a/scripts/cmake/vcpkg_acquire_msys.cmake
+++ b/scripts/cmake/vcpkg_acquire_msys.cmake
@@ -343,8 +343,8 @@ function(vcpkg_acquire_msys out_msys_root)
DEPS msys2-runtime
)
z_vcpkg_acquire_msys_declare_package(
- URL "https://repo.msys2.org/msys/x86_64/msys2-runtime-3.2.0-8-x86_64.pkg.tar.zst"
- SHA512 fdd86f4ffa6e274d6fef1676a4987971b1f2e1ec556eee947adcb4240dc562180afc4914c2bdecba284012967d3d3cf4d1a392f798a3b32a3668d6678a86e8d3
+ URL "https://repo.msys2.org/msys/x86_64/msys2-runtime-3.4.6-1-x86_64.pkg.tar.zst"
+ SHA512 fbdcf2572d242b14ef3b39f29a6119ee58705bad651c9da48ffd11e80637e8d767d20ed5d562f67d92eecd01f7fc3bc351af9d4f84fb9b321d2a9aff858b3619
)
z_vcpkg_acquire_msys_declare_package(
URL "https://repo.msys2.org/msys/x86_64/which-2.21-4-x86_64.pkg.tar.zst"
From 0912a1a3cc5ebe16181d39f302ddab258f5b757d Mon Sep 17 00:00:00 2001
From: Jonliu1993 <[email protected]>
Date: Fri, 13 Jan 2023 15:34:32 +0800
Subject: [PATCH 1/2] [vcpkg] update msys-libiconv versio

---
scripts/cmake/vcpkg_acquire_msys.cmake | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/cmake/vcpkg_acquire_msys.cmake b/scripts/cmake/vcpkg_acquire_msys.cmake
index 98effb4f9ef32..5cfdd1dc67960 100644
--- a/scripts/cmake/vcpkg_acquire_msys.cmake
+++ b/scripts/cmake/vcpkg_acquire_msys.cmake
@@ -184,8 +184,8 @@ function(vcpkg_acquire_msys out_msys_root)
DEPS libiconv libintl
)
z_vcpkg_acquire_msys_declare_package(
- URL "https://repo.msys2.org/msys/x86_64/libtool-2.4.6-9-x86_64.pkg.tar.xz"
- SHA512 b309799e5a9d248ef66eaf11a0bd21bf4e8b9bd5c677c627ec83fa760ce9f0b54ddf1b62cbb436e641fbbde71e3b61cb71ff541d866f8ca7717a3a0dbeb00ebf
+ URL "https://repo.msys2.org/msys/x86_64/libtool-2.4.6-14-x86_64.pkg.tar.zst"
+ SHA512 ba983ed9c2996d06b0d21b8fab9505267115f2106341f130e92d6b66dad87b0f0e82707daf0b676a28966bfaa24f6c41b6eef9e1f9bf985611471024f2b0ac97
DEPS grep sed coreutils file findutils
)
z_vcpkg_acquire_msys_declare_package(
39 changes: 39 additions & 0 deletions files/vcpkg-patches/release-only.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
diff --git a/triplets/x64-windows.cmake b/triplets/x64-windows.cmake
index d0be7297f..bd6b9f271 100644
--- a/triplets/x64-windows.cmake
+++ b/triplets/x64-windows.cmake
@@ -2,3 +2,4 @@ set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)

+set(VCPKG_BUILD_TYPE release)

diff --git a/ports/dlfcn-win32/portfile.cmake b/ports/dlfcn-win32/portfile.cmake
index 29726bcc3..1b2e8b4ba 100644
--- a/ports/dlfcn-win32/portfile.cmake
+++ b/ports/dlfcn-win32/portfile.cmake
@@ -14,12 +14,7 @@ vcpkg_cmake_configure(

vcpkg_cmake_install()

-file(READ "${CURRENT_PACKAGES_DIR}/debug/share/dlfcn-win32/dlfcn-win32-targets-debug.cmake" dlfcn-win32_DEBUG_MODULE)
-string(REPLACE "\${_IMPORT_PREFIX}" "\${_IMPORT_PREFIX}/debug" dlfcn-win32_DEBUG_MODULE "${dlfcn-win32_DEBUG_MODULE}")
-file(WRITE "${CURRENT_PACKAGES_DIR}/share/dlfcn-win32/dlfcn-win32-targets-debug.cmake" "${dlfcn-win32_DEBUG_MODULE}")

-file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
-file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

vcpkg_copy_pdbs()

diff --git a/ports/ode/portfile.cmake b/ports/ode/portfile.cmake
index 9b68b29f7..cc4dcadca 100644
--- a/ports/ode/portfile.cmake
+++ b/ports/ode/portfile.cmake
@@ -18,7 +18,6 @@ if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
else()
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/bin/ode-config" "${CURRENT_PACKAGES_DIR}" "`dirname $0`/..")
- vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/bin/ode-config" "${CURRENT_PACKAGES_DIR}" "`dirname $0`/../..")
endif()
file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
11 changes: 8 additions & 3 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
version "0.1.4"
chef_version ">= 14.0"

# be careful if set a version on docker since it can conflict with other
# repositories (chef-osrf)
depends "docker"
# For adding dependencies on Windows pleaes check the tools/ directory
# to be sure that bootstrap tools script is not broken afterwards

if platform?('linux')
# be careful if set a version on docker since it can conflict with other
# repositories (chef-osrf)
depends "docker"
end
18 changes: 18 additions & 0 deletions recipes/pip_installs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
required_pip_packages = %w[
vcstool
colcon-common-extensions
]

# Use explicit location because python may not be on the PATH if chef-solo has not been run before
#
execute 'pip_update' do
command lazy {
"#{node.run_state[:python_dir]}\\python.exe -m pip install -U pip setuptools==59.6.0"
}
end

execute 'pip_required' do
command lazy {
"#{node.run_state[:python_dir]}\\python.exe -m pip install -U #{required_pip_packages.join(' ')}"
}
end
11 changes: 11 additions & 0 deletions recipes/python.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
python_version = "3.11.2"
python_dir = "C:\\Python#{python_version.split('.')[0..1].join}"

# Add this value to the chef run state for use in the pip_installs recipe.
node.run_state[:python_dir] = python_dir

windows_package 'python' do
source "https://www.python.org/ftp/python/#{python_version}/python-#{python_version}-amd64.exe"
options "/quiet TargetDir=#{python_dir} PrependPath=1 Include_debug=1 Include_symbols=1"
installer_type :custom
end
57 changes: 57 additions & 0 deletions recipes/vcpkg.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
vcpkg_dir = 'C:/vcpkg'

# TODO: (j-rivero): grab the snapshot tab from release-tools once the
# gz-collections.yaml is ready with that info
git vcpkg_dir do
repository 'https://github.com/microsoft/vcpkg.git'
revision '2022.02.23'
action :sync
end

# This should be in sync with release-tools scripts
git "#{vcpkg_dir}/osrf_vcpkg_ports" do
repository 'https://github.com/osrf/vcpkg-ports/'
revision 'master'
action :sync
end

execute 'bootstrap-vcpkg' do
command "#{vcpkg_dir}/bootstrap-vcpkg.bat"
cwd vcpkg_dir
action :run
end

chocolatey_package 'patch'

patches_temp = "#{vcpkg_dir}/.osrf_snapshot_patches"
patches_applied = "#{patches_temp}/PACTHES_APPLIED"

directory patches_temp do
action :create
end

vcpkg_patches = %w(
msys.patch
release-only.patch
)

# Copy the .patch files to a temporary directory
vcpkg_patches.each do |file|
cookbook_file "#{patches_temp}\#{file}" do
source "vcpkg-patches/#{file}"
action :create
not_if { ::File.exist?(patches_applied) }
end

batch 'apply_patches' do
cwd vcpkg_dir
code "patch -p1 -i #{patches_temp}\#{file}"
action :run
not_if { ::File.exist?(patches_applied) }
end
end

file patches_applied do
action :create
not_if { ::File.exist?(patches_applied) }
end
66 changes: 66 additions & 0 deletions recipes/visual_studio.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# For more information about command line arguments, see:
# https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2019

# If BuildTools is not already installed, install it
packages_to_install = %w[
Microsoft.Component.MSBuild
Microsoft.Net.Component.4.6.1.TargetingPack
Microsoft.Net.Component.4.8.SDK
Microsoft.VisualStudio.Component.CoreBuildTools
Microsoft.VisualStudio.Component.Roslyn.Compiler
Microsoft.VisualStudio.Component.TextTemplating
Microsoft.VisualStudio.Component.VC.ATL
Microsoft.VisualStudio.Component.VC.ATLMFC
Microsoft.VisualStudio.Component.VC.CLI.Support
Microsoft.VisualStudio.Component.VC.CoreBuildTools
Microsoft.VisualStudio.Component.VC.CoreIde
Microsoft.VisualStudio.Component.VC.Redist.14.Latest
Microsoft.VisualStudio.Component.VC.Tools.x86.x64
Microsoft.VisualStudio.Component.Windows10SDK
Microsoft.VisualStudio.Component.Windows10SDK.19041
Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core
Microsoft.VisualStudio.Workload.MSBuildTools
Microsoft.VisualStudio.Workload.VCTools
]

package_arguments = packages_to_install.map{ |pkg| '--add ' + pkg}.join(' ')
base_options = '--quiet --wait --norestart '

installer_options = base_options + package_arguments

node.default['vs_version'] = 'community'

visual_studio_source = 'https://aka.ms/vs/16/release/vs_%s.exe' % node['vs_version']

vs_version_camel_case = {
'buildtools' => 'BuildTools',
'community' => 'Community',
'professional' => 'Professional',
'enterprise' => 'Enterprise'
}[node['vs_version']]

visual_studio_path = 'c:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\%s' % vs_version_camel_case
windows_package 'Update VS' do
source visual_studio_source
installer_type :custom
returns [0, 3010]
options 'update ' + installer_options
timeout 1200
only_if {::Dir.exist?(visual_studio_path)}
end

windows_package 'Install vs_buildtools' do
source visual_studio_source
installer_type :custom
action :install
returns [0, 1605, 1614, 1641, 3010]
options installer_options
timeout 1200
not_if {::Dir.exist?(visual_studio_path)}
end

windows_env 'VCTargetsPath' do
key_name 'VCTargetsPath'
value File.join(visual_studio_path, 'MSBuild\\Microsoft\\VC\\v160\\')
action :create
end
37 changes: 37 additions & 0 deletions recipes/windows_agent_build_tools.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
windows_package 'Install cuda' do
source 'https://developer.download.nvidia.com/compute/cuda/12.0.1/local_installers/cuda_12.0.1_528.33_windows.exe'
installer_type :custom
options '/s'
end

include_recipe 'osrf_jenkins_agent::python'
include_recipe 'osrf_jenkins_agent::pip_installs'
include_recipe 'osrf_jenkins_agent::visual_studio'

chocolatey_package 'meinberg-ntp'

chocolatey_package 'wget'

chocolatey_package 'ruby' do
version [ '3.1.3.1' ]
end

chocolatey_package 'cmake' do
version [ '3.25' ]
end

windows_env 'PATH' do
key_name 'PATH'
value 'C:\\Program Files\\Git\\cmd;C:\\Program Files\\CMake\\bin'
delim ';'
action :modify
end

# AdoptOpenJDK installer documentation https://adoptopenjdk.net/installation.html#windows-msi
windows_package 'openjdk' do
options 'INSTALLLEVEL=1 /quiet'
source 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u242-b08_openj9-0.18.1/OpenJDK8U-jdk_x64_windows_openj9_8u242b08_openj9-0.18.1.msi'
action :install
end

include_recipe 'osrf_jenkins_agent::vcpkg'
18 changes: 18 additions & 0 deletions tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Provision a system with the base software

In order to bring only the software dependencies used by the build agent to build software but do not link it to the buildfarm
the helper script in this repository can be used. It will install chocolatey for installing git and chefdk and run chef
installations to create a development enviroment which includes different system installations (CUDA, Visual Studio, etc) and
the vcpkg installtion on `C:\vcpkg`.

To run the helper:


```powershell
Set-ExecutionPolicy Bypass -Scope Process -Force;. { iwr -useb https://raw.githubusercontent.com/osrf/osrf_jenkins_agent/latest/tools/bootstrap-windows-base-packages.ps1 } | iex

# Close the powershell and reopen (to get the git installation correctly)
# run again

Set-ExecutionPolicy Bypass -Scope Process -Force;. { iwr -useb https://raw.githubusercontent.com/osrf/osrf_jenkins_agent/latest/tools/bootstrap-windows-base-packages.ps1 } | iex
```
11 changes: 11 additions & 0 deletions tools/bootstrap-windows-base-packages.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$ErrorActionPreference = 'Stop'
Set-ExecutionPolicy Bypass -Scope Process -Force;. { iwr -useb https://chocolatey.org/install.ps1 } | iex
choco install -y git chefdk
refreshenv
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
Write-Host "NEEDS TO CLOSE POWERSHELL AND RUN AGAIN TO MAKE GIT WORK"

git clone --verbose --progress https://github.com/osrf/osrf_jenkins_agent.git
cd osrf_jenkins_agent\tools
chef-solo.bat -c ..\solo.rb -j osrf-windows-agent-pkgs.solo.json
Write-Host "Completed chef-solo result $?"
5 changes: 5 additions & 0 deletions tools/osrf-windows-agent-pkgs.solo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"run_list": ["recipe[osrf_jenkins_agent::windows_agent_build_tools]"],
"override_attributes": {
}
}