2021-09-30 12:16:39 +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)
|
2022-04-05 17:39:40 +00:00
|
|
|
CHANGELOGTIME := $(shell rpm --specfile *.spec --qf '%{CHANGELOGTIME}\n' | head -1)
|
2022-04-11 13:06:59 +00:00
|
|
|
SOURCE_DATE_EPOCH := $(shell echo $$(( $(CHANGELOGTIME) - $(CHANGELOGTIME) % 86400 )))
|
2021-07-08 13:59:27 +00:00
|
|
|
|
|
|
|
NAME := grafana
|
|
|
|
RPM_NAME := $(NAME)
|
2021-09-30 12:16:39 +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-05-20 14:57:43 +00:00
|
|
|
|
2021-10-08 14:53:45 +00:00
|
|
|
# patches which must be applied before creating the vendor tarball, for example:
|
|
|
|
# - changes in dependency versions
|
|
|
|
# - changes in Go module imports (which affect the vendored Go modules)
|
|
|
|
PATCHES_PRE_VENDOR := \
|
2022-07-06 10:57:30 +00:00
|
|
|
0004-remove-unused-backend-dependencies.patch \
|
|
|
|
0005-remove-unused-frontend-crypto.patch \
|
|
|
|
0007-disable-husky-git-hook.patch \
|
2021-10-08 14:53:45 +00:00
|
|
|
|
|
|
|
# patches which must be applied before creating the webpack, for example:
|
|
|
|
# - changes in Node.js sources or vendored dependencies
|
2022-01-18 16:03:36 +00:00
|
|
|
PATCHES_PRE_WEBPACK := \
|
2022-07-06 10:57:30 +00:00
|
|
|
0005-remove-unused-frontend-crypto.patch \
|
2021-10-08 14:53:45 +00:00
|
|
|
|
2021-06-07 15:24:19 +00:00
|
|
|
|
2021-07-08 13:59:27 +00:00
|
|
|
all: $(SOURCE_TAR) $(VENDOR_TAR) $(WEBPACK_TAR)
|
|
|
|
|
|
|
|
$(SOURCE_TAR):
|
|
|
|
spectool -g $(RPM_NAME).spec
|
|
|
|
|
|
|
|
$(VENDOR_TAR): $(SOURCE_TAR)
|
2022-04-05 17:39:40 +00:00
|
|
|
# Start with a clean state
|
2021-09-30 12:16:39 +00:00
|
|
|
rm -rf $(SOURCE_DIR)
|
2022-04-05 17:39:40 +00:00
|
|
|
tar pxf $(SOURCE_TAR)
|
2021-05-20 14:57:43 +00:00
|
|
|
|
2021-09-30 12:16:39 +00:00
|
|
|
# Patches to apply before vendoring
|
2021-10-08 14:53:45 +00:00
|
|
|
for patch in $(PATCHES_PRE_VENDOR); do echo applying $$patch ...; patch -d $(SOURCE_DIR) -p1 --fuzz=0 < $$patch; done
|
2020-07-30 15:52:28 +00:00
|
|
|
|
2020-11-25 17:55:36 +00:00
|
|
|
# Go
|
2021-09-30 12:16:39 +00:00
|
|
|
cd $(SOURCE_DIR) && go mod vendor -v
|
2022-06-22 17:13:29 +00:00
|
|
|
# Generate Go files
|
|
|
|
cd $(SOURCE_DIR) && make gen-go
|
2021-06-07 15:24:19 +00:00
|
|
|
# Remove unused crypto
|
2022-07-06 10:57:30 +00:00
|
|
|
rm -r $(SOURCE_DIR)/vendor/golang.org/x/crypto/bcrypt
|
|
|
|
rm -r $(SOURCE_DIR)/vendor/golang.org/x/crypto/blowfish
|
|
|
|
rm -r $(SOURCE_DIR)/vendor/golang.org/x/crypto/cast5
|
|
|
|
rm -r $(SOURCE_DIR)/vendor/golang.org/x/crypto/openpgp/elgamal
|
|
|
|
rm $(SOURCE_DIR)/vendor/golang.org/x/crypto/openpgp/packet/ocfb.go
|
|
|
|
rm -r $(SOURCE_DIR)/vendor/golang.org/x/crypto/pkcs12/internal/rc2
|
2021-09-30 12:16:39 +00:00
|
|
|
awk '$$2~/^v/ && $$4 != "indirect" {print "Provides: bundled(golang(" $$1 ")) = " substr($$2, 2)}' $(SOURCE_DIR)/go.mod | \
|
2020-11-25 17:55:36 +00:00
|
|
|
sed -E 's/=(.*)-(.*)-(.*)/=\1-\2.\3/g' > $@.manifest
|
2020-11-04 16:44:15 +00:00
|
|
|
|
2020-11-25 17:55:36 +00:00
|
|
|
# Node.js
|
2022-04-05 17:39:40 +00:00
|
|
|
cd $(SOURCE_DIR) && yarn install --frozen-lockfile
|
2020-11-04 16:44:15 +00:00
|
|
|
# Remove files with licensing issues
|
2022-06-22 17:13:29 +00:00
|
|
|
find $(SOURCE_DIR)/.yarn -name 'node-notifier' -prune -exec rm -r {} \;
|
|
|
|
find $(SOURCE_DIR)/.yarn -name 'nodemon' -prune -exec rm -r {} \;
|
|
|
|
#rm -r $(SOURCE_DIR)/node_modules/visjs-network/examples
|
2021-09-30 12:16:39 +00:00
|
|
|
./list_bundled_nodejs_packages.py $(SOURCE_DIR) >> $@.manifest
|
|
|
|
|
2020-11-25 17:55:36 +00:00
|
|
|
# Create tarball
|
2022-04-05 17:39:40 +00:00
|
|
|
XZ_OPT=-9 tar \
|
|
|
|
--sort=name \
|
2022-04-11 13:06:59 +00:00
|
|
|
--mtime="@$(SOURCE_DATE_EPOCH)" --clamp-mtime \
|
2022-04-05 17:39:40 +00:00
|
|
|
--owner=0 --group=0 --numeric-owner \
|
|
|
|
-cJf $@ \
|
2021-09-30 12:16:39 +00:00
|
|
|
$(SOURCE_DIR)/vendor \
|
2022-06-22 17:13:29 +00:00
|
|
|
$$(find $(SOURCE_DIR) -type f -name "wire_gen.go" | LC_ALL=C sort) \
|
|
|
|
$(SOURCE_DIR)/.pnp.cjs \
|
|
|
|
$(SOURCE_DIR)/.yarn/cache \
|
|
|
|
$(SOURCE_DIR)/.yarn/unplugged
|
2020-11-04 16:44:15 +00:00
|
|
|
|
2021-07-08 13:59:27 +00:00
|
|
|
$(WEBPACK_TAR): $(VENDOR_TAR)
|
2022-04-05 17:39:40 +00:00
|
|
|
# Start with a clean state
|
2021-10-08 14:53:45 +00:00
|
|
|
rm -rf $(SOURCE_DIR)
|
2022-04-05 17:39:40 +00:00
|
|
|
tar pxf $(SOURCE_TAR)
|
|
|
|
tar pxf $(VENDOR_TAR)
|
2021-10-08 14:53:45 +00:00
|
|
|
|
|
|
|
# Patches to apply before creating the webpack
|
|
|
|
for patch in $(PATCHES_PRE_WEBPACK); do echo applying $$patch ...; patch -d $(SOURCE_DIR) -p1 --fuzz=0 < $$patch; done
|
|
|
|
|
2022-04-05 17:39:40 +00:00
|
|
|
# Build frontend
|
2021-09-30 12:16:39 +00:00
|
|
|
cd $(SOURCE_DIR) && \
|
2020-11-25 17:55:36 +00:00
|
|
|
../build_frontend.sh
|
2020-07-30 15:52:28 +00:00
|
|
|
|
2022-04-05 17:39:40 +00:00
|
|
|
# Create tarball
|
|
|
|
tar \
|
|
|
|
--sort=name \
|
2022-04-11 13:06:59 +00:00
|
|
|
--mtime="@$(SOURCE_DATE_EPOCH)" --clamp-mtime \
|
2022-04-05 17:39:40 +00:00
|
|
|
--owner=0 --group=0 --numeric-owner \
|
|
|
|
-czf $@ \
|
2022-06-22 17:13:29 +00:00
|
|
|
$(SOURCE_DIR)/plugins-bundled \
|
2022-04-05 17:39:40 +00:00
|
|
|
$(SOURCE_DIR)/public/build \
|
2022-06-22 17:13:29 +00:00
|
|
|
$(SOURCE_DIR)/public/img \
|
|
|
|
$(SOURCE_DIR)/public/lib \
|
2022-07-06 10:57:30 +00:00
|
|
|
$(SOURCE_DIR)/public/locales \
|
2022-06-22 17:13:29 +00:00
|
|
|
$(SOURCE_DIR)/public/views
|
2020-07-30 15:52:28 +00:00
|
|
|
|
|
|
|
clean:
|
2021-07-08 13:59:27 +00:00
|
|
|
rm -rf *.tar.gz *.tar.xz *.manifest *.rpm $(NAME)-*/
|