From 9f609daf3ef7fac1da76112605b3bb93edbd547d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Fri, 20 Oct 2023 10:27:11 +0200 Subject: [PATCH] Fix NPM 'postinstall' task in Windows Fixes #1179 Provide `getmake.py` with the absolute path in which it must place fetched stuff. --- npm-scripts.mjs | 4 +++- worker/scripts/getmake.py | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/npm-scripts.mjs b/npm-scripts.mjs index 7ca9942e75..2089a6379e 100644 --- a/npm-scripts.mjs +++ b/npm-scripts.mjs @@ -445,7 +445,9 @@ function installMsysMake() pythonPath = String(res.stdout).trim(); } - executeCmd(`${pythonPath} worker\\scripts\\getmake.py`); + const dir = path.resolve('worker/out/msys'); + + executeCmd(`${pythonPath} worker\\scripts\\getmake.py --dir="${dir}"`); } function ensureDir(dir) diff --git a/worker/scripts/getmake.py b/worker/scripts/getmake.py index c6c0dbb9a3..50ec9ea7f1 100644 --- a/worker/scripts/getmake.py +++ b/worker/scripts/getmake.py @@ -1,10 +1,21 @@ -import io, hashlib, tarfile, urllib.request +import argparse, io, hashlib, tarfile, urllib.request + +argParser = argparse.ArgumentParser() + +argParser.add_argument( + '--dir', + type=str, + required=True, + help='absolute path of the directoy in which fetched content will be placed' +) + +args = argParser.parse_args() def get(url, digest): data = urllib.request.urlopen(url).read() assert hashlib.sha256(data).hexdigest() == digest tar = tarfile.open(fileobj=io.BytesIO(data)) - tar.extractall('worker/out/msys') + tar.extractall(args.dir) tar.close() get('https://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/msys-1.0.19-1/msysCORE-1.0.19-1-msys-1.0.19-bin.tar.xz/download', '8c4157d739a460f85563bc4451e9f1bbd42b13c4f63770d43b9f45a781f07858')