Makefile: Factorize rpm name
This commit is contained in:
parent
8eaa689491
commit
0493621504
1 changed files with 13 additions and 12 deletions
25
Makefile
25
Makefile
|
|
@ -1,13 +1,14 @@
|
||||||
# extract name from package.json
|
# extract name from package.json
|
||||||
PACKAGE_NAME := $(shell awk '/"name":/ {gsub(/[",]/, "", $$2); print $$2}' package.json)
|
PACKAGE_NAME := $(shell awk '/"name":/ {gsub(/[",]/, "", $$2); print $$2}' package.json)
|
||||||
|
RPM_NAME := cockpit-$(PACKAGE_NAME)
|
||||||
VERSION := $(shell T=$$(git describe 2>/dev/null) || T=1; echo $$T | tr '-' '.')
|
VERSION := $(shell T=$$(git describe 2>/dev/null) || T=1; echo $$T | tr '-' '.')
|
||||||
ifeq ($(TEST_OS),)
|
ifeq ($(TEST_OS),)
|
||||||
TEST_OS = centos-8-stream
|
TEST_OS = centos-8-stream
|
||||||
endif
|
endif
|
||||||
export TEST_OS
|
export TEST_OS
|
||||||
TARFILE=cockpit-$(PACKAGE_NAME)-$(VERSION).tar.xz
|
TARFILE=$(RPM_NAME)-$(VERSION).tar.xz
|
||||||
NODE_CACHE=cockpit-$(PACKAGE_NAME)-node-$(VERSION).tar.xz
|
NODE_CACHE=$(RPM_NAME)-node-$(VERSION).tar.xz
|
||||||
RPMFILE=$(shell rpmspec -D"VERSION $(VERSION)" -q cockpit-$(PACKAGE_NAME).spec.in).rpm
|
RPMFILE=$(shell rpmspec -D"VERSION $(VERSION)" -q $(RPM_NAME).spec.in).rpm
|
||||||
VM_IMAGE=$(CURDIR)/test/images/$(TEST_OS)
|
VM_IMAGE=$(CURDIR)/test/images/$(TEST_OS)
|
||||||
# stamp file to check if/when npm install ran
|
# stamp file to check if/when npm install ran
|
||||||
NODE_MODULES_TEST=package-lock.json
|
NODE_MODULES_TEST=package-lock.json
|
||||||
|
|
@ -63,7 +64,7 @@ watch:
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf dist/
|
rm -rf dist/
|
||||||
[ ! -e cockpit-$(PACKAGE_NAME).spec.in ] || rm -f cockpit-$(PACKAGE_NAME).spec
|
rm -f $(RPM_NAME).spec
|
||||||
|
|
||||||
install: $(WEBPACK_TEST)
|
install: $(WEBPACK_TEST)
|
||||||
mkdir -p $(DESTDIR)/usr/share/cockpit/$(PACKAGE_NAME)
|
mkdir -p $(DESTDIR)/usr/share/cockpit/$(PACKAGE_NAME)
|
||||||
|
|
@ -87,28 +88,28 @@ dist: $(TARFILE)
|
||||||
# pre-built dist/ (so it's not necessary) and ship packge-lock.json (so that
|
# pre-built dist/ (so it's not necessary) and ship packge-lock.json (so that
|
||||||
# node_modules/ can be reconstructed if necessary)
|
# node_modules/ can be reconstructed if necessary)
|
||||||
$(TARFILE): export NODE_ENV=production
|
$(TARFILE): export NODE_ENV=production
|
||||||
$(TARFILE): $(WEBPACK_TEST) cockpit-$(PACKAGE_NAME).spec
|
$(TARFILE): $(WEBPACK_TEST) $(RPM_NAME).spec
|
||||||
if type appstream-util >/dev/null 2>&1; then appstream-util validate-relax --nonet *.metainfo.xml; fi
|
if type appstream-util >/dev/null 2>&1; then appstream-util validate-relax --nonet *.metainfo.xml; fi
|
||||||
touch -r package.json $(NODE_MODULES_TEST)
|
touch -r package.json $(NODE_MODULES_TEST)
|
||||||
touch dist/*
|
touch dist/*
|
||||||
tar --xz -cf cockpit-$(PACKAGE_NAME)-$(VERSION).tar.xz --transform 's,^,cockpit-$(PACKAGE_NAME)/,' \
|
tar --xz -cf $(TARFILE) --transform 's,^,$(RPM_NAME)/,' \
|
||||||
--exclude cockpit-$(PACKAGE_NAME).spec.in --exclude node_modules \
|
--exclude $(RPM_NAME).spec.in --exclude node_modules \
|
||||||
$$(git ls-files) src/lib package-lock.json cockpit-$(PACKAGE_NAME).spec dist/
|
$$(git ls-files) src/lib package-lock.json $(RPM_NAME).spec dist/
|
||||||
|
|
||||||
$(NODE_CACHE): $(NODE_MODULES_TEST)
|
$(NODE_CACHE): $(NODE_MODULES_TEST)
|
||||||
tar --xz -cf $@ node_modules
|
tar --xz -cf $@ node_modules
|
||||||
|
|
||||||
node-cache: $(NODE_CACHE)
|
node-cache: $(NODE_CACHE)
|
||||||
|
|
||||||
srpm: $(TARFILE) $(NODE_CACHE) cockpit-$(PACKAGE_NAME).spec
|
srpm: $(TARFILE) $(NODE_CACHE) $(RPM_NAME).spec
|
||||||
rpmbuild -bs \
|
rpmbuild -bs \
|
||||||
--define "_sourcedir `pwd`" \
|
--define "_sourcedir `pwd`" \
|
||||||
--define "_srcrpmdir `pwd`" \
|
--define "_srcrpmdir `pwd`" \
|
||||||
cockpit-$(PACKAGE_NAME).spec
|
$(RPM_NAME).spec
|
||||||
|
|
||||||
rpm: $(RPMFILE)
|
rpm: $(RPMFILE)
|
||||||
|
|
||||||
$(RPMFILE): $(TARFILE) $(NODE_CACHE) cockpit-$(PACKAGE_NAME).spec
|
$(RPMFILE): $(TARFILE) $(NODE_CACHE) $(RPM_NAME).spec
|
||||||
mkdir -p "`pwd`/output"
|
mkdir -p "`pwd`/output"
|
||||||
mkdir -p "`pwd`/rpmbuild"
|
mkdir -p "`pwd`/rpmbuild"
|
||||||
rpmbuild -bb \
|
rpmbuild -bb \
|
||||||
|
|
@ -118,7 +119,7 @@ $(RPMFILE): $(TARFILE) $(NODE_CACHE) cockpit-$(PACKAGE_NAME).spec
|
||||||
--define "_srcrpmdir `pwd`" \
|
--define "_srcrpmdir `pwd`" \
|
||||||
--define "_rpmdir `pwd`/output" \
|
--define "_rpmdir `pwd`/output" \
|
||||||
--define "_buildrootdir `pwd`/build" \
|
--define "_buildrootdir `pwd`/build" \
|
||||||
cockpit-$(PACKAGE_NAME).spec
|
$(RPM_NAME).spec
|
||||||
find `pwd`/output -name '*.rpm' -printf '%f\n' -exec mv {} . \;
|
find `pwd`/output -name '*.rpm' -printf '%f\n' -exec mv {} . \;
|
||||||
rm -r "`pwd`/rpmbuild"
|
rm -r "`pwd`/rpmbuild"
|
||||||
rm -r "`pwd`/output" "`pwd`/build"
|
rm -r "`pwd`/output" "`pwd`/build"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue