## START: Set by rpmautospec ## (rpmautospec version 0.2.5) %define autorelease(e:s:pb:) %{?-p:0.}%{lua: release_number = 5; 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 svgo %bcond_without tests %global forgeurl https://github.com/svg/%{npm_name} Name: nodejs-%{npm_name} Version: 2.8.0 %forgemeta Release: %autorelease Summary: Nodejs-based tool for optimizing SVG vector graphics files # The package itself is MIT; other licenses come from bundled dependencies. See # %%{npm_name}-%%{version}-bundled-licenses.txt, audited-null-licenses.toml, # and the package.json files of the bundled dependencies for details. License: MIT and BSD and ISC and CC0 URL: %{forgeurl} Source0: https://registry.npmjs.org/%{npm_name}/-/%{npm_name}-%{version}.tgz # The documentation and 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 # While https://bugzilla.redhat.com/show_bug.cgi?id=1920223 is now fixed, we # prefer to verify licenses at build time anyway. Source5: check-null-licenses Source6: audited-null-licenses.toml # Downstream man page hand-written for Fedora based on --help output Source7: %{npm_name}.1 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) Requires: nodejs # This package predates the new naming guidelines for NodeJS pacakges as of # Fedora 34. Since it primarily provides the svgo CLI tool, it should be called # svgo rather than nodejs-svgo. We might go through the packaging renaming # process at some point; for now, we add a virtual Provides. See # https://docs.fedoraproject.org/en-US/packaging-guidelines/Node.js/ # #_naming_guidelines Provides: %{npm_name} = %{version}-%{release} %description SVG Optimizer is a Nodejs-based tool for optimizing SVG vector graphics files. Why? SVG files, especially those exported from various editors, usually contain a lot of redundant and useless information. This can include editor metadata, comments, hidden elements, default or non-optimal values and other stuff that can be safely removed or converted without affecting the SVG rendering result. %prep %setup -q -n package # Copy in the documentation and tests from the GitHub tarball. %setup -q -T -D -b 1 -n package for dir in 'docs' 'test' do cp -rp "../%{npm_name}-%{version}/${dir}" ./ 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/* . ! [ -e ../node_modules_prod/.bin ] popd # Remove dotfiles (hidden files) from bundled dependencies. Currently this is # just a top-level .package-lock.json. 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. Currently there are # none. find node_modules_prod -type f \( -name '.*' -o -size 0 \) -print -delete # Copy in the man page cp -p '%{SOURCE7}' . # Remove pre-built browser JavaScript bundle rm -rf dist # Ensure script entry point is executable chmod -v 0755 bin/%{npm_name} # 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|}' \ # No build required %install install -d %{buildroot}%{nodejs_sitelib}/%{npm_name} cp -rp \ package.json \ bin lib plugins \ 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}/bin/%{npm_name} \ %{buildroot}%{_bindir}/%{npm_name} symlinks -c -o %{buildroot}%{_bindir}/%{npm_name} install -t '%{buildroot}%{_mandir}/man1' -D -p -m 0644 %{npm_name}.1 # 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} '%{SOURCE5}' --exceptions '%{SOURCE6}' --with prod node_modules_prod %if %{with tests} %{__nodejs} -e 'require("./")' # 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} '%{SOURCE5}' --exceptions '%{SOURCE6}' --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/ # Otherwise Haste looks in these anyway, and finds things to complain about rm -rf node_modules_prod node_modules_dev NODE_ENV=test ./node_modules/.bin/jest --coverage ./test/*/_index.test.js %else %{_bindir}/echo -e "\e[101m -=#=- Tests disabled -=#=- \e[0m" %endif %files %license LICENSE %{npm_name}-%{version}-bundled-licenses.txt %doc *.md %doc docs/ %{nodejs_sitelib}/%{npm_name} %{_bindir}/%{npm_name} %{_mandir}/man1/%{npm_name}.1* %changelog * sam. déc. 04 2021 Benjamin A. Beasley 2.8.0-5 - Hardlink duplicate files in the dependency bundle * sam. déc. 04 2021 Benjamin A. Beasley 2.8.0-4 - Convert python3 BR to python3-devel per guidelines * sam. déc. 04 2021 Benjamin A. Beasley 2.8.0-3 - Re-generate (update) dependency bundle * mer. nov. 03 2021 Benjamin A. Beasley 2.8.0-2 - Update downstream man page for 2.8.0 * mer. nov. 03 2021 Benjamin A. Beasley 2.8.0-1 - Update to 2.8.0 (close RHBZ#2019658) * ven. sept. 24 2021 Benjamin A. Beasley 2.7.0-1 - Update to 2.7.0 (close RHBZ#2007555) * jeu. sept. 16 2021 Benjamin A. Beasley 2.6.1-1 - Update to 2.6.1 (close RHBZ#2005047) * mar. sept. 14 2021 Benjamin A. Beasley 2.6.0-1 - Update to 2.6.0 (close RHBZ#2004064) * dim. août 29 2021 Benjamin A. Beasley 2.5.0-2 - Hand-write man page instead of using help2man * dim. août 29 2021 Benjamin A. Beasley 2.5.0-1 - Update to 2.5.0 (close RHBZ#1998809) * sam. août 28 2021 Benjamin A. Beasley 2.4.0-2 - Faster shebang fix * sam. août 14 2021 Benjamin A. Beasley 2.4.0-1 - Update to 2.4.0 (fix RHBZ#1993587) * lun. juil. 26 2021 Benjamin A. Beasley 2.3.1-6 - Check dev bundle licenses *after* unpacking it * lun. juil. 26 2021 Benjamin A. Beasley 2.3.1-5 - Improved error detection in check-null-licenses * lun. juil. 26 2021 Benjamin A. Beasley 2.3.1-4 - Remove unnecessary nodejs_symlink_deps macro in check section * jeu. juil. 22 2021 Fedora Release Engineering 2.3.1-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild * Sat Jun 26 2021 Benjamin A. Beasley - 2.3.1-1 - Update to 2.3.1 (closes RHBZ#1976511) * Sun Jun 13 2021 Benjamin A. Beasley - 2.3.0-4 - Preserve timestamp on bundled dependency license list file - Re-generate dependency bundle * Wed May 12 2021 Benjamin A. Beasley - 2.3.0-3 - Move “forge” macros to the top of the spec file - Re-generate dependency bundle * Mon Mar 29 2021 Benjamin A. Beasley - 2.3.0-2 - Fix regression: missed correcting /usr/bin/env shebang in main script * Mon Mar 29 2021 Benjamin A. Beasley - 2.3.0-1 - Update to 2.3.0 * Wed Mar 10 2021 Benjamin A. Beasley - 2.2.2-1 - Update to 2.2.2 * Sat Mar 06 2021 Benjamin A. Beasley - 2.2.1-1 - Update to 2.2.1 * Tue Mar 02 2021 Benjamin A. Beasley - 2.2.0-1 - Update to 2.2.0 * Wed Feb 24 2021 Benjamin A. Beasley - 2.1.0-1 - Update to 2.1.0 * Sun Feb 21 2021 Benjamin A. Beasley - 2.0.3-1 - Update to 2.0.3 * Sat Feb 20 2021 Benjamin A. Beasley - 2.0.2-1 - Update to 2.0.2 * Thu Feb 18 2021 Benjamin A. Beasley - 2.0.1-1 - Update to 2.0.1 * Thu Feb 18 2021 Benjamin A. Beasley - 2.0.0-1 - Update to 2.0.0 * Mon Jan 25 2021 Benjamin A. Beasley - 1.3.2-3 - Add a check for null license fields in dependencies * Wed Jan 20 2021 Benjamin A. Beasley - 1.3.2-2 - Switch enable_tests global to a build conditional - Add a more detailed description from upstream - Assorted spec file tidying, and style adjustments to suit personal preference - Convert absolute symlink to relative for executable - Use the GitHub tarball as a second source, rather than creating tests/docs/examples tarballs from the git tag with a dl-tests.sh script - Drop patch removing underscores in entity names; this test passes now - Fix bundled prod dependencies not actually installed - Do not install docs/ and examples/ under node_modules, only under _docdir - Add virtual Provides for svgo - Hold css-select dependency to '~2.0.0' to work around https://github.com/svg/svgo/issues/1315 - Fix or explicitly suppress (via an rpmlintrc file) all rpmlint output - Add a man page, generated with help2man * Thu Jan 14 2021 Troy Dawson - 1.3.2-1 - Update to 1.3.2 - Bundle runtime (prod) and testing (dev) dependencies * Sat Aug 01 2020 Fedora Release Engineering - 0.7.2-9 - Second attempt - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild * Tue Jul 28 2020 Fedora Release Engineering - 0.7.2-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild * Wed Jan 29 2020 Fedora Release Engineering - 0.7.2-7 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild * Thu Jul 25 2019 Fedora Release Engineering - 0.7.2-6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild * Fri Feb 01 2019 Fedora Release Engineering - 0.7.2-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild * Fri Jul 13 2018 Fedora Release Engineering - 0.7.2-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild * Sat Mar 10 2018 Tom Hughes - 0.7.2-3 - Relax npm(colors) dependency * Thu Feb 08 2018 Fedora Release Engineering - 0.7.2-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild * Wed Sep 20 2017 Jared Smith - 0.7.2-1 - Update to upstream 0.7.2 release * Mon Jul 25 2016 Jared Smith - 0.6.6-4 - Add .yml file * Mon Jul 25 2016 Jared Smith - 0.6.6-3 - Fix some dependency versions * Sun Jul 24 2016 Jared Smith - 0.6.6-2 - Fix tests so that the run correctly * Sat Jul 23 2016 Jared Smith - 0.6.6-1 - Update to upstream 0.6.6 release * Sun Oct 25 2015 Jared Smith - 0.5.6-1 - Initial packaging