File node-gyp.spec of Package node-gyp

#
# spec file for package node-gyp
#
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


# The internal dependency generator adds lots of unnecessary Requires:
# and strange Provides: own(foo) because it slurps in all package.json
%global __nodejs_provides %{nil}
%global __nodejs_requires %{nil}

Name:           node-gyp
Version:        11.2.0
Release:        0
Summary:        Node.js native addon build tool
License:        MIT
URL:            https://github.com/nodejs/node-gyp
Source0:        %{name}-%{version}.tar.gz
Source3:        Makefile
#
Source10:       package-lock.json
Source11:       node_modules.spec.inc
%include        %{_sourcedir}/node_modules.spec.inc
BuildRequires:  local-npm-registry
BuildRequires:  fdupes
BuildArch:      noarch
#
Requires:       nodejs-common
Requires:       python3

%description
node-gyp is a cross-platform command-line tool written in Node.js for compiling
native addon modules for Node.js.

%prep
%autosetup -p 1
cp %{SOURCE10} .
local-npm-registry %{_sourcedir} install --include=dev

%build

%install
rm -rf ./node_modules/
npm install --offline

# fix shebangs
find . -type f -exec sed -i 's|/usr/bin/env |/usr/bin/|' {} \;
find ./node_modules/ -iname "*.h" -delete
find ./node_modules/ -iname "*.c" -delete

mkdir -p %{buildroot}/usr/lib/%{name}/
tar xf %{SOURCE0} -C %{buildroot}/usr/lib/%{name}/ --strip-components=1
ls -lh %{buildroot}/usr/lib/%{name}/
rm -rf %{buildroot}/usr/lib/%{name}/node_modules/
cp -r ./node_modules/ %{buildroot}/usr/lib/%{name}/
find %{buildroot}/usr/lib/%{name}/  -type f -exec sed -i 's|/usr/bin/env |/usr/bin/|' {} \;

mkdir -p %{buildroot}/%{_bindir}/
ln -s /usr/lib/%{name}/bin/%{name}.js %{buildroot}/%{_bindir}/%{name}

%fdupes %{buildroot}/usr/lib/%{name}/
rm -f %{buildroot}/usr/lib/%{name}/node_modules/require-inject/CHANGELOG.md~

%files
%license LICENSE
%doc README.md
%{_bindir}/%{name}
/usr/lib/%{name}/

%changelog

openSUSE Build Service is sponsored by