2019-10-17 13:56:45 +00:00
|
|
|
pkgname := BuildSourceImage
|
|
|
|
CTR_IMAGE := localhost/containers/buildsourceimage
|
|
|
|
CTR_ENGINE ?= podman
|
|
|
|
BATS_OPTS ?=
|
|
|
|
cleanfiles =
|
2019-09-18 15:35:34 +00:00
|
|
|
# these are packages whose src.rpms are very small
|
2019-10-17 13:56:45 +00:00
|
|
|
srpm_urls = \
|
2019-09-18 15:35:34 +00:00
|
|
|
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
|
2019-10-17 13:56:45 +00:00
|
|
|
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
|
2019-09-11 08:41:07 +00:00
|
|
|
|
2019-09-19 11:50:30 +00:00
|
|
|
export CTR_IMAGE
|
|
|
|
export CTR_ENGINE
|
|
|
|
|
2019-09-11 08:41:07 +00:00
|
|
|
all: validate
|
|
|
|
|
2019-09-18 13:15:45 +00:00
|
|
|
validate: .validate
|
2019-09-11 09:45:53 +00:00
|
|
|
|
2019-09-18 13:15:45 +00:00
|
|
|
cleanfiles += .validate
|
2019-10-17 13:56:45 +00:00
|
|
|
.validate: $(SHELL_SRC)
|
|
|
|
shellcheck $(SHELL_SRC) && touch $@
|
2019-09-18 13:15:45 +00:00
|
|
|
|
|
|
|
build-container: .build-container
|
|
|
|
|
|
|
|
cleanfiles += .build-container
|
2019-10-17 13:56:45 +00:00
|
|
|
.build-container: .validate Dockerfile $(SHELL_SRC)
|
2019-09-11 09:13:02 +00:00
|
|
|
@echo
|
2019-09-18 15:35:34 +00:00
|
|
|
@echo "==> Building BuildSourceImage Container"
|
2019-09-18 13:15:45 +00:00
|
|
|
$(CTR_ENGINE) build --quiet --file Dockerfile --tag $(CTR_IMAGE) . && touch $@
|
2019-09-11 09:13:02 +00:00
|
|
|
|
2019-09-18 15:35:34 +00:00
|
|
|
cleanfiles += .testprep $(srpms)
|
|
|
|
.testprep:
|
|
|
|
@echo "==> Fetching SRPMs for testing against"
|
|
|
|
mkdir -p $@/{srpms,tmp}
|
|
|
|
wget -P $@/srpms/ $(srpm_urls)
|
|
|
|
|
2019-09-11 09:13:02 +00:00
|
|
|
.PHONY: test-integration
|
2019-09-18 15:35:34 +00:00
|
|
|
test-integration: .build-container .testprep
|
2019-09-11 09:13:02 +00:00
|
|
|
@echo
|
2019-09-18 15:35:34 +00:00
|
|
|
@echo "==> Running integration tests"
|
2019-09-26 19:09:40 +00:00
|
|
|
TMPDIR=$(realpath .testprep/tmp) bats $(BATS_OPTS) test/
|
2019-09-18 13:15:45 +00:00
|
|
|
|
2019-10-17 13:56:45 +00:00
|
|
|
.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)
|
2019-09-18 13:15:45 +00:00
|
|
|
|
|
|
|
clean:
|
|
|
|
if [ -n "$(cleanfiles)" ] ; then rm -rf $(cleanfiles) ; fi
|