Skip to content

Commit 9f2fe0e

Browse files
committed
Add MSYS HOME directory
1 parent de584b2 commit 9f2fe0e

File tree

4 files changed

+81
-38
lines changed

4 files changed

+81
-38
lines changed

dist/index.js

Lines changed: 69 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ let msSt
527527
let msys2Sync = '-Sy'
528528

529529
// SSD drive, used for most downloads and MSYS
530-
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
530+
const drive = (process.env.GITHUB_WORKSPACE || 'C')[0]
531531

532532
// location to extract old MSYS packages
533533
const dirDK7z = `${drive}:\\DevKit64\\mingw\\x86_64-w64-mingw32`
@@ -717,6 +717,12 @@ const run = async () => {
717717
await installMSYS2()
718718
grpEnd(msSt)
719719
}
720+
721+
// add home directory for user
722+
const dirHome = `C:\\msys64\\home\\${process.env.USERNAME}`
723+
if (!fs.existsSync(dirHome)) {
724+
fs.mkdirSync(dirHome, { recursive: true })
725+
}
720726
} else {
721727
// get list of available pkgs for Ruby 2.2 & 2.3
722728
old_pkgs = __webpack_require__(169).old_pkgs
@@ -1151,8 +1157,18 @@ function getProxyUrl(serverUrl) {
11511157
return proxyUrl ? proxyUrl.href : '';
11521158
}
11531159
exports.getProxyUrl = getProxyUrl;
1154-
const HttpRedirectCodes = [HttpCodes.MovedPermanently, HttpCodes.ResourceMoved, HttpCodes.SeeOther, HttpCodes.TemporaryRedirect, HttpCodes.PermanentRedirect];
1155-
const HttpResponseRetryCodes = [HttpCodes.BadGateway, HttpCodes.ServiceUnavailable, HttpCodes.GatewayTimeout];
1160+
const HttpRedirectCodes = [
1161+
HttpCodes.MovedPermanently,
1162+
HttpCodes.ResourceMoved,
1163+
HttpCodes.SeeOther,
1164+
HttpCodes.TemporaryRedirect,
1165+
HttpCodes.PermanentRedirect
1166+
];
1167+
const HttpResponseRetryCodes = [
1168+
HttpCodes.BadGateway,
1169+
HttpCodes.ServiceUnavailable,
1170+
HttpCodes.GatewayTimeout
1171+
];
11561172
const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
11571173
const ExponentialBackoffCeiling = 10;
11581174
const ExponentialBackoffTimeSlice = 5;
@@ -1277,18 +1293,22 @@ class HttpClient {
12771293
*/
12781294
async request(verb, requestUrl, data, headers) {
12791295
if (this._disposed) {
1280-
throw new Error("Client has already been disposed.");
1296+
throw new Error('Client has already been disposed.');
12811297
}
12821298
let parsedUrl = url.parse(requestUrl);
12831299
let info = this._prepareRequest(verb, parsedUrl, headers);
12841300
// Only perform retries on reads since writes may not be idempotent.
1285-
let maxTries = (this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1) ? this._maxRetries + 1 : 1;
1301+
let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1
1302+
? this._maxRetries + 1
1303+
: 1;
12861304
let numTries = 0;
12871305
let response;
12881306
while (numTries < maxTries) {
12891307
response = await this.requestRaw(info, data);
12901308
// Check if it's an authentication challenge
1291-
if (response && response.message && response.message.statusCode === HttpCodes.Unauthorized) {
1309+
if (response &&
1310+
response.message &&
1311+
response.message.statusCode === HttpCodes.Unauthorized) {
12921312
let authenticationHandler;
12931313
for (let i = 0; i < this.handlers.length; i++) {
12941314
if (this.handlers[i].canHandleAuthentication(response)) {
@@ -1306,21 +1326,32 @@ class HttpClient {
13061326
}
13071327
}
13081328
let redirectsRemaining = this._maxRedirects;
1309-
while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1
1310-
&& this._allowRedirects
1311-
&& redirectsRemaining > 0) {
1312-
const redirectUrl = response.message.headers["location"];
1329+
while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 &&
1330+
this._allowRedirects &&
1331+
redirectsRemaining > 0) {
1332+
const redirectUrl = response.message.headers['location'];
13131333
if (!redirectUrl) {
13141334
// if there's no location to redirect to, we won't
13151335
break;
13161336
}
13171337
let parsedRedirectUrl = url.parse(redirectUrl);
1318-
if (parsedUrl.protocol == 'https:' && parsedUrl.protocol != parsedRedirectUrl.protocol && !this._allowRedirectDowngrade) {
1319-
throw new Error("Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.");
1338+
if (parsedUrl.protocol == 'https:' &&
1339+
parsedUrl.protocol != parsedRedirectUrl.protocol &&
1340+
!this._allowRedirectDowngrade) {
1341+
throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.');
13201342
}
13211343
// we need to finish reading the response before reassigning response
13221344
// which will leak the open socket.
13231345
await response.readBody();
1346+
// strip authorization header if redirected to a different hostname
1347+
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
1348+
for (let header in headers) {
1349+
// header names are case insensitive
1350+
if (header.toLowerCase() === 'authorization') {
1351+
delete headers[header];
1352+
}
1353+
}
1354+
}
13241355
// let's make the request with the new redirectUrl
13251356
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
13261357
response = await this.requestRaw(info, data);
@@ -1371,8 +1402,8 @@ class HttpClient {
13711402
*/
13721403
requestRawWithCallback(info, data, onResult) {
13731404
let socket;
1374-
if (typeof (data) === 'string') {
1375-
info.options.headers["Content-Length"] = Buffer.byteLength(data, 'utf8');
1405+
if (typeof data === 'string') {
1406+
info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
13761407
}
13771408
let callbackCalled = false;
13781409
let handleResult = (err, res) => {
@@ -1385,7 +1416,7 @@ class HttpClient {
13851416
let res = new HttpClientResponse(msg);
13861417
handleResult(null, res);
13871418
});
1388-
req.on('socket', (sock) => {
1419+
req.on('socket', sock => {
13891420
socket = sock;
13901421
});
13911422
// If we ever get disconnected, we want the socket to timeout eventually
@@ -1400,10 +1431,10 @@ class HttpClient {
14001431
// res should have headers
14011432
handleResult(err, null);
14021433
});
1403-
if (data && typeof (data) === 'string') {
1434+
if (data && typeof data === 'string') {
14041435
req.write(data, 'utf8');
14051436
}
1406-
if (data && typeof (data) !== 'string') {
1437+
if (data && typeof data !== 'string') {
14071438
data.on('close', function () {
14081439
req.end();
14091440
});
@@ -1430,31 +1461,34 @@ class HttpClient {
14301461
const defaultPort = usingSsl ? 443 : 80;
14311462
info.options = {};
14321463
info.options.host = info.parsedUrl.hostname;
1433-
info.options.port = info.parsedUrl.port ? parseInt(info.parsedUrl.port) : defaultPort;
1434-
info.options.path = (info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
1464+
info.options.port = info.parsedUrl.port
1465+
? parseInt(info.parsedUrl.port)
1466+
: defaultPort;
1467+
info.options.path =
1468+
(info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
14351469
info.options.method = method;
14361470
info.options.headers = this._mergeHeaders(headers);
14371471
if (this.userAgent != null) {
1438-
info.options.headers["user-agent"] = this.userAgent;
1472+
info.options.headers['user-agent'] = this.userAgent;
14391473
}
14401474
info.options.agent = this._getAgent(info.parsedUrl);
14411475
// gives handlers an opportunity to participate
14421476
if (this.handlers) {
1443-
this.handlers.forEach((handler) => {
1477+
this.handlers.forEach(handler => {
14441478
handler.prepareRequest(info.options);
14451479
});
14461480
}
14471481
return info;
14481482
}
14491483
_mergeHeaders(headers) {
1450-
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {});
1484+
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
14511485
if (this.requestOptions && this.requestOptions.headers) {
14521486
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers));
14531487
}
14541488
return lowercaseKeys(headers || {});
14551489
}
14561490
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
1457-
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {});
1491+
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
14581492
let clientHeader;
14591493
if (this.requestOptions && this.requestOptions.headers) {
14601494
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
@@ -1492,7 +1526,7 @@ class HttpClient {
14921526
proxyAuth: proxyUrl.auth,
14931527
host: proxyUrl.hostname,
14941528
port: proxyUrl.port
1495-
},
1529+
}
14961530
};
14971531
let tunnelAgent;
14981532
const overHttps = proxyUrl.protocol === 'https:';
@@ -1519,7 +1553,9 @@ class HttpClient {
15191553
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
15201554
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
15211555
// we have to cast it to any and change it directly
1522-
agent.options = Object.assign(agent.options || {}, { rejectUnauthorized: false });
1556+
agent.options = Object.assign(agent.options || {}, {
1557+
rejectUnauthorized: false
1558+
});
15231559
}
15241560
return agent;
15251561
}
@@ -1580,7 +1616,7 @@ class HttpClient {
15801616
msg = contents;
15811617
}
15821618
else {
1583-
msg = "Failed request: (" + statusCode + ")";
1619+
msg = 'Failed request: (' + statusCode + ')';
15841620
}
15851621
let err = new Error(msg);
15861622
// attach statusCode and body obj (if available) to the error object
@@ -1735,12 +1771,10 @@ function getProxyUrl(reqUrl) {
17351771
}
17361772
let proxyVar;
17371773
if (usingSsl) {
1738-
proxyVar = process.env["https_proxy"] ||
1739-
process.env["HTTPS_PROXY"];
1774+
proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY'];
17401775
}
17411776
else {
1742-
proxyVar = process.env["http_proxy"] ||
1743-
process.env["HTTP_PROXY"];
1777+
proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY'];
17441778
}
17451779
if (proxyVar) {
17461780
proxyUrl = url.parse(proxyVar);
@@ -1752,7 +1786,7 @@ function checkBypass(reqUrl) {
17521786
if (!reqUrl.hostname) {
17531787
return false;
17541788
}
1755-
let noProxy = process.env["no_proxy"] || process.env["NO_PROXY"] || '';
1789+
let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
17561790
if (!noProxy) {
17571791
return false;
17581792
}
@@ -1773,7 +1807,10 @@ function checkBypass(reqUrl) {
17731807
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
17741808
}
17751809
// Compare request host against noproxy
1776-
for (let upperNoProxyItem of noProxy.split(',').map(x => x.trim().toUpperCase()).filter(x => x)) {
1810+
for (let upperNoProxyItem of noProxy
1811+
.split(',')
1812+
.map(x => x.trim().toUpperCase())
1813+
.filter(x => x)) {
17771814
if (upperReqHosts.some(x => x === upperNoProxyItem)) {
17781815
return true;
17791816
}

mingw.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ let msSt
1212
let msys2Sync = '-Sy'
1313

1414
// SSD drive, used for most downloads and MSYS
15-
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
15+
const drive = (process.env.GITHUB_WORKSPACE || 'C')[0]
1616

1717
// location to extract old MSYS packages
1818
const dirDK7z = `${drive}:\\DevKit64\\mingw\\x86_64-w64-mingw32`
@@ -202,6 +202,12 @@ export const run = async () => {
202202
await installMSYS2()
203203
grpEnd(msSt)
204204
}
205+
206+
// add home directory for user
207+
const dirHome = `C:\\msys64\\home\\${process.env.USERNAME}`
208+
if (!fs.existsSync(dirHome)) {
209+
fs.mkdirSync(dirHome, { recursive: true })
210+
}
205211
} else {
206212
// get list of available pkgs for Ruby 2.2 & 2.3
207213
old_pkgs = require('./open_knapsack_pkgs').old_pkgs

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
"license": "MIT",
2424
"dependencies": {
2525
"@actions/core": "^1.2.3",
26-
"@actions/http-client": "^1.0.7"
26+
"@actions/http-client": "^1.0.8"
2727
}
2828
}

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.3.tgz#e844b4fa0820e206075445079130868f95bfca95"
88
integrity sha512-Wp4xnyokakM45Uuj4WLUxdsa8fJjKVl1fDTsPbTEcTcuu0Nb26IPQbOtjmnfaCPGcaoPOOqId8H9NapZ8gii4w==
99

10-
"@actions/http-client@^1.0.7":
11-
version "1.0.7"
12-
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-1.0.7.tgz#157515a4d7f92aac5b27ee616600e3f8a50870c2"
13-
integrity sha512-PY3ys/XH5WMekkHyZhYSa/scYvlE5T/TV/T++vABHuY5ZRgtiBZkn2L2tV5Pv/xDCl59lSZb9WwRuWExDyAsSg==
10+
"@actions/http-client@^1.0.8":
11+
version "1.0.8"
12+
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-1.0.8.tgz#8bd76e8eca89dc8bcf619aa128eba85f7a39af45"
13+
integrity sha512-G4JjJ6f9Hb3Zvejj+ewLLKLf99ZC+9v+yCxoYf9vSyH+WkzPLB2LuUtRMGNkooMqdugGBFStIKXOuvH1W+EctA==
1414
dependencies:
1515
tunnel "0.0.6"
1616

0 commit comments

Comments
 (0)