From: Andreas Ă–man Date: Tue, 10 Apr 2012 18:14:48 +0000 (+0200) Subject: Fix the way we generate version tags inside the binary X-Git-Tag: 3.0~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f7689099a4bfc5b60c5045b25fa1f9f6620cf87;p=thirdparty%2Ftvheadend.git Fix the way we generate version tags inside the binary --- diff --git a/Makefile b/Makefile index 100c71f08..a5136ac00 100644 --- a/Makefile +++ b/Makefile @@ -151,14 +151,11 @@ BUNDLE_OBJS=$(BUNDLE_SRCS:%.c=%.o) OBJDIRS+= $(sort $(dir $(BUNDLE_OBJS))) .PRECIOUS: ${BUNDLE_SRCS} -VERSION=$(shell support/version.sh) -CURVERSION=$(shell cat ${BUILDDIR}/ver || echo "0") # Common CFLAGS for all files CFLAGS_com = -g -funsigned-char -O2 CFLAGS_com += -D_FILE_OFFSET_BITS=64 CFLAGS_com += -I${BUILDDIR} -I${CURDIR}/src -I${CURDIR} -CFLAGS_com += -DHTS_VERSION=\"$(VERSION)\" MKBUNDLE = $(CURDIR)/support/mkbundle @@ -188,18 +185,17 @@ ${BUILDDIR}/%.so: ${SRCS_EXTRA} ${CC} -O -fbuiltin -fomit-frame-pointer -fPIC -shared -o $@ $< -ldl clean: - rm -rf ${BUILDDIR}/src ${BUILDDIR}/bundles ${BUILDDIR}/ver + rm -rf ${BUILDDIR}/src ${BUILDDIR}/bundles find . -name "*~" | xargs rm -f distclean: clean rm -rf build.* -ifneq ($(VERSION), $(CURVERSION)) -.PHONY: src/version.c -$(info Version changed) -src/version.c: - @echo $(VERSION) >${BUILDDIR}/ver -endif +# Create buildversion.h +src/version.c: $(BUILDDIR)/buildversion.h +$(BUILDDIR)/buildversion.h: FORCE + @$(CURDIR)/support/version.sh $(CURDIR) $@ +FORCE: # Include dependency files if they exist. diff --git a/src/dvr/mkmux.c b/src/dvr/mkmux.c index 1303d69f9..8a73b517e 100644 --- a/src/dvr/mkmux.c +++ b/src/dvr/mkmux.c @@ -143,14 +143,13 @@ static htsbuf_queue_t * mk_build_segment_info(mk_mux_t *mkm) { htsbuf_queue_t *q = htsbuf_queue_alloc(0); - extern char *htsversion_full; char app[128]; - snprintf(app, sizeof(app), "HTS Tvheadend %s", htsversion_full); + snprintf(app, sizeof(app), "Tvheadend %s", tvheadend_version); ebml_append_bin(q, 0x73a4, mkm->uuid, sizeof(mkm->uuid)); ebml_append_string(q, 0x7ba9, mkm->title); - ebml_append_string(q, 0x4d80, "HTS Tvheadend Matroska muxer"); + ebml_append_string(q, 0x4d80, "Tvheadend Matroska muxer"); ebml_append_string(q, 0x5741, app); ebml_append_uint(q, 0x2ad7b1, MATROSKA_TIMESCALE); diff --git a/src/htsp.c b/src/htsp.c index 6c6fcbcbf..1a630fa7e 100644 --- a/src/htsp.c +++ b/src/htsp.c @@ -50,7 +50,6 @@ static void *htsp_server; #define HTSP_PRIV_MASK (ACCESS_STREAMING) -extern const char *htsversion; extern char *dvr_storage; LIST_HEAD(htsp_connection_list, htsp_connection); @@ -1032,7 +1031,7 @@ htsp_method_hello(htsp_connection_t *htsp, htsmsg_t *in) htsmsg_add_u32(r, "htspversion", HTSP_PROTO_VERSION); htsmsg_add_str(r, "servername", "HTS Tvheadend"); - htsmsg_add_str(r, "serverversion", htsversion); + htsmsg_add_str(r, "serverversion", tvheadend_version); htsmsg_add_bin(r, "challenge", htsp->htsp_challenge, 32); htsp_update_logname(htsp); diff --git a/src/main.c b/src/main.c index 370bb2ae3..9474ea8b9 100644 --- a/src/main.c +++ b/src/main.c @@ -60,8 +60,6 @@ #include "ffdecsa/FFdecsa.h" int running; -extern const char *htsversion; -extern const char *htsversion_full; time_t dispatch_clock; static LIST_HEAD(, gtimer) gtimers; pthread_mutex_t global_lock; @@ -150,7 +148,7 @@ gtimer_disarm(gtimer_t *gti) static void usage(const char *argv0) { - printf("HTS Tvheadend %s\n", htsversion_full); + printf("HTS Tvheadend %s\n", tvheadend_version); printf("usage: %s [options]\n", argv0); printf("\n"); printf(" -a Use only DVB adapters specified (csv)\n"); @@ -432,7 +430,7 @@ main(int argc, char **argv) tvhlog(LOG_NOTICE, "START", "HTS Tvheadend version %s started, " "running as PID:%d UID:%d GID:%d, settings located in '%s'", - htsversion_full, + tvheadend_version, getpid(), getuid(), getgid(), hts_settings_get_root()); if(crash) diff --git a/src/trap.c b/src/trap.c index 1e92497dd..bd7611861 100644 --- a/src/trap.c +++ b/src/trap.c @@ -220,9 +220,6 @@ callback(struct dl_phdr_info *info, size_t size, void *data) } -extern const char *htsversion_full; - - void trap_init(const char *ver) { @@ -259,7 +256,7 @@ trap_init(const char *ver) "PRG: %s (%s) " "[%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x] " - "CWD: %s ", ver, htsversion_full, + "CWD: %s ", ver, tvheadend_version, digest[0], digest[1], digest[2], diff --git a/src/tvheadend.h b/src/tvheadend.h index 85f8395f9..74b778341 100644 --- a/src/tvheadend.h +++ b/src/tvheadend.h @@ -15,7 +15,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - #ifndef TVHEADEND_H #define TVHEADEND_H @@ -34,6 +33,8 @@ #include "redblack.h" +extern const char *tvheadend_version; + #define PTS_UNSET INT64_C(0x8000000000000000) extern pthread_mutex_t global_lock; diff --git a/src/version.c b/src/version.c index 118eb0c40..9aebe049d 100644 --- a/src/version.c +++ b/src/version.c @@ -1,9 +1,4 @@ +#include "buildversion.h" #include "config.h" -#ifdef HTS_RELEASE_TAG -const char *htsversion=HTS_RELEASE_TAG; -const char *htsversion_full=HTS_RELEASE_TAG " (" HTS_VERSION ")"; -#else -const char *htsversion=HTS_VERSION; -const char *htsversion_full=HTS_VERSION; -#endif +const char *tvheadend_version = BUILD_VERSION; diff --git a/src/webui/extjs.c b/src/webui/extjs.c index 2505232f8..c1884d02f 100644 --- a/src/webui/extjs.c +++ b/src/webui/extjs.c @@ -43,9 +43,6 @@ #include "epg.h" #include "iptv_input.h" -extern const char *htsversion; -extern const char *htsversion_full; - static void extjs_load(htsbuf_queue_t *hq, const char *script) { @@ -166,7 +163,7 @@ extjs_root(http_connection_t *hc, const char *remain, void *opaque) "\n" "
\n" "\n", - htsversion); + tvheadend_version); http_output_html(hc); return 0; } @@ -185,7 +182,7 @@ page_about(http_connection_t *hc, const char *remain, void *opaque) "
" "HTS Tvheadend %s" "

" - "© 2006 - 2010 Andreas \303\226man, et al.

" + "© 2006 - 2012 Andreas \303\226man, et al.

" "
" "" "http://www.lonelycoder.com/hts

" @@ -197,8 +194,8 @@ page_about(http_connection_t *hc, const char *remain, void *opaque) "

" "Build: %s" "", - htsversion, - htsversion_full); + tvheadend_version, + tvheadend_version); http_output_html(hc); return 0; diff --git a/src/webui/statedump.c b/src/webui/statedump.c index 911a31ec3..4816c65bd 100644 --- a/src/webui/statedump.c +++ b/src/webui/statedump.c @@ -37,7 +37,6 @@ #endif extern char tvh_binshasum[20]; -extern char *htsversion_full; int page_statedump(http_connection_t *hc, const char *remain, void *opaque); @@ -162,7 +161,7 @@ page_statedump(http_connection_t *hc, const char *remain, void *opaque) htsbuf_qprintf(hq, "Tvheadend %s Binary SHA1: " "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", - htsversion_full, + tvheadend_version, tvh_binshasum[0], tvh_binshasum[1], tvh_binshasum[2], diff --git a/support/version.sh b/support/version.sh index 98035c683..cee649507 100755 --- a/support/version.sh +++ b/support/version.sh @@ -1,23 +1,11 @@ #!/bin/sh -# check for SVN revision number -revision=`cd "$1" && LC_ALL=C svn info 2> /dev/null | grep Revision | cut -d' ' -f2` -test $revision || revision=`cd "$1" && grep revision .svn/entries 2>/dev/null | cut -d '"' -f2` -test $revision || revision=`cd "$1" && sed -n -e '/^dir$/{n;p;q}' .svn/entries 2>/dev/null` -test $revision && revision=SVN-r$revision +revision=`$1/support/getver.sh` -# check for git short hash -if ! test $revision; then - revision=`cd "$1" && git log -1 --pretty=format:%h` - test $revision && revision=git-$revision -fi +NEW_REVISION="#define BUILD_VERSION \"$revision\"" +OLD_REVISION=`cat $2 2> /dev/null` -# check for debian changelog -if ! test $revision; then - revision=`cd "$1" && cat debian/changelog |head -1|cut -f2 -d' '|sed s/\(//|sed s/\)//` +# Update version.h only on revision changes to avoid spurious rebuilds +if test "$NEW_REVISION" != "$OLD_REVISION"; then + echo "$NEW_REVISION" > "$2" fi - -# no version number found -test $revision || revision=UNKNOWN - -echo $revision