File grafana-image-renderer.spec of Package grafana-image-renderer

#
# spec file for package grafana-image-renderer-min
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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/
#

%define plugins_dir %{_localstatedir}/lib/grafana/plugins/

Name:           grafana-image-renderer
Version:        1.0.7
Release:        0
Summary:        Grafana Image Renderer
License:        Apache-2.0
Group:          System/Monitoring
URL:            https://github.com/grafana/%{name}
Source:         https://github.com/grafana/%{name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        %{name}-rpmlintrc
Source10:       npm_deps.tar.bz2
Patch1:         fix_gettid_naming_conflict.patch
Patch2:         fix_dependencies.patch
Patch3:         constrain_to_node10.patch
Requires:       nodejs10
Requires:       grafana
Requires:       chromium
Requires:       ca-certificates
BuildRequires:  ca-certificates
BuildRequires:  fdupes
BuildRequires:  pkgconf-pkg-config
BuildRequires:  pkgconfig(openssl)
BuildRequires:  pkgconfig(zlib)
BuildRequires:  npm10
BuildRequires:  grafana
BuildRequires:  xz
BuildRequires:  gcc-c++

%description
Grafana Backend Image Renderer that uses headless chrome to capture images.

%prep
%setup -q -a 10
%patch1 -p1
%patch2 -p1
%patch3 -p1

%build
export CXXFLAGS='%{optflags} -Wno-ignored-qualifiers -Wno-stringop-truncation -Wno-cast-function-type'
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD='true'
npm rebuild --build-from-source
%make_build

%install
mv node_modules/grpc/build/Release/grpc_node.node grpc_node.node
rm -rf node_modules/grpc/build

install -d -m 755 %{buildroot}/%{plugins_dir}%{name}
install -d -m 755 %{buildroot}/%{plugins_dir}%{name}/build
install -d -m 755 %{buildroot}/%{plugins_dir}%{name}/proto

install -m 644 plugin.json %{buildroot}/%{plugins_dir}%{name} 
install -m 755 plugin_start_linux_amd64 %{buildroot}/%{plugins_dir}%{name}
install -m 755 grpc_node.node %{buildroot}/%{plugins_dir}%{name}
install -m 644 build/*.js* %{buildroot}/%{plugins_dir}%{name}/build
install -m 644 proto/*.proto %{buildroot}/%{plugins_dir}%{name}/proto

cp -r node_modules %{buildroot}/%{plugins_dir}%{name}

ln -s -f /etc/ssl/ca-bundle.pem %{buildroot}/%{plugins_dir}%{name}/node_modules/grpc/deps/grpc/etc/roots.pem

# clean
# hidden files and directories
find %{buildroot}/%{plugins_dir}%{name} -name ".*" -exec rm -rf {} +
# backup files
find %{buildroot}/%{plugins_dir}%{name} -name "*.md~" -delete
rm %{buildroot}/%{plugins_dir}%{name}/node_modules/form-data/README.md.bak
# build dependencies
find %{buildroot}/%{plugins_dir}%{name}/node_modules -name *.[ch] -delete
%fdupes %{buildroot}/%{plugins_dir}%{name}

# fix permissions
chmod 0755 %{buildroot}/%{plugins_dir}%{name}/node_modules/dashdash/etc/dashdash.bash_completion.in
chmod 0755 %{buildroot}/%{plugins_dir}%{name}/node_modules/optjs/test.js
chmod 0755 %{buildroot}/%{plugins_dir}%{name}/node_modules/ps-tree/bin/ps-tree.js
chmod 0755 %{buildroot}/%{plugins_dir}%{name}/node_modules/tsc-watch/lib/tsc-watch.js

%post
%restart_on_update grafana-server

%postun
%restart_on_update grafana-server

%files
%defattr(-,grafana,grafana)
%{plugins_dir}/%{name}
%license LICENSE
%doc README.md

%changelog
openSUSE Build Service is sponsored by