Blame SOURCES/Makefile

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