Skip to content

Commit

Permalink
Fix NPM 'postinstall' task in Windows
Browse files Browse the repository at this point in the history
Fixes #1179

Provide `getmake.py` with the absolute path in which it must place fetched stuff.
  • Loading branch information
ibc committed Oct 20, 2023
1 parent e782b79 commit 9f609da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion npm-scripts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 13 additions & 2 deletions worker/scripts/getmake.py
Original file line number Diff line number Diff line change
@@ -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')
Expand Down

0 comments on commit 9f609da

Please sign in to comment.