@@ -6,9 +6,7 @@ const tmpdir = require('../common/tmpdir');
6
6
const { inspect } = require ( 'util' ) ;
7
7
8
8
const { readFileSync, copyFileSync, statSync } = require ( 'fs' ) ;
9
- const {
10
- spawnSyncAndExitWithoutError,
11
- } = require ( '../common/child_process' ) ;
9
+ const { spawnSyncAndExitWithoutError } = require ( '../common/child_process' ) ;
12
10
13
11
function skipIfSingleExecutableIsNotSupported ( ) {
14
12
if ( ! process . config . variables . single_executable_application )
@@ -18,31 +16,48 @@ function skipIfSingleExecutableIsNotSupported() {
18
16
common . skip ( `Unsupported platform ${ process . platform } .` ) ;
19
17
20
18
if ( process . platform === 'linux' && process . config . variables . is_debug === 1 )
21
- common . skip ( 'Running the resultant binary fails with `Couldn\'t read target executable"`.' ) ;
19
+ common . skip (
20
+ 'Running the resultant binary fails with `Couldn\'t read target executable"`.'
21
+ ) ;
22
22
23
23
if ( process . config . variables . node_shared )
24
- common . skip ( 'Running the resultant binary fails with ' +
25
- '`/home/iojs/node-tmp/.tmp.2366/sea: error while loading shared libraries: ' +
26
- 'libnode.so.112: cannot open shared object file: No such file or directory`.' ) ;
24
+ common . skip (
25
+ 'Running the resultant binary fails with ' +
26
+ '`/home/iojs/node-tmp/.tmp.2366/sea: error while loading shared libraries: ' +
27
+ 'libnode.so.112: cannot open shared object file: No such file or directory`.'
28
+ ) ;
27
29
28
30
if ( process . config . variables . icu_gyp_path === 'tools/icu/icu-system.gyp' )
29
- common . skip ( 'Running the resultant binary fails with ' +
30
- '`/home/iojs/node-tmp/.tmp.2379/sea: error while loading shared libraries: ' +
31
- 'libicui18n.so.71: cannot open shared object file: No such file or directory`.' ) ;
32
-
33
- if ( ! process . config . variables . node_use_openssl || process . config . variables . node_shared_openssl )
34
- common . skip ( 'Running the resultant binary fails with `Node.js is not compiled with OpenSSL crypto support`.' ) ;
31
+ common . skip (
32
+ 'Running the resultant binary fails with ' +
33
+ '`/home/iojs/node-tmp/.tmp.2379/sea: error while loading shared libraries: ' +
34
+ 'libicui18n.so.71: cannot open shared object file: No such file or directory`.'
35
+ ) ;
36
+
37
+ if (
38
+ ! process . config . variables . node_use_openssl ||
39
+ process . config . variables . node_shared_openssl
40
+ )
41
+ common . skip (
42
+ 'Running the resultant binary fails with `Node.js is not compiled with OpenSSL crypto support`.'
43
+ ) ;
35
44
36
45
if ( process . config . variables . want_separate_host_toolset !== 0 )
37
- common . skip ( 'Running the resultant binary fails with `Segmentation fault (core dumped)`.' ) ;
46
+ common . skip (
47
+ 'Running the resultant binary fails with `Segmentation fault (core dumped)`.'
48
+ ) ;
38
49
39
50
if ( process . platform === 'linux' ) {
40
- const osReleaseText = readFileSync ( '/etc/os-release' , { encoding : 'utf-8' } ) ;
51
+ const osReleaseText = readFileSync ( '/etc/os-release' , {
52
+ encoding : 'utf-8' ,
53
+ } ) ;
41
54
const isAlpine = / ^ N A M E = " A l p i n e L i n u x " / m. test ( osReleaseText ) ;
42
55
if ( isAlpine ) common . skip ( 'Alpine Linux is not supported.' ) ;
43
56
44
57
if ( process . arch === 's390x' ) {
45
- common . skip ( 'On s390x, postject fails with `memory access out of bounds`.' ) ;
58
+ common . skip (
59
+ 'On s390x, postject fails with `memory access out of bounds`.'
60
+ ) ;
46
61
}
47
62
}
48
63
@@ -54,7 +69,9 @@ function skipIfSingleExecutableIsNotSupported() {
54
69
readFileSync ( process . execPath ) ;
55
70
} catch ( e ) {
56
71
if ( e . code === 'ERR_FS_FILE_TOO_LARGE' ) {
57
- common . skip ( 'The Node.js binary is too large to be supported by postject' ) ;
72
+ common . skip (
73
+ 'The Node.js binary is too large to be supported by postject'
74
+ ) ;
58
75
}
59
76
}
60
77
@@ -66,34 +83,54 @@ function skipIfSingleExecutableIsNotSupported() {
66
83
const stat = statSync ( process . execPath ) ;
67
84
const expectedSpace = stat . size + 10 * 1024 * 1024 ;
68
85
if ( ! tmpdir . hasEnoughSpace ( expectedSpace ) ) {
69
- common . skip ( `Available disk space < ${ Math . floor ( expectedSpace / 1024 / 1024 ) } MB` ) ;
86
+ common . skip (
87
+ `Available disk space < ${ Math . floor ( expectedSpace / 1024 / 1024 ) } MB`
88
+ ) ;
70
89
}
71
90
}
72
91
73
- function generateSEA ( targetExecutable , sourceExecutable , seaBlob , verifyWorkflow = false ) {
92
+ function generateSEA (
93
+ targetExecutable ,
94
+ sourceExecutable ,
95
+ seaBlob ,
96
+ verifyWorkflow = false
97
+ ) {
74
98
try {
75
99
copyFileSync ( sourceExecutable , targetExecutable ) ;
76
100
} catch ( e ) {
77
- const message = `Cannot copy ${ sourceExecutable } to ${ targetExecutable } : ${ inspect ( e ) } ` ;
101
+ const message = `Cannot copy ${ sourceExecutable } to ${ targetExecutable } : ${ inspect (
102
+ e
103
+ ) } `;
78
104
if ( verifyWorkflow ) {
79
105
throw new Error ( message ) ;
80
106
}
81
107
common . skip ( message ) ;
82
108
}
83
109
console . log ( `Copied ${ sourceExecutable } to ${ targetExecutable } ` ) ;
84
110
85
- const postjectFile = fixtures . path ( 'postject-copy' , 'node_modules' , 'postject' , 'dist' , 'cli.js' ) ;
111
+ const postjectFile = fixtures . path (
112
+ 'postject-copy' ,
113
+ 'node_modules' ,
114
+ 'postject' ,
115
+ 'dist' ,
116
+ 'cli.js'
117
+ ) ;
86
118
try {
87
119
spawnSyncAndExitWithoutError ( process . execPath , [
88
120
postjectFile ,
89
121
targetExecutable ,
90
122
'NODE_SEA_BLOB' ,
91
123
seaBlob ,
92
- '--sentinel-fuse' , 'NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2' ,
93
- ...process . platform === 'darwin' ? [ '--macho-segment-name' , 'NODE_SEA' ] : [ ] ,
124
+ '--sentinel-fuse' ,
125
+ 'NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2' ,
126
+ ...( process . platform === 'darwin'
127
+ ? [ '--macho-segment-name' , 'NODE_SEA' ]
128
+ : [ ] ) ,
94
129
] ) ;
95
130
} catch ( e ) {
96
- const message = `Cannot inject ${ seaBlob } into ${ targetExecutable } : ${ inspect ( e ) } ` ;
131
+ const message = `Cannot inject ${ seaBlob } into ${ targetExecutable } : ${ inspect (
132
+ e
133
+ ) } `;
97
134
if ( verifyWorkflow ) {
98
135
throw new Error ( message ) ;
99
136
}
@@ -103,8 +140,12 @@ function generateSEA(targetExecutable, sourceExecutable, seaBlob, verifyWorkflow
103
140
104
141
if ( process . platform === 'darwin' ) {
105
142
try {
106
- spawnSyncAndExitWithoutError ( 'codesign' , [ '--sign' , '-' , targetExecutable ] ) ;
107
- spawnSyncAndExitWithoutError ( 'codesign' , [ '--verify' , targetExecutable ] ) ;
143
+ spawnSyncAndExitWithoutError ( 'codesign' , [
144
+ '--sign' ,
145
+ '-' ,
146
+ targetExecutable ,
147
+ ] ) ;
148
+ spawnSyncAndExitWithoutError ( 'codesign' , [ '--verify' , targetExecutable ] ) ;
108
149
} catch ( e ) {
109
150
const message = `Cannot sign ${ targetExecutable } : ${ inspect ( e ) } ` ;
110
151
if ( verifyWorkflow ) {
@@ -115,7 +156,7 @@ function generateSEA(targetExecutable, sourceExecutable, seaBlob, verifyWorkflow
115
156
console . log ( `Signed ${ targetExecutable } ` ) ;
116
157
} else if ( process . platform === 'win32' ) {
117
158
try {
118
- spawnSyncAndExitWithoutError ( 'where' , [ 'signtool' ] ) ;
159
+ spawnSyncAndExitWithoutError ( 'where' , [ 'signtool' ] ) ;
119
160
} catch ( e ) {
120
161
const message = `Cannot find signtool: ${ inspect ( e ) } ` ;
121
162
if ( verifyWorkflow ) {
@@ -125,10 +166,22 @@ function generateSEA(targetExecutable, sourceExecutable, seaBlob, verifyWorkflow
125
166
}
126
167
let stderr ;
127
168
try {
128
- ( { stderr } = spawnSyncAndExitWithoutError ( 'signtool' , [ 'sign' , '/fd' , 'SHA256' , targetExecutable ] ) ) ;
129
- spawnSyncAndExitWithoutError ( 'signtool' , [ 'verify' , '/pa' , 'SHA256' , targetExecutable ] ) ;
169
+ ( { stderr } = spawnSyncAndExitWithoutError ( 'signtool' , [
170
+ 'sign' ,
171
+ '/fd' ,
172
+ 'SHA256' ,
173
+ '/a' ,
174
+ targetExecutable ,
175
+ ] ) ) ;
176
+ spawnSyncAndExitWithoutError ( 'signtool' , [
177
+ 'verify' ,
178
+ '/pa' ,
179
+ targetExecutable ,
180
+ ] ) ;
130
181
} catch ( e ) {
131
- const message = `Cannot sign ${ targetExecutable } : ${ inspect ( e ) } \n${ stderr } ` ;
182
+ const message = `Cannot sign ${ targetExecutable } : ${ inspect (
183
+ e
184
+ ) } \n${ stderr } `;
132
185
if ( verifyWorkflow ) {
133
186
throw new Error ( message ) ;
134
187
}
0 commit comments