Update for Actions MSYS2 install

1. Use 'Git for Windows' cert.pem file
2. Add MSYS2 to path for mswin (after msvc additions)
3. Rearrange code for cleanup when MSYS2 is added to Window image
This commit is contained in:
MSP-Greg
2020-03-24 18:45:54 +01:00
committed by Benoit Daloze
parent d96d3894b6
commit f70e6bf7d0
2 changed files with 54 additions and 34 deletions
Generated Vendored
+27 -17
View File
@@ -4804,6 +4804,12 @@ const exec = __webpack_require__(986)
const tc = __webpack_require__(533) const tc = __webpack_require__(533)
const rubyInstallerVersions = __webpack_require__(471).versions const rubyInstallerVersions = __webpack_require__(471).versions
// needed for 2.2, 2.3, and mswin, cert file used by Git for Windows
const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem'
// standard MSYS2 location, found by 'devkit'
const msys2 = 'C:\\msys64'
function getAvailableVersions(platform, engine) { function getAvailableVersions(platform, engine) {
if (engine === 'ruby') { if (engine === 'ruby') {
return Object.keys(rubyInstallerVersions) return Object.keys(rubyInstallerVersions)
@@ -4829,11 +4835,8 @@ async function install(platform, ruby) {
await exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true }) await exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true })
const rubyPrefix = `${drive}:\\${base}` const rubyPrefix = `${drive}:\\${base}`
// we use certs and embedded MSYS2 from hostedRuby
const hostedRuby = latestHostedRuby()
let toolchainPaths = (version === 'mswin') ? let toolchainPaths = (version === 'mswin') ?
await setupMSWin(hostedRuby) : await setupMingw(hostedRuby, version) await setupMSWin() : await setupMingw(version)
const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths] const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths]
// Install Bundler if needed // Install Bundler if needed
@@ -4844,46 +4847,53 @@ async function install(platform, ruby) {
return [rubyPrefix, newPathEntries] return [rubyPrefix, newPathEntries]
} }
function latestHostedRuby() { // Remove when Actions Windows image contains MSYS2 install
async function symLinkToEmbeddedMSYS2() {
const toolCacheVersions = tc.findAllVersions('Ruby') const toolCacheVersions = tc.findAllVersions('Ruby')
toolCacheVersions.sort() toolCacheVersions.sort()
if (toolCacheVersions.length === 0) { if (toolCacheVersions.length === 0) {
throw new Error('Could not find MSYS2 in the toolcache') throw new Error('Could not find MSYS2 in the toolcache')
} }
const latestVersion = toolCacheVersions.slice(-1)[0] const latestVersion = toolCacheVersions.slice(-1)[0]
return tc.find('Ruby', latestVersion) const hostedRuby = tc.find('Ruby', latestVersion)
await exec.exec(`cmd /c mklink /D ${msys2} ${hostedRuby}\\msys64`)
} }
async function setupMingw(hostedRuby, version) { async function setupMingw(version) {
if (version.startsWith('2.2') || version.startsWith('2.3')) { if (version.startsWith('2.2') || version.startsWith('2.3')) {
core.exportVariable('SSL_CERT_FILE', `${hostedRuby}\\ssl\\cert.pem`) core.exportVariable('SSL_CERT_FILE', certFile)
} }
// Link to embedded MSYS2 in hostedRuby // Remove when Actions Windows image contains MSYS2 install
const msys2 = 'C:\\msys64'
if (!fs.existsSync(msys2)) { if (!fs.existsSync(msys2)) {
const hostedMSYS2 = `${hostedRuby}\\msys64` await symLinkToEmbeddedMSYS2()
await exec.exec(`cmd /c mklink /D ${msys2} ${hostedMSYS2}`)
} }
return [`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`] return [`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`]
} }
async function setupMSWin(hostedRuby) { async function setupMSWin() {
// All standard MSVC OpenSSL builds use C:\Program Files\Common Files\SSL // All standard MSVC OpenSSL builds use C:\Program Files\Common Files\SSL
const certsDir = 'C:\\Program Files\\Common Files\\SSL\\certs' const certsDir = 'C:\\Program Files\\Common Files\\SSL\\certs'
if (!fs.existsSync(certsDir)) { if (!fs.existsSync(certsDir)) {
fs.mkdirSync(certsDir) fs.mkdirSync(certsDir)
} }
// Copy cert.pem from hosted Ruby // cert.pem location is hard-coded by OpenSSL msvc builds
const cert = 'C:\\Program Files\\Common Files\\SSL\\cert.pem' const cert = 'C:\\Program Files\\Common Files\\SSL\\cert.pem'
if (!fs.existsSync(cert)) { if (!fs.existsSync(cert)) {
const hostedCert = `${hostedRuby}\\ssl\\cert.pem` fs.copyFileSync(certFile, cert)
fs.copyFileSync(hostedCert, cert)
} }
return addVCVARSEnv() // Remove when Actions Windows image contains MSYS2 install
if (!fs.existsSync(msys2)) {
await symLinkToEmbeddedMSYS2()
}
let pathAry = addVCVARSEnv()
// add MSYS2 paths for misc gnu utilities like bison and ragel
pathAry.push(`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`)
return pathAry
} }
/* Sets MSVC environment for use in Actions /* Sets MSVC environment for use in Actions
+27 -17
View File
@@ -8,6 +8,12 @@ const exec = require('@actions/exec')
const tc = require('@actions/tool-cache') const tc = require('@actions/tool-cache')
const rubyInstallerVersions = require('./windows-versions').versions const rubyInstallerVersions = require('./windows-versions').versions
// needed for 2.2, 2.3, and mswin, cert file used by Git for Windows
const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem'
// standard MSYS2 location, found by 'devkit'
const msys2 = 'C:\\msys64'
export function getAvailableVersions(platform, engine) { export function getAvailableVersions(platform, engine) {
if (engine === 'ruby') { if (engine === 'ruby') {
return Object.keys(rubyInstallerVersions) return Object.keys(rubyInstallerVersions)
@@ -33,11 +39,8 @@ export async function install(platform, ruby) {
await exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true }) await exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true })
const rubyPrefix = `${drive}:\\${base}` const rubyPrefix = `${drive}:\\${base}`
// we use certs and embedded MSYS2 from hostedRuby
const hostedRuby = latestHostedRuby()
let toolchainPaths = (version === 'mswin') ? let toolchainPaths = (version === 'mswin') ?
await setupMSWin(hostedRuby) : await setupMingw(hostedRuby, version) await setupMSWin() : await setupMingw(version)
const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths] const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths]
// Install Bundler if needed // Install Bundler if needed
@@ -48,46 +51,53 @@ export async function install(platform, ruby) {
return [rubyPrefix, newPathEntries] return [rubyPrefix, newPathEntries]
} }
function latestHostedRuby() { // Remove when Actions Windows image contains MSYS2 install
async function symLinkToEmbeddedMSYS2() {
const toolCacheVersions = tc.findAllVersions('Ruby') const toolCacheVersions = tc.findAllVersions('Ruby')
toolCacheVersions.sort() toolCacheVersions.sort()
if (toolCacheVersions.length === 0) { if (toolCacheVersions.length === 0) {
throw new Error('Could not find MSYS2 in the toolcache') throw new Error('Could not find MSYS2 in the toolcache')
} }
const latestVersion = toolCacheVersions.slice(-1)[0] const latestVersion = toolCacheVersions.slice(-1)[0]
return tc.find('Ruby', latestVersion) const hostedRuby = tc.find('Ruby', latestVersion)
await exec.exec(`cmd /c mklink /D ${msys2} ${hostedRuby}\\msys64`)
} }
async function setupMingw(hostedRuby, version) { async function setupMingw(version) {
if (version.startsWith('2.2') || version.startsWith('2.3')) { if (version.startsWith('2.2') || version.startsWith('2.3')) {
core.exportVariable('SSL_CERT_FILE', `${hostedRuby}\\ssl\\cert.pem`) core.exportVariable('SSL_CERT_FILE', certFile)
} }
// Link to embedded MSYS2 in hostedRuby // Remove when Actions Windows image contains MSYS2 install
const msys2 = 'C:\\msys64'
if (!fs.existsSync(msys2)) { if (!fs.existsSync(msys2)) {
const hostedMSYS2 = `${hostedRuby}\\msys64` await symLinkToEmbeddedMSYS2()
await exec.exec(`cmd /c mklink /D ${msys2} ${hostedMSYS2}`)
} }
return [`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`] return [`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`]
} }
async function setupMSWin(hostedRuby) { async function setupMSWin() {
// All standard MSVC OpenSSL builds use C:\Program Files\Common Files\SSL // All standard MSVC OpenSSL builds use C:\Program Files\Common Files\SSL
const certsDir = 'C:\\Program Files\\Common Files\\SSL\\certs' const certsDir = 'C:\\Program Files\\Common Files\\SSL\\certs'
if (!fs.existsSync(certsDir)) { if (!fs.existsSync(certsDir)) {
fs.mkdirSync(certsDir) fs.mkdirSync(certsDir)
} }
// Copy cert.pem from hosted Ruby // cert.pem location is hard-coded by OpenSSL msvc builds
const cert = 'C:\\Program Files\\Common Files\\SSL\\cert.pem' const cert = 'C:\\Program Files\\Common Files\\SSL\\cert.pem'
if (!fs.existsSync(cert)) { if (!fs.existsSync(cert)) {
const hostedCert = `${hostedRuby}\\ssl\\cert.pem` fs.copyFileSync(certFile, cert)
fs.copyFileSync(hostedCert, cert)
} }
return addVCVARSEnv() // Remove when Actions Windows image contains MSYS2 install
if (!fs.existsSync(msys2)) {
await symLinkToEmbeddedMSYS2()
}
let pathAry = addVCVARSEnv()
// add MSYS2 paths for misc gnu utilities like bison and ragel
pathAry.push(`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`)
return pathAry
} }
/* Sets MSVC environment for use in Actions /* Sets MSVC environment for use in Actions