Blame SOURCES/Makefile

897738
ifndef VER
897738
  $(error VER is undefined)
897738
endif
897738
ifndef REL
897738
  $(error REL is undefined)
897738
endif
28ad2d
897738
NAME       := grafana
897738
RPM_NAME   := $(NAME)
897738
SOURCE_DIR := $(NAME)-$(VER)
897738
SOURCE_TAR := $(NAME)-$(VER).tar.gz
897738
VENDOR_TAR := $(RPM_NAME)-vendor-$(VER)-$(REL).tar.xz
897738
WEBPACK_TAR := $(RPM_NAME)-webpack-$(VER)-$(REL).tar.gz
897738
897738
ALL_PATCHES := $(wildcard *.patch)
897738
PATCHES_TO_APPLY := $(filter-out 009-patch-unused-backend-crypto.patch 010-fips.patch,$(ALL_PATCHES))
897738
897738
all: $(SOURCE_TAR) $(VENDOR_TAR) $(WEBPACK_TAR)
897738
897738
$(SOURCE_TAR):
897738
	spectool -g $(RPM_NAME).spec
897738
897738
$(VENDOR_TAR): $(SOURCE_TAR)
28ad2d
	rm -rf grafana-$(VER)
28ad2d
	tar xfz grafana-$(VER).tar.gz
28ad2d
897738
	# patches can affect Go or Node.js dependencies, or the webpack
897738
	for patch in $(PATCHES_TO_APPLY); do patch -d grafana-$(VER) -p1 --fuzz=0 < $$patch; done
897738
28ad2d
	# Go
28ad2d
	cd grafana-$(VER) && go mod vendor -v
897738
	# Remove unused crypto
897738
	rm grafana-$(VER)/vendor/golang.org/x/crypto/cast5/cast5.go
897738
	rm grafana-$(VER)/vendor/golang.org/x/crypto/ed25519/ed25519.go
897738
	rm grafana-$(VER)/vendor/golang.org/x/crypto/ed25519/internal/edwards25519/const.go
897738
	rm grafana-$(VER)/vendor/golang.org/x/crypto/ed25519/internal/edwards25519/edwards25519.go
897738
	rm grafana-$(VER)/vendor/golang.org/x/crypto/openpgp/elgamal/elgamal.go
897738
	rm grafana-$(VER)/vendor/golang.org/x/crypto/openpgp/packet/ocfb.go
28ad2d
	awk '$$2~/^v/ && $$4 != "indirect" {print "Provides: bundled(golang(" $$1 ")) = " substr($$2, 2)}' grafana-$(VER)/go.mod | \
28ad2d
		sed -E 's/=(.*)-(.*)-(.*)/=\1-\2.\3/g' > $@.manifest
28ad2d
28ad2d
	# Node.js
28ad2d
	cd grafana-$(VER) && yarn install --pure-lockfile
28ad2d
	# Remove files with licensing issues
28ad2d
	find grafana-$(VER) -type d -name 'node-notifier' -prune -exec rm -r {} \;
897738
	find grafana-$(VER) -type d -name 'property-information' -prune -exec rm -r {} \;
897738
	find grafana-$(VER) -type f -name '*.exe' -delete
897738
	rm -r grafana-$(VER)/node_modules/visjs-network/examples
28ad2d
	./list_bundled_nodejs_packages.py grafana-$(VER)/ >> $@.manifest
28ad2d
28ad2d
	# Create tarball
28ad2d
	XZ_OPT=-9 tar cfJ $@ \
28ad2d
		grafana-$(VER)/vendor \
28ad2d
		$$(find grafana-$(VER) -type d -name "node_modules" -prune)
28ad2d
897738
$(WEBPACK_TAR): $(VENDOR_TAR)
28ad2d
	cd grafana-$(VER) && \
28ad2d
		../build_frontend.sh
28ad2d
28ad2d
	tar cfz $@ grafana-$(VER)/public/build grafana-$(VER)/public/views grafana-$(VER)/plugins-bundled
28ad2d
28ad2d
clean:
897738
	rm -rf *.tar.gz *.tar.xz *.manifest *.rpm $(NAME)-*/