## START: Set by rpmautospec ## (rpmautospec version 0.2.5) %define autorelease(e:s:pb:) %{?-p:0.}%{lua: release_number = 4; base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}")); print(release_number + base_release_number - 1); }%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{?dist} ## END: Set by rpmautospec %global npm_name fkill-cli Name: %{npm_name} Version: 7.0.0 Release: %autorelease Summary: Fabulously kill processes # License of fkill-cli is MIT; others come from bundled dependencies. See # the license file %%{npm_name}-%%{version}-bundled-licenses.txt for a list of # licenses in NPM format. Each bundled dependency has the license specified in # the "license" key of its package.json file. License: MIT and 0BSD and ASL 2.0 and BSD and CC0 and CC-BY and ISC and (MIT or CC0) %global forgeurl https://github.com/sindresorhus/%{npm_name} %forgemeta URL: %{forgeurl} Source0: https://registry.npmjs.org/%{npm_name}/-/%{npm_name}-%{version}.tgz # The test files are not included in the NPM tarball. Instead of using a # dl-tests.sh script source, we add the corresponding GitHub tarball as a # second source. This results in some duplication in the source RPM, but it is # a lot simpler! # # Note https://docs.fedoraproject.org/en-US/packaging-guidelines/Node.js/ says, # “The canonical method for shipping most node modules is tarballs from the npm # registry. […] This method should be preferred to using checkouts from git or # automatically generated tarballs from GitHub.” (Otherwise, we might just use # the GitHub tarball as the primary source.) Source1: %{forgesource} # Created with (from nodejs-packaging RPM): # nodejs-packaging-bundler %%{npm_name} %%{version} Source2: %{npm_name}-%{version}-nm-prod.tgz Source3: %{npm_name}-%{version}-nm-dev.tgz Source4: %{npm_name}-%{version}-bundled-licenses.txt # Hand-written man page Source5: fkill.1 # While https://bugzilla.redhat.com/show_bug.cgi?id=1920223 is fixed, we find # that it is still useful to audit null licenses at build time and to keep # manually-approved exceptions in a file. Source6: check-null-licenses Source7: audited-null-licenses.toml ExclusiveArch: %{nodejs_arches} noarch BuildArch: noarch BuildRequires: nodejs-devel BuildRequires: symlinks BuildRequires: hardlink BuildRequires: rsync # For check-null-licenses BuildRequires: python3-devel BuildRequires: python3dist(toml) # Dependencies shell out to ps and ss: BuildRequires: procps-ng BuildRequires: iproute Requires: nodejs # Dependencies shell out to ps and ss: Requires: procps-ng Requires: iproute %global test_sources fixture.js test.js %description %{summary}. %prep %setup -q -n package # Copy in the tests from the GitHub tarball. %setup -q -T -D -b 1 -n package for src in %{test_sources} do cp -p "../%{npm_name}-%{version}/${src}" ./ done cp -p '%{SOURCE4}' . # Set up bundled runtime (prod) node modules. tar -xzf '%{SOURCE2}' mkdir -p node_modules pushd node_modules ln -s ../node_modules_prod/* . ln -s ../node_modules_prod/.bin . popd # Fix shebang lines in executables. For some reason, brp-mangle-shebangs does # not seem to do this under %%nodejs_sitelib. find . -type f -perm /0111 -exec gawk \ '/^#!\/usr\/bin\/env[[:blank:]]/ { print FILENAME }; { nextfile }' \ '{}' '+' | xargs -r sed -r -i '1{s|^(#!/usr/bin/)env[[:blank:]]+([^[:blank:]]+)|\1\2|}' \ # Remove dotfiles (hidden files) from bundled dependencies. As of 6.1.0-1, # these include: (.editorconfig .eslintignore .eslintrc .eslintrc.json .gitkeep # .istanbul.yml .jscs.json .npmignore .nycrc .travis.yml) and are all not # needed at runtime. If a dependency appears with an important hidden file, we # may need to exclude it from removal. # # Also remove zero-length files from bundled dependencies. As of 6.1.0-1, these # are only in tests and examples for bundled dependencies, neither of which # will be used by the installed package, so it is OK if these portions of the # dependencies are broken by the removal. find node_modules_prod -type f \( -name '.*' -o -size 0 \) -print -delete # Remove hidden directories from bundled dependencies, except those known to be # useful. If a dependency appears with an important hidden directory, we may # need to exclude it from removal. # # We do need to keep .bin/ directories around, as they will be used in %%check. # We can remove them from the installed buildroot, however. find node_modules_prod -depth -type d -name '.*' ! -name '.bin' \ -printf '--> Remove hidden directory %p\n' -exec rm -rvf '{}' ';' # Fix some goofy permissions find node_modules_prod -type f -name '*.json' -perm /0111 \ -execdir chmod -v a-x '{}' '+' # Nothing to build %install install -d '%{buildroot}%{nodejs_sitelib}/%{npm_name}' cp -rp \ package.json \ cli.js \ interactive.js \ node_modules node_modules_prod \ '%{buildroot}%{nodejs_sitelib}/%{npm_name}' install -d '%{buildroot}%{_bindir}' # Create an absolute symlink in the buildroot, then convert it to a relative # one that will still resolve after installation. Otherwise, to create a # relative symlink, we would have to know how deeply nested %%nodejs_sitelib # is, which breaks the abstraction of using a macro. ln -sf '%{buildroot}%{nodejs_sitelib}/%{npm_name}/cli.js' \ '%{buildroot}%{_bindir}/fkill' symlinks -c -o '%{buildroot}%{_bindir}/fkill' install -D -t '%{buildroot}%{_mandir}/man1' -p -m 0644 '%{SOURCE5}' # We do not need binaries associated with bundled node libraries, so even .bin # directories may be removed from the buildroot. find '%{buildroot}/%{nodejs_sitelib}/%{npm_name}/node_modules_prod' \ -depth -type d -name '.bin' \ -printf '--> Remove hidden directory %p\n' -exec rm -rvf '{}' ';' # Also, remove the .bin symlink: rm -vf '%{buildroot}/%{nodejs_sitelib}/%{npm_name}/node_modules/.bin' # Hardlink duplicate files in the dependency bundle. We don’t pass the “-t” # option to “hardlink”, so only files with the same mtime (not just identical # contents) are hardlinked. hardlink '%{buildroot}/%{nodejs_sitelib}/%{npm_name}/node_modules_prod' %check %{python3} '%{SOURCE6}' --exceptions '%{SOURCE7}' --with prod node_modules_prod # We do not call: # %%{__nodejs} -e 'require("./")' # because this package does not provide an importable module. See the lack of a # "main" or "module" key in package.json. # Set up bundled dev node_modules for testing. We must do this here, not in # prep, so that they are not pulled into the installed RPM. tar -xzf '%{SOURCE3}' %{python3} '%{SOURCE6}' --exceptions '%{SOURCE7}' --with dev node_modules_dev # The usual symlinking approach recommended by the guidelines does not work as # some dependencies are split across the prod and dev tarballs due to plugins. # Instead, we overlay the two directories using local rsync. This is less # space-efficient, but it works! rm -rf node_modules cp -rp ./node_modules_prod node_modules rsync -aqP ./node_modules_dev/ ./node_modules/ # See scripts.test in package.json. We must explicitly specify the test script, # or ava recurses inside node_modules*/ looking for tests and finds a great # many excuses to crash. NODE_ENV=test ./node_modules/.bin/ava test.js %files %doc readme.md %license license %{npm_name}-%{version}-bundled-licenses.txt %{nodejs_sitelib}/%{npm_name} %{_bindir}/fkill %{_mandir}/man1/fkill.1* %changelog * Fri Dec 03 2021 Benjamin A. Beasley 7.0.0-4 - Hardlink duplicate files in the dependency bundle * Fri Dec 03 2021 Benjamin A. Beasley 7.0.0-3 - Convert python3 BR to python3-devel per guidelines * Fri Oct 15 2021 Benjamin A. Beasley 7.0.0-1 - Update to 7.0.0 (close RHBZ#2014388) * Sat Aug 28 2021 Benjamin A. Beasley 6.2.0-10 - Faster shebang fix * Mon Jul 26 2021 Benjamin A. Beasley 6.2.0-8 - Check dev bundle licenses *after* unpacking it * Mon Jul 26 2021 Benjamin A. Beasley 6.2.0-7 - Improved error detection in check-null-licenses * Mon Jul 26 2021 Benjamin A. Beasley 6.2.0-6 - Remove unnecessary nodejs_symlink_deps macro in check section * Mon Jul 26 2021 Benjamin A. Beasley 6.2.0-5 - More shell quoting * Mon Jul 26 2021 Benjamin A. Beasley 6.2.0-4 - Preserve timestamp on bundled dependency license list file * Wed Jul 21 2021 Fedora Release Engineering 6.2.0-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild * Sun Jul 11 2021 Benjamin A. Beasley - 6.2.0-1 - Update to 6.2.0 (closes RHBZ#1981060) * Thu Jun 10 2021 Benjamin A. Beasley - 6.1.0-1 - Initial package