grafana/SOURCES/Makefile

65 lines
2.5 KiB
Makefile
Raw Normal View History

2021-10-05 14:21:02 +00:00
VERSION := $(shell rpm --specfile *.spec --qf '%{VERSION}\n' | head -1)
RELEASE := $(shell rpm --specfile *.spec --qf '%{RELEASE}\n' | head -1 | cut -d. -f1)
2021-07-16 04:21:25 +00:00
NAME := grafana
RPM_NAME := $(NAME)
2021-10-05 14:21:02 +00:00
SOURCE_DIR := $(NAME)-$(VERSION)
SOURCE_TAR := $(NAME)-$(VERSION).tar.gz
VENDOR_TAR := $(RPM_NAME)-vendor-$(VERSION)-$(RELEASE).tar.xz
WEBPACK_TAR := $(RPM_NAME)-webpack-$(VERSION)-$(RELEASE).tar.gz
2021-06-15 04:22:21 +00:00
2021-10-05 14:21:02 +00:00
ALL_PATCHES := $(sort $(wildcard *.patch))
VENDOR_PATCHES := $(sort $(wildcard *.vendor.patch))
COND_PATCHES := $(sort $(wildcard *.cond.patch))
REGULAR_PATCHES := $(filter-out $(VENDOR_PATCHES) $(COND_PATCHES),$(ALL_PATCHES))
2021-06-15 04:22:21 +00:00
2021-07-16 04:21:25 +00:00
all: $(SOURCE_TAR) $(VENDOR_TAR) $(WEBPACK_TAR)
$(SOURCE_TAR):
spectool -g $(RPM_NAME).spec
$(VENDOR_TAR): $(SOURCE_TAR)
2021-10-05 14:21:02 +00:00
rm -rf $(SOURCE_DIR)
tar xf $(SOURCE_TAR)
2021-06-15 04:22:21 +00:00
2021-10-05 14:21:02 +00:00
# Patches to apply before vendoring
for patch in $(REGULAR_PATCHES); do echo applying $$patch ...; patch -d $(SOURCE_DIR) -p1 --fuzz=0 < $$patch; done
2021-06-15 04:22:21 +00:00
# Go
2021-10-05 14:21:02 +00:00
cd $(SOURCE_DIR) && go mod vendor -v
2021-06-15 04:22:21 +00:00
# Remove unused crypto
2021-10-05 14:21:02 +00:00
rm $(SOURCE_DIR)/vendor/golang.org/x/crypto/cast5/cast5.go
rm $(SOURCE_DIR)/vendor/golang.org/x/crypto/ed25519/ed25519.go
rm $(SOURCE_DIR)/vendor/golang.org/x/crypto/ed25519/internal/edwards25519/const.go
rm $(SOURCE_DIR)/vendor/golang.org/x/crypto/ed25519/internal/edwards25519/edwards25519.go
rm $(SOURCE_DIR)/vendor/golang.org/x/crypto/openpgp/elgamal/elgamal.go
rm $(SOURCE_DIR)/vendor/golang.org/x/crypto/openpgp/packet/ocfb.go
awk '$$2~/^v/ && $$4 != "indirect" {print "Provides: bundled(golang(" $$1 ")) = " substr($$2, 2)}' $(SOURCE_DIR)/go.mod | \
2021-06-15 04:22:21 +00:00
sed -E 's/=(.*)-(.*)-(.*)/=\1-\2.\3/g' > $@.manifest
# Node.js
2021-10-05 14:21:02 +00:00
cd $(SOURCE_DIR) && yarn install --pure-lockfile
2021-06-15 04:22:21 +00:00
# Remove files with licensing issues
2021-10-05 14:21:02 +00:00
find $(SOURCE_DIR) -type d -name 'node-notifier' -prune -exec rm -r {} \;
find $(SOURCE_DIR) -type d -name 'property-information' -prune -exec rm -r {} \;
find $(SOURCE_DIR) -type f -name '*.exe' -delete
rm -r $(SOURCE_DIR)/node_modules/visjs-network/examples
./list_bundled_nodejs_packages.py $(SOURCE_DIR) >> $@.manifest
# Patches to apply after vendoring
for patch in $(VENDOR_PATCHES); do echo applying $$patch ...; patch -d $(SOURCE_DIR) -p1 --fuzz=0 < $$patch; done
2021-06-15 04:22:21 +00:00
# Create tarball
2021-10-05 14:21:02 +00:00
time XZ_OPT=-9 tar cJf $@ \
$(SOURCE_DIR)/vendor \
$$(find $(SOURCE_DIR) -type d -name "node_modules" -prune)
2021-06-15 04:22:21 +00:00
2021-07-16 04:21:25 +00:00
$(WEBPACK_TAR): $(VENDOR_TAR)
2021-10-05 14:21:02 +00:00
cd $(SOURCE_DIR) && \
2021-06-15 04:22:21 +00:00
../build_frontend.sh
2021-10-05 14:21:02 +00:00
tar cfz $@ $(SOURCE_DIR)/public/build $(SOURCE_DIR)/public/views $(SOURCE_DIR)/plugins-bundled
2021-06-15 04:22:21 +00:00
clean:
2021-07-16 04:21:25 +00:00
rm -rf *.tar.gz *.tar.xz *.manifest *.rpm $(NAME)-*/