Dev set up

This commit is contained in:
2019-07-01 10:15:24 -04:00
parent da1a3d5491
commit 23a4e98668
340 changed files with 23143 additions and 41 deletions

View File

@ -0,0 +1,56 @@
#
# Cookbook:: mingw
# Resource:: get
#
# Copyright:: 2016, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Installs the core msys utilities needed for mingw/git/any other posix
# based toolchain at a desired location using mingw-get.exe.
property :package, String, name_property: true
property :root, String, required: true
resource_name :mingw_get
action_class do
def mingw_do_action(action_cmd)
seven_zip_archive "fetching mingw-get to #{win_friendly_path(root)}" do
source 'http://iweb.dl.sourceforge.net/project/mingw/Installer/mingw-get/mingw-get-0.6.2-beta-20131004-1/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip'
path root
checksum '2e0e9688d42adc68c5611759947e064156e169ff871816cae52d33ee0655826d'
not_if do
::File.exist?(::File.join(root, 'bin/mingw-get.exe'))
end
end
execute "performing #{action_cmd} for #{package}" do
command ".\\bin\\mingw-get.exe -v #{action_cmd} #{package}"
cwd root
end
end
end
action :install do
mingw_do_action('install')
end
action :upgrade do
mingw_do_action('upgrade')
end
action :remove do
mingw_do_action('remove')
end

View File

@ -0,0 +1,139 @@
#
# Cookbook:: mingw
# Resource:: msys2_package
#
# Copyright:: 2016, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Installs msys2 base system and installs/upgrades packages within in.
#
# Where's the version flag? Where's idempotence you say? Well f*** you
# for trying to version your product. This is arch. They live on the edge.
# You never get anything but the latest version. And if that's broken...
# well that's your problem isn't it? And they don't believe in preserving
# older versions. Good luck!
property :package, String, name_property: true
property :root, String, required: true
resource_name :msys2_package
action_class do
#
# Runs a command through a bash login shell made by our shim .bat file.
# The bash.bat file defaults %HOME% to #{root}/home/%USERNAME% and requests
# that the command be run in the current working directory.
#
def msys2_exec(comment, cmd)
f_root = win_friendly_path(root)
execute comment do
command ".\\bin\\bash.bat -c '#{cmd}'"
cwd f_root
live_stream true
environment('MSYSTEM' => 'MSYS')
end
end
def msys2_init
cache_dir = ::File.join(root, '.cache')
f_cache_dir = win_friendly_path(cache_dir)
base_url = node['msys2']['url']
base_checksum = node['msys2']['checksum']
unless ::File.exist?(::File.join(root, 'msys2.exe'))
seven_zip_archive "cache msys2 base to #{f_cache_dir}" do
source base_url
path f_cache_dir
checksum base_checksum
overwrite true
end
seven_zip_archive "extract msys2 base archive to #{f_cache_dir}" do
source "#{f_cache_dir}\\#{tar_name(base_url)}"
path f_cache_dir
overwrite true
end
ruby_block 'copy msys2 base files to root' do
block do
# Oh my god msys2 and pacman are picky as hell when it comes to
# updating core files. They use the mtime on certain files to
# determine if they need to updated or not and simply skip various
# steps otherwise.
::FileUtils.cp_r(::Dir.glob("#{cache_dir}/msys64/*"), root, preserve: true)
end
end
end
pacman_key_dir = ::File.join(root, 'etc/pacman.d/gnupg')
bin_dir = ::File.join(root, 'bin')
directory win_friendly_path(bin_dir)
cookbook_file win_friendly_path("#{bin_dir}/bash.bat") do
source 'bash.bat'
cookbook 'mingw'
end
cookbook_file win_friendly_path(::File.join(root, 'custom-upgrade.sh')) do
source 'custom-upgrade.sh'
cookbook 'mingw'
end
cookbook_file win_friendly_path(::File.join(root, 'etc/profile.d/custom_prefix.sh')) do
source 'custom_prefix.sh'
cookbook 'mingw'
end
# $HOME is using files from /etc/skel. The home-directory creation step
# will automatically be performed if other users log in - so if you wish
# to globally modify user first time setup, edit /etc/skel or add
# "post-setup" steps to /etc/post-install/
# The first-time init shell must be restarted and cannot be reused.
msys2_exec('msys2 first time init', 'exit') unless ::File.exist?(pacman_key_dir)
# Update pacman and msys base packages.
if ::File.exist?(::File.join(root, 'usr/bin/update-core')) || !::File.exist?(::File.join(root, 'custom-upgrade.sh'))
msys2_exec('upgrade msys2 core', '/custom-upgrade.sh')
msys2_exec('upgrade msys2 core: part 2', 'pacman -Suu --noconfirm')
# Now we can actually upgrade everything ever.
msys2_exec('upgrade entire msys2 system: 1', 'pacman -Syuu --noconfirm')
# Might need to do it once more to pick up a few stragglers.
msys2_exec('upgrade entire msys2 system: 2', 'pacman -Syuu --noconfirm')
end
end
def msys2_do_action(comment, action_cmd)
msys2_init
msys2_exec(comment, action_cmd)
end
end
action :install do
msys2_do_action("installing #{package}", "pacman -S --needed --noconfirm #{package}")
end
# Package name is ignored. This is arch. Why would you ever upgrade a single
# package and its deps? That'll just break everything else that ever depended
# on a different version of that dep. Because arch is wonderful like that.
# So you only get the choice to move everything to latest or not... it's the
# most agile development possible!
action :upgrade do
msys2_do_action("upgrading #{package}", "pacman -Syu --noconfirm #{package}")
end
action :remove do
msys2_do_action("removing #{package}", "pacman -R --noconfirm #{package}")
end

View File

@ -0,0 +1,114 @@
#
# Cookbook:: mingw
# Resource:: tdm_gcc
#
# Copyright:: 2016, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Installs a gcc based C/C++ compiler and runtime from TDM GCC.
property :flavor, Symbol, is: [:sjlj_32, :seh_sjlj_64], default: :seh_sjlj_64
property :root, String, required: true
property :version, String, is: ['5.1.0'], name_property: true
resource_name :mingw_tdm_gcc
tdm_gcc_64 = {
'http://iweb.dl.sourceforge.net/project/tdm-gcc/TDM-GCC%205%20series/5.1.0-tdm64-1/gcc-5.1.0-tdm64-1-core.tar.lzma' =>
'29393aac890847089ad1e93f81a28f6744b1609c00b25afca818f3903e42e4bd',
'http://iweb.dl.sourceforge.net/project/tdm-gcc/MinGW-w64%20runtime/GCC%205%20series/mingw64runtime-v4-git20150618-gcc5-tdm64-1.tar.lzma' =>
'29186e0bb36824b10026d78bdcf238d631d8fc1d90718d2ebbd9ec239b6f94dd',
'http://iweb.dl.sourceforge.net/project/tdm-gcc/GNU%20binutils/binutils-2.25-tdm64-1.tar.lzma' =>
'4722bb7b4d46cef714234109e25e5d1cfd29f4e53365b6d615c8a00735f60e40',
'http://iweb.dl.sourceforge.net/project/tdm-gcc/TDM-GCC%205%20series/5.1.0-tdm64-1/gcc-5.1.0-tdm64-1-c%2B%2B.tar.lzma' =>
'17fd497318d1ac187a113e8665330d746ad9607a0406ab2374db0d8e6f4094d1',
}
tdm_gcc_32 = {
'http://iweb.dl.sourceforge.net/project/tdm-gcc/TDM-GCC%205%20series/5.1.0-tdm-1%20SJLJ/gcc-5.1.0-tdm-1-core.tar.lzma' =>
'9199e6ecbce956ff4704b52098beb38e313176ace610285fb93758a08752870e',
'http://iweb.dl.sourceforge.net/project/tdm-gcc/TDM-GCC%205%20series/5.1.0-tdm-1%20SJLJ/gcc-5.1.0-tdm-1-c%2B%2B.tar.lzma' =>
'19fe46819ce43531d066b438479300027bbf06da57e8a10be5100466f80c28fc',
}
action :install do
cache_dir = ::File.join(root, '.cache')
f_root = win_friendly_path(root)
if flavor == :sjlj_32
[
'binutils-bin=2.25.1',
'libintl-dll=0.18.3.2',
'mingwrt-dll=3.21.1',
'mingwrt-dev=3.21.1',
'w32api-dev=3.17',
].each do |package_fragment|
mingw_get "install #{package_fragment} at #{f_root}" do
package "mingw32-#{package_fragment}-*"
root new_resource.root
end
end
end
to_fetch =
case flavor
when :sjlj_32
tdm_gcc_32
when :seh_sjlj_64
tdm_gcc_64
else
raise "Unknown flavor: #{flavor}"
end
to_fetch.each do |url, hash|
seven_zip_archive "cache #{archive_name(url)} to #{win_friendly_path(cache_dir)}" do
source url
path cache_dir
checksum hash
overwrite true
end
seven_zip_archive "extract #{tar_name(url)} to #{f_root}" do
source ::File.join(cache_dir, tar_name(url))
path root
overwrite true
end
end
# Patch time.h headers for compatibility with winpthreads.
# These patches were made for binutils 2.25.1 for 32-bit TDM GCC only.
if flavor == :sjlj_32
include_dir = win_friendly_path(::File.join(root, 'include'))
cookbook_file "#{include_dir}\\pthread.h" do
cookbook 'mingw'
source 'pthread.h'
end
cookbook_file "#{include_dir}\\time.h" do
cookbook 'mingw'
source 'time.h'
end
end
end
def archive_name(source)
url = ::URI.parse(source)
::File.basename(::URI.unescape(url.path))
end
def tar_name(source)
aname = archive_name(source)
::File.basename(aname, ::File.extname(aname))
end