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
f90bfa
# patches which must be applied before creating the vendor tarball, for example:
f90bfa
# - changes in dependency versions
f90bfa
# - changes in Go module imports (which affect the vendored Go modules)
f90bfa
PATCHES_PRE_VENDOR := \
f90bfa
	005-remove-unused-dependencies.patch \
f90bfa
	008-remove-unused-frontend-crypto.patch
f90bfa
f90bfa
# patches which must be applied before creating the webpack, for example:
f90bfa
# - changes in Node.js sources or vendored dependencies
f90bfa
PATCHES_PRE_WEBPACK :=
f90bfa
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)
f90bfa
	# start with a clean state
aa839f
	rm -rf $(SOURCE_DIR)
aa839f
	tar xf $(SOURCE_TAR)
77b9e5
aa839f
	# Patches to apply before vendoring
f90bfa
	for patch in $(PATCHES_PRE_VENDOR); 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
68ed87
	# Create tarball
f90bfa
	XZ_OPT=-9 time -p tar cJf $@ \
aa839f
		$(SOURCE_DIR)/vendor \
aa839f
		$$(find $(SOURCE_DIR) -type d -name "node_modules" -prune)
68ed87
75474d
$(WEBPACK_TAR): $(VENDOR_TAR)
f90bfa
	# start with a clean state
f90bfa
	rm -rf $(SOURCE_DIR)
f90bfa
	tar xf $(SOURCE_TAR)
f90bfa
	tar xf $(VENDOR_TAR)
f90bfa
f90bfa
	# Patches to apply before creating the webpack
f90bfa
	for patch in $(PATCHES_PRE_WEBPACK); do echo applying $$patch ...; patch -d $(SOURCE_DIR) -p1 --fuzz=0 < $$patch; done
f90bfa
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)-*/