Blame SOURCES/Makefile

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