diff --git a/packages/std/toolchain/native/index.bri b/packages/std/toolchain/native/index.bri index f75330c..ba5984e 100644 --- a/packages/std/toolchain/native/index.bri +++ b/packages/std/toolchain/native/index.bri @@ -181,6 +181,28 @@ export const toolchain = std.memo( // Add a symlink for the C compiler toolchain = toolchain.insert("bin/cc", std.symlink({ target: "gcc" })); + // Fix broken library symlinks + toolchain = toolchain.insert( + "lib/libuuid.so", + std.symlink({ target: "libuuid.so.1" }), + ); + toolchain = toolchain.insert( + "lib/libblkid.so", + std.symlink({ target: "libblk.id.so.1" }), + ); + toolchain = toolchain.insert( + "lib/libsmartcols.so", + std.symlink({ target: "libsmartcols.so.1" }), + ); + toolchain = toolchain.insert( + "lib/libfdisk.so", + std.symlink({ target: "libfdisk.so.1" }), + ); + toolchain = toolchain.insert( + "lib/libmount.so", + std.symlink({ target: "libmount.so.1" }), + ); + // Add a symlink that libtool needs toolchain = toolchain.insert( "share/libtool/m4", @@ -204,7 +226,7 @@ export const toolchain = std.memo( // Perl library paths PERL5LIB: { - append: [{ path: "share/autconf" }, { path: "share/automake-1.16" }], + append: [{ path: "share/autoconf" }, { path: "share/automake-1.16" }], }, // pkg-config search paths @@ -261,6 +283,8 @@ export const toolchain = std.memo( toolchain = fixShebangs(toolchain); + toolchain = makePkgConfigPathsRelative(toolchain); + toolchain = std.sync(toolchain); return toolchain; @@ -350,3 +374,30 @@ function fixShebangs( }) .toDirectory(); } + +function makePkgConfigPathsRelative( + recipe: std.AsyncRecipe, +): std.Recipe { + // Replaces things that look like absolute paths in pkg-config files with + // relative paths (using the `${pcfiledir}` variable) + return std + .process({ + command: std.tpl`${stage2()}/bin/bash`, + args: [ + "-c", + std.indoc` + set -euo pipefail + + find "$BRIOCHE_OUTPUT"/lib/pkgconfig -name '*.pc' -type f -print0 \ + | while IFS= read -r -d $'\\0' file; do + sed -i 's|=/|=\${pcfiledir}/../../|' "$file" + done + `, + ], + env: { + PATH: std.tpl`${stage2()}/bin`, + }, + outputScaffold: recipe, + }) + .toDirectory(); +}