Skip to content

Commit 44338c5

Browse files
MSP-Gregeregon
authored andcommitted
Fix tar extraction with windows-2016 image
1. common.js - add function win2nix(path) to convert windows style paths to nix style 2. ruby_builder.js - use Git tar for windows-2016, leave windows-2019 as is
1 parent 037dfa7 commit 44338c5

3 files changed

Lines changed: 39 additions & 6 deletions

File tree

common.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,12 @@ function findUbuntuVersion() {
4242
throw new Error('Could not find Ubuntu version')
4343
}
4444
}
45+
46+
// convert windows path like C:\Users\runneradmin to /c/Users/runneradmin
47+
export function win2nix(path) {
48+
if (/^[A-Z]:/i.test(path)) {
49+
// path starts with drive
50+
path = `/${path[0].toLowerCase()}${path.split(':')[1]}`
51+
}
52+
return path.replace(/\\/g, '/').replace(/ /g, '\\ ')
53+
}

dist/index.js

Lines changed: 20 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ruby-builder.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,16 @@ async function downloadAndExtract(platform, engine, version) {
3434
return await tc.downloadTool(url)
3535
})
3636

37-
const tar = platform.startsWith('windows') ? 'C:\\Windows\\system32\\tar.exe' : 'tar'
38-
await common.measure('Extracting Ruby', async () =>
39-
exec.exec(tar, [ '-xz', '-C', rubiesDir, '-f', downloadPath ]))
37+
await common.measure('Extracting Ruby', async () => {
38+
if (process.env.ImageOS === 'win16') {
39+
const tar = '"C:\\Program Files\\Git\\usr\\bin\\tar.exe"'
40+
await exec.exec(tar, [ '-xz', '-C', common.win2nix(rubiesDir), '-f',
41+
common.win2nix(downloadPath) ])
42+
} else {
43+
const tar = platform.startsWith('windows') ? 'C:\\Windows\\system32\\tar.exe' : 'tar'
44+
await exec.exec(tar, [ '-xz', '-C', rubiesDir, '-f', downloadPath ])
45+
}
46+
})
4047

4148
return path.join(rubiesDir, `${engine}-${version}`)
4249
}

0 commit comments

Comments
 (0)