Use image-customize --build to build/install distribution packages

This centralizes/factorizes the rpm package builds, and builds
RPM packages in the VM instead of on the host, which is cleaner. It also
paves the way for supporting Debian and arch builds.

Drop the `make srpm` rule, as it's not very useful. Keep the `make rpm`
rule, as sometimes developers do this manually. This might be replaced
later on with another image-customize feature which copies the built rpm
out of the VM.
This commit is contained in:
Martin Pitt 2022-02-04 06:57:26 +01:00 committed by Martin Pitt
parent 799d8f5cc9
commit b2662eeebd
2 changed files with 10 additions and 18 deletions

View file

@ -9,7 +9,6 @@ export TEST_OS
TARFILE=$(RPM_NAME)-$(VERSION).tar.xz TARFILE=$(RPM_NAME)-$(VERSION).tar.xz
NODE_CACHE=$(RPM_NAME)-node-$(VERSION).tar.xz NODE_CACHE=$(RPM_NAME)-node-$(VERSION).tar.xz
SPEC=$(RPM_NAME).spec SPEC=$(RPM_NAME).spec
RPMFILE=$(shell rpmspec -D"VERSION $(VERSION)" -q packaging/$(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
@ -102,15 +101,8 @@ $(NODE_CACHE): $(NODE_MODULES_TEST)
node-cache: $(NODE_CACHE) node-cache: $(NODE_CACHE)
srpm: $(TARFILE) $(NODE_CACHE) $(SPEC) # convenience target for developers
rpmbuild -bs \ rpm: $(TARFILE) $(NODE_CACHE) $(SPEC)
--define "_sourcedir `pwd`" \
--define "_srcrpmdir `pwd`" \
$(SPEC)
rpm: $(RPMFILE)
$(RPMFILE): $(TARFILE) $(NODE_CACHE) $(SPEC)
mkdir -p "`pwd`/output" mkdir -p "`pwd`/output"
mkdir -p "`pwd`/rpmbuild" mkdir -p "`pwd`/rpmbuild"
rpmbuild -bb \ rpmbuild -bb \
@ -124,13 +116,13 @@ $(RPMFILE): $(TARFILE) $(NODE_CACHE) $(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"
# sanity check
test -e "$(RPMFILE)"
# build a VM with locally built rpm installed # build a VM with locally built distro pkgs installed
$(VM_IMAGE): $(RPMFILE) bots $(VM_IMAGE): $(TARFILE) $(NODE_CACHE) bots
rm -f $(VM_IMAGE) $(VM_IMAGE).qcow2 rm -f $(VM_IMAGE) $(VM_IMAGE).qcow2
bots/image-customize -v -i cockpit-ws -i `pwd`/$(RPMFILE) -s $(CURDIR)/test/vm.install $(TEST_OS) bots/image-customize --verbose --upload $(NODE_CACHE):/var/tmp/ --build $(TARFILE) \
--install cockpit-ws \
--script $(CURDIR)/test/vm.install $(TEST_OS)
# convenience target for the above # convenience target for the above
vm: $(VM_IMAGE) vm: $(VM_IMAGE)
@ -172,4 +164,4 @@ $(NODE_MODULES_TEST): package.json
env -u NODE_ENV npm install env -u NODE_ENV npm install
env -u NODE_ENV npm prune env -u NODE_ENV npm prune
.PHONY: all clean install devel-install print-version dist node-cache srpm rpm check vm update-po .PHONY: all clean install devel-install print-version dist node-cache rpm check vm update-po

View file

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# image-customize script to enable cockpit in test VMs # image-customize script to prepare a bots VM for testing this application
# The application RPM will be installed separately # The application package will be installed separately
set -eu set -eu
# don't force https:// (self-signed cert) # don't force https:// (self-signed cert)