nodejs-undici/nodejs-undici.spec

93 lines
3.0 KiB
RPMSpec
Raw Normal View History

2023-10-03 12:04:54 +00:00
%global npm_name undici
%global llhttp_version_major 8
%global llhttp_version_minor 1
%global llhttp_version_patch 0
Name: nodejs-%{npm_name}
Summary: An HTTP/1.1 client, written from scratch for Node.js
Version: 5.28.3
2023-10-03 12:04:54 +00:00
Release: %autorelease
License: MIT
URL: https://undici.nodejs.org
# See Source4 on how these archives were generated
Source0: %{npm_name}-%{version}-stripped.tar.gz
Source1: %{npm_name}-%{version}-nm-prod.tgz
Source2: %{npm_name}-%{version}-nm-dev.tgz
Source3: %{npm_name}-%{version}-bundled-licenses.txt
Source4: %{npm_name}-sources.sh
# Upstream proposal: https://github.com/nodejs/undici/pull/2403
Patch0: 0001-feat-allow-customization-of-build-environment.patch
Patch1: 0002-Support-building-for-externally-shared-js-builtins-2.patch
Patch2: 0002-chore-refine-esbuild-node-detection.patch
2023-10-03 12:04:54 +00:00
# Binary artifacts in this package are aimed at the wasm32-wasi "architecture".
%global _binaries_in_noarch_packages_terminate_build 0
BuildArch: noarch
# would be %%{nodejs_arches} noarch, but lld is not yet supported on s390x
ExclusiveArch: %{ix86} x86_64 aarch64 ppc64le riscv64 noarch
2023-10-03 12:04:54 +00:00
BuildRequires: clang lld wasi-libc-devel
BuildRequires: nodejs-devel npm
# for autosetup -S git_am
BuildRequires: git-core
# This package bundles it's own copy of llhttp
Provides: bundled(llhttp) = %{llhttp_version_major}.%{llhttp_version_minor}.%{llhttp_version_patch}
%description
An HTTP/1.1 client, written from scratch for Node.js.
%prep
%autosetup -n %{npm_name}-%{version} -S git_am
cp -p %{S:3} .
# Check for bundled llhttp version
if ! grep -q 'LLHTTP_VERSION_MAJOR %{llhttp_version_major}' deps/llhttp/include/llhttp.h \
|| ! grep -q 'LLHTTP_VERSION_MINOR %{llhttp_version_minor}' deps/llhttp/include/llhttp.h \
|| ! grep -q 'LLHTTP_VERSION_PATCH %{llhttp_version_patch}' deps/llhttp/include/llhttp.h
then
echo 'llhttp version mismatch' >&2; exit 2
fi
# Link node_modules
mkdir -p node_modules/.bin/
tar -xzf %{S:1}
ln -srt node_modules/ node_modules_prod/*
ln -srt node_modules/.bin/ node_modules_prod/.bin
%build
export WASM_CC=clang
export WASM_CFLAGS='--target=wasm32-wasi --sysroot=/usr/wasm32-wasi'
export WASM_LDFLAGS='-nodefaultlibs'
export WASM_LDLIBS='-lc'
# `npm run build` uses docker; invoke the build script directly
env EXTERNAL_PATH='%{nodejs_sitelib}/%{npm_name}' %{__nodejs} build/wasm.js
2023-10-03 12:04:54 +00:00
npm --offline pack
%install
mkdir -p %{buildroot}%{nodejs_sitelib}/%{npm_name}
tar -C %{buildroot}%{nodejs_sitelib}/%{npm_name} -xzf %{npm_name}-%{version}.tgz --strip-components=1
cp -prt %{buildroot}%{nodejs_sitelib}/%{npm_name} node_modules_prod node_modules
%check
%{__nodejs} -e 'require("./")'
tar -xzf %{S:2}
ln -fsrt node_modules/ node_modules_dev/*
ln -fsrt node_modules/.bin/ node_modules_dev/.bin/*
# Depends on the environment/OpenSSL version, etc. Informational only.
npm --offline run test || :
%files
%doc README.md
%license LICENSE %{npm_name}-%{version}-bundled-licenses.txt
%dir %{nodejs_sitelib}
2023-10-03 12:04:54 +00:00
%{nodejs_sitelib}/%{npm_name}
%changelog
%autochangelog