Commit 0725f4bb authored by Ben Gamari's avatar Ben Gamari 🐢

Rework handling of win32 toolchain tarballs

parent 813842f4
......@@ -1034,7 +1034,7 @@ source-tarball:
- ghc-*.tar.xz
- version
script:
- mk/get-win32-tarballs.sh download all
- python3 mk/get-win32-tarballs.py download all
- ./boot
- ./configure
- make sdist
......
......@@ -347,7 +347,7 @@ set_up_tarballs() {
else
action="download"
fi
mk/get-win32-tarballs.sh $action $HostArch > missing-win32-tarballs
$PYTHON mk/get-win32-tarballs.py $action $mingw_arch > missing-win32-tarballs
case $? in
0)
rm missing-win32-tarballs
......@@ -359,7 +359,7 @@ set_up_tarballs() {
echo
echo " * run configure with the --enable-tarballs-autodownload option"
echo
echo " * run mk/get-win32-tarballs.sh download ${HostArch}"
echo " * run mk/get-win32-tarballs.py download $mingw_arch"
echo
echo " * manually download the files listed in ./missing-win32-tarballs and place"
echo " them in the ghc-tarballs directory."
......
......@@ -61,12 +61,6 @@ dnl ** figure out how to do a BSD-ish install **
#
AC_PROG_INSTALL
#
dnl ** find `find`, used by get-win32-tarballs.sh (see #12502)
#
FP_PROG_FIND()
export FIND
#
dnl ** how to do symlinks **
#
......
......@@ -33,7 +33,8 @@ configureRules = do
-- We cannot use windowsHost here due to a cyclic dependency.
when windowsHost $ do
putBuild "| Checking for Windows tarballs..."
quietly $ cmd ["bash", "mk/get-win32-tarballs.sh", "download", System.arch]
pythonPath <- builderPath Python
quietly $ cmd [pythonPath, "mk/get-win32-tarballs.py", "download", System.arch]
let srcs = map (<.> "in") outs
context = vanillaContext Stage0 compiler
need srcs
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from pathlib import Path
import urllib.request
import subprocess
import argparse
TARBALL_VERSION = '0.1'
BASE_URL = "https://downloads.haskell.org/ghc/mingw/{}".format(TARBALL_VERSION)
BASE_URL = "http://home.smart-cactus.org/~ben/ghc/mingw/{}".format(TARBALL_VERSION)
DEST = Path('ghc-tarballs/mingw-w64')
ARCHS = ['i686', 'x86_64', 'sources']
def file_url(arch: str, fname: str) -> str:
return "{base}/{arch}/{fname}".format(
base=BASE_URL,
arch=arch,
fname=fname)
def fetch(url: str, dest: Path):
print('Fetching', url, '=>', dest)
urllib.request.urlretrieve(url, dest)
def fetch_arch(arch: str):
req = urllib.request.urlopen(file_url(arch, 'MANIFEST'))
files = req.read().decode('UTF-8').split('\n')
d = DEST / arch
if not d.is_dir():
d.mkdir(parents=True)
fetch(file_url(arch, 'SHA256SUMS'), d / 'SHA256SUMS')
for fname in files:
if not (d / fname).is_file():
fetch(file_url(arch, fname), d / fname)
verify(arch)
def verify(arch: str):
cmd = ['sha256sum', '--quiet', '--check', '--ignore-missing', 'SHA256SUMS']
subprocess.check_call(cmd, cwd=DEST / arch)
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument('mode', choices=['verify', 'download'])
parser.add_argument(
'arch',
choices=ARCHS + ['all'],
help="Architecture to fetch (either i686, x86_64, sources, or all)")
args = parser.parse_args()
action = fetch_arch if args.mode == 'download' else verify
if args.arch == 'all':
for arch in ARCHS:
action(arch)
else:
action(args.arch)
if __name__ == '__main__':
main()
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment