rpm: crafting an rpmspec for this tool
Now you can `make srpm` or `make rpm`. Additionally, trying to make a way for copr to build this as well. We'll see if that is something.
This commit is contained in:
parent
27c11edb8b
commit
f7d8f1315c
5 changed files with 110 additions and 11 deletions
63
Makefile
63
Makefile
|
@ -1,14 +1,29 @@
|
|||
SRC := ./BuildSourceImage.sh
|
||||
CTR_IMAGE := localhost/containers/buildsourceimage
|
||||
CTR_ENGINE ?= podman
|
||||
BATS_OPTS ?=
|
||||
cleanfiles =
|
||||
pkgname := BuildSourceImage
|
||||
CTR_IMAGE := localhost/containers/buildsourceimage
|
||||
CTR_ENGINE ?= podman
|
||||
BATS_OPTS ?=
|
||||
cleanfiles =
|
||||
# these are packages whose src.rpms are very small
|
||||
srpm_urls = \
|
||||
srpm_urls = \
|
||||
https://archive.kernel.org/centos-vault/7.0.1406/os/Source/SPackages/basesystem-10.0-7.el7.centos.src.rpm \
|
||||
https://archive.kernel.org/centos-vault/7.0.1406/os/Source/SPackages/rootfiles-8.1-11.el7.src.rpm \
|
||||
https://archive.kernel.org/centos-vault/7.0.1406/os/Source/SPackages/centos-bookmarks-7-1.el7.src.rpm
|
||||
srpms = $(addprefix ./.testprep/srpms/,$(notdir $(rpms)))
|
||||
srpms = $(addprefix ./.testprep/srpms/,$(notdir $(rpms)))
|
||||
|
||||
spec ?= $(pkgname).spec
|
||||
pwd := $(shell pwd)
|
||||
NAME := $(shell rpmspec -q --qf "%{name}" $(spec))
|
||||
VERSION := $(shell rpmspec -q --qf "%{version}" $(spec))
|
||||
RELEASE := $(shell rpmspec -q --qf "%{release}" $(spec))
|
||||
ARCH := $(shell rpmspec -q --qf "%{arch}" $(spec))
|
||||
NVR := $(NAME)-$(VERSION)-$(RELEASE)
|
||||
outdir ?= $(pwd)
|
||||
|
||||
SHELL_SRC := ./BuildSourceImage.sh
|
||||
DIST_FILES := \
|
||||
$(SHELL_SRC) \
|
||||
LICENSE \
|
||||
README.md
|
||||
|
||||
export CTR_IMAGE
|
||||
export CTR_ENGINE
|
||||
|
@ -18,13 +33,13 @@ all: validate
|
|||
validate: .validate
|
||||
|
||||
cleanfiles += .validate
|
||||
.validate: $(SRC)
|
||||
shellcheck $(SRC) && touch $@
|
||||
.validate: $(SHELL_SRC)
|
||||
shellcheck $(SHELL_SRC) && touch $@
|
||||
|
||||
build-container: .build-container
|
||||
|
||||
cleanfiles += .build-container
|
||||
.build-container: .validate Dockerfile $(SRC)
|
||||
.build-container: .validate Dockerfile $(SHELL_SRC)
|
||||
@echo
|
||||
@echo "==> Building BuildSourceImage Container"
|
||||
$(CTR_ENGINE) build --quiet --file Dockerfile --tag $(CTR_IMAGE) . && touch $@
|
||||
|
@ -41,6 +56,34 @@ test-integration: .build-container .testprep
|
|||
@echo "==> Running integration tests"
|
||||
TMPDIR=$(realpath .testprep/tmp) bats $(BATS_OPTS) test/
|
||||
|
||||
.PHONY: srpm
|
||||
srpm: $(NVR).src.rpm
|
||||
@echo $^
|
||||
|
||||
cleanfiles += $(NVR).src.rpm
|
||||
$(NVR).src.rpm: $(spec) $(DIST_FILES)
|
||||
rpmbuild \
|
||||
--define '_sourcedir $(pwd)' \
|
||||
--define '_specdir $(pwd)' \
|
||||
--define '_builddir $(pwd)' \
|
||||
--define '_srcrpmdir $(outdir)' \
|
||||
--define '_rpmdir $(outdir)' \
|
||||
--nodeps \
|
||||
-bs ./$(spec)
|
||||
|
||||
.PHONY: rpm
|
||||
rpm: $(ARCH)/$(NVR).$(ARCH).rpm
|
||||
@echo $^
|
||||
|
||||
cleanfiles += $(ARCH)/$(NVR).$(ARCH).rpm
|
||||
$(ARCH)/$(NVR).$(ARCH).rpm: $(spec) $(DIST_FILES)
|
||||
rpmbuild \
|
||||
--define '_sourcedir $(pwd)' \
|
||||
--define '_specdir $(pwd)' \
|
||||
--define '_builddir $(pwd)' \
|
||||
--define '_srcrpmdir $(outdir)' \
|
||||
--define '_rpmdir $(outdir)' \
|
||||
-bb ./$(spec)
|
||||
|
||||
clean:
|
||||
if [ -n "$(cleanfiles)" ] ; then rm -rf $(cleanfiles) ; fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue