Blame SOURCES/Makefile

aa839f
VERSION := $(shell rpm --specfile *.spec --qf '%{VERSION}\n' | head -1)
aa839f
RELEASE := $(shell rpm --specfile *.spec --qf '%{RELEASE}\n' | head -1 | cut -d. -f1)
75474d
75474d
NAME       := grafana
75474d
RPM_NAME   := $(NAME)
aa839f
SOURCE_DIR := $(NAME)-$(VERSION)
aa839f
SOURCE_TAR := $(NAME)-$(VERSION).tar.gz
aa839f
VENDOR_TAR := $(RPM_NAME)-vendor-$(VERSION)-$(RELEASE).tar.xz
aa839f
WEBPACK_TAR := $(RPM_NAME)-webpack-$(VERSION)-$(RELEASE).tar.gz
77b9e5
aa839f
ALL_PATCHES     := $(sort $(wildcard *.patch))
aa839f
VENDOR_PATCHES  := $(sort $(wildcard *.vendor.patch))
aa839f
COND_PATCHES    := $(sort $(wildcard *.cond.patch))
aa839f
REGULAR_PATCHES := $(filter-out $(VENDOR_PATCHES) $(COND_PATCHES),$(ALL_PATCHES))
dfc470
75474d
all: $(SOURCE_TAR) $(VENDOR_TAR) $(WEBPACK_TAR)
75474d
75474d
$(SOURCE_TAR):
75474d
	spectool -g $(RPM_NAME).spec
75474d
75474d
$(VENDOR_TAR): $(SOURCE_TAR)
aa839f
	rm -rf $(SOURCE_DIR)
aa839f
	tar xf $(SOURCE_TAR)
77b9e5
aa839f
	# Patches to apply before vendoring
aa839f
	for patch in $(REGULAR_PATCHES); do echo applying $$patch ...; patch -d $(SOURCE_DIR) -p1 --fuzz=0 < $$patch; done
68ed87
68ed87
	# Go
aa839f
	cd $(SOURCE_DIR) && go mod vendor -v
dfc470
	# Remove unused crypto
aa839f
	rm $(SOURCE_DIR)/vendor/golang.org/x/crypto/cast5/cast5.go
aa839f
	rm $(SOURCE_DIR)/vendor/golang.org/x/crypto/ed25519/ed25519.go
aa839f
	rm $(SOURCE_DIR)/vendor/golang.org/x/crypto/ed25519/internal/edwards25519/const.go
aa839f
	rm $(SOURCE_DIR)/vendor/golang.org/x/crypto/ed25519/internal/edwards25519/edwards25519.go
aa839f
	rm $(SOURCE_DIR)/vendor/golang.org/x/crypto/openpgp/elgamal/elgamal.go
aa839f
	rm $(SOURCE_DIR)/vendor/golang.org/x/crypto/openpgp/packet/ocfb.go
aa839f
	awk '$$2~/^v/ && $$4 != "indirect" {print "Provides: bundled(golang(" $$1 ")) = " substr($$2, 2)}' $(SOURCE_DIR)/go.mod | \
68ed87
		sed -E 's/=(.*)-(.*)-(.*)/=\1-\2.\3/g' > $@.manifest
68ed87
68ed87
	# Node.js
aa839f
	cd $(SOURCE_DIR) && yarn install --pure-lockfile
68ed87
	# Remove files with licensing issues
aa839f
	find $(SOURCE_DIR) -type d -name 'node-notifier' -prune -exec rm -r {} \;
aa839f
	find $(SOURCE_DIR) -type d -name 'property-information' -prune -exec rm -r {} \;
aa839f
	find $(SOURCE_DIR) -type f -name '*.exe' -delete
aa839f
	rm -r $(SOURCE_DIR)/node_modules/visjs-network/examples
aa839f
	./list_bundled_nodejs_packages.py $(SOURCE_DIR) >> $@.manifest
aa839f
aa839f
	# Patches to apply after vendoring
aa839f
	for patch in $(VENDOR_PATCHES); do echo applying $$patch ...; patch -d $(SOURCE_DIR) -p1 --fuzz=0 < $$patch; done
68ed87
68ed87
	# Create tarball
aa839f
	time XZ_OPT=-9 tar cJf $@ \
aa839f
		$(SOURCE_DIR)/vendor \
aa839f
		$$(find $(SOURCE_DIR) -type d -name "node_modules" -prune)
68ed87
75474d
$(WEBPACK_TAR): $(VENDOR_TAR)
aa839f
	cd $(SOURCE_DIR) && \
68ed87
		../build_frontend.sh
68ed87
aa839f
	tar cfz $@ $(SOURCE_DIR)/public/build $(SOURCE_DIR)/public/views $(SOURCE_DIR)/plugins-bundled
68ed87
68ed87
clean:
75474d
	rm -rf *.tar.gz *.tar.xz *.manifest *.rpm $(NAME)-*/