URL: https://github.com/freeipa/freeipa/pull/226 Author: pspacek Title: #226: Build refactoring phase 5 Action: opened
PR body: """ This PR fixes IPA_VERSION_IS_GIT_SNAPSHOT option and vendor version passing from SPEC to configure. At also contains minor cleanup and srpm target which is used by Coverity. """ To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/226/head:pr226 git checkout pr226
From e701748b2eaf5f15803229d450a082a48f22560e Mon Sep 17 00:00:00 2001 From: Petr Spacek <pspa...@redhat.com> Date: Wed, 9 Nov 2016 13:34:04 +0100 Subject: [PATCH 1/8] Build: fix make clean to remove build artifacts from top-level directory make lint and make dist were generating files which were not removed by make clean. https://fedorahosted.org/freeipa/ticket/6418 --- Makefile.am | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index ffa5de2..031aef4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,11 @@ SUBDIRS = asn1 util client contrib daemons init install ipaclient ipalib ipaplatform ipapython ipaserver ipatests po -MOSTLYCLEANFILES = ipasetup.pyc ipasetup.pyo +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) # user-facing scripts dist_bin_SCRIPTS = ipa @@ -25,6 +30,11 @@ EXTRA_DIST = .mailmap \ pylintrc \ pytest.ini +clean-local: + rm -rf "$(RPMBUILD)" + rm -rf "$(top_builddir)/dist" + rm -rf "$(top_srcdir)/__pycache__" + # convenience targets for RPM build RPMBUILD ?= $(abs_builddir)/rpmbuild TARBALL = $(PACKAGE)-$(VERSION).tar.gz From 814cae9b122c96304e16cf67f90a42f0659e2174 Mon Sep 17 00:00:00 2001 From: Petr Spacek <pspa...@redhat.com> Date: Wed, 9 Nov 2016 15:42:30 +0100 Subject: [PATCH 2/8] Build: remove unused and redundant code from configure.ac and po/Makefile.in https://fedorahosted.org/freeipa/ticket/6418 --- configure.ac | 4 ---- po/Makefile.in | 1 - 2 files changed, 5 deletions(-) diff --git a/configure.ac b/configure.ac index 6e82c62..5646cb0 100644 --- a/configure.ac +++ b/configure.ac @@ -17,9 +17,6 @@ AC_HEADER_STDC AM_CONDITIONAL([HAVE_GCC], [test "$ac_cv_prog_gcc" = yes]) -AC_SUBST(VERSION) -AC_SUBST([INSTALL_DATA], ['$(INSTALL) -m 644 -p']) - dnl --------------------------------------------------------------------------- dnl - Check for NSPR/NSS dnl --------------------------------------------------------------------------- @@ -359,7 +356,6 @@ AC_ARG_WITH([vendor-suffix], [VENDOR_SUFFIX=${withval}], [VENDOR_SUFFIX=""]) -dnl TODO: IPA_VENDOR_RELEASE AC_SUBST([API_VERSION], [IPA_API_VERSION]) AC_SUBST([DATA_VERSION], [IPA_DATA_VERSION]) AC_SUBST([NUM_VERSION], [IPA_NUM_VERSION]) diff --git a/po/Makefile.in b/po/Makefile.in index b42d8fc..0ab449c 100644 --- a/po/Makefile.in +++ b/po/Makefile.in @@ -5,7 +5,6 @@ datadir = ${datarootdir} localedir = ${datarootdir}/locale INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL@ -m 644 AWK = @AWK@ SED = @SED@ MKDIR_P = @MKDIR_P@ From a5673d0ff2307b0cc289f47698bf4452d9a625f0 Mon Sep 17 00:00:00 2001 From: Petr Spacek <pspa...@redhat.com> Date: Wed, 9 Nov 2016 16:15:19 +0100 Subject: [PATCH 3/8] Build: IPA_VERSION_IS_GIT_SNAPSHOT checks if source directory is Git repo https://fedorahosted.org/freeipa/ticket/6418 --- configure.ac | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/configure.ac b/configure.ac index 5646cb0..1b672fb 100644 --- a/configure.ac +++ b/configure.ac @@ -350,6 +350,17 @@ AC_MSG_RESULT([${IPAPLATFORM}]) dnl --------------------------------------------------------------------------- dnl Version information from VERSION.m4 and command line dnl --------------------------------------------------------------------------- +dnl Are we in source tree? +AM_CONDITIONAL([IS_GIT_SNAPSHOT], [test "IPA_VERSION_IS_GIT_SNAPSHOT" == "yes"]) +AM_COND_IF([IS_GIT_SNAPSHOT], [ + AC_MSG_CHECKING([if source directory is a Git reposistory]) + if test ! -d "${srcdir}/.git"; then + AC_MSG_ERROR([Git reposistory is required by VERSION.m4 IPA_VERSION_IS_GIT_SNAPSHOT but not found]) + else + AC_MSG_RESULT([yes]) + fi +]) + AC_ARG_WITH([vendor-suffix], AS_HELP_STRING([--with-vendor-suffix=STRING], [Vendor string used by package system, e.g. "-1.fc24"]), From 398e1e222e89e4a82b2a52ced9548fa14fe580e7 Mon Sep 17 00:00:00 2001 From: Petr Spacek <pspa...@redhat.com> Date: Wed, 9 Nov 2016 16:21:51 +0100 Subject: [PATCH 4/8] Build: use POSIX 1003.1-1988 (ustar) file format for tar archives Default format used by Autotools limits length of paths to 99 characters. This is not enough for tarballs with Git snapshots. https://fedorahosted.org/freeipa/ticket/6418 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 1b672fb..53d5dab 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,7 @@ AC_INIT([freeipa], AC_CONFIG_HEADERS([config.h]) -AM_INIT_AUTOMAKE([foreign]) +AM_INIT_AUTOMAKE([foreign 1.9 tar-ustar]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES]) AC_PROG_CC_C99 From e567d11b4ddd4c879ab7e4a3a7feda9c757e6101 Mon Sep 17 00:00:00 2001 From: Petr Spacek <pspa...@redhat.com> Date: Wed, 9 Nov 2016 16:16:45 +0100 Subject: [PATCH 5/8] 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. If you want quick builds, do not enable IPA_VERSION_IS_GIT_SNAPSHOT. https://fedorahosted.org/freeipa/ticket/6418 --- Makefile.am | 46 ++++++++++++++++++++++++++++++++++++++++++---- VERSION.m4 | 22 +++++++++++++--------- configure.ac | 1 + 3 files changed, 56 insertions(+), 13 deletions(-) diff --git a/Makefile.am b/Makefile.am index 031aef4..6a85f8c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -36,6 +36,8 @@ clean-local: rm -rf "$(top_srcdir)/__pycache__" # 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 +51,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 236a406..efc8307 100644 --- a/VERSION.m4 +++ b/VERSION.m4 @@ -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 53d5dab..4d0b09c 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 From f747bbf22b76548801a220a8c20bc3f78cccfbce Mon Sep 17 00:00:00 2001 From: Petr Spacek <pspa...@redhat.com> Date: Thu, 10 Nov 2016 10:14:32 +0100 Subject: [PATCH 6/8] Build: add make srpms target https://fedorahosted.org/freeipa/ticket/6418 --- Makefile.am | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 6a85f8c..7c7c6c6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,7 +37,7 @@ clean-local: # convenience targets for RPM build .PHONY: rpmroot rpmdistdir version-update _dist-version-bakein _rpms-prep \ - rpms _rpms-body + rpms _rpms-body srpms _srpms-body RPMBUILD ?= $(abs_builddir)/rpmbuild TARBALL = $(PACKAGE)-$(VERSION).tar.gz rpmroot: @@ -93,6 +93,14 @@ _rpms-body: _rpms-prep cp $(RPMBUILD)/SRPMS/*$$(cat $(top_builddir)/.version)*.src.rpm $(top_builddir)/dist/srpms/ rm -f rm -f $(top_builddir)/.version +srpms: $(VERSION_UPDATE_TARGET) + $(MAKE) _srpms-body + +_srpms-body: _rpms-prep + rpmbuild --define "_topdir $(RPMBUILD)" -bs $(top_builddir)/$(PACKAGE).spec + 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 POLINT_TARGET = polint From 49a241fab546827ac51a2f2b9397e57f891236f1 Mon Sep 17 00:00:00 2001 From: Petr Spacek <pspa...@redhat.com> Date: Thu, 10 Nov 2016 10:55:59 +0100 Subject: [PATCH 7/8] Build: update IPA_VERSION_IS_GIT_SNAPSHOT to comply with PEP440 Python setuptools started to warn about forward incompatibility. Now we are following PEP440 so it should not cause any problems with future versions of setuptools. https://fedorahosted.org/freeipa/ticket/6418 --- VERSION.m4 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/VERSION.m4 b/VERSION.m4 index efc8307..45c750c 100644 --- a/VERSION.m4 +++ b/VERSION.m4 @@ -5,7 +5,7 @@ # 1.0.x New production series # # 1.0.x{alpha,beta,rc}y Alpha/Preview/Testing, Beta, # # Release Candidate # -# 1.0.0.20170102030405.GITabcdefg Build from GIT # +# 1.0.0.dev20170102030405+gitabcdefg Build from GIT # # # ######################################################## @@ -38,10 +38,10 @@ define(IPA_VERSION_PRE_RELEASE, ) # in the development BRANCH, and set to 'no' only in # # the IPA_X_X_RELEASE BRANCH # # # -# <MAJOR>.<MINOR>.<RELEASE>.<TIMESTAMP>.GIT<hash> # +# <MAJOR>.<MINOR>.<RELEASE>.dev<TIMESTAMP>+git<hash> # # # # e.g. define(IPA_VERSION_IS_GIT_SNAPSHOT, yes) # -# -> "1.0.0.20170102030405.GITabcdefg" # +# -> "1.0.0.dev20170102030405+gitabcdefg" # # # # This option works only with GNU m4: # # it requires esyscmd m4 macro. # @@ -105,11 +105,12 @@ dnl helper for translit in IPA_VERSION define(NEWLINE,` ') -dnl Git snapshot: 20170102030405.GITabcdefg +dnl Git snapshot: dev20170102030405+gitabcdefg define(IPA_GIT_VERSION, translit(dnl remove new lines from version (from esyscmd) ifelse(IPA_VERSION_IS_GIT_SNAPSHOT, yes,dnl +dev esyscmd(date -u +'%Y%m%d%H%M')dnl 20170102030405 -.GIT ++git esyscmd(git log -1 --format="%h" HEAD),dnl abcdefg ), NEWLINE)) dnl IPA_GIT_VERSION end @@ -118,7 +119,7 @@ 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 -dnl version with Git snapshot: 1.0.0.20170102030405.GITabcdefg +dnl version with Git snapshot: 1.0.0.dev20170102030405+gitabcdefg ifelse(IPA_VERSION_IS_GIT_SNAPSHOT, yes, . IPA_GIT_VERSION), From f9dc9499dddf962cc69deebff78026fe5698f49e Mon Sep 17 00:00:00 2001 From: Petr Spacek <pspa...@redhat.com> Date: Thu, 10 Nov 2016 11:09:51 +0100 Subject: [PATCH 8/8] Build: pass down %{release} from SPEC to configure This is required in order to bake-in precise vendor version to version.py. https://fedorahosted.org/freeipa/ticket/6418 --- freeipa.spec.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freeipa.spec.in b/freeipa.spec.in index f2be4bc..53035f8 100644 --- a/freeipa.spec.in +++ b/freeipa.spec.in @@ -687,7 +687,7 @@ This package contains tests that verify IPA functionality under Python 3. %build # UI compilation segfaulted on some arches when the stack was lower (#1040576) export JAVA_STACK_SIZE="8m" -%configure +%configure --with-vendor-suffix=-%{release} %make_build
-- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code