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
1
.copr/Makefile
Symbolic link
1
.copr/Makefile
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../Makefile
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,3 +2,5 @@
|
||||||
.build-container
|
.build-container
|
||||||
.testprep
|
.testprep
|
||||||
.validate
|
.validate
|
||||||
|
*.rpm
|
||||||
|
x86_64/
|
||||||
|
|
|
@ -16,6 +16,8 @@ _usage() {
|
||||||
_version
|
_version
|
||||||
echo "Usage: $(basename "$0") [-D] [-b <path>] [-c <path>] [-e <path>] [-r <path>] [-o <path>] [-i <image>] [-p <image>] [-l] [-d <drivers>]"
|
echo "Usage: $(basename "$0") [-D] [-b <path>] [-c <path>] [-e <path>] [-r <path>] [-o <path>] [-i <image>] [-p <image>] [-l] [-d <drivers>]"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo " Container Source Image tool"
|
||||||
|
echo ""
|
||||||
echo -e " -b <path>\tbase path for source image builds"
|
echo -e " -b <path>\tbase path for source image builds"
|
||||||
echo -e " -c <path>\tbuild context for the container image. Can be provided via CONTEXT_DIR env variable"
|
echo -e " -c <path>\tbuild context for the container image. Can be provided via CONTEXT_DIR env variable"
|
||||||
echo -e " -e <path>\textra src for the container image. Can be provided via EXTRA_SRC_DIR env variable"
|
echo -e " -e <path>\textra src for the container image. Can be provided via EXTRA_SRC_DIR env variable"
|
||||||
|
@ -128,6 +130,14 @@ _tar() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_rpm_download() {
|
||||||
|
if [ "$(command -v yumdownloader)" != "" ] ; then
|
||||||
|
yumdownloader "${@}"
|
||||||
|
else
|
||||||
|
dnf download "${@}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# output things, only when $DEBUG is set
|
# output things, only when $DEBUG is set
|
||||||
_debug() {
|
_debug() {
|
||||||
if [ -n "${DEBUG}" ] ; then
|
if [ -n "${DEBUG}" ] ; then
|
||||||
|
@ -841,7 +851,7 @@ sourcedriver_rpm_fetch() {
|
||||||
rpm=${srcrpm%*.src.rpm}
|
rpm=${srcrpm%*.src.rpm}
|
||||||
if [ ! -f "${out_dir}/${srcrpm}" ] ; then
|
if [ ! -f "${out_dir}/${srcrpm}" ] ; then
|
||||||
_debug "--> fetching ${srcrpm}"
|
_debug "--> fetching ${srcrpm}"
|
||||||
dnf download \
|
_rpm_download \
|
||||||
--quiet \
|
--quiet \
|
||||||
--installroot "${rootfs}" \
|
--installroot "${rootfs}" \
|
||||||
--release "${release}" \
|
--release "${release}" \
|
||||||
|
|
43
BuildSourceImage.spec
Normal file
43
BuildSourceImage.spec
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
Name: BuildSourceImage
|
||||||
|
Version: 0.2
|
||||||
|
Release: 1%{?dist}
|
||||||
|
Summary: Container Source Image tool
|
||||||
|
|
||||||
|
Group: containers
|
||||||
|
License: GPLv2
|
||||||
|
URL: https://github.com/containers/BuildSourceImage
|
||||||
|
Source0: BuildSourceImage.sh
|
||||||
|
|
||||||
|
#BuildRequires:
|
||||||
|
Requires: jq
|
||||||
|
Requires: skopeo
|
||||||
|
Requires: findutils
|
||||||
|
Requires: file
|
||||||
|
%if 0%{?rhel} > 6
|
||||||
|
Requires: yum-utils
|
||||||
|
%else
|
||||||
|
Requires: dnf-command(download)
|
||||||
|
%endif
|
||||||
|
|
||||||
|
%description
|
||||||
|
%{summary}.
|
||||||
|
|
||||||
|
%prep
|
||||||
|
|
||||||
|
|
||||||
|
%build
|
||||||
|
|
||||||
|
|
||||||
|
%install
|
||||||
|
%{__mkdir_p} %{buildroot}/%{_bindir}
|
||||||
|
%{__install} -T -m 0755 ${RPM_SOURCE_DIR}/BuildSourceImage.sh %{buildroot}/%{_bindir}/BuildSourceImage
|
||||||
|
|
||||||
|
|
||||||
|
%files
|
||||||
|
%doc ${RPM_SOURCE_DIR}/LICENSE ${RPM_SOURCE_DIR}/README.md
|
||||||
|
%{_bindir}/BuildSourceImage
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
|
51
Makefile
51
Makefile
|
@ -1,4 +1,4 @@
|
||||||
SRC := ./BuildSourceImage.sh
|
pkgname := BuildSourceImage
|
||||||
CTR_IMAGE := localhost/containers/buildsourceimage
|
CTR_IMAGE := localhost/containers/buildsourceimage
|
||||||
CTR_ENGINE ?= podman
|
CTR_ENGINE ?= podman
|
||||||
BATS_OPTS ?=
|
BATS_OPTS ?=
|
||||||
|
@ -10,6 +10,21 @@ srpm_urls = \
|
||||||
https://archive.kernel.org/centos-vault/7.0.1406/os/Source/SPackages/centos-bookmarks-7-1.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_IMAGE
|
||||||
export CTR_ENGINE
|
export CTR_ENGINE
|
||||||
|
|
||||||
|
@ -18,13 +33,13 @@ all: validate
|
||||||
validate: .validate
|
validate: .validate
|
||||||
|
|
||||||
cleanfiles += .validate
|
cleanfiles += .validate
|
||||||
.validate: $(SRC)
|
.validate: $(SHELL_SRC)
|
||||||
shellcheck $(SRC) && touch $@
|
shellcheck $(SHELL_SRC) && touch $@
|
||||||
|
|
||||||
build-container: .build-container
|
build-container: .build-container
|
||||||
|
|
||||||
cleanfiles += .build-container
|
cleanfiles += .build-container
|
||||||
.build-container: .validate Dockerfile $(SRC)
|
.build-container: .validate Dockerfile $(SHELL_SRC)
|
||||||
@echo
|
@echo
|
||||||
@echo "==> Building BuildSourceImage Container"
|
@echo "==> Building BuildSourceImage Container"
|
||||||
$(CTR_ENGINE) build --quiet --file Dockerfile --tag $(CTR_IMAGE) . && touch $@
|
$(CTR_ENGINE) build --quiet --file Dockerfile --tag $(CTR_IMAGE) . && touch $@
|
||||||
|
@ -41,6 +56,34 @@ test-integration: .build-container .testprep
|
||||||
@echo "==> Running integration tests"
|
@echo "==> Running integration tests"
|
||||||
TMPDIR=$(realpath .testprep/tmp) bats $(BATS_OPTS) test/
|
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:
|
clean:
|
||||||
if [ -n "$(cleanfiles)" ] ; then rm -rf $(cleanfiles) ; fi
|
if [ -n "$(cleanfiles)" ] ; then rm -rf $(cleanfiles) ; fi
|
||||||
|
|
Loading…
Reference in a new issue