diff --git a/Makefile b/Makefile.no_phantomjs similarity index 100% rename from Makefile rename to Makefile.no_phantomjs diff --git a/Makefile.phantomjs b/Makefile.phantomjs new file mode 100644 index 0000000..4098c71 --- /dev/null +++ b/Makefile.phantomjs @@ -0,0 +1,33 @@ +NAME = grafana +SPEC = $(NAME).spec + +default: verify-deps clean tar + +verify-deps: + @which yarn >/dev/null 2>&1 || ( echo "yarn not found; run \`sudo npm install -g yarn\`" && false ) + @which grunt >/dev/null 2>&1 || ( echo "grunt not found; run \`sudo npm install -g grunt-cli\`" && false ) + +clean: + rm -f $(NAME)-*.tar $(NAME)-*.tar.xz + +tar: + osc service disabledrun + @version=$$( awk '/^Version:/ {print $$2}' $(SPEC) ) && \ + echo "Package version is $$version" && \ + basename=$(NAME)-$$version && \ + tar=$$basename.tar && \ + tmpdir=$$(mktemp -d -p .) && \ + cd $$tmpdir && \ + tar -xf ../$$tar && \ + cd $$basename && \ + sed -i 's/base\///' public/sass/base/_fonts.scss && \ + yarn install --pure-lockfile && \ + grunt release && \ + cp -pr tmp/public . && \ + cp -pr tmp/tools . && \ + cd .. && \ + echo "Updating $$basename/tools $$basename/public in tarball..." && \ + tar -rf ../$$tar $$basename/tools $$basename/public && \ + cd .. && \ + xz $$tar && \ + rm -rf $$tmpdir diff --git a/grafana.changes b/grafana.changes index 19b00b9..ba221da 100644 --- a/grafana.changes +++ b/grafana.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Tue Jul 30 14:14:38 CEST 2019 - ro@suse.de + +- make phantomjs dependency configurable + ------------------------------------------------------------------- Thu Jul 11 08:21:07 UTC 2019 - Jan Fajerski diff --git a/grafana.spec b/grafana.spec index 0510c40..4bda5b1 100644 --- a/grafana.spec +++ b/grafana.spec @@ -25,6 +25,8 @@ %define _fillupdir /var/adm/fillup-templates %endif +%bcond_with phantomjs + Name: grafana Version: 6.2.5 Release: 0 @@ -37,13 +39,18 @@ Source1: %{name}-rpmlintrc # Instructions on the build process Source2: README # Makefile to automate build process -Source3: Makefile +Source3: Makefile.no_phantomjs +Source4: Makefile.phantomjs BuildRequires: fdupes BuildRequires: go >= 1.11 BuildRequires: golang-packaging BuildRequires: shadow Requires(post): %insserv_prereq BuildRoot: %{_tmppath}/%{name}-%{version}-build +%if %{with phantomjs} +BuildRequires: phantomjs +Requires: phantomjs +%endif %{?systemd_requires} %description @@ -54,6 +61,11 @@ dashboards and data with teams. %prep %setup -q -n grafana-%{version} +%if %{with phantomjs} +cp %{S:4} %_sourcedir/Makefile +%else +cp %{S:3} %_sourcedir/Makefile +%endif %build %goprep github.com/grafana/grafana @@ -98,6 +110,17 @@ cp -pr public %{buildroot}%{_datadir}/%{name}/ install -d -m755 %{buildroot}%{_datadir}/%{name}/vendor install -d -m755 %{buildroot}%{_datadir}/%{name}/tools +%if %{with phantomjs} +# phantomjs is used for rendering PNG images of graphs. The frontend asset +# build process downloadsa prebuilt x86_64 binary, which ends up in +# vendor/phantomjs/phantomjs. This is ugly but works for x86_64. It naturally +# will not work for other architectures, so instead we remove the phantomjs +# binary and install a symlink to the systemwide /usr/bin/phantomjs. +cp -pr tools/phantomjs %{buildroot}%{_datadir}/%{name}/tools/ +rm -f %{buildroot}%{_datadir}/%{name}/tools/phantomjs/phantomjs +ln -s %{_bindir}/phantomjs %{buildroot}%{_datadir}/%{name}/tools/phantomjs/phantomjs +%endif + # Do *not* use %%fudpes -s -- this will result in grafana failing to load # all the plugins (something in the plugin scanner can't cope with files # in there being symlinks).