[Home]

Summary:ASTERISK-12507: [patch] Generate a version when asterisk is built in a git repository
Reporter:Tzafrir Cohen (tzafrir)Labels:
Date Opened:2008-08-02 11:09:15Date Closed:2008-09-11 17:48:52
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/BuildSystem
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) git_version_h.diff
( 1) ver_999999.diff
Description:Currently asterisk knows to generate version.h from two potential sources:

1. a .version file in the source tree. This is used for tarballs or tarballs.
2. 'svn info' when building an a subversion repository and there's no .version file.

This patch adds handling to building in a git repository, similar to (2):

* Like in (2), the numeric version number is 999999.
* Unlike in (2), though, I could not think of a nice way to derive a text version string. Thus the version name is simply "GIT".

Without the Makefile part of this patch, building fails in a git repository (specifically: at res/res_snmp.c). Thus I do not consider it a feature.

The current patch is vs. 1.4. A similar patch should probably work vs. 1.6. I'll add one soon.
Comments:By: Tzafrir Cohen (tzafrir) 2008-08-02 14:32:02

hmm... is the the right fix?

in git, the .git subdirectory is only at the top-level directory of the repository. While I expect asterisk to be a single component, it may not be the case. Someone may decide to make Asterisk part of a larger project. And the the main asterisk directory will have no .git subdirectory.

Also, let's consider other version control systems. IIRC bzr and mercurial are similar to git in that respect (a single subdirectory, .bzr/.hg under the toplevel directory of the project. With svk there is no such subdirectory for the whole tree (it is all under your $HOME/.svk).

So maybe make those changes:

if no file .version: use version number 999999

By: Tilghman Lesher (tilghman) 2008-08-05 09:45:04

Going down this road puts us on a slippery slope towards supporting every single other source control system that just one person on the project uses.  I'm not comfortable with that decision.  If we're going to support git at all in Asterisk, then there needs to be much more than one person on the project using it.

By: Tzafrir Cohen (tzafrir) 2008-08-05 10:02:38

Right. That patch does use any information from the git repository.

As I mentioned in the later comment, the Makefile part should be simplified into "everything except a .version file", as there's nothing special there for the case of a subversion repository.

So we're left with the need to generate a version string. Maybe just change it to "if there's no .version and we're not in a subversion repository, just make label it "UNKNOWN"?

By: Tilghman Lesher (tilghman) 2008-08-05 10:12:44

or "unsupported"

By: Digium Subversion (svnbot) 2008-08-05 10:22:02

Repository: asterisk
Revision: 135648

U   trunk/build_tools/make_version

------------------------------------------------------------------------
r135648 | tilghman | 2008-08-05 10:22:01 -0500 (Tue, 05 Aug 2008) | 3 lines

Always output a version string, even when we can't figure out what we are.
(Closes issue ASTERISK-12507)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=135648

By: Tzafrir Cohen (tzafrir) 2008-08-05 10:37:24

Not so fast :-)

There's still the makefile change.

test: move .version and .svn aside, run 'make distclean' and rebuild.

By: Tzafrir Cohen (tzafrir) 2008-08-05 12:31:05

Reopening, see my previous comment.

By: Tilghman Lesher (tilghman) 2008-08-05 16:47:48

I just tried this, and it made ZERO difference to the build process.

By: Tzafrir Cohen (tzafrir) 2008-08-06 17:45:19

Just re-tested on 1.4 .

To save time, the following is done on a tree that is already fully-built.

tzafrir@sweetmorn:~/Proj/Asterisk/Svn/asterisk-1.4$ cat include/asterisk/version.h
/*
* version.h
* Automatically generated
*/
#define ASTERISK_VERSION "SVN-branch-1.4-r136168"
#define ASTERISK_VERSION_NUM 999999
tzafrir@sweetmorn:~/Proj/Asterisk/Svn/asterisk-1.4$ mv .svn _svn
tzafrir@sweetmorn:~/Proj/Asterisk/Svn/asterisk-1.4$ rm include/asterisk/version.h
tzafrir@sweetmorn:~/Proj/Asterisk/Svn/asterisk-1.4$ make include/asterisk/version.h
tzafrir@sweetmorn:~/Proj/Asterisk/Svn/asterisk-1.4$ cat include/asterisk/version.h
/*
* version.h
* Automatically generated
*/
#define ASTERISK_VERSION ""
#define ASTERISK_VERSION_NUM
tzafrir@sweetmorn:~/Proj/Asterisk/Svn/asterisk-1.4$ LANG=C make
menuselect/menuselect --check-deps menuselect.makeopts
Generating embedded module rules ...
make[1]: Entering directory `/home/tzafrir/Proj/Asterisk/Svn/asterisk-1.4/utils'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/tzafrir/Proj/Asterisk/Svn/asterisk-1.4/utils'
make[1]: Entering directory `/home/tzafrir/Proj/Asterisk/Svn/asterisk-1.4/agi'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/tzafrir/Proj/Asterisk/Svn/asterisk-1.4/agi'
make[1]: Entering directory `/home/tzafrir/Proj/Asterisk/Svn/asterisk-1.4/res'
  [CC] snmp/agent.c -> snmp/agent.o
snmp/agent.c: In function 'ast_var_Version':
snmp/agent.c:724: error: expected expression before ';' token
make[1]: *** [snmp/agent.o] Error 1
make[1]: Leaving directory `/home/tzafrir/Proj/Asterisk/Svn/asterisk-1.4/res'
make: *** [res] Error 2

# now applying the Makefile fix from ver_999999.diff to Makefile alone.

And:

tzafrir@sweetmorn:~/Proj/Asterisk/Svn/asterisk-1.4$ rm include/asterisk/version.h
tzafrir@sweetmorn:~/Proj/Asterisk/Svn/asterisk-1.4$ make include/asterisk/version.h
tzafrir@sweetmorn:~/Proj/Asterisk/Svn/asterisk-1.4$ cat include/asterisk/version.h
/*
* version.h
* Automatically generated
*/
#define ASTERISK_VERSION ""
#define ASTERISK_VERSION_NUM 999999

tzafrir@sweetmorn:~/Proj/Asterisk/Svn/asterisk-1.4$ LANG=C make
menuselect/menuselect --check-deps menuselect.makeopts
Generating embedded module rules ...
make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `all'.
  [CC] snmp/agent.c -> snmp/agent.o
  [LD] res_snmp.o snmp/agent.o -> res_snmp.so
make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `all'.
  [CC] asterisk.c -> asterisk.o
  [CC] http.c -> http.o
  [LD] abstract_jb.o acl.o aescrypt.o aeskey.o aestab.o alaw.o app.o ast_expr2.o ast_expr2f.o asterisk.o astmm.o astobj2.o audiohook.o autoservice.o callerid.o cdr.o channel.o chanvars.o cli.o config.o cryptostub.o db.o devicestate.o dial.o dns.o dnsmgr.o dsp.o enum.o file.o fixedjitterbuf.o frame.o fskmodem.o global_datastores.o http.o image.o indications.o io.o jitterbuf.o loader.o logger.o manager.o md5.o netsock.o pbx.o plc.o privacy.o rtp.o say.o sched.o sha1.o slinfactory.o srv.o stdtime/localtime.o strcompat.o tdd.o term.o threadstorage.o translate.o udptl.o ulaw.o utils.o editline/libedit.a db1-ast/libdb1.a -> asterisk
+--------- Asterisk Build Complete ---------+
+ Asterisk has successfully been built, and +
+ can be installed by running:              +
+                                           +
+               make install                +
+-------------------------------------------+

By: Tilghman Lesher (tilghman) 2008-08-06 19:54:02

Yes, but these changes aren't going into 1.4.  They are a candidate for trunk only, and trunk does not fail to build.  ASTERISK_VERSION_NUM appears nowhere in trunk for res/snmp/agent.c.

By: Tilghman Lesher (tilghman) 2008-09-11 17:48:51

No response from reporter.