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 <mbasti@redhat.com>
Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit is contained in:
Petr Spacek 2016-10-21 22:35:28 +02:00 committed by Martin Babinsky
parent 2725e440bf
commit c48e5fd811
9 changed files with 127 additions and 124 deletions

View File

@ -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

View File

@ -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 @@
# #
# <MAJOR>.<MINOR>.<RELEASE> #
# #
# 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 #
# #
# <MAJOR>.<MINOR>.<RELEASE>alpha<ALPHA_RELEASE> #
# <MAJOR>.<MINOR>.<RELEASE><PRE_RELEASE> #
# #
# e.g. IPA_VERSION_ALPHA_RELEASE=1 #
# -> "1.0.0alpha1" #
########################################################
IPA_VERSION_ALPHA_RELEASE=
########################################################
# For 'beta' releases the version will be #
# #
# <MAJOR>.<MINOR>.<RELEASE>beta<BETA_RELEASE> #
# #
# e.g. IPA_VERSION_BETA_RELEASE=1 #
# -> "1.0.0beta1" #
########################################################
IPA_VERSION_BETA_RELEASE=
########################################################
# For 'rc' releases the version will be #
# #
# <MAJOR>.<MINOR>.<RELEASE>rc<RC_RELEASE> #
# #
# 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 #
# #
# <MAJOR>.<MINOR>.<RELEASE>GITxxx #
# <MAJOR>.<MINOR>.<RELEASE>.<TIMESTAMP>.GIT<hash> #
# #
# 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'

View File

@ -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}
"

View File

@ -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@

View File

@ -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<pviktori@redhat.com> - __VERSION__-__RELEASE__
* Tue Nov 26 2013 Petr Viktorin <pviktori@redhat.com> - @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

View File

@ -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');
}
};
})();
})();

View File

@ -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 """

View File

@ -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",

View File

@ -1 +0,0 @@
define([IPA_VERSION], [__VERSION__])