Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions packages/alex/build.ncl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
let { BuildSpec, Local, OutputBin, Source, .. } = import "minimal.ncl" in
let base = import "../base/build.ncl" in
let bash = import "../bash/build.ncl" in
let ghc-bootstrap = import "../ghc-bootstrap/build.ncl" in
let gmp = import "../gmp/build.ncl" in
let toolchain = import "../toolchain/build.ncl" in

let version = "3.5.1.0" in
{
name = "alex",

build_deps = [
{ file = "build.sh" } | Local,
{
url = "https://hackage.haskell.org/package/alex-%{version}/alex-%{version}.tar.gz",
sha256 = "c92efe86f8eb959ee03be6c04ee57ebc7e4abc75a6c4b26551215d7443e92a07",
extract = true,
} | Source,
base,
bash,
ghc-bootstrap,
toolchain,
],

runtime_deps = [
base,
gmp,
],

cmd = "./build.sh",
build_args = {
include version,
},

outputs = {
alex = { glob = "usr/bin/alex" } | OutputBin,
},

attrs = {
upstream_version = version,
},
} | BuildSpec
19 changes: 19 additions & 0 deletions packages/alex/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -euo pipefail

cd "alex-$MINIMAL_ARG_VERSION"

# Determine setup file
SETUP_FILE="Setup.hs"
if [ -f Setup.lhs ]; then
SETUP_FILE="Setup.lhs"
elif [ ! -f Setup.hs ]; then
echo "import Distribution.Simple" > Setup.hs
echo "main = defaultMain" >> Setup.hs
SETUP_FILE="Setup.hs"
fi

ghc --make "$SETUP_FILE"
./Setup configure --prefix=/usr
./Setup build
./Setup copy --destdir="$OUTPUT_DIR"
Comment thread
coderabbitai[bot] marked this conversation as resolved.
64 changes: 64 additions & 0 deletions packages/ghc-bootstrap/build.ncl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
let { BuildSpec, Local, OutputBin, OutputData, OutputLib, Source, .. } = import "minimal.ncl" in
let { target, .. } = import "config.ncl" in
let base = import "../base/build.ncl" in
let bash = import "../bash/build.ncl" in
let gmp = import "../gmp/build.ncl" in
let make = import "../make/build.ncl" in
let ncurses = import "../ncurses/build.ncl" in
let perl = import "../perl/build.ncl" in
let tar = import "../tar/build.ncl" in
let toolchain = import "../toolchain/build.ncl" in
let xz = import "../xz/build.ncl" in

let version = "9.8.1" in
{
name = "ghc-bootstrap",

build_deps = [
{ file = "build.sh" } | Local,
match {
{ arch = 'Amd64, .. } =>
{
url = "https://downloads.haskell.org/~ghc/%{version}/ghc-%{version}-x86_64-deb11-linux.tar.xz",
sha256 = "ca4dde3a6f34f1fe6d0783767671f02e862f1b0222ef2dc2c5c68cc2abc1abae",
extract = false,
} | Source,
{ arch = 'Arm64, .. } =>
{
url = "https://downloads.haskell.org/~ghc/%{version}/ghc-%{version}-aarch64-deb10-linux.tar.xz",
sha256 = "aab7af72614f8bf9ca624407aa4dbc69bc009c2b4cc1a0f3c062008db81bdb95",
extract = false,
} | Source,
} target,
base,
bash,
gmp,
make,
ncurses,
perl,
tar,
toolchain,
xz,
],

runtime_deps = [
base,
gmp,
ncurses,
],

cmd = "./build.sh",
build_args = {
include version,
},

outputs = {
bins = { glob = "usr/bin/*" } | OutputBin,
libs = { glob = "usr/lib/ghc-%{version}/**", allow_executable = true } | OutputData,
libtinfo = { glob = "usr/lib/*.so*" } | OutputLib,
},

attrs = {
upstream_version = version,
},
} | BuildSpec
90 changes: 90 additions & 0 deletions packages/ghc-bootstrap/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/bin/bash
set -euo pipefail

BOOTSTRAP_ARCH="$(uname -m)"
case "$BOOTSTRAP_ARCH" in
x86_64)
BOOTSTRAP_TAR="ghc-${MINIMAL_ARG_VERSION}-x86_64-deb11-linux.tar.xz"
;;
aarch64)
BOOTSTRAP_TAR="ghc-${MINIMAL_ARG_VERSION}-aarch64-deb10-linux.tar.xz"
;;
*)
echo "Unsupported architecture: $BOOTSTRAP_ARCH"
exit 1
;;
esac

# Extract prebuilt GHC
mkdir -p bootstrap-src
tar -xof "$BOOTSTRAP_TAR" -C bootstrap-src --strip-components=1

# Configure and install GHC to $OUTPUT_DIR/usr
cd bootstrap-src
./configure --prefix=/usr
make install_bin install_lib update_package_db DESTDIR="$OUTPUT_DIR"

# Find the real ncurses library dynamically
NCURSES_PATH=""
for path in \
/usr/lib/libncursesw.so.6 \
/usr/lib/libncurses.so.6 \
/usr/lib64/libncursesw.so.6 \
/usr/lib64/libncurses.so.6 \
/lib/*/libncursesw.so.6 \
/lib/*/libncurses.so.6 \
/usr/lib/*/libncursesw.so.6 \
/usr/lib/*/libncurses.so.6 \
/lib/libncursesw.so.6 \
/lib/libncurses.so.6; do
if [ -f "$path" ]; then
NCURSES_PATH="$path"
break
fi
done

if [ -z "$NCURSES_PATH" ]; then
if command -v gcc >/dev/null 2>&1; then
for libname in libncursesw.so.6 libncurses.so.6; do
GCC_FOUND_PATH="$(gcc -print-file-name=$libname)"
if [ -f "$GCC_FOUND_PATH" ]; then
NCURSES_PATH="$GCC_FOUND_PATH"
break
fi
done
fi
fi

if [ -z "$NCURSES_PATH" ]; then
if command -v ldconfig >/dev/null 2>&1; then
for libname in libncursesw.so.6 libncurses.so.6; do
LDCONFIG_PATH="$(ldconfig -p | awk -v lib="$libname" '$0 ~ lib {print $NF; exit}')"
if [ -f "$LDCONFIG_PATH" ]; then
NCURSES_PATH="$LDCONFIG_PATH"
break
fi
done
fi
fi
Comment thread
coderabbitai[bot] marked this conversation as resolved.

if [ -z "$NCURSES_PATH" ]; then
echo "Error: Could not locate libncursesw.so.6 or libncurses.so.6" >&2
exit 1
fi

# We also need a libtinfo.so.6, which GHC expects.
mkdir -p "$OUTPUT_DIR/usr/lib"
cp -p "$NCURSES_PATH" "$OUTPUT_DIR/usr/lib/libtinfo.so.6"

# Let's also copy it in the GHC lib directory:
GHC_LIB_DIR="$OUTPUT_DIR/usr/lib/ghc-${MINIMAL_ARG_VERSION}/lib"
if [ -d "$GHC_LIB_DIR" ]; then
cp -p "$NCURSES_PATH" "$GHC_LIB_DIR/libtinfo.so.6"
fi

# Modify bootstrap settings to use standard ld instead of ld.gold
SETTINGS_FILE="$OUTPUT_DIR/usr/lib/ghc-${MINIMAL_ARG_VERSION}/lib/settings"
if [ -f "$SETTINGS_FILE" ]; then
sed -i 's/-fuse-ld=gold//g' "$SETTINGS_FILE"
sed -i 's|/usr/bin/ld.gold|/usr/bin/ld|g' "$SETTINGS_FILE"
fi
26 changes: 6 additions & 20 deletions packages/ghc/build.ncl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
let { Attrs, BuildSpec, Local, Needs, OutputBin, OutputData, OutputLib, Source, Test, .. } = import "minimal.ncl" in
let alex = import "../alex/build.ncl" in
let base = import "../base/build.ncl" in
let bash = import "../bash/build.ncl" in
let binutils = import "../binutils/build.ncl" in
Expand All @@ -15,6 +16,8 @@ let automake = import "../automake/build.ncl" in
let m4 = import "../m4/build.ncl" in
let curl = import "../curl/build.ncl" in
let make = import "../make/build.ncl" in
let ghc-bootstrap = import "../ghc-bootstrap/build.ncl" in
let happy = import "../happy/build.ncl" in

let version = "9.10.3" in
{
Expand All @@ -27,33 +30,16 @@ let version = "9.10.3" in
sha256 = "d266864b9e0b7b741abe8c9d6a790d7c01c21cf43a1419839119255878ebc59a",
extract = false,
} | Source,
{
url = "https://downloads.haskell.org/~ghc/9.8.1/ghc-9.8.1-x86_64-deb11-linux.tar.xz",
sha256 = "ca4dde3a6f34f1fe6d0783767671f02e862f1b0222ef2dc2c5c68cc2abc1abae",
extract = false,
} | Source,
{
url = "https://downloads.haskell.org/~ghc/9.8.1/ghc-9.8.1-aarch64-deb10-linux.tar.xz",
sha256 = "aab7af72614f8bf9ca624407aa4dbc69bc009c2b4cc1a0f3c062008db81bdb95",
extract = false,
} | Source,
{
url = "https://downloads.haskell.org/~ghc/%{version}/hadrian-bootstrap-sources/hadrian-bootstrap-sources-9.8.1.tar.gz",
sha256 = "eec7233763bc31801fcbc996edc9c1f5abae707c1661deb8b22f0a7c2780b5e9",
extract = false,
} | Source,
{
url = "https://hackage.haskell.org/package/alex-3.5.1.0/alex-3.5.1.0.tar.gz",
sha256 = "c92efe86f8eb959ee03be6c04ee57ebc7e4abc75a6c4b26551215d7443e92a07",
extract = false,
} | Source,
{
url = "https://hackage.haskell.org/package/happy-1.20.1.1/happy-1.20.1.1.tar.gz",
sha256 = "8b4e7dc5a6c5fd666f8f7163232931ab28746d0d17da8fa1cbd68be9e878881b",
extract = false,
} | Source,
alex,
base,
bash,
ghc-bootstrap,
happy,
perl,
python,
gmp,
Expand Down
Loading