summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile.am51
-rw-r--r--VERSION.m424
-rw-r--r--configure.ac1
4 files changed, 62 insertions, 16 deletions
diff --git a/.gitignore b/.gitignore
index e1a42d61f..de61aff50 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,6 +28,8 @@ build/
compile
test-driver
freeipa-*.tar.gz
+.tarball_name
+.version
# Python compilation
*.pyc
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
diff --git a/VERSION.m4 b/VERSION.m4
index 236a40635..75326fb25 100644
--- a/VERSION.m4
+++ b/VERSION.m4
@@ -46,7 +46,7 @@ define(IPA_VERSION_PRE_RELEASE, )
# This option works only with GNU m4: #
# it requires esyscmd m4 macro. #
########################################################
-define(IPA_VERSION_IS_GIT_SNAPSHOT, no)
+define(IPA_VERSION_IS_GIT_SNAPSHOT, yes)
########################################################
# The version of IPA data. This is used to identify #
@@ -105,24 +105,28 @@ dnl helper for translit in IPA_VERSION
define(NEWLINE,`
')
-define(IPA_VERSION, translit(dnl remove new lines from version (from esyscmd)
+dnl Git snapshot: 20170102030405.GITabcdefg
+define(IPA_GIT_VERSION, translit(dnl remove new lines from version (from esyscmd)
ifelse(IPA_VERSION_IS_GIT_SNAPSHOT, yes,dnl
-dnl Git snapshot: 1.0.0.20170102030405.GITabcdefg
-IPA_VERSION_MAJOR.IPA_VERSION_MINOR.IPA_VERSION_RELEASE.dnl 1.0.0
esyscmd(date -u +'%Y%m%d%H%M')dnl 20170102030405
.GIT
esyscmd(git log -1 --format="%h" HEAD),dnl abcdefg
-dnl Git end
-ifelse(IPA_VERSION_PRE_RELEASE, ,
-dnl Release version: 1.0.0
-IPA_VERSION_MAJOR.IPA_VERSION_MINOR.IPA_VERSION_RELEASE,
-dnl Pre-release: 1.0.0rc1; newline separates m4 tokens
+), NEWLINE))
+dnl IPA_GIT_VERSION end
+
+define(IPA_VERSION, translit(dnl remove new lines from version (from esyscmd)
+dnl 1.0.0
IPA_VERSION_MAJOR.IPA_VERSION_MINOR.IPA_VERSION_RELEASE
-IPA_VERSION_PRE_RELEASE)),
+IPA_VERSION_PRE_RELEASE
+dnl version with Git snapshot: 1.0.0.20170102030405.GITabcdefg
+ifelse(IPA_VERSION_IS_GIT_SNAPSHOT, yes,
+.
+IPA_GIT_VERSION),
NEWLINE)) dnl IPA_VERSION end
dnl DEBUG: uncomment following lines and run command m4 VERSION.m4
dnl `IPA_VERSION: ''IPA_VERSION'
+dnl `IPA_GIT_VERSION: ''IPA_GIT_VERSION'
dnl `IPA_API_VERSION: ''IPA_API_VERSION'
dnl `IPA_DATA_VERSION: ''IPA_DATA_VERSION'
dnl `IPA_NUM_VERSION: ''IPA_NUM_VERSION'
diff --git a/configure.ac b/configure.ac
index 53d5dab98..4d0b09c71 100644
--- a/configure.ac
+++ b/configure.ac
@@ -372,6 +372,7 @@ AC_SUBST([DATA_VERSION], [IPA_DATA_VERSION])
AC_SUBST([NUM_VERSION], [IPA_NUM_VERSION])
AC_SUBST(VENDOR_SUFFIX)
AC_SUBST([VERSION], [IPA_VERSION])
+AC_SUBST([GIT_VERSION], [IPA_GIT_VERSION])
dnl ---------------------------------------------------------------------------
dnl Finish