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