From b968e988b7e727574d4da67a1f5b835346dabb9b Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: May 10 2022 07:00:24 +0000 Subject: import js-d3-flame-graph-4.0.7-1.el8 --- diff --git a/.gitignore b/.gitignore index b11100a..a197e02 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -SOURCES/d3-flame-graph-3.0.2.tar.gz -SOURCES/d3-flame-graph-deps-3.0.2.tar.xz +SOURCES/d3-flame-graph-4.0.7.tar.gz +SOURCES/js-d3-flame-graph-vendor-4.0.7-1.tar.xz diff --git a/.js-d3-flame-graph.metadata b/.js-d3-flame-graph.metadata index 34a9123..4124caf 100644 --- a/.js-d3-flame-graph.metadata +++ b/.js-d3-flame-graph.metadata @@ -1,2 +1,2 @@ -fb58e7c0a97d85b88c62d7e87cc782fb99c41fe9 SOURCES/d3-flame-graph-3.0.2.tar.gz -a14d4a0d127cbbabab3d0280e492c74deb2ac206 SOURCES/d3-flame-graph-deps-3.0.2.tar.xz +b80fbdf125fcadec5ec1b3d8acc216f6cbd4c2d5 SOURCES/d3-flame-graph-4.0.7.tar.gz +7dafbc87ec919cdb14e5b01fbdb115a75312f7fb SOURCES/js-d3-flame-graph-vendor-4.0.7-1.tar.xz diff --git a/SOURCES/001-remove-unused-frontend-crypto-and-patch-md4.patch b/SOURCES/001-remove-unused-frontend-crypto-and-patch-md4.patch new file mode 100644 index 0000000..5d99e56 --- /dev/null +++ b/SOURCES/001-remove-unused-frontend-crypto-and-patch-md4.patch @@ -0,0 +1,62 @@ +diff --git a/package.json b/package.json +index 9469638..d81424f 100644 +--- a/package.json ++++ b/package.json +@@ -61,5 +61,9 @@ + "d3-scale": "^3.2.1", + "d3-selection": "^1.4.1", + "d3-transition": "^1.3.2" ++ }, ++ "resolutions": { ++ "crypto-browserify": "https://registry.yarnpkg.com/@favware/skip-dependency/-/skip-dependency-1.1.1.tgz", ++ "http-signature": "https://registry.yarnpkg.com/@favware/skip-dependency/-/skip-dependency-1.1.1.tgz" + } + } +diff --git a/webpack.config.js b/webpack.config.js +index 00e171a..8997a9f 100644 +--- a/webpack.config.js ++++ b/webpack.config.js +@@ -8,6 +8,13 @@ const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin') + const TerserPlugin = require('terser-webpack-plugin') + const packageFile = require('./package.json') + ++// monkey patch crypto module to not use deprecated md4 hash algorithm, ++// which is removed in OpenSSL 3.0 ++// https://github.com/webpack/webpack/issues/13572#issuecomment-923736472 ++const crypto = require("crypto"); ++const crypto_orig_createHash = crypto.createHash; ++crypto.createHash = algorithm => crypto_orig_createHash(algorithm == "md4" ? "sha256" : algorithm); ++ + module.exports = [{ + context: path.join(__dirname, 'src'), + entry: { +@@ -21,6 +28,9 @@ module.exports = [{ + libraryExport: 'default', + libraryTarget: 'umd' + }, ++ node: { ++ crypto: false ++ }, + plugins: [ + new CopyWebpackPlugin([{ + from: 'flamegraph.css', +@@ -58,6 +68,9 @@ module.exports = [{ + library: ['flamegraph', '[name]'], + libraryTarget: 'umd' + }, ++ node: { ++ crypto: false ++ }, + module: { + rules: [{ + test: /\.js$/, +@@ -79,6 +92,9 @@ module.exports = [{ + path: path.resolve(__dirname, 'dist', 'templates'), + filename: 'bundle.js' + }, ++ node: { ++ crypto: false ++ }, + plugins: [ + new CleanWebpackPlugin({ + protectWebpackAssets: false, diff --git a/SOURCES/Makefile b/SOURCES/Makefile new file mode 100644 index 0000000..a3a453a --- /dev/null +++ b/SOURCES/Makefile @@ -0,0 +1,39 @@ +VERSION := $(shell rpm --specfile *.spec --qf '%{VERSION}\n' | head -1) +RELEASE := $(shell rpm --specfile *.spec --qf '%{RELEASE}\n' | head -1 | cut -d. -f1) + +NAME := d3-flame-graph +RPM_NAME := js-$(NAME) +SOURCE_DIR := $(NAME)-$(VERSION) +SOURCE_TAR := $(NAME)-$(VERSION).tar.gz +VENDOR_TAR := $(RPM_NAME)-vendor-$(VERSION)-$(RELEASE).tar.xz + +ALL_PATCHES := $(sort $(wildcard *.patch)) +VENDOR_PATCHES := $(sort $(wildcard *.vendor.patch)) +COND_PATCHES := $(sort $(wildcard *.cond.patch)) +REGULAR_PATCHES := $(filter-out $(VENDOR_PATCHES) $(COND_PATCHES),$(ALL_PATCHES)) + +all: $(SOURCE_TAR) $(VENDOR_TAR) + +$(SOURCE_TAR): + spectool -g $(RPM_NAME).spec + +$(VENDOR_TAR): $(SOURCE_TAR) + rm -rf $(SOURCE_DIR) + tar xf $(SOURCE_TAR) + + # Patches to apply before vendoring + for patch in $(REGULAR_PATCHES); do echo applying $$patch ...; patch -d $(SOURCE_DIR) -p1 --fuzz=0 < $$patch; done + + # Node.js + cd $(SOURCE_DIR) && yarn import && yarn install --pure-lockfile + ./list_bundled_nodejs_packages.py $(SOURCE_DIR) >> $@.manifest + + # Patches to apply after vendoring + for patch in $(VENDOR_PATCHES); do echo applying $$patch ...; patch -d $(SOURCE_DIR) -p1 --fuzz=0 < $$patch; done + + # Create tarball + XZ_OPT=-9 time -p tar cJf $@ \ + $(SOURCE_DIR)/node_modules + +clean: + rm -rf *.tar.gz *.tar.xz *.manifest *.rpm $(NAME)-*/ diff --git a/SOURCES/create_dependency_bundle.sh b/SOURCES/create_dependency_bundle.sh deleted file mode 100755 index b0af465..0000000 --- a/SOURCES/create_dependency_bundle.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -eu - -SRC=$(readlink -f "${1:?Usage: $0 source destination}") -DEST=$(readlink -f "${2:?Usage: $0 source destination}") - -if [ -f "$DEST" ]; then - echo "File $DEST exists already." - exit 0 -fi -if [ "$#" -gt 2 ]; then - PATCHES=$(readlink -f "${@:3}") -else - PATCHES="" -fi - -pushd "$(mktemp -d)" - -echo Extracting sources... -tar xfz "$SRC" -cd d3-flame-graph-* - -echo Applying patches... -for patch in $PATCHES -do - patch -p1 < $patch -done - -echo Installing dependencies... -npm install - -echo Compressing... -XZ_OPT=-9 tar cJf "$DEST" node_modules - -popd diff --git a/SOURCES/list_bundled_nodejs_packages.py b/SOURCES/list_bundled_nodejs_packages.py new file mode 100755 index 0000000..3158c2c --- /dev/null +++ b/SOURCES/list_bundled_nodejs_packages.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 +# +# generates Provides: bundled(npm(...)) = ... lines for each declared dependency and devDependency of package.json +# +import sys +import json +import re +from packaging import version + + +def read_declared_pkgs(package_json_path): + with open(package_json_path) as f: + package_json = json.load(f) + return list(package_json['dependencies'].keys()) + list(package_json['devDependencies'].keys()) + + +def read_installed_pkgs(yarn_lock_path): + with open(yarn_lock_path) as f: + lockfile = f.read() + return re.findall(r'^"?' # can start with a " + r'(.+?)@.+(?:,.*)?:\n' # characters up to @ + r' version "(.+)"', # and the version + lockfile, re.MULTILINE) + + +def list_provides(declared_pkgs, installed_pkgs): + for declared_pkg in declared_pkgs: + # there can be multiple versions installed of one package (transitive dependencies) + # but rpm doesn't support Provides: with a single package and multiple versions + # so let's declare the oldest version here + versions = [version.parse(pkg_version) + for pkg_name, pkg_version in installed_pkgs if pkg_name == declared_pkg] + oldest_version = sorted(versions)[0] + yield f"Provides: bundled(npm({declared_pkg})) = {oldest_version}" + + +if __name__ == "__main__": + if len(sys.argv) != 2: + print(f"usage: {sys.argv[0]} package-X.Y.Z/", file=sys.stdout) + sys.exit(1) + + package_dir = sys.argv[1] + declared_pkgs = read_declared_pkgs(f"{package_dir}/package.json") + installed_pkgs = read_installed_pkgs(f"{package_dir}/yarn.lock") + provides = list_provides(declared_pkgs, installed_pkgs) + for provide in sorted(provides): + print(provide) diff --git a/SPECS/js-d3-flame-graph.spec b/SPECS/js-d3-flame-graph.spec index 1692cbb..db8647a 100644 --- a/SPECS/js-d3-flame-graph.spec +++ b/SPECS/js-d3-flame-graph.spec @@ -2,8 +2,8 @@ %global github https://github.com/spiermar/d3-flame-graph Name: js-d3-flame-graph -Version: 3.0.2 -Release: 2%{?dist} +Version: 4.0.7 +Release: 1%{?dist} Summary: A D3.js plugin that produces flame graphs BuildArch: noarch @@ -12,39 +12,50 @@ License: ASL 2.0 URL: %{github} Source0: %{github}/archive/%{version}/%{pkgname}-%{version}.tar.gz -Source1: d3-flame-graph-deps-%{version}.tar.xz -Source2: create_dependency_bundle.sh +# Note: In case there were no changes to this tarball, the NVR of this tarball +# lags behind the NVR of this package. +Source1: js-d3-flame-graph-vendor-%{version}-1.tar.xz +Source2: Makefile +Source3: list_bundled_nodejs_packages.py + +Patch1: 001-remove-unused-frontend-crypto-and-patch-md4.patch BuildRequires: web-assets-devel BuildRequires: nodejs +%if 0%{?fedora} +Requires: web-assets-filesystem +%endif + # Bundled npm packages -Provides: bundled(nodejs-clean-webpack-plugin) = 3.0.0 -Provides: bundled(nodejs-copy-webpack-plugin) = 5.1.1 -Provides: bundled(nodejs-css-loader) = 3.4.2 -Provides: bundled(nodejs-d3-array) = 2.4.0 -Provides: bundled(nodejs-d3-dispatch) = 1.0.6 -Provides: bundled(nodejs-d3-ease) = 1.0.6 -Provides: bundled(nodejs-d3-format) = 1.4.3 -Provides: bundled(nodejs-d3-hierarchy) = 1.1.9 -Provides: bundled(nodejs-d3-scale) = 3.2.1 -Provides: bundled(nodejs-d3-selection) = 1.4.1 -Provides: bundled(nodejs-d3-transition) = 1.3.2 -Provides: bundled(nodejs-eslint) = 6.8.0 -Provides: bundled(nodejs-eslint-config-standard) = 14.1.0 -Provides: bundled(nodejs-eslint-loader) = 3.0.3 -Provides: bundled(nodejs-eslint-plugin-import) = 2.20.1 -Provides: bundled(nodejs-eslint-plugin-node) = 11.0.0 -Provides: bundled(nodejs-eslint-plugin-promise) = 4.2.1 -Provides: bundled(nodejs-eslint-plugin-standard) = 4.0.1 -Provides: bundled(nodejs-html-webpack-plugin) = 3.2.0 -Provides: bundled(nodejs-script-ext-html-webpack-plugin) = 2.1.4 -Provides: bundled(nodejs-style-loader) = 1.1.3 -Provides: bundled(nodejs-tape) = 4.13.2 -Provides: bundled(nodejs-terser-webpack-plugin) = 2.3.5 -Provides: bundled(nodejs-webpack) = 4.42.0 -Provides: bundled(nodejs-webpack-cli) = 3.3.11 -Provides: bundled(nodejs-webpack-dev-server) = 3.10.3 +Provides: bundled(npm(babel-preset-env)) = 1.7.0 +Provides: bundled(npm(clean-webpack-plugin)) = 3.0.0 +Provides: bundled(npm(copy-webpack-plugin)) = 5.1.1 +Provides: bundled(npm(css-loader)) = 3.5.2 +Provides: bundled(npm(d3-array)) = 2.4.0 +Provides: bundled(npm(d3-dispatch)) = 1.0.6 +Provides: bundled(npm(d3-ease)) = 1.0.6 +Provides: bundled(npm(d3-format)) = 1.4.4 +Provides: bundled(npm(d3-hierarchy)) = 1.1.9 +Provides: bundled(npm(d3-scale)) = 3.2.1 +Provides: bundled(npm(d3-selection)) = 1.4.1 +Provides: bundled(npm(d3-transition)) = 1.3.2 +Provides: bundled(npm(eslint)) = 6.8.0 +Provides: bundled(npm(eslint-config-standard)) = 14.1.1 +Provides: bundled(npm(eslint-loader)) = 4.0.0 +Provides: bundled(npm(eslint-plugin-import)) = 2.20.2 +Provides: bundled(npm(eslint-plugin-node)) = 11.1.0 +Provides: bundled(npm(eslint-plugin-promise)) = 4.2.1 +Provides: bundled(npm(eslint-plugin-standard)) = 4.0.1 +Provides: bundled(npm(html-webpack-plugin)) = 4.2.0 +Provides: bundled(npm(jest)) = 25.4.0 +Provides: bundled(npm(prettier)) = 2.0.4 +Provides: bundled(npm(script-ext-html-webpack-plugin)) = 2.1.4 +Provides: bundled(npm(style-loader)) = 1.1.4 +Provides: bundled(npm(terser-webpack-plugin)) = 1.4.3 +Provides: bundled(npm(webpack)) = 4.42.1 +Provides: bundled(npm(webpack-cli)) = 3.3.11 +Provides: bundled(npm(webpack-dev-server)) = 3.10.3 %description A D3.js plugin that produces flame graphs from hierarchical data. @@ -58,12 +69,15 @@ Documentation and example files for js-d3-flame-graph. %prep -%setup -q -n %{pkgname}-%{version} -%setup -q -a 1 -n %{pkgname}-%{version} +%setup -q -T -D -b 0 -n %{pkgname}-%{version} +%setup -q -T -D -b 1 -n %{pkgname}-%{version} + +%patch1 -p1 + %build -rm -rf dist -./node_modules/webpack/bin/webpack.js --mode production +./node_modules/.bin/webpack --mode production + %install install -d -m 755 %{buildroot}/%{_datadir}/%{pkgname} @@ -73,6 +87,11 @@ rmdir dist/templates install -d -m 755 %{buildroot}/%{_jsdir}/%{pkgname} cp -a dist/* %{buildroot}/%{_jsdir}/%{pkgname} + +%check +./node_modules/.bin/jest + + %files %{_jsdir}/%{pkgname} %{_datadir}/%{pkgname} @@ -80,9 +99,14 @@ cp -a dist/* %{buildroot}/%{_jsdir}/%{pkgname} %license LICENSE %doc README.md + %files doc %doc README.md examples + %changelog +* Fri Oct 01 2021 Andreas Gerstmayr - 4.0.7-1 +- update to 4.0.7 tagged upstream community sources, see CHANGELOG + * Fri Mar 20 2020 Andreas Gerstmayr 3.0.2-1 - initial version