summaryrefslogtreecommitdiffstats
path: root/Makefile.am
diff options
context:
space:
mode:
authorPetr Spacek <pspacek@redhat.com>2016-11-09 16:16:45 +0100
committerMartin Basti <mbasti@redhat.com>2016-11-11 10:41:38 +0100
commita691b7d1837595fecd37bf88a875cb0753f7e698 (patch)
tree948ffaa6e404de8add3dea4d9729a82fcc935b84 /Makefile.am
parent3dc5d2c6f9a0fc134616c615634ae505ef753f77 (diff)
downloadfreeipa-a691b7d1837595fecd37bf88a875cb0753f7e698.tar.gz
freeipa-a691b7d1837595fecd37bf88a875cb0753f7e698.tar.xz
freeipa-a691b7d1837595fecd37bf88a875cb0753f7e698.zip
Build: IPA_VERSION_IS_GIT_SNAPSHOT re-generates version number on RPM build
This is a huge hack. rpms target will touch VERSION.m4 file. This change is then detected by automake Makefiles which subsequently re-execute configure and make. We have to workaround fact that variables in new make targets (executed after new configure) are different than original ones. Also, we have to 'bake-in' precise snapshot version from Git to VERSION.m4 inside of RPM tarball so the RPM does not depend on git anymore. All this magic slows build down a bit. Do not enable IPA_VERSION_IS_GIT_SNAPSHOT if you want fastest possible builds. The option IPA_VERSION_IS_GIT_SNAPSHOT is now enabled by default as it was before we started the build system refactoring effort. https://fedorahosted.org/freeipa/ticket/6418 Reviewed-By: Tomas Krizek <tkrizek@redhat.com>
Diffstat (limited to 'Makefile.am')
-rw-r--r--Makefile.am51
1 files changed, 45 insertions, 6 deletions
diff --git a/Makefile.am b/Makefile.am
index 031aef4f2..8953375af 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,8 +4,7 @@ MOSTLYCLEANFILES = ipasetup.pyc ipasetup.pyo \
ignore_import_errors.pyc ignore_import_errors.pyo \
ipasetup.pyc ipasetup.pyo \
lite-server.pyc lite-server.pyo \
- pylint_plugins.pyc pylint_plugins.pyo \
- $(TARBALL)
+ pylint_plugins.pyc pylint_plugins.pyo
# user-facing scripts
dist_bin_SCRIPTS = ipa
@@ -34,8 +33,12 @@ clean-local:
rm -rf "$(RPMBUILD)"
rm -rf "$(top_builddir)/dist"
rm -rf "$(top_srcdir)/__pycache__"
+ rm -f "$(top_builddir)"/$(PACKAGE)-*.tar.gz
+
# convenience targets for RPM build
+.PHONY: rpmroot rpmdistdir version-update _dist-version-bakein _rpms-prep \
+ rpms _rpms-body
RPMBUILD ?= $(abs_builddir)/rpmbuild
TARBALL = $(PACKAGE)-$(VERSION).tar.gz
rpmroot:
@@ -49,11 +52,47 @@ rpmdistdir:
mkdir -p $(top_builddir)/dist/rpms
mkdir -p $(top_builddir)/dist/srpms
-rpms: dist-gzip rpmroot rpmdistdir
- cp $(top_builddir)/$(TARBALL) $(RPMBUILD)/SOURCES/
+# force IPA version re-generation (useful for build from Git)
+version-update:
+ touch $(srcdir)/VERSION.m4
+
+# convert Git snapshot version to static value usable from inside of tarball
+_dist-version-bakein:
+if !IS_GIT_SNAPSHOT
+ @echo "version-bakein target requires IPA_VERSION_IS_GIT_SNAPSHOT=yes"
+ exit 1
+endif !IS_GIT_SNAPSHOT
+ chmod u+w $(top_distdir)/VERSION.m4
+ $(SED) -e 's/^define(IPA_VERSION_IS_GIT_SNAPSHOT,.*)/define(IPA_VERSION_IS_GIT_SNAPSHOT, no)/' -i $(top_distdir)/VERSION.m4
+ $(SED) -e 's/^define(IPA_VERSION_PRE_RELEASE,\(.*\))/define(IPA_VERSION_PRE_RELEASE,\1.$(GIT_VERSION))/' -i $(top_distdir)/VERSION.m4
+ cd $(top_distdir) && autoconf # re-generate configure from VERSION.m4
+
+if IS_GIT_SNAPSHOT
+VERSION_UPDATE_TARGET = version-update
+VERSION_BAKEIN_TARGET = _dist-version-bakein
+endif IS_GIT_SNAPSHOT
+
+# HACK to support IPA_VERSION_IS_GIT_SNAPSHOT:
+# touch VERSION.m4 will reexecute configure and change $(VERSION) used by dist
+# but it will not change $(VERSION) in already running target rpms.
+# We need to record new $(TARBALL) value used by dist for furher use
+# in rpms target.
+dist-hook: $(VERSION_BAKEIN_TARGET)
+ echo "$(TARBALL)" > $(top_builddir)/.tarball_name
+ echo "$(VERSION)" > $(top_builddir)/.version
+
+_rpms-prep: dist-gzip rpmroot rpmdistdir
+ cp $(top_builddir)/$$(cat $(top_builddir)/.tarball_name) $(RPMBUILD)/SOURCES/
+ rm -f $(top_builddir)/.tarball_name
+
+rpms: $(VERSION_UPDATE_TARGET)
+ $(MAKE) _rpms-body
+
+_rpms-body: _rpms-prep
rpmbuild --define "_topdir $(RPMBUILD)" -ba $(top_builddir)/$(PACKAGE).spec
- cp $(RPMBUILD)/RPMS/*/*.rpm $(top_builddir)/dist/rpms/
- cp $(RPMBUILD)/SRPMS/*.src.rpm $(top_builddir)/dist/srpms/
+ cp $(RPMBUILD)/RPMS/*/*$$(cat $(top_builddir)/.version)*.rpm $(top_builddir)/dist/rpms/
+ cp $(RPMBUILD)/SRPMS/*$$(cat $(top_builddir)/.version)*.src.rpm $(top_builddir)/dist/srpms/
+ rm -f rm -f $(top_builddir)/.version
.PHONY: lint
if WITH_POLINT