diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75131a9..cb972e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ name: ci jobs: lint-unit: - uses: sous-chefs/.github/.github/workflows/lint-unit.yml@5.0.8 + uses: sous-chefs/.github/.github/workflows/lint-unit.yml@6.0.0 permissions: actions: write checks: write @@ -18,32 +18,28 @@ jobs: integration: needs: lint-unit - runs-on: windows-2025 + runs-on: windows-latest strategy: matrix: - os: - - "windows-2019" suite: - - "tools32" - - "tools64" - - "msys2-tools64" + - default + - tools32 + - tools64 + - msys2-tools64 fail-fast: false steps: - name: Check out code uses: actions/checkout@v5 - - name: Install Chef - uses: actionshub/chef-install@main - - name: test-kitchen - uses: actionshub/test-kitchen@main + - name: Install Cinc Workstation + uses: sous-chefs/.github/.github/actions/install-workstation@6.0.0 + - name: Test Kitchen + run: kitchen test ${{ matrix.suite }} env: CHEF_LICENSE: accept-no-persist KITCHEN_LOCAL_YAML: kitchen.exec.yml - with: - suite: ${{ matrix.suite }} - os: ${{ matrix.os }} final: runs-on: ubuntu-latest needs: [integration] steps: - - run: echo ${{needs.integration.outputs}} + - run: echo Done diff --git a/.github/workflows/prevent-file-change.yml b/.github/workflows/prevent-file-change.yml index abbb46d..357dd73 100644 --- a/.github/workflows/prevent-file-change.yml +++ b/.github/workflows/prevent-file-change.yml @@ -9,8 +9,11 @@ name: prevent-file-change - edited - synchronize +permissions: + pull-requests: write + jobs: prevent-file-change: - uses: sous-chefs/.github/.github/workflows/prevent-file-change.yml@5.0.8 + uses: sous-chefs/.github/.github/workflows/prevent-file-change.yml@6.0.0 secrets: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4db4a8d..e892f26 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,8 +16,10 @@ permissions: jobs: release: - uses: sous-chefs/.github/.github/workflows/release-cookbook.yml@5.0.8 + uses: sous-chefs/.github/.github/workflows/release-cookbook.yml@6.0.0 secrets: token: ${{ secrets.PORTER_GITHUB_TOKEN }} supermarket_user: ${{ secrets.CHEF_SUPERMARKET_USER }} supermarket_key: ${{ secrets.CHEF_SUPERMARKET_KEY }} + slack_bot_token: ${{ secrets.SLACK_BOT_TOKEN }} + slack_channel_id: ${{ secrets.SLACK_CHANNEL_ID }} diff --git a/.markdownlint-cli2.yaml b/.markdownlint-cli2.yaml index ac5076b..e42be9b 100644 --- a/.markdownlint-cli2.yaml +++ b/.markdownlint-cli2.yaml @@ -7,3 +7,4 @@ config: maximum: 2 ignores: - .github/copilot-instructions.md + - .windsurf/** diff --git a/Berksfile b/Berksfile index 8d7e06d..34fea21 100644 --- a/Berksfile +++ b/Berksfile @@ -1,12 +1,3 @@ -def fixture(name) - cookbook "mingw_#{name}", path: "test/fixtures/cookbooks/mingw_#{name}" -end - source 'https://supermarket.chef.io' metadata - -group :integration do - fixture 'tdm_install' - fixture 'msys2_install' -end diff --git a/LIMITATIONS.md b/LIMITATIONS.md new file mode 100644 index 0000000..ef82b9f --- /dev/null +++ b/LIMITATIONS.md @@ -0,0 +1,34 @@ +# Limitations + +## Package Availability + +This cookbook manages Windows toolchains. It does not use APT, DNF/YUM, or Zypper package repositories. + +### MSYS2 + +* MSYS2 pre-built packages currently require 64-bit Windows 10 or Windows Server 2016 or later. +* The MSYS2 GUI installer currently requires 64-bit Windows 10 1809 or Windows Server 2019 or later. +* MSYS2 still publishes `x86_64` base archives from `https://repo.msys2.org/distrib/x86_64/`. +* 32-bit Windows MSYS2 archives are no longer actively supported. +* The `MINGW32` and `MINGW64` environments can still target Windows 7 and later, but running current MSYS2 packages requires a newer host OS. + +### MinGW and TDM-GCC + +* `mingw_get` and `mingw_tdm_gcc` install legacy SourceForge-hosted archives. +* TDM-GCC 5.1.0 artifacts are from 2015 and should be treated as legacy compatibility tooling. +* The cookbook only supports the TDM-GCC archive checksums already encoded in the resource. + +## Architecture Limitations + +* The MSYS2 default base archive used by this cookbook is `x86_64`. +* `msys2_package` package names decide whether 32-bit or 64-bit MinGW packages are installed inside the MSYS2 root. +* `mingw_tdm_gcc` supports the existing `:sjlj_32` and `:seh_sjlj_64` flavors only. + +## Source/Compiled Installation + +This cookbook installs pre-built toolchain archives and packages. It does not build MinGW, MSYS2, or TDM-GCC from source. + +## Known Issues + +* Windows Server 2012 R2 is no longer a suitable default test target. Microsoft regular support ended on October 10, 2023, and MSYS2 dropped active support for Windows 8.1 / Windows Server 2012 R2 on February 28, 2026. +* `mingw_get` and `mingw_tdm_gcc` rely on old SourceForge URLs. They remain for compatibility but MSYS2 should be preferred for new installs. diff --git a/README.md b/README.md index fb54b06..165fef0 100644 --- a/README.md +++ b/README.md @@ -1,52 +1,58 @@ # mingw Cookbook -Installs a mingw/msys based compiler tools chain on windows. This is required for compiling C software from source. +Installs MinGW / MSYS2 / TDM-GCC compiler toolchains on Windows. Use it to bootstrap a C/C++ build environment for software that needs to be compiled from source. ## Requirements ### Platforms -- Windows +- Windows Server 2019, 2022, 2025 (or equivalent client SKUs) ### Chef -- Chef 15.3+ +- Chef Infra Client 16+ ### Cookbooks -- seven_zip +None. + +## Upgrading from 4.x + +The 4.x line shipped a `mingw::default` recipe and `node['msys2']` attributes. Both have been removed in favor of resource properties. See [migration.md](./migration.md) for a step-by-step upgrade guide. ## Usage -Add this cookbook as a dependency to your cookbook in its `metadata.rb` and include the default recipe in one of your recipes. +Add the cookbook as a dependency: ```ruby # metadata.rb depends 'mingw' ``` +Then call any of the resources from your own recipes — there is no recipe to include. + ```ruby # your recipe.rb -include_recipe 'mingw::default' +msys2_package 'base-devel' do + root 'C:\msys2' +end ``` -Use the `msys2_package` resource in any recipe to fetch msys2 based packages. Use the `mingw_get` resource in any recipe to fetch mingw packages. Use the `mingw_tdm_gcc` resource to fetch a version of the TDM GCC compiler. +By default, prefer the MSYS2 packages: they are newer and better supported. -By default, you should prefer the msys2 packages as they are newer and better supported. C/C++ compilers on windows use various different exception formats and you need to pick the right one for your task. In the 32-bit world, you have SJLJ (set-jump/long-jump) based exception handling and DWARF-2 (shortened to DW2) based exception handling. SJLJ produces code that can happily throw exceptions across stack frames of code compiled by MSVC. DW2 involves more extensive metadata but produces code that cannot unwind MSVC generated stack-frames - hence you need to ensure that you don't have any code that throws across a "system call". Certain languages and runtimes have specific requirements as to the exception format supported. As an example, if you are building code for Rust, you will probably need a modern gcc from msys2 with DW2 support as that's what the panic/exception formatter in Rust depends on. In a 64-bit world, you may still use SJLJ but compilers all commonly support SEH (structured exception handling). +C/C++ compilers on Windows use different exception formats and you need to pick the one your build expects. In 32-bit, you have SJLJ (set-jump/long-jump) and DWARF-2 (DW2). SJLJ can throw across MSVC-built stack frames; DW2 cannot. Some toolchains require a specific format — for example, Rust needs a modern gcc from MSYS2 with DW2. In 64-bit you can still use SJLJ but compilers commonly support SEH (structured exception handling) too. -Of course, to further complicate matters, different versions of different compilers support different exception handling. The default compilers that come with mingw_get are 32-bit only compilers and support DW2\. The TDM compilers come in 3 flavors: a 32-bit only version with SJLJ support, a 32-bit only version with DW2 support and a "multilib" compiler which supports only SJLJ in 32-bit mode but can produce 64-bit SEH code. The standard library support varies drastically between these various compiler flavors (even within the same version). In msys2, you can install a mingw-w64 based compilers for either 32-bit DW2 support or 64-bit SEH support. If all this hurts your brain, I can only apologize. +The compilers shipped via `mingw_get` are 32-bit DW2. TDM-GCC ships in three flavors: 32-bit SJLJ, 32-bit DW2, and a multi-lib that builds 64-bit SEH and 32-bit SJLJ. MSYS2 lets you install mingw-w64 toolchains for either 32-bit DW2 or 64-bit SEH. ## Resources -- [minw_get](./documentation/mingw_get.md) +- [mingw_get](./documentation/mingw_get.md) - [mingw_tdm_gcc](./documentation/mingw_tdm_gcc.md) - [msys2_package](./documentation/msys2_package.md) ## License & Authors -**Author:** Cookbook Engineering Team ([cookbooks@chef.io](mailto:cookbooks@chef.io)) - -**Copyright:** 2009-2016, Chef Software, Inc. +**Author:** Sous Chefs ([help@sous-chefs.org](mailto:help@sous-chefs.org)) ```text Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/attributes/default.rb b/attributes/default.rb deleted file mode 100644 index 9176ec3..0000000 --- a/attributes/default.rb +++ /dev/null @@ -1,3 +0,0 @@ -# override these attributes to pull the msys2 package from a custom url -default['msys2']['url'] = 'http://downloads.sourceforge.net/project/msys2/Base/x86_64/msys2-base-x86_64-20160205.tar.xz' -default['msys2']['checksum'] = '7e97e2af042e1b6f62cf0298fe84839014ef3d4a3e7825cffc6931c66cc0fc20' diff --git a/documentation/mingw_get.md b/documentation/mingw_get.md index 0dca24b..1eded6c 100644 --- a/documentation/mingw_get.md +++ b/documentation/mingw_get.md @@ -1,19 +1,23 @@ # mingw_get +Manages legacy MinGW packages from SourceForge using `mingw-get.exe`. Prefer `msys2_package` for new installs; `mingw_get` exists for compatibility with legacy toolchains and is required by `mingw_tdm_gcc` in 32-bit mode. + ## Actions -- `:install` - Installs a mingw package from sourceforge using mingw-get.exe. -- `:remove` - Uninstalls a mingw package. -- `:upgrade` - Upgrades a mingw package (even to a lower version). +- `:install` - Installs the named mingw-get package. Default action. +- `:remove` - Uninstalls the named mingw-get package. +- `:upgrade` - Upgrades the named mingw-get package (may downgrade). -## Parameters +## Properties -- `package` - A mingw-get package (or meta-package) to fetch and install. You may use a legal package wild-card pattern here if you are installing. This is the name attribute. -- `root` - The root directory where msys and mingw tools will be installed. This directory must not contain any spaces in order to pacify old posix tools and most Makefiles. +- `package` - A mingw-get package or meta-package. Wildcards are accepted. This is the name attribute. +- `root` - The directory where MinGW/MSYS will be installed. Must not contain spaces. +- `source_url` - URL to the `mingw-get` archive. Defaults to the SourceForge mirror that the cookbook ships with. +- `checksum` - SHA-256 checksum of the `mingw-get` archive. ## Examples -To get the core msys developer tools in `C:\mingw32` +Install the core MSYS developer tools at `C:\mingw32`: ```ruby mingw_get 'msys-base=2013072300-msys-bin.meta' do diff --git a/documentation/mingw_tdm_gcc.md b/documentation/mingw_tdm_gcc.md index be5ec68..2a670bd 100644 --- a/documentation/mingw_tdm_gcc.md +++ b/documentation/mingw_tdm_gcc.md @@ -1,18 +1,21 @@ # mingw_tdm_gcc +Installs a TDM-GCC compiler toolchain on Windows. Provides a compiler only — pair with `mingw_get` (or `msys2_package`) for support tools (`make`, `grep`, `awk`, `bash`, etc.). + ## Actions -- `:install` - Installs the TDM compiler toolchain at the given path. This only gives you a compiler. If you need any support tooling such as make/grep/awk/bash etc., see `mingw_get`. +- `:install` - Downloads and extracts the TDM-GCC archives at `root`. Default action. +- `:remove` - Recursively deletes the install root. -## Parameters +## Properties -- `flavor` - Either `:sjlj_32` or `:seh_sjlj_64`. TDM-64 is a 32/64-bit multi-lib "cross-compiler" toolchain that builds 64-bit by default. It uses structured exception handling (SEH) in 64-bit code and setjump-longjump exception handling (SJLJ) in 32-bit code. TDM-32 only builds 32-bit binaries and uses SJLJ. -- `root` - The root directory where compiler tools and runtime will be installed. This directory must not contain any spaces in order to pacify old posix tools and most Makefiles. -- `version` - The version of the compiler to fetch and install. This is the name attribute. Currently, '5.1.0' is supported. +- `flavor` - Either `:sjlj_32` or `:seh_sjlj_64`. The 64-bit flavor is a multi-lib cross-compiler that defaults to 64-bit output and uses SEH for 64-bit code; SJLJ for any 32-bit code it produces. The 32-bit flavor only builds 32-bit binaries and uses SJLJ. +- `root` - The install root. Must not contain spaces. +- `version` - The TDM-GCC version. Currently only `'5.1.0'` is supported. This is the name attribute. ## Examples -To get the 32-bit TDM GCC compiler in `C:\mingw32` +Install the 32-bit TDM-GCC compiler at `C:\mingw32`: ```ruby mingw_tdm_gcc '5.1.0' do @@ -20,3 +23,21 @@ mingw_tdm_gcc '5.1.0' do root 'C:\mingw32' end ``` + +Install the 64-bit TDM-GCC compiler at `C:\mingw64`: + +```ruby +mingw_tdm_gcc '5.1.0' do + flavor :seh_sjlj_64 + root 'C:\mingw64' +end +``` + +Remove a TDM-GCC install (deletes the entire `root` tree): + +```ruby +mingw_tdm_gcc '5.1.0' do + root 'C:\mingw64' + action :remove +end +``` diff --git a/documentation/msys2_package.md b/documentation/msys2_package.md index c46db21..5f50882 100644 --- a/documentation/msys2_package.md +++ b/documentation/msys2_package.md @@ -1,27 +1,47 @@ # msys2_package -- ':install' - Installs an msys2 package using pacman. -- ':remove' - Uninstalls any existing msys2 package. -- ':upgrade' - Upgrades the specified package using pacman. +Manages MSYS2 packages on Windows. The first call against a given `root` bootstraps the MSYS2 base file system at that path; subsequent calls reuse it. -All options also automatically attempt to install a 64-bit based msys2 base file system at the root path specified. Note that you probably won't need a "32-bit" msys2 unless you are actually on a 32-bit only platform. You can still install both 32 and 64-bit compilers and libraries in a 64-bit msys2 base file system. +## Actions -## Attributes +- `:install` - Installs the named MSYS2 package via `pacman -S --needed --noconfirm`. Default action. +- `:remove` - Uninstalls the named MSYS2 package via `pacman -R --noconfirm`. +- `:upgrade` - Upgrades the named MSYS2 package (and all dependencies — pacman) via `pacman -Syu --noconfirm`. -- `node['msys2']['url']` - overrides the url from which to download the package. -- `node['msys2']['checksum']` - overrides the checksum used to verify the downloaded package. +All actions automatically install the 64-bit MSYS2 base file system at `root` if it is not already present. You will not normally need a 32-bit MSYS2 base; you can still install both 32-bit and 64-bit compilers and libraries from inside a 64-bit base. -## Parameters +## Properties -- `package` - An msys2 pacman package (or meta-package) to fetch and install. You may use a legal package wild-card pattern here if you are installing. This is the name attribute. -- `root` - The root directory where msys2 tools will be installed. This directory must not contain any spaces in order to pacify old posix tools and most Makefiles. +- `package` - The pacman package (or meta-package) name. Wildcards are accepted by pacman. This is the name attribute. +- `root` - The directory where the MSYS2 base file system lives (and where `pacman` runs). Must not contain spaces. +- `source_url` - URL to the MSYS2 base archive. Defaults to the SourceForge `msys2-base-x86_64-20160205.tar.xz` mirror that the cookbook ships with. +- `checksum` - SHA-256 checksum of the base archive. Must match `source_url`. ## Examples -To get the core msys2 developer tools in `C:\msys2` +Install the `base-devel` meta-package using the bundled MSYS2 base archive: ```ruby msys2_package 'base-devel' do root 'C:\msys2' end ``` + +Pin the cookbook to a custom MSYS2 base archive: + +```ruby +msys2_package 'base-devel' do + root 'C:\msys2' + source_url 'https://example.test/msys2-base-x86_64.tar.xz' + checksum 'abc123...' +end +``` + +Remove a package: + +```ruby +msys2_package 'base-devel' do + root 'C:\msys2' + action :remove +end +``` diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml deleted file mode 100644 index 47eff95..0000000 --- a/kitchen.dokken.yml +++ /dev/null @@ -1,113 +0,0 @@ -driver: - name: dokken - privileged: true - chef_version: <%= ENV['CHEF_VERSION'] || 'current' %> - -transport: { name: dokken } -provisioner: { name: dokken } - -platforms: - - name: almalinux-8 - driver: - image: dokken/almalinux-8 - pid_one_command: /usr/lib/systemd/systemd - - - name: almalinux-9 - driver: - image: dokken/almalinux-9 - pid_one_command: /usr/lib/systemd/systemd - - - name: amazonlinux-2023 - driver: - image: dokken/amazonlinux-2023 - pid_one_command: /usr/lib/systemd/systemd - - - name: centos-7 - driver: - image: dokken/centos-7 - pid_one_command: /usr/lib/systemd/systemd - - - name: centos-stream-8 - driver: - image: dokken/centos-stream-8 - pid_one_command: /usr/lib/systemd/systemd - - - name: centos-stream-9 - driver: - image: dokken/centos-stream-9 - pid_one_command: /usr/lib/systemd/systemd - - - name: debian-9 - driver: - image: dokken/debian-9 - pid_one_command: /bin/systemd - - - name: debian-10 - driver: - image: dokken/debian-10 - pid_one_command: /bin/systemd - - - name: debian-11 - driver: - image: dokken/debian-11 - pid_one_command: /bin/systemd - - - name: debian-12 - driver: - image: dokken/debian-12 - pid_one_command: /bin/systemd - - - name: fedora-latest - driver: - image: dokken/fedora-latest - pid_one_command: /usr/lib/systemd/systemd - - - name: opensuse-leap-15 - driver: - image: dokken/opensuse-leap-15 - pid_one_command: /usr/lib/systemd/systemd - - - name: oraclelinux-7 - driver: - image: dokken/oraclelinux-7 - pid_one_command: /usr/lib/systemd/systemd - - - name: oraclelinux-8 - driver: - image: dokken/oraclelinux-8 - pid_one_command: /usr/lib/systemd/systemd - - - name: oraclelinux-9 - driver: - image: dokken/oraclelinux-9 - pid_one_command: /usr/lib/systemd/systemd - - - name: rockylinux-8 - driver: - image: dokken/rockylinux-8 - pid_one_command: /usr/lib/systemd/systemd - - - name: rockylinux-9 - driver: - image: dokken/rockylinux-9 - pid_one_command: /usr/lib/systemd/systemd - - - name: ubuntu-18.04 - driver: - image: dokken/ubuntu-18.04 - pid_one_command: /bin/systemd - - - name: ubuntu-20.04 - driver: - image: dokken/ubuntu-20.04 - pid_one_command: /bin/systemd - - - name: ubuntu-22.04 - driver: - image: dokken/ubuntu-22.04 - pid_one_command: /bin/systemd - - - name: ubuntu-23.04 - driver: - image: dokken/ubuntu-23.04 - pid_one_command: /bin/systemd diff --git a/kitchen.exec.yml b/kitchen.exec.yml index ba7b2a9..ada987f 100644 --- a/kitchen.exec.yml +++ b/kitchen.exec.yml @@ -1,7 +1,47 @@ --- -driver: { name: exec } -transport: { name: exec } +driver: + name: exec + +transport: + name: exec + +provisioner: + name: chef_zero + product_name: cinc + chef_omnibus_install: false + chef_license: accept + enforce_idempotency: true + multiple_converge: 2 + deprecations_as_errors: true + +verifier: + name: inspec platforms: - - name: macos-latest - - name: windows-latest + - name: windows-2022 + +suites: + - name: default + run_list: + - recipe[test::default] + verifier: + inspec_tests: + - test/integration/default + - name: tools32 + run_list: + - recipe[test::tools32] + verifier: + inspec_tests: + - test/integration/tools32 + - name: tools64 + run_list: + - recipe[test::tools64] + verifier: + inspec_tests: + - test/integration/tools64 + - name: msys2_tools64 + run_list: + - recipe[test::msys2_tools64] + verifier: + inspec_tests: + - test/integration/msys2_tools64 diff --git a/kitchen.global.yml b/kitchen.global.yml deleted file mode 100644 index a382fcd..0000000 --- a/kitchen.global.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- -provisioner: - name: chef_infra - product_name: chef - product_version: <%= ENV['CHEF_VERSION'] || 'latest' %> - channel: stable - install_strategy: once - chef_license: accept - enforce_idempotency: <%= ENV['ENFORCE_IDEMPOTENCY'] || true %> - multiple_converge: <%= ENV['MULTIPLE_CONVERGE'] || 2 %> - deprecations_as_errors: true - log_level: <%= ENV['CHEF_LOG_LEVEL'] || 'auto' %> - -verifier: - name: inspec - -platforms: - - name: almalinux-8 - - name: almalinux-9 - - name: amazonlinux-2023 - - name: centos-7 - - name: centos-stream-8 - - name: centos-stream-9 - - name: debian-9 - - name: debian-10 - - name: debian-11 - - name: debian-12 - - name: fedora-latest - - name: opensuse-leap-15 - - name: oraclelinux-7 - - name: oraclelinux-8 - - name: oraclelinux-9 - - name: rockylinux-8 - - name: rockylinux-9 - - name: ubuntu-18.04 - - name: ubuntu-20.04 - - name: ubuntu-22.04 - - name: ubuntu-23.04 diff --git a/kitchen.yml b/kitchen.yml index 18e8ce5..6f2f0e1 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -4,24 +4,49 @@ driver: provisioner: name: chef_zero + product_name: cinc + product_version: <%= ENV['CINC_VERSION'] || 'latest' %> + channel: stable + install_strategy: once + chef_license: accept + enforce_idempotency: <%= ENV['ENFORCE_IDEMPOTENCY'] || true %> + multiple_converge: <%= ENV['MULTIPLE_CONVERGE'] || 2 %> + deprecations_as_errors: true + log_level: <%= ENV['CHEF_LOG_LEVEL'] || 'auto' %> -# Uncomment the following verifier to leverage Inspec instead of Busser (the -# default verifier) -# verifier: -# name: inspec +verifier: + name: inspec platforms: - - name: windows-2012r2 + - name: windows-2019 driver_config: - box: tas50/windows_2012r2 + box: gusztavvargadr/windows-server-2019-standard + - name: windows-2022 + driver_config: + box: gusztavvargadr/windows-server-2022-standard suites: + - name: default + run_list: + - recipe[test::default] + verifier: + inspec_tests: + - test/integration/default - name: tools32 run_list: - - recipe[mingw_tdm_install::install32] + - recipe[test::tools32] + verifier: + inspec_tests: + - test/integration/tools32 - name: tools64 run_list: - - recipe[mingw_tdm_install::install64] + - recipe[test::tools64] + verifier: + inspec_tests: + - test/integration/tools64 - name: msys2_tools64 run_list: - - recipe[mingw_msys2_install::default] + - recipe[test::msys2_tools64] + verifier: + inspec_tests: + - test/integration/msys2_tools64 diff --git a/libraries/_helper.rb b/libraries/_helper.rb deleted file mode 100644 index 662faa2..0000000 --- a/libraries/_helper.rb +++ /dev/null @@ -1,38 +0,0 @@ -# -# Cookbook:: mingw -# Library:: _helper -# -# Copyright:: 2016-2019, 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. -# - -module Mingw - module Helper - def win_friendly_path(path) - path.gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR || '\\') if path - 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 - end -end - -Chef::Resource.include Mingw::Helper diff --git a/libraries/helpers.rb b/libraries/helpers.rb new file mode 100644 index 0000000..6f411ab --- /dev/null +++ b/libraries/helpers.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require 'cgi' +require 'uri' + +module Mingw + module Helpers + def win_friendly_path(path) + path.gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR || '\\') if path + end + + def archive_name(source) + url = ::URI.parse(source) + ::File.basename(::CGI.unescape(url.path)) + end + + def tar_name(source) + aname = archive_name(source) + ::File.basename(aname, ::File.extname(aname)) + end + end +end diff --git a/metadata.rb b/metadata.rb index 31a8323..fd22fae 100644 --- a/metadata.rb +++ b/metadata.rb @@ -6,8 +6,6 @@ version '4.0.6' source_url 'https://github.com/sous-chefs/mingw' issues_url 'https://github.com/sous-chefs/mingw/issues' -chef_version '>= 15.3' +chef_version '>= 16.0' supports 'windows' - -depends 'seven_zip' diff --git a/migration.md b/migration.md new file mode 100644 index 0000000..5f572c6 --- /dev/null +++ b/migration.md @@ -0,0 +1,55 @@ +# Migration Guide + +## What Changed + +`mingw` is now a custom-resource-only cookbook. The `mingw::default` recipe and `node['msys2']` attributes have been removed. + +## Recipe Migration + +Before: + +```ruby +include_recipe 'mingw::default' + +msys2_package 'base-devel' do + root 'C:\msys2' +end +``` + +After: + +```ruby +msys2_package 'base-devel' do + root 'C:\msys2' +end +``` + +Archive extraction now uses Chef Infra Client's built-in `archive_file` resource. + +## Attribute Migration + +Before: + +```ruby +default['msys2']['url'] = 'https://example.test/msys2-base.tar.xz' +default['msys2']['checksum'] = 'abc123' +``` + +After: + +```ruby +msys2_package 'base-devel' do + root 'C:\msys2' + source_url 'https://example.test/msys2-base.tar.xz' + checksum 'abc123' +end +``` + +## Test Cookbook Examples + +The migration examples live in `test/cookbooks/test/recipes/`: + +* `default.rb` installs the default MSYS2 workflow. +* `msys2_tools64.rb` installs the MSYS2 64-bit toolchain. +* `tools32.rb` installs the legacy 32-bit TDM-GCC workflow. +* `tools64.rb` installs the legacy 64-bit TDM-GCC workflow. diff --git a/recipes/default.rb b/recipes/default.rb deleted file mode 100644 index a766653..0000000 --- a/recipes/default.rb +++ /dev/null @@ -1,19 +0,0 @@ -# -# Cookbook:: mingw -# Recipe:: default -# -# Copyright:: 2016-2019, 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. - -include_recipe 'seven_zip::default' diff --git a/resources/get.rb b/resources/get.rb index 4a408f0..d591cde 100644 --- a/resources/get.rb +++ b/resources/get.rb @@ -1,8 +1,9 @@ +# frozen_string_literal: true # # Cookbook:: mingw # Resource:: get # -# Copyright:: 2016-2019, Chef Software, Inc. +# Copyright:: 2016-2026, Sous Chefs # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -10,34 +11,49 @@ # # 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. unified_mode true +provides :mingw_get + property :package, String, name_property: true property :root, String, required: true +property :source_url, String, + default: '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' +property :checksum, String, + default: '2e0e9688d42adc68c5611759947e064156e169ff871816cae52d33ee0655826d' 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 + include Mingw::Helpers + + def fetch_mingw_get + f_cache_dir = win_friendly_path(::File.join(new_resource.root, '.cache')) + f_root = win_friendly_path(new_resource.root) + archive_path = ::File.join(f_cache_dir, archive_name(new_resource.source_url)) + + directory f_cache_dir do + recursive true + end + + remote_file "cache mingw-get to #{f_cache_dir}" do + path archive_path + source new_resource.source_url + checksum new_resource.checksum + end + + archive_file "extract mingw-get to #{f_root}" do + path archive_path + destination f_root end + end + + def mingw_do_action(action_cmd) + fetch_mingw_get - execute "performing #{action_cmd} for #{package}" do - command ".\\bin\\mingw-get.exe -v #{action_cmd} #{package}" - cwd root + f_root = win_friendly_path(new_resource.root) + execute "performing #{action_cmd} for #{new_resource.package}" do + command ".\\bin\\mingw-get.exe -v #{action_cmd} #{new_resource.package}" + cwd f_root end end end diff --git a/resources/msys2_package.rb b/resources/msys2_package.rb index ec9e4e1..ea8626e 100644 --- a/resources/msys2_package.rb +++ b/resources/msys2_package.rb @@ -1,8 +1,9 @@ +# frozen_string_literal: true # # Cookbook:: mingw # Resource:: msys2_package # -# Copyright:: 2016-2019, Chef Software, Inc. +# Copyright:: 2016-2026, Sous Chefs # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -10,131 +11,105 @@ # # 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! unified_mode true +provides :msys2_package + property :package, String, name_property: true property :root, String, required: true - -provides :msys2_package +property :source_url, String, + default: 'http://downloads.sourceforge.net/project/msys2/Base/x86_64/msys2-base-x86_64-20160205.tar.xz' +property :checksum, String, + default: '7e97e2af042e1b6f62cf0298fe84839014ef3d4a3e7825cffc6931c66cc0fc20' 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 + include Mingw::Helpers def msys2_init - cache_dir = ::File.join(root, '.cache') + cache_dir = ::File.join(new_resource.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 + archive_path = ::File.join(f_cache_dir, archive_name(new_resource.source_url)) - 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 + directory f_cache_dir do + recursive true + end + + remote_file "cache msys2 base to #{f_cache_dir}" do + path archive_path + source new_resource.source_url + checksum new_resource.checksum + end + + archive_file "extract msys2 base archive to #{f_cache_dir}" do + path archive_path + destination f_cache_dir + 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 + ruby_block 'copy msys2 base files to root' do + block do + ::FileUtils.cp_r(::Dir.glob("#{cache_dir}/msys64/*"), new_resource.root, preserve: true) end + not_if { ::File.exist?(::File.join(new_resource.root, 'msys2.exe')) } end - pacman_key_dir = ::File.join(root, 'etc/pacman.d/gnupg') - bin_dir = ::File.join(root, 'bin') + bin_dir = ::File.join(new_resource.root, 'bin') + f_bin_dir = win_friendly_path(bin_dir) - directory win_friendly_path(bin_dir) + directory f_bin_dir - cookbook_file win_friendly_path("#{bin_dir}/bash.bat") do - source 'bash.bat' + template "#{f_bin_dir}\\bash.bat" do + source 'bash.bat.erb' cookbook 'mingw' end - cookbook_file win_friendly_path(::File.join(root, 'custom-upgrade.sh')) do - source 'custom-upgrade.sh' + template win_friendly_path(::File.join(new_resource.root, 'custom-upgrade.sh')) do + source 'custom-upgrade.sh.erb' cookbook 'mingw' end - cookbook_file win_friendly_path(::File.join(root, 'etc/profile.d/custom_prefix.sh')) do - source 'custom_prefix.sh' + template win_friendly_path(::File.join(new_resource.root, 'etc/profile.d/custom_prefix.sh')) do + source 'custom_prefix.sh.erb' 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. + pacman_key_dir = ::File.join(new_resource.root, 'etc/pacman.d/gnupg') 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')) + if ::File.exist?(::File.join(new_resource.root, 'usr/bin/update-core')) || + !::File.exist?(::File.join(new_resource.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) + def msys2_exec(comment, cmd) + f_root = win_friendly_path(new_resource.root) + execute comment do + command ".\\bin\\bash.bat -c '#{cmd}'" + cwd f_root + live_stream true + environment('MSYSTEM' => 'MSYS') + end end end action :install do - msys2_do_action("installing #{package}", "pacman -S --needed --noconfirm #{package}") + msys2_init + msys2_exec("installing #{new_resource.package}", + "pacman -S --needed --noconfirm #{new_resource.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}") + msys2_init + msys2_exec("upgrading #{new_resource.package}", + "pacman -Syu --noconfirm #{new_resource.package}") end action :remove do - msys2_do_action("removing #{package}", "pacman -R --noconfirm #{package}") + msys2_init + msys2_exec("removing #{new_resource.package}", + "pacman -R --noconfirm #{new_resource.package}") end diff --git a/resources/tdm_gcc.rb b/resources/tdm_gcc.rb index bd496ae..c2ef4e8 100644 --- a/resources/tdm_gcc.rb +++ b/resources/tdm_gcc.rb @@ -1,8 +1,9 @@ +# frozen_string_literal: true # # Cookbook:: mingw # Resource:: tdm_gcc # -# Copyright:: 2016-2019, Chef Software, Inc. +# Copyright:: 2016-2026, Sous Chefs # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -10,104 +11,98 @@ # # 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. unified_mode true -property :flavor, Symbol, is: [:sjlj_32, :seh_sjlj_64], default: :seh_sjlj_64 +provides :mingw_tdm_gcc + +property :flavor, Symbol, equal_to: %i(sjlj_32 seh_sjlj_64), default: :seh_sjlj_64 property :root, String, required: true -property :version, String, is: ['5.1.0'], name_property: true +property :version, String, equal_to: ['5.1.0'], name_property: true -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', -} +action_class do + include Mingw::Helpers -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', -} + def tdm_gcc_archives_for(flavor) + case flavor + when :seh_sjlj_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', + } + when :sjlj_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', + } + end + end +end action :install do - cache_dir = ::File.join(root, '.cache') - f_root = win_friendly_path(root) + f_cache_dir = win_friendly_path(::File.join(new_resource.root, '.cache')) + f_root = win_friendly_path(new_resource.root) + + directory f_cache_dir do + recursive true + end - 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}-*" + if new_resource.flavor == :sjlj_32 + %w( + 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 |fragment| + mingw_get "install #{fragment} at #{f_root}" do + package "mingw32-#{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 + tdm_gcc_archives_for(new_resource.flavor).each do |url, hash| + archive_path = ::File.join(f_cache_dir, archive_name(url)) - to_fetch.each do |url, hash| - seven_zip_archive "cache #{archive_name(url)} to #{win_friendly_path(cache_dir)}" do + remote_file "cache #{archive_name(url)} to #{f_cache_dir}" do + path archive_path 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 + archive_file "extract #{tar_name(url)} to #{f_root}" do + path archive_path + destination f_root 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 + if new_resource.flavor == :sjlj_32 + include_dir = win_friendly_path(::File.join(new_resource.root, 'include')) + + template "#{include_dir}\\pthread.h" do cookbook 'mingw' - source 'pthread.h' + source 'pthread.h.erb' end - cookbook_file "#{include_dir}\\time.h" do + template "#{include_dir}\\time.h" do cookbook 'mingw' - source 'time.h' + source 'time.h.erb' 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)) +action :remove do + directory new_resource.root do + action :delete + recursive true + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b68cb28..c603764 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,5 +3,5 @@ RSpec.configure do |config| config.platform = 'windows' - config.version = '2012R2' + config.version = '2019' end diff --git a/spec/unit/libraries/helpers_spec.rb b/spec/unit/libraries/helpers_spec.rb new file mode 100644 index 0000000..60a0cd9 --- /dev/null +++ b/spec/unit/libraries/helpers_spec.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require 'spec_helper' +require_relative '../../../libraries/helpers' + +describe Mingw::Helpers do + let(:helper) { Class.new { include Mingw::Helpers }.new } + + describe '#win_friendly_path' do + it 'converts separators to Windows separators' do + expect(helper.win_friendly_path('C:/msys2/bin')).to eq('C:\\msys2\\bin') + end + end + + describe '#archive_name' do + it 'decodes escaped archive paths' do + expect(helper.archive_name('https://example.test/GCC%205%20series/archive.tar.lzma')).to eq('archive.tar.lzma') + end + end + + describe '#tar_name' do + it 'removes the outer archive extension' do + expect(helper.tar_name('https://example.test/archive.tar.lzma')).to eq('archive.tar') + end + end +end diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb deleted file mode 100644 index d145af2..0000000 --- a/spec/unit/recipes/default_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# -# Cookbook:: mingw -# Spec:: default -# -# Copyright:: 2016-2019, 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. - -require 'spec_helper' - -describe 'mingw::default' do - context 'When all attributes are default, on an unspecified platform' do - let(:chef_run) do - runner = ChefSpec::ServerRunner.new - runner.converge(described_recipe) - end - - it 'converges successfully' do - expect { chef_run }.to_not raise_error - end - end -end diff --git a/spec/unit/resources/get_spec.rb b/spec/unit/resources/get_spec.rb new file mode 100644 index 0000000..82d6db5 --- /dev/null +++ b/spec/unit/resources/get_spec.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'mingw_get' do + step_into :mingw_get + platform 'windows', '2019' + + context 'installing a package' do + recipe do + mingw_get 'msys-base=2013072300-msys-bin.meta' do + root 'C:\\mingw32' + end + end + + it { is_expected.to create_directory('C:\\mingw32\\.cache') } + it { is_expected.to create_remote_file('cache mingw-get to C:\\mingw32\\.cache') } + it { is_expected.to extract_archive_file('extract mingw-get to C:\\mingw32').with(destination: 'C:\\mingw32') } + + it do + is_expected.to run_execute('performing install for msys-base=2013072300-msys-bin.meta').with( + command: '.\\bin\\mingw-get.exe -v install msys-base=2013072300-msys-bin.meta', + cwd: 'C:\\mingw32' + ) + end + end + + context 'removing a package' do + recipe do + mingw_get 'msys-base=2013072300-msys-bin.meta' do + root 'C:\\mingw32' + action :remove + end + end + + it { is_expected.to run_execute('performing remove for msys-base=2013072300-msys-bin.meta') } + end +end diff --git a/spec/unit/resources/msys2_package_spec.rb b/spec/unit/resources/msys2_package_spec.rb new file mode 100644 index 0000000..47d589e --- /dev/null +++ b/spec/unit/resources/msys2_package_spec.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'msys2_package' do + step_into :msys2_package + platform 'windows', '2019' + + context 'installing a package with defaults' do + recipe do + msys2_package 'base-devel' do + root 'C:\\msys2' + end + end + + it { is_expected.to create_directory('C:\\msys2\\.cache') } + it { is_expected.to create_remote_file('cache msys2 base to C:\\msys2\\.cache').with(source: 'http://downloads.sourceforge.net/project/msys2/Base/x86_64/msys2-base-x86_64-20160205.tar.xz', checksum: '7e97e2af042e1b6f62cf0298fe84839014ef3d4a3e7825cffc6931c66cc0fc20') } + it { is_expected.to extract_archive_file('extract msys2 base archive to C:\\msys2\\.cache').with(destination: 'C:\\msys2\\.cache') } + it { is_expected.to create_directory('C:\\msys2\\bin') } + it { is_expected.to create_template('C:\\msys2\\bin\\bash.bat').with(source: 'bash.bat.erb') } + it { is_expected.to create_template('C:\\msys2\\custom-upgrade.sh').with(source: 'custom-upgrade.sh.erb') } + it { is_expected.to create_template('C:\\msys2\\etc\\profile.d\\custom_prefix.sh').with(source: 'custom_prefix.sh.erb') } + + it do + is_expected.to run_execute('installing base-devel').with( + command: '.\\bin\\bash.bat -c \'pacman -S --needed --noconfirm base-devel\'', + cwd: 'C:\\msys2' + ) + end + end + + context 'installing with a custom base archive' do + recipe do + msys2_package 'base-devel' do + root 'C:\\msys2' + source_url 'https://example.test/msys2-base-x86_64.tar.xz' + checksum 'abc123' + end + end + + it { is_expected.to create_remote_file('cache msys2 base to C:\\msys2\\.cache').with(source: 'https://example.test/msys2-base-x86_64.tar.xz', checksum: 'abc123') } + end + + context 'removing a package' do + recipe do + msys2_package 'base-devel' do + root 'C:\\msys2' + action :remove + end + end + + it { is_expected.to run_execute('removing base-devel') } + end +end diff --git a/spec/unit/resources/tdm_gcc_spec.rb b/spec/unit/resources/tdm_gcc_spec.rb new file mode 100644 index 0000000..985de53 --- /dev/null +++ b/spec/unit/resources/tdm_gcc_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'mingw_tdm_gcc' do + step_into :mingw_tdm_gcc + platform 'windows', '2019' + + context 'installing 64-bit TDM-GCC' do + recipe do + mingw_tdm_gcc '5.1.0' do + root 'C:\\mingw64' + flavor :seh_sjlj_64 + end + end + + it { is_expected.to create_directory('C:\\mingw64\\.cache') } + it { is_expected.to create_remote_file('cache gcc-5.1.0-tdm64-1-core.tar.lzma to C:\\mingw64\\.cache').with(checksum: '29393aac890847089ad1e93f81a28f6744b1609c00b25afca818f3903e42e4bd') } + it { is_expected.to extract_archive_file('extract gcc-5.1.0-tdm64-1-core.tar to C:\\mingw64').with(destination: 'C:\\mingw64') } + end + + context 'installing 32-bit TDM-GCC' do + recipe do + mingw_tdm_gcc '5.1.0' do + root 'C:\\mingw32' + flavor :sjlj_32 + end + end + + it { is_expected.to install_mingw_get('install binutils-bin=2.25.1 at C:\\mingw32') } + it { is_expected.to create_template('C:\\mingw32\\include\\pthread.h').with(source: 'pthread.h.erb') } + it { is_expected.to create_template('C:\\mingw32\\include\\time.h').with(source: 'time.h.erb') } + end +end diff --git a/files/default/bash.bat b/templates/default/bash.bat.erb similarity index 100% rename from files/default/bash.bat rename to templates/default/bash.bat.erb diff --git a/files/default/custom-upgrade.sh b/templates/default/custom-upgrade.sh.erb similarity index 100% rename from files/default/custom-upgrade.sh rename to templates/default/custom-upgrade.sh.erb diff --git a/files/default/custom_prefix.sh b/templates/default/custom_prefix.sh.erb similarity index 100% rename from files/default/custom_prefix.sh rename to templates/default/custom_prefix.sh.erb diff --git a/files/default/pthread.h b/templates/default/pthread.h.erb similarity index 100% rename from files/default/pthread.h rename to templates/default/pthread.h.erb diff --git a/files/default/time.h b/templates/default/time.h.erb similarity index 100% rename from files/default/time.h rename to templates/default/time.h.erb diff --git a/test/cookbooks/test/metadata.rb b/test/cookbooks/test/metadata.rb new file mode 100644 index 0000000..d6b859a --- /dev/null +++ b/test/cookbooks/test/metadata.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +name 'test' +version '0.1.0' + +depends 'mingw' diff --git a/test/cookbooks/test/recipes/default.rb b/test/cookbooks/test/recipes/default.rb new file mode 100644 index 0000000..98d1fb7 --- /dev/null +++ b/test/cookbooks/test/recipes/default.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +root_path = "#{ENV.fetch('SYSTEMDRIVE')}\\msys2" + +msys2_package 'base-devel' do + root root_path +end diff --git a/test/cookbooks/test/recipes/msys2_tools64.rb b/test/cookbooks/test/recipes/msys2_tools64.rb new file mode 100644 index 0000000..e298cfb --- /dev/null +++ b/test/cookbooks/test/recipes/msys2_tools64.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +root_path = "#{ENV.fetch('SYSTEMDRIVE')}\\msys2" + +msys2_package 'base-devel' do + root root_path +end + +msys2_package 'mingw-w64-x86_64-toolchain' do + root root_path +end diff --git a/test/cookbooks/test/recipes/tools32.rb b/test/cookbooks/test/recipes/tools32.rb new file mode 100644 index 0000000..f67dd40 --- /dev/null +++ b/test/cookbooks/test/recipes/tools32.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +root_path = "#{ENV.fetch('SYSTEMDRIVE')}\\mingw32" + +mingw_get 'msys core - 32 bit' do + package 'msys-base=2013072300-msys-bin.meta' + root root_path +end + +mingw_get 'msys core extensions - 32 bit' do + package 'msys-coreutils-ext=5.97-3-*' + root root_path +end + +mingw_get 'msys perl - 32 bit' do + package 'msys-perl-bin=5.8.8-*' + root root_path +end + +mingw_tdm_gcc '5.1.0' do + flavor :sjlj_32 + root root_path +end diff --git a/test/cookbooks/test/recipes/tools64.rb b/test/cookbooks/test/recipes/tools64.rb new file mode 100644 index 0000000..0494b84 --- /dev/null +++ b/test/cookbooks/test/recipes/tools64.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +root_path = "#{ENV.fetch('SYSTEMDRIVE')}\\mingw64" + +mingw_get 'msys core - 64 bit' do + package 'msys-base=2013072300-msys-bin.meta' + root root_path +end + +mingw_get 'msys core extensions - 64 bit' do + package 'msys-coreutils-ext=5.97-3-*' + root root_path +end + +mingw_get 'msys perl - 64 bit' do + package 'msys-perl-bin=5.8.8-*' + root root_path +end + +mingw_tdm_gcc '5.1.0' do + flavor :seh_sjlj_64 + root root_path +end diff --git a/test/fixtures/cookbooks/mingw_msys2_install/metadata.rb b/test/fixtures/cookbooks/mingw_msys2_install/metadata.rb deleted file mode 100644 index 28e7506..0000000 --- a/test/fixtures/cookbooks/mingw_msys2_install/metadata.rb +++ /dev/null @@ -1,5 +0,0 @@ -name 'mingw_msys2_install' -version '0.1.0' - -supports 'windows' -depends 'mingw' diff --git a/test/fixtures/cookbooks/mingw_msys2_install/recipes/default.rb b/test/fixtures/cookbooks/mingw_msys2_install/recipes/default.rb deleted file mode 100644 index d3b190a..0000000 --- a/test/fixtures/cookbooks/mingw_msys2_install/recipes/default.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# Cookbook:: mingw_msys2_install -# Recipe:: default -# -# Copyright:: 2016-2019, 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. - -include_recipe 'mingw::default' - -root_path = "#{ENV['SYSTEMDRIVE']}\\msys2" - -msys2_package 'base-devel' do - root root_path -end - -msys2_package 'mingw-w64-x86_64-toolchain' do - root root_path -end diff --git a/test/fixtures/cookbooks/mingw_tdm_install/metadata.rb b/test/fixtures/cookbooks/mingw_tdm_install/metadata.rb deleted file mode 100644 index 2a8825d..0000000 --- a/test/fixtures/cookbooks/mingw_tdm_install/metadata.rb +++ /dev/null @@ -1,5 +0,0 @@ -name 'mingw_tdm_install' -version '0.1.0' - -supports 'windows' -depends 'mingw' diff --git a/test/fixtures/cookbooks/mingw_tdm_install/recipes/default.rb b/test/fixtures/cookbooks/mingw_tdm_install/recipes/default.rb deleted file mode 100644 index f4aae72..0000000 --- a/test/fixtures/cookbooks/mingw_tdm_install/recipes/default.rb +++ /dev/null @@ -1,20 +0,0 @@ -# -# Cookbook:: mingw_tdm_install -# Recipe:: default -# -# Copyright:: 2016-2019, 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. - -include_recipe 'mingw_tdm_install::install32' -include_recipe 'mingw_tdm_install::install64' diff --git a/test/fixtures/cookbooks/mingw_tdm_install/recipes/install32.rb b/test/fixtures/cookbooks/mingw_tdm_install/recipes/install32.rb deleted file mode 100644 index d10c67c..0000000 --- a/test/fixtures/cookbooks/mingw_tdm_install/recipes/install32.rb +++ /dev/null @@ -1,42 +0,0 @@ -# -# Cookbook:: mingw_install_tdm -# Recipe:: install32 -# -# Copyright:: 2016-2019, 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. - -include_recipe 'mingw::default' - -root_path = "#{ENV['SYSTEMDRIVE']}\\mingw32" - -mingw_get 'msys core - 32 bit' do - package 'msys-base=2013072300-msys-bin.meta' - root root_path -end - -mingw_get 'msys core extensions - 32 bit' do - package 'msys-coreutils-ext=5.97-3-*' - root root_path -end - -mingw_get 'msys perl - 32 bit' do - package 'msys-perl-bin=5.8.8-*' - root root_path -end - -mingw_tdm_gcc 'TDM GCC - 32 bit' do - version '5.1.0' - flavor :sjlj_32 - root root_path -end diff --git a/test/fixtures/cookbooks/mingw_tdm_install/recipes/install64.rb b/test/fixtures/cookbooks/mingw_tdm_install/recipes/install64.rb deleted file mode 100644 index 94cf25a..0000000 --- a/test/fixtures/cookbooks/mingw_tdm_install/recipes/install64.rb +++ /dev/null @@ -1,42 +0,0 @@ -# -# Cookbook:: mingw_install_tdm -# Recipe:: install64 -# -# Copyright:: 2016-2019, 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. - -include_recipe 'mingw::default' - -root_path = "#{ENV['SYSTEMDRIVE']}\\mingw64" - -mingw_get 'msys core - 64 bit' do - package 'msys-base=2013072300-msys-bin.meta' - root root_path -end - -mingw_get 'msys core extensions - 64 bit' do - package 'msys-coreutils-ext=5.97-3-*' - root root_path -end - -mingw_get 'msys perl - 64 bit' do - package 'msys-perl-bin=5.8.8-*' - root root_path -end - -mingw_tdm_gcc 'TDM GCC - 64 bit' do - version '5.1.0' - flavor :seh_sjlj_64 - root root_path -end diff --git a/test/integration/default/controls/default_spec.rb b/test/integration/default/controls/default_spec.rb new file mode 100644 index 0000000..a6e0de3 --- /dev/null +++ b/test/integration/default/controls/default_spec.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +title 'Default MSYS2 Installation' + +control 'mingw-msys2-default-01' do + impact 1.0 + title 'MSYS2 base is installed' + + describe file('C:\\msys2\\msys2.exe') do + it { should exist } + end + + describe file('C:\\msys2\\bin\\bash.bat') do + it { should exist } + end +end + +control 'mingw-msys2-default-02' do + impact 1.0 + title 'base-devel is installed' + + describe command('cmd.exe /c "set MSYSTEM=MSYS&& C:\\msys2\\bin\\bash.bat -lc \"pacman -Q base-devel\""') do + its('exit_status') { should eq 0 } + end +end diff --git a/test/integration/default/inspec.yml b/test/integration/default/inspec.yml new file mode 100644 index 0000000..0fc4431 --- /dev/null +++ b/test/integration/default/inspec.yml @@ -0,0 +1,7 @@ +--- +name: default +title: mingw default resource smoke tests +maintainer: Sous Chefs +license: Apache-2.0 +summary: Verifies the default MSYS2 installation path +version: 1.0.0 diff --git a/test/integration/helpers/serverspec/spec_helper.rb b/test/integration/helpers/serverspec/spec_helper.rb deleted file mode 100644 index c1fddf0..0000000 --- a/test/integration/helpers/serverspec/spec_helper.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'serverspec' - -if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM).nil? - set :backend, :exec -else - set :backend, :cmd - set :os, family: 'windows' -end diff --git a/test/integration/msys2_tools64/controls/msys2_tools64_spec.rb b/test/integration/msys2_tools64/controls/msys2_tools64_spec.rb new file mode 100644 index 0000000..5e99af3 --- /dev/null +++ b/test/integration/msys2_tools64/controls/msys2_tools64_spec.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +title '64-bit MSYS2 Toolchain' + +control 'mingw-msys2-tools64-01' do + impact 1.0 + title '64-bit MSYS2 compiler is installed' + + describe file('C:\\msys2\\mingw64\\bin\\gcc.exe') do + it { should exist } + end + + describe command('cmd.exe /c "set MSYSTEM=MINGW64&& C:\\msys2\\bin\\bash.bat -lc \"/mingw64/bin/gcc -dumpmachine\""') do + its('stdout') { should cmp "x86_64-w64-mingw32\n" } + its('exit_status') { should eq 0 } + end +end + +control 'mingw-msys2-tools64-02' do + impact 1.0 + title '64-bit MSYS2 compiler can build binaries' + + describe command('cmd.exe /c "set MSYSTEM=MINGW64&& C:\\msys2\\bin\\bash.bat -lc \"echo int main(){} | /mingw64/bin/gcc -xc -o test.exe -\""') do + its('exit_status') { should eq 0 } + end +end diff --git a/test/integration/msys2_tools64/inspec.yml b/test/integration/msys2_tools64/inspec.yml new file mode 100644 index 0000000..a38fa99 --- /dev/null +++ b/test/integration/msys2_tools64/inspec.yml @@ -0,0 +1,7 @@ +--- +name: msys2_tools64 +title: MSYS2 64-bit toolchain tests +maintainer: Sous Chefs +license: Apache-2.0 +summary: Verifies a 64-bit MSYS2 MinGW toolchain +version: 1.0.0 diff --git a/test/integration/msys2_tools64/serverspec/msys2_spec.rb b/test/integration/msys2_tools64/serverspec/msys2_spec.rb deleted file mode 100644 index e70aab7..0000000 --- a/test/integration/msys2_tools64/serverspec/msys2_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -set :path, "C:\\msys2\\bin;C:\\msys2\\mingw64\\bin;C:\\msys2\\usr\\bin;#{ENV['PATH']}" - -describe command('gcc --version') do - its(:exit_status) { should eq 0 } - its(:stdout) { should include 'gcc.exe (Rev1, Built by MSYS2 project)' } -end - -describe command('gcc -dumpmachine') do - its(:exit_status) { should eq 0 } - its(:stdout) { should eq "x86_64-w64-mingw32\n" } -end - -describe command('as --version') do - its(:exit_status) { should eq 0 } - its(:stdout) { should include '2.25' } - its(:stdout) { should include 'x86_64-w64-mingw32' } -end - -describe command('make --version') do - its(:exit_status) { should eq 0 } - its(:stdout) { should include 'GNU Make 4.1' } - its(:stdout) { should include 'x86_64-pc-msys' } -end diff --git a/test/integration/tools32/controls/tools32_spec.rb b/test/integration/tools32/controls/tools32_spec.rb new file mode 100644 index 0000000..0b560df --- /dev/null +++ b/test/integration/tools32/controls/tools32_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +title '32-bit TDM-GCC Toolchain' + +control 'mingw-tools32-01' do + impact 1.0 + title '32-bit compiler is installed' + + describe file('C:\\mingw32\\bin\\gcc.exe') do + it { should exist } + end + + describe command('C:\\mingw32\\bin\\gcc.exe -dumpmachine') do + its('stdout') { should cmp "mingw32\n" } + its('exit_status') { should eq 0 } + end +end + +control 'mingw-tools32-02' do + impact 1.0 + title '32-bit support tools are installed' + + describe command('C:\\mingw32\\bin\\as.exe --version') do + its('stdout') { should include '2.25.1' } + its('stdout') { should include 'mingw32' } + its('exit_status') { should eq 0 } + end + + describe command('C:\\mingw32\\msys\\1.0\\bin\\make.exe --version') do + its('stdout') { should include 'GNU Make 3.81' } + its('exit_status') { should eq 0 } + end +end diff --git a/test/integration/tools32/inspec.yml b/test/integration/tools32/inspec.yml new file mode 100644 index 0000000..17f0aa8 --- /dev/null +++ b/test/integration/tools32/inspec.yml @@ -0,0 +1,7 @@ +--- +name: tools32 +title: mingw 32-bit TDM-GCC tests +maintainer: Sous Chefs +license: Apache-2.0 +summary: Verifies the 32-bit TDM-GCC toolchain +version: 1.0.0 diff --git a/test/integration/tools32/serverspec/mingw_spec.rb b/test/integration/tools32/serverspec/mingw_spec.rb deleted file mode 100644 index 85284c6..0000000 --- a/test/integration/tools32/serverspec/mingw_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper' - -set :path, "C:\\mingw32\\bin;C:\\mingw32\\msys\\1.0\\bin;#{ENV['PATH']}" - -describe command('gcc --version') do - its(:exit_status) { should eq 0 } - its(:stdout) { should include 'gcc.exe (tdm-1) 5.1.0' } -end - -describe command('gcc -dumpmachine') do - its(:exit_status) { should eq 0 } - its(:stdout) { should eq "mingw32\n" } -end - -describe command('as --version') do - its(:exit_status) { should eq 0 } - its(:stdout) { should include '2.25.1' } - its(:stdout) { should include 'mingw32' } -end - -describe command('make --version') do - its(:exit_status) { should eq 0 } - its(:stdout) { should include 'GNU Make 3.81' } -end diff --git a/test/integration/tools64/controls/tools64_spec.rb b/test/integration/tools64/controls/tools64_spec.rb new file mode 100644 index 0000000..270dfac --- /dev/null +++ b/test/integration/tools64/controls/tools64_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +title '64-bit TDM-GCC Toolchain' + +control 'mingw-tools64-01' do + impact 1.0 + title '64-bit compiler is installed' + + describe file('C:\\mingw64\\bin\\gcc.exe') do + it { should exist } + end + + describe command('C:\\mingw64\\bin\\gcc.exe -dumpmachine') do + its('stdout') { should cmp "x86_64-w64-mingw32\n" } + its('exit_status') { should eq 0 } + end +end + +control 'mingw-tools64-02' do + impact 1.0 + title '64-bit support tools are installed' + + describe command('C:\\mingw64\\bin\\as.exe --version') do + its('stdout') { should include 'x86_64-w64-mingw32' } + its('exit_status') { should eq 0 } + end + + describe command('C:\\mingw64\\msys\\1.0\\bin\\make.exe --version') do + its('stdout') { should include 'GNU Make 3.81' } + its('exit_status') { should eq 0 } + end +end diff --git a/test/integration/tools64/inspec.yml b/test/integration/tools64/inspec.yml new file mode 100644 index 0000000..4182e5e --- /dev/null +++ b/test/integration/tools64/inspec.yml @@ -0,0 +1,7 @@ +--- +name: tools64 +title: mingw 64-bit TDM-GCC tests +maintainer: Sous Chefs +license: Apache-2.0 +summary: Verifies the 64-bit TDM-GCC toolchain +version: 1.0.0 diff --git a/test/integration/tools64/serverspec/mingw_spec.rb b/test/integration/tools64/serverspec/mingw_spec.rb deleted file mode 100644 index 5604fdc..0000000 --- a/test/integration/tools64/serverspec/mingw_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper' - -set :path, "C:\\mingw64\\bin;C:\\mingw64\\msys\\1.0\\bin;#{ENV['PATH']}" - -describe command('gcc --version') do - its(:exit_status) { should eq 0 } - its(:stdout) { should include 'gcc.exe (tdm64-1) 5.1.0' } -end - -describe command('gcc -dumpmachine') do - its(:exit_status) { should eq 0 } - its(:stdout) { should eq "x86_64-w64-mingw32\n" } -end - -describe command('as --version') do - its(:exit_status) { should eq 0 } - its(:stdout) { should include '2.25' } - its(:stdout) { should include 'x86_64-w64-mingw32' } -end - -describe command('make --version') do - its(:exit_status) { should eq 0 } - its(:stdout) { should include 'GNU Make 3.81' } -end