grafana/Makefile

64 lines
2.2 KiB
Makefile
Raw Normal View History

ifndef VER
$(error VER is undefined)
endif
ifndef REL
$(error REL is undefined)
endif
NAME := grafana
RPM_NAME := $(NAME)
SOURCE_DIR := $(NAME)-$(VER)
SOURCE_TAR := $(NAME)-$(VER).tar.gz
VENDOR_TAR := $(RPM_NAME)-vendor-$(VER)-$(REL).tar.xz
WEBPACK_TAR := $(RPM_NAME)-webpack-$(VER)-$(REL).tar.gz
2021-05-20 14:57:43 +00:00
ALL_PATCHES := $(wildcard *.patch)
PATCHES_TO_APPLY := $(filter-out 009-patch-unused-backend-crypto.patch 010-fips.patch,$(ALL_PATCHES))
all: $(SOURCE_TAR) $(VENDOR_TAR) $(WEBPACK_TAR)
$(SOURCE_TAR):
spectool -g $(RPM_NAME).spec
$(VENDOR_TAR): $(SOURCE_TAR)
rm -rf grafana-$(VER)
2020-07-30 15:52:28 +00:00
tar xfz grafana-$(VER).tar.gz
2021-05-20 14:57:43 +00:00
# patches can affect Go or Node.js dependencies, or the webpack
for patch in $(PATCHES_TO_APPLY); do patch -d grafana-$(VER) -p1 --fuzz=0 < $$patch; done
2020-07-30 15:52:28 +00:00
2020-11-25 17:55:36 +00:00
# Go
2020-07-30 15:52:28 +00:00
cd grafana-$(VER) && go mod vendor -v
# Remove unused crypto
rm grafana-$(VER)/vendor/golang.org/x/crypto/cast5/cast5.go
rm grafana-$(VER)/vendor/golang.org/x/crypto/ed25519/ed25519.go
rm grafana-$(VER)/vendor/golang.org/x/crypto/ed25519/internal/edwards25519/const.go
rm grafana-$(VER)/vendor/golang.org/x/crypto/ed25519/internal/edwards25519/edwards25519.go
rm grafana-$(VER)/vendor/golang.org/x/crypto/openpgp/elgamal/elgamal.go
rm grafana-$(VER)/vendor/golang.org/x/crypto/openpgp/packet/ocfb.go
2020-07-30 15:52:28 +00:00
awk '$$2~/^v/ && $$4 != "indirect" {print "Provides: bundled(golang(" $$1 ")) = " substr($$2, 2)}' grafana-$(VER)/go.mod | \
2020-11-25 17:55:36 +00:00
sed -E 's/=(.*)-(.*)-(.*)/=\1-\2.\3/g' > $@.manifest
2020-11-25 17:55:36 +00:00
# Node.js
cd grafana-$(VER) && yarn install --pure-lockfile
# Remove files with licensing issues
find grafana-$(VER) -type d -name 'node-notifier' -prune -exec rm -r {} \;
find grafana-$(VER) -type d -name 'property-information' -prune -exec rm -r {} \;
find grafana-$(VER) -type f -name '*.exe' -delete
rm -r grafana-$(VER)/node_modules/visjs-network/examples
2020-11-25 17:55:36 +00:00
./list_bundled_nodejs_packages.py grafana-$(VER)/ >> $@.manifest
2020-07-30 15:52:28 +00:00
2020-11-25 17:55:36 +00:00
# Create tarball
XZ_OPT=-9 tar cfJ $@ \
grafana-$(VER)/vendor \
$$(find grafana-$(VER) -type d -name "node_modules" -prune)
$(WEBPACK_TAR): $(VENDOR_TAR)
2020-07-30 15:52:28 +00:00
cd grafana-$(VER) && \
2020-11-25 17:55:36 +00:00
../build_frontend.sh
2020-07-30 15:52:28 +00:00
tar cfz $@ grafana-$(VER)/public/build grafana-$(VER)/public/views grafana-$(VER)/plugins-bundled
2020-07-30 15:52:28 +00:00
clean:
rm -rf *.tar.gz *.tar.xz *.manifest *.rpm $(NAME)-*/