From c48e5fd811326dc64e19490f88003e442815a052 Mon Sep 17 00:00:00 2001 From: Petr Spacek Date: Fri, 21 Oct 2016 22:35:28 +0200 Subject: [PATCH] Build: move version handling from Makefile to configure Version information is now in VERSION.m4 instead of VERSION. Makefile target version-update was minimized and configure can be run before make. Makefile temporarily contains hardcoded version which has to match the one specified in VERSION.m4. This is preparatory step which will allow us to replace hand-made Makefile with one generated by Automake. https://fedorahosted.org/freeipa/ticket/6418 Reviewed-By: Martin Basti Reviewed-By: Christian Heimes --- Makefile | 67 ++---------------- VERSION => VERSION.m4 | 116 ++++++++++++++++++++----------- configure.ac | 27 ++++++- daemons/ipa-version.h.in | 6 +- freeipa.spec.in | 18 +++-- install/ui/src/libs/loader.js.in | 6 +- ipapython/version.py.in | 8 +-- ipasetup.py.in | 2 +- version.m4.in | 1 - 9 files changed, 127 insertions(+), 124 deletions(-) rename VERSION => VERSION.m4 (51%) delete mode 100644 version.m4.in diff --git a/Makefile b/Makefile index 761b57ddc..691f7532a 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,6 @@ # IPA build system cannot cope with parallel build; disable parallel build .NOTPARALLEL: -include VERSION - SUBDIRS=util asn1 daemons install ipapython ipalib CLIENTDIRS=ipapython ipalib client util asn1 CLIENTPYDIRS=ipaclient ipaplatform @@ -13,42 +11,11 @@ PRJ_PREFIX=freeipa RPMBUILD ?= $(PWD)/rpmbuild TARGET ?= master -IPA_NUM_VERSION ?= $(shell printf %d%02d%02d $(IPA_VERSION_MAJOR) $(IPA_VERSION_MINOR) $(IPA_VERSION_RELEASE)) - -# After updating the version in VERSION you should run the version-update -# target. - -ifeq ($(IPA_VERSION_IS_GIT_SNAPSHOT),"yes") -DATESTR:=$(shell date -u +'%Y%m%d%H%M') -GIT_VERSION:=$(shell git show --pretty=format:"%h" --stat HEAD 2>/dev/null|head -1) -ifneq ($(GIT_VERSION),) -IPA_VERSION=$(IPA_VERSION_MAJOR).$(IPA_VERSION_MINOR).$(IPA_VERSION_RELEASE).$(DATESTR)GIT$(GIT_VERSION) -endif # in a git tree and git returned a version -endif # git - -ifndef IPA_VERSION -ifdef IPA_VERSION_ALPHA_RELEASE -IPA_VERSION=$(IPA_VERSION_MAJOR).$(IPA_VERSION_MINOR).$(IPA_VERSION_RELEASE).alpha$(IPA_VERSION_ALPHA_RELEASE) -else -ifdef IPA_VERSION_BETA_RELEASE -IPA_VERSION=$(IPA_VERSION_MAJOR).$(IPA_VERSION_MINOR).$(IPA_VERSION_RELEASE).beta$(IPA_VERSION_BETA_RELEASE) -else -ifdef IPA_VERSION_RC_RELEASE -IPA_VERSION=$(IPA_VERSION_MAJOR).$(IPA_VERSION_MINOR).$(IPA_VERSION_RELEASE).rc$(IPA_VERSION_RC_RELEASE) -else -IPA_VERSION=$(IPA_VERSION_MAJOR).$(IPA_VERSION_MINOR).$(IPA_VERSION_RELEASE) -endif # rc -endif # beta -endif # alpha -endif # ipa_version - -IPA_VENDOR_VERSION=$(IPA_VERSION)$(IPA_VENDOR_VERSION_SUFFIX) - +# temporary hack until we replace hand-made Makefile with the generated one +IPA_VERSION=4.4.90 TARBALL_PREFIX=freeipa-$(IPA_VERSION) TARBALL=$(TARBALL_PREFIX).tar.gz -IPA_RPM_RELEASE=$(shell cat RELEASE) - LIBDIR ?= /usr/lib DEVELOPER_MODE ?= 0 @@ -151,43 +118,19 @@ lint: apilint acilint pylint po-validate jslint test: ./make-test -release-update: - if [ ! -e RELEASE ]; then echo 0 > RELEASE; fi - -ipapython/version.py: ipapython/version.py.in FORCE - sed -e s/__VERSION__/$(IPA_VERSION)/ $< > $@ - sed -i -e "s:__NUM_VERSION__:$(IPA_NUM_VERSION):" $@ - sed -i -e "s:__VENDOR_VERSION__:$(IPA_VENDOR_VERSION):" $@ - sed -i -e "s:__API_VERSION__:$(IPA_API_VERSION_MAJOR).$(IPA_API_VERSION_MINOR):" $@ +ipapython/version.py: API.txt bootstrap-autogen grep -Po '(?<=default: ).*' API.txt | sed -n -i -e "/__DEFAULT_PLUGINS__/!{p;b};r /dev/stdin" $@ touch -r $< $@ -ipasetup.py: ipasetup.py.in FORCE - sed -e s/__VERSION__/$(IPA_VERSION)/ $< > $@ - .PHONY: egg_info -egg_info: ipapython/version.py ipaplatform/__init__.py ipasetup.py +egg_info: ipapython/version.py ipaplatform/__init__.py for directory in $(PYPKGDIRS); do \ pushd $${directory} ; \ $(PYTHON) setup.py egg_info $(EXTRA_SETUP); \ popd ; \ done -version-update: release-update ipapython/version.py ipasetup.py - sed -e s/__VERSION__/$(IPA_VERSION)/ -e s/__RELEASE__/$(IPA_RPM_RELEASE)/ \ - freeipa.spec.in > freeipa.spec - sed -e s/__VERSION__/$(IPA_VERSION)/ version.m4.in \ - > version.m4 - sed -e s/__NUM_VERSION__/$(IPA_NUM_VERSION)/ install/ui/src/libs/loader.js.in \ - > install/ui/src/libs/loader.js - sed -i -e "s:__API_VERSION__:$(IPA_API_VERSION_MAJOR).$(IPA_API_VERSION_MINOR):" install/ui/src/libs/loader.js - sed -e s/__VERSION__/$(IPA_VERSION)/ daemons/ipa-version.h.in \ - > daemons/ipa-version.h - sed -i -e "s:__NUM_VERSION__:$(IPA_NUM_VERSION):" daemons/ipa-version.h - sed -i -e "s:__DATA_VERSION__:$(IPA_DATA_VERSION):" daemons/ipa-version.h - - sed -e s/__VERSION__/$(IPA_VERSION)/ client/version.m4.in \ - > client/version.m4 +version-update: ipapython/version.py apilint: bootstrap-autogen ./makeapi --validate diff --git a/VERSION b/VERSION.m4 similarity index 51% rename from VERSION rename to VERSION.m4 index 41c3b2add..236a40635 100644 --- a/VERSION +++ b/VERSION.m4 @@ -1,11 +1,11 @@ ######################################################## -# freeIPA Version # +# FreeIPA Version # # # -# freeIPA versions are as follows # +# FreeIPA versions are as follows # # 1.0.x New production series # # 1.0.x{alpha,beta,rc}y Alpha/Preview/Testing, Beta, # # Release Candidate # -# 1.0.0GITabcdefg Build from GIT # +# 1.0.0.20170102030405.GITabcdefg Build from GIT # # # ######################################################## @@ -14,56 +14,39 @@ # # # .. # # # -# e.g. IPA_VERSION_MAJOR=1 # -# IPA_VERSION_MINOR=0 # -# IPA_VERSION_RELEASE=0 # +# e.g. define(IPA_VERSION_MAJOR, 1) # +# define(IPA_VERSION_MINOR, 0) # +# define(IPA_VERSION_RELEASE, 0) # # -> "1.0.0" # ######################################################## -IPA_VERSION_MAJOR=4 -IPA_VERSION_MINOR=4 -IPA_VERSION_RELEASE=90 +define(IPA_VERSION_MAJOR, 4) +define(IPA_VERSION_MINOR, 4) +define(IPA_VERSION_RELEASE, 90) ######################################################## -# For 'alpha' releases the version will be # +# For 'pre' releases the version will be # # # -# ..alpha # +# .. # # # -# e.g. IPA_VERSION_ALPHA_RELEASE=1 # -# -> "1.0.0alpha1" # -######################################################## -IPA_VERSION_ALPHA_RELEASE= - -######################################################## -# For 'beta' releases the version will be # -# # -# ..beta # -# # -# e.g. IPA_VERSION_BETA_RELEASE=1 # -# -> "1.0.0beta1" # -######################################################## -IPA_VERSION_BETA_RELEASE= - -######################################################## -# For 'rc' releases the version will be # -# # -# ..rc # -# # -# e.g. IPA_VERSION_RC_RELEASE=1 # +# e.g. define(IPA_VERSION_PRE_RELEASE, rc1) # # -> "1.0.0rc1" # ######################################################## -IPA_VERSION_RC_RELEASE= +define(IPA_VERSION_PRE_RELEASE, ) ######################################################## # To mark GIT snapshots this should be set to 'yes' # # in the development BRANCH, and set to 'no' only in # # the IPA_X_X_RELEASE BRANCH # # # -# ..GITxxx # +# ....GIT # # # -# e.g. IPA_VERSION_IS_SVN_SNAPSHOT=yes # -# -> "1.0.0GITabcdefg" # +# e.g. define(IPA_VERSION_IS_GIT_SNAPSHOT, yes) # +# -> "1.0.0.20170102030405.GITabcdefg" # +# # +# This option works only with GNU m4: # +# it requires esyscmd m4 macro. # ######################################################## -IPA_VERSION_IS_GIT_SNAPSHOT="yes" +define(IPA_VERSION_IS_GIT_SNAPSHOT, no) ######################################################## # The version of IPA data. This is used to identify # @@ -73,10 +56,10 @@ IPA_VERSION_IS_GIT_SNAPSHOT="yes" # # # The format is %Y%m%d%H%M%S # # # -# e.g. IPA_DATA_VERSION=`date +%Y%m%d%H%M%S` # +# e.g. define(IPA_DATA_VERSION, 20100614120000) # # -> "20100614120000" # ######################################################## -IPA_DATA_VERSION=20100614120000 +define(IPA_DATA_VERSION, 20100614120000) ######################################################## # The version of the IPA API. This controls which # @@ -89,6 +72,57 @@ IPA_DATA_VERSION=20100614120000 # The format is a whole number # # # ######################################################## -IPA_API_VERSION_MAJOR=2 -IPA_API_VERSION_MINOR=216 +define(IPA_API_VERSION_MAJOR, 2) +define(IPA_API_VERSION_MINOR, 216) # Last change: DNS: Support URI resource record type + + +######################################################## +# Following values are auto-generated from values above +# That way m4 madness lies +######################################################## + +######################################################## +# IPA_NUM_VERSION is auto-generated +# format suitable for aritmetical comparison. +######################################################## +dnl for some reason AC_SUBST([NUM_VERSION], [IPA_NUM_VERSION]) +dnl does not work when we use macro "format" instead of "esyscmd" +define(IPA_NUM_VERSION, esyscmd(printf "%d%02d%02d" IPA_VERSION_MAJOR IPA_VERSION_MINOR IPA_VERSION_RELEASE)) + + +######################################################## +# IPA_API_VERSION: format is APImajor.APIminor +######################################################## +define(IPA_API_VERSION, IPA_API_VERSION_MAJOR.IPA_API_VERSION_MINOR) + + +######################################################## +# IPA_VERSION is one string formated according to rules +# described on top of this file +######################################################## +dnl helper for translit in IPA_VERSION +define(NEWLINE,` +') + +define(IPA_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 +IPA_VERSION_MAJOR.IPA_VERSION_MINOR.IPA_VERSION_RELEASE +IPA_VERSION_PRE_RELEASE)), +NEWLINE)) dnl IPA_VERSION end + +dnl DEBUG: uncomment following lines and run command m4 VERSION.m4 +dnl `IPA_VERSION: ''IPA_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 b9f424ea6..6464d196a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ(2.59) -m4_include(version.m4) +m4_include(VERSION.m4) AC_INIT([ipa-server], IPA_VERSION, [https://hosted.fedoraproject.org/projects/freeipa/newticket]) @@ -9,7 +9,6 @@ AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([foreign]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES]) -AM_MAINTAINER_MODE AC_PROG_CC_C99 AC_DISABLE_STATIC LT_INIT @@ -332,6 +331,22 @@ AC_SUBST([IPAPLATFORM]) AC_MSG_RESULT([${IPAPLATFORM}]) +dnl --------------------------------------------------------------------------- +dnl Version information from VERSION.m4 and command line +dnl --------------------------------------------------------------------------- +AC_ARG_WITH([vendor-suffix], + AS_HELP_STRING([--with-vendor-suffix=STRING], + [Vendor string used by package system, e.g. "-1.fc24"]), + [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]) +AC_SUBST(VENDOR_SUFFIX) +AC_SUBST([VERSION], [IPA_VERSION]) + dnl --------------------------------------------------------------------------- dnl Finish dnl --------------------------------------------------------------------------- @@ -383,6 +398,7 @@ AC_SUBST(CFLAGS) AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) + # Files AC_CONFIG_LINKS([ipaplatform/__init__.py:ipaplatform/$IPAPLATFORM/__init__.py ipaplatform/constants.py:ipaplatform/$IPAPLATFORM/constants.py @@ -417,6 +433,8 @@ AC_CONFIG_FILES([ daemons/ipa-slapi-plugins/ipa-sidgen/Makefile daemons/ipa-slapi-plugins/ipa-range-check/Makefile daemons/ipa-slapi-plugins/topology/Makefile + daemons/ipa-version.h + freeipa.spec install/Makefile install/certmonger/Makefile install/conf/Makefile @@ -431,6 +449,7 @@ AC_CONFIG_FILES([ install/ui/css/Makefile install/ui/src/Makefile install/ui/src/libs/Makefile + install/ui/src/libs/loader.js install/ui/images/Makefile install/ui/build/Makefile install/ui/build/dojo/Makefile @@ -441,6 +460,8 @@ AC_CONFIG_FILES([ install/restart_scripts/Makefile install/wsgi/Makefile install/oddjob/Makefile + ipapython/version.py + ipasetup.py ipatests/man/Makefile po/Makefile util/Makefile @@ -455,6 +476,7 @@ echo " IPA Server $VERSION ======================== + vendor version: ${VERSION}${VENDOR_SUFFIX} prefix: ${prefix} exec_prefix: ${exec_prefix} libdir: ${libdir} @@ -472,5 +494,4 @@ echo " KRB5 libs: ${KRB5_LIBS} KRAD libs: ${KRAD_LIBS} OpenSSL crypto libs: ${CRYPTO_LIBS} - Maintainer mode: ${USE_MAINTAINER_MODE} " diff --git a/daemons/ipa-version.h.in b/daemons/ipa-version.h.in index 3a475414e..4ab6b95a0 100644 --- a/daemons/ipa-version.h.in +++ b/daemons/ipa-version.h.in @@ -35,14 +35,14 @@ * END COPYRIGHT BLOCK **/ /* The full version including strings */ -#define VERSION "__VERSION__" +#define VERSION "@VERSION@" /* Just the numeric portion of the version so one can do direct numeric comparisons to see if the API is compatible. */ -#define NUM_VERSION __NUM_VERSION__ +#define NUM_VERSION @NUM_VERSION@ /* The data version. This is distinguished from the server version based on the compatibility of the data/plugins/etc from one version to another. */ -#define DATA_VERSION __DATA_VERSION__ +#define DATA_VERSION @DATA_VERSION@ diff --git a/freeipa.spec.in b/freeipa.spec.in index fbe7ff99c..9e30a3927 100644 --- a/freeipa.spec.in +++ b/freeipa.spec.in @@ -30,9 +30,18 @@ %define _hardened_build 1 +# Work-around fact that RPM SPEC parser does not accept +# "Version: @VERSION@" in freeipa.spec.in used for Autoconf string replacement +%define IPA_VERSION @VERSION@ +%define AT_SIGN @ +# redefine IPA_VERSION only if its value matches the Autoconf placeholder +%if "%{IPA_VERSION}" == "%{AT_SIGN}VERSION%{AT_SIGN}" + %define IPA_VERSION nonsense.to.please.RPM.SPEC.parser +%endif + Name: freeipa -Version: __VERSION__ -Release: __RELEASE__%{?dist} +Version: %{IPA_VERSION} +Release: upstream Summary: The Identity, Policy and Audit system Group: System Environment/Base @@ -680,8 +689,6 @@ export JAVA_STACK_SIZE="8m" export CFLAGS="%{optflags} $CFLAGS" export LDFLAGS="%{__global_ldflags} $LDFLAGS" -export IPA_VENDOR_VERSION_SUFFIX=-%{release} - %if ! %{ONLY_CLIENT} make IPA_VERSION_IS_GIT_SNAPSHOT=no LIBDIR=%{_libdir} %{?_smp_mflags} all %else @@ -699,7 +706,6 @@ make %{?_smp_mflags} client-check VERBOSE=yes LIBDIR=%{_libdir} %install rm -rf %{buildroot} -export IPA_VENDOR_VERSION_SUFFIX=-%{release} make version-update LIBDIR=%{_libdir} %if ! %{ONLY_CLIENT} make install DESTDIR=%{buildroot} LIBDIR=%{_libdir} @@ -1438,6 +1444,6 @@ fi %changelog -* Tue Nov 26 2013 Petr Viktorin - __VERSION__-__RELEASE__ +* Tue Nov 26 2013 Petr Viktorin - @VERSION@-@VENDOR_SUFFIX@ - Remove changelog. The history is kept in Git, downstreams have own logs. # note, this entry is here to placate tools that expect a non-empty changelog diff --git a/install/ui/src/libs/loader.js.in b/install/ui/src/libs/loader.js.in index 6a50f327d..5159b439d 100644 --- a/install/ui/src/libs/loader.js.in +++ b/install/ui/src/libs/loader.js.in @@ -20,8 +20,8 @@ (function() { var loader = window.ipa_loader = { - num_version: '__NUM_VERSION__', - api_version: '__API_VERSION__' + num_version: '@NUM_VERSION@', + api_version: '@API_VERSION@' }; var head = document.getElementsByTagName('head')[0]; @@ -102,4 +102,4 @@ link(icons[i] + suffix, 'icon'); } }; -})(); \ No newline at end of file +})(); diff --git a/ipapython/version.py.in b/ipapython/version.py.in index fab260254..9dc9714f9 100644 --- a/ipapython/version.py.in +++ b/ipapython/version.py.in @@ -18,10 +18,10 @@ # # The full version including strings -VERSION="__VERSION__" +VERSION="@VERSION@" # A fuller version including the vendor tag (e.g. 3.3.3-34.fc20) -VENDOR_VERSION="__VENDOR_VERSION__" +VENDOR_VERSION="@VERSION@@VENDOR_SUFFIX@" # Just the numeric portion of the version so one can do direct numeric @@ -41,11 +41,11 @@ VENDOR_VERSION="__VENDOR_VERSION__" # IPA 3.2.1: NUM_VERSION=30201 # IPA 3.2.99: NUM_VERSION=30299 (development version) # IPA 3.3.0: NUM_VERSION=30300 -NUM_VERSION=__NUM_VERSION__ +NUM_VERSION=@NUM_VERSION@ # The version of the API. -API_VERSION=u'__API_VERSION__' +API_VERSION=u'@API_VERSION@' DEFAULT_PLUGINS = frozenset(l.strip() for l in """ diff --git a/ipasetup.py.in b/ipasetup.py.in index f291d2213..2835527b3 100644 --- a/ipasetup.py.in +++ b/ipasetup.py.in @@ -19,7 +19,7 @@ import os import sys common_args = dict( - version="__VERSION__", + version="@VERSION@", license="GPL", author="FreeIPA Developers", author_email="freeipa-devel@redhat.com", diff --git a/version.m4.in b/version.m4.in deleted file mode 100644 index 5ddc8cea3..000000000 --- a/version.m4.in +++ /dev/null @@ -1 +0,0 @@ -define([IPA_VERSION], [__VERSION__])