Makefile: simplify make rpm
Prior to this patch, `make rpm` would produce rpms that have the latest tag as their versions. This was confusing, because one could never know which contents are in a locally built rpm. Change this so that the is version always based on the commit hash of HEAD. This is easy: the golang macros read a `%commit` macro when it exists and do this for us. To simplify more, only define `%_topdir` to ./rpmbuild and use rpmbuild's known directory structure (SPEC, SOURCES, RPMS, ...) otherwise, to make it easier to find build results. Build the specfile, tarball, source rpms, and rpms with `make rpm`, without separate sub-targets. We can reintroduce them if they're needed somewhere.
This commit is contained in:
parent
792f5062e7
commit
c5543562b8
2 changed files with 39 additions and 24 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -4,7 +4,7 @@ __pycache__
|
||||||
|
|
||||||
/*.rpm
|
/*.rpm
|
||||||
/.osbuild
|
/.osbuild
|
||||||
/output
|
/rpmbuild
|
||||||
|
|
||||||
/test/.vagrant
|
/test/.vagrant
|
||||||
|
|
||||||
|
|
|
||||||
61
Makefile
61
Makefile
|
|
@ -1,36 +1,51 @@
|
||||||
PACKAGE_NAME = osbuild
|
|
||||||
VERSION := $(shell python3 setup.py --version)
|
VERSION := $(shell python3 setup.py --version)
|
||||||
NEXT_VERSION := $(shell expr "$(VERSION)" + 1)
|
NEXT_VERSION := $(shell expr "$(VERSION)" + 1)
|
||||||
|
COMMIT=$(shell git rev-parse HEAD)
|
||||||
|
|
||||||
.PHONY: sdist tarball srpm rpm copy-rpms-to-test check-working-directory vagrant-test vagrant-test-keep-running bump-version
|
.PHONY: sdist copy-rpms-to-test check-working-directory vagrant-test vagrant-test-keep-running bump-version
|
||||||
|
|
||||||
sdist:
|
sdist:
|
||||||
python3 setup.py sdist
|
python3 setup.py sdist
|
||||||
find `pwd`/dist -name '*.tar.gz' -printf '%f\n' -exec mv {} . \;
|
find `pwd`/dist -name '*.tar.gz' -printf '%f\n' -exec mv {} . \;
|
||||||
|
|
||||||
tarball:
|
#
|
||||||
git archive --prefix=osbuild-$(VERSION)/ --format=tar.gz HEAD > osbuild-$(VERSION).tar.gz
|
# Building packages
|
||||||
|
#
|
||||||
|
# The following rules build osbuild packages from the current HEAD commit,
|
||||||
|
# based on the spec file in this directory. The resulting packages have the
|
||||||
|
# commit hash in their version, so that they don't get overwritten when calling
|
||||||
|
# `make rpm` again after switching to another branch.
|
||||||
|
#
|
||||||
|
# All resulting files (spec files, source rpms, rpms) are written into
|
||||||
|
# ./rpmbuild, using rpmbuild's usual directory structure.
|
||||||
|
#
|
||||||
|
|
||||||
srpm: $(PACKAGE_NAME).spec check-working-directory tarball
|
RPM_SPECFILE=rpmbuild/SPECS/osbuild-$(COMMIT).spec
|
||||||
/usr/bin/rpmbuild -bs \
|
RPM_TARBALL=rpmbuild/SOURCES/osbuild-$(COMMIT).tar.gz
|
||||||
--define "_sourcedir $(CURDIR)" \
|
|
||||||
--define "_srcrpmdir $(CURDIR)" \
|
|
||||||
$(PACKAGE_NAME).spec
|
|
||||||
|
|
||||||
rpm: $(PACKAGE_NAME).spec check-working-directory tarball
|
$(RPM_SPECFILE):
|
||||||
- rm -r "`pwd`/output"
|
mkdir -p $(CURDIR)/rpmbuild/SPECS
|
||||||
mkdir -p "`pwd`/output"
|
(echo "%global commit $(COMMIT)"; git show HEAD:osbuild.spec) > $(RPM_SPECFILE)
|
||||||
mkdir -p "`pwd`/rpmbuild"
|
|
||||||
/usr/bin/rpmbuild -bb \
|
$(RPM_TARBALL):
|
||||||
--define "_sourcedir `pwd`" \
|
mkdir -p $(CURDIR)/rpmbuild/SOURCES
|
||||||
--define "_specdir `pwd`" \
|
git archive --prefix=osbuild-$(COMMIT)/ --format=tar.gz HEAD > $(RPM_TARBALL)
|
||||||
--define "_builddir `pwd`/rpmbuild" \
|
|
||||||
--define "_srcrpmdir `pwd`" \
|
.PHONY: srpm
|
||||||
--define "_rpmdir `pwd`/output" \
|
srpm: $(RPM_SPECFILE) $(RPM_TARBALL)
|
||||||
--define "_buildrootdir `pwd`/build" \
|
rpmbuild -bs \
|
||||||
$(PACKAGE_NAME).spec
|
--define "_topdir $(CURDIR)/rpmbuild" \
|
||||||
rm -r "`pwd`/rpmbuild"
|
$(RPM_SPECFILE)
|
||||||
rm -r "`pwd`/build"
|
|
||||||
|
.PHONY: rpm
|
||||||
|
rpm: $(RPM_SPECFILE) $(RPM_TARBALL)
|
||||||
|
rpmbuild -bb \
|
||||||
|
--define "_topdir $(CURDIR)/rpmbuild" \
|
||||||
|
$(RPM_SPECFILE)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Vagrant
|
||||||
|
#
|
||||||
|
|
||||||
copy-rpms-to-test: rpm
|
copy-rpms-to-test: rpm
|
||||||
- rm test/testing-rpms/*.rpm
|
- rm test/testing-rpms/*.rpm
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue