Blame SOURCES/Makefile

a02e90
VERSION := $(shell rpm --specfile *.spec --qf '%{VERSION}\n' | head -1)
a02e90
RELEASE := $(shell rpm --specfile *.spec --qf '%{RELEASE}\n' | head -1 | cut -d. -f1)
404e11
a02e90
NAME       := grafana-pcp
a02e90
RPM_NAME   := $(NAME)
a02e90
SOURCE_DIR := $(NAME)-$(VERSION)
a02e90
SOURCE_TAR := $(NAME)-$(VERSION).tar.gz
a02e90
VENDOR_TAR := $(RPM_NAME)-vendor-$(VERSION)-$(RELEASE).tar.xz
a02e90
WEBPACK_TAR := $(RPM_NAME)-webpack-$(VERSION)-$(RELEASE).tar.gz
de0a85
a02e90
# patches which must be applied before creating the vendor tarball, for example:
a02e90
# - changes in dependency versions
a02e90
# - changes in Go module imports (which affect the vendored Go modules)
a02e90
PATCHES_PRE_VENDOR := \
a02e90
	001-remove-unused-frontend-crypto.patch
de0a85
a02e90
# patches which must be applied before creating the webpack, for example:
a02e90
# - changes in Node.js sources or vendored dependencies
a02e90
PATCHES_PRE_WEBPACK := \
a02e90
	001-remove-unused-frontend-crypto.patch
404e11
a02e90
a02e90
all: $(SOURCE_TAR) $(VENDOR_TAR) $(WEBPACK_TAR)
a02e90
a02e90
$(SOURCE_TAR):
a02e90
	spectool -g $(RPM_NAME).spec
a02e90
a02e90
$(VENDOR_TAR): $(SOURCE_TAR)
a02e90
	# start with a clean state
a02e90
	rm -rf $(SOURCE_DIR)
a02e90
	tar xf $(SOURCE_TAR)
a02e90
a02e90
	# Patches to apply before vendoring
a02e90
	for patch in $(PATCHES_PRE_VENDOR); do echo applying $$patch ...; patch -d $(SOURCE_DIR) -p1 --fuzz=0 < $$patch; done
de0a85
404e11
	# Go
a02e90
	cd $(SOURCE_DIR) && go mod vendor -v
a02e90
	awk '$$2~/^v/ && $$4 != "indirect" {print "Provides: bundled(golang(" $$1 ")) = " substr($$2, 2)}' $(SOURCE_DIR)/go.mod | \
404e11
		sed -E 's/=(.*)-(.*)-(.*)/=\1-\2.\3/g' > $@.manifest
404e11
404e11
	# Node.js
a02e90
	cd $(SOURCE_DIR) && yarn install --pure-lockfile
404e11
	# Remove files with licensing issues
a02e90
	find $(SOURCE_DIR) -type d -name 'node-notifier' -prune -exec rm -r {} \;
a02e90
	find $(SOURCE_DIR) -type f -name '*.exe' -delete
404e11
	# Remove not required packages
a02e90
	rm -r $(SOURCE_DIR)/node_modules/puppeteer
a02e90
	./list_bundled_nodejs_packages.py $(SOURCE_DIR) >> $@.manifest
404e11
404e11
	# Jsonnet
a02e90
	cd $(SOURCE_DIR) && jb --jsonnetpkg-home=vendor_jsonnet install
404e11
404e11
	# Create tarball
a02e90
	XZ_OPT=-9 time -p tar cJf $@ \
a02e90
		$(SOURCE_DIR)/vendor \
a02e90
		$(SOURCE_DIR)/node_modules \
a02e90
		$(SOURCE_DIR)/vendor_jsonnet
a02e90
a02e90
$(WEBPACK_TAR): $(VENDOR_TAR)
a02e90
	# start with a clean state
a02e90
	rm -rf $(SOURCE_DIR)
a02e90
	tar xf $(SOURCE_TAR)
a02e90
	tar xf $(VENDOR_TAR)
a02e90
a02e90
	# Patches to apply before creating the webpack
a02e90
	for patch in $(PATCHES_PRE_WEBPACK); do echo applying $$patch ...; patch -d $(SOURCE_DIR) -p1 --fuzz=0 < $$patch; done
404e11
a02e90
	cd $(SOURCE_DIR) && \
de0a85
		../build_frontend.sh
404e11
a02e90
	tar cfz $@ $(SOURCE_DIR)/dist
404e11
404e11
clean:
a02e90
	rm -rf *.tar.gz *.tar.xz *.manifest *.rpm $(NAME)-*/