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