Skip to content

Commit 83fdad0

Browse files
committed
Ensure that /dev/fd, /dev/mqueue and friends exist
It would be very nice, of course, if the MSYS2 runtime emulated these entries automagically, i.e. without them having to exist on disk. In the meantime, though, let's just create those entries on disk, just like Git for Windows' installer does. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 4125b66 commit 83fdad0

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
"artifactsize",
1414
"autodrain",
1515
"Backoff",
16+
"mqueue",
1617
"MSYSTEM",
1718
"Pacman",
1819
"unzipper",
19-
"vercel"
20+
"vercel",
21+
"winsymlinks"
2022
],
2123
"git.ignoreLimitWarning": true
2224
}

__tests__/main.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,15 @@ if (process.env.RUN_NETWORK_TESTS !== 'true') {
5858
expect(
5959
statSync.bind(null, `${outputDirectory}/mingw64/bin/gcc.exe`)
6060
).not.toThrow()
61+
62+
const hello = child_process.spawnSync(
63+
'usr\\bin\\bash.exe',
64+
['-lc', 'cat <(echo hello)'],
65+
{
66+
cwd: outputDirectory
67+
}
68+
)
69+
expect(hello.stderr.toString()).toBe('')
70+
expect(hello.stdout.toString()).toBe('hello\n')
6171
})
6272
}

main.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import * as core from '@actions/core'
2+
import {get, mkdirp} from './src/downloader'
23
import {restoreCache, saveCache} from '@actions/cache'
3-
import {get} from './src/downloader'
44
import process from 'process'
5+
import {spawnSync} from 'child_process'
56

67
async function run(): Promise<void> {
78
try {
@@ -80,6 +81,29 @@ async function run(): Promise<void> {
8081
) {
8182
core.exportVariable('LC_CTYPE', 'C.UTF-8')
8283
}
84+
85+
// ensure that /dev/fd/*, /dev/mqueue and friends exist
86+
for (const path of ['/dev/mqueue', '/dev/shm']) {
87+
mkdirp(`${outputDirectory}${path}`)
88+
}
89+
90+
const ln = (linkPath: string, target: string): void => {
91+
const child = spawnSync('ln.exe', ['-s', target, linkPath], {
92+
cwd: outputDirectory,
93+
env: {
94+
MSYS: 'winsymlinks:sys'
95+
}
96+
})
97+
if (child.error) throw child.error
98+
}
99+
for (const [linkPath, target] of Object.entries({
100+
fd: 'fd',
101+
stdin: 'fd/0',
102+
stdout: 'fd/1',
103+
stderr: 'fd/2'
104+
})) {
105+
ln(`/dev/${linkPath}`, `/proc/self/${target}`)
106+
}
83107
} catch (error) {
84108
core.setFailed(error instanceof Error ? error.message : `${error}`)
85109
}

src/downloader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async function fetchJSONFromURL<T>(url: string): Promise<T> {
1919
return (await res.json()) as T
2020
}
2121

22-
function mkdirp(directoryPath: string): void {
22+
export function mkdirp(directoryPath: string): void {
2323
try {
2424
const stat = fs.statSync(directoryPath)
2525
if (stat.isDirectory()) {

0 commit comments

Comments
 (0)