Skip to content

Commit

Permalink
add install-ghc.sh trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
evan0greenup committed Nov 5, 2024
1 parent d04f52a commit fbd7f3f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
_name=ghcup-hs
pkgname=hx-${_name}
pkgver=0.1.30.0
pkgrel=4
pkgrel=5
license=("LGPL-3.0-only")
arch=('x86_64')
url="https://github.com/haskell/ghcup-hs"
Expand All @@ -14,7 +14,7 @@ replaces=("ghcup-hs")
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/haskell/ghcup-hs/archive/refs/tags/v${pkgver}.tar.gz"
"ghcup_entry_proxy.py")
sha256sums=('89d158023f634f079ac6a306bb87d208445384a725d47b432f6858c8876cbef6'
'3834519e8f0e43cb280cd1f722bea6e52fbfd4bc0a75c277a7c80ae4779ae8e9')
'9e440ce518a46d9d1b42617dd45fd8fc557e66a64fd49929694fdf7336a78263')
_resolver="lts-21.25"
prepare() {
stack update --resolver=$_resolver
Expand Down
13 changes: 12 additions & 1 deletion ghcup_entry_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pathlib
import sys
import os

import subprocess

Expand All @@ -27,6 +28,8 @@ def parse_args() -> tuple[str, list[str]]:
return prog_filename.name, remaining_args


GHC_INSTALL_SH_FILE_URL = "https://raw.githubusercontent.com/haskell/ghcup-hs/master/scripts/hooks/stack/ghc-install.sh"

def launch():
prog_name, remaining_args = parse_args()

Expand All @@ -35,17 +38,25 @@ def launch():
pathlib.Path("~").expanduser().joinpath(".ghcup", "bin", prog_name)
)
if not target_exec_path.is_file():
pkg_name = CMD_TO_PKG_TABLE[prog_name]
subprocess.run(
[
"ghcup",
"install",
CMD_TO_PKG_TABLE[prog_name],
pkg_name,
"--set",
"recommended",
],
shell=False,
check=True,
)
if pkg_name == "stack":
ghc_install_sh_filename = pathlib.Path("~").expanduser().joinpath(".stack", "hooks", "ghc-install.sh")
ghc_install_sh_filename.parent.mkdir(exist_ok=True, parents=True)
subprocess.run(["curl", GHC_INSTALL_SH_FILE_URL, "-o", ghc_install_sh_filename], shell=False, check=True)
subprocess.run(["chmod", "u+x", ghc_install_sh_filename])
subprocess.run(["stack", "config", "set", "system-ghc", "false", "--global"])

subprocess.run([target_exec_path, *remaining_args], shell=False, check=True)


Expand Down

0 comments on commit fbd7f3f

Please sign in to comment.