]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Fix the way we generate version tags inside the binary
authorAndreas Öman <andreas@lonelycoder.com>
Tue, 10 Apr 2012 18:14:48 +0000 (20:14 +0200)
committerAndreas Öman <andreas@lonelycoder.com>
Tue, 10 Apr 2012 18:14:48 +0000 (20:14 +0200)
Makefile
src/dvr/mkmux.c
src/htsp.c
src/main.c
src/trap.c
src/tvheadend.h
src/version.c
src/webui/extjs.c
src/webui/statedump.c
support/version.sh

index 100c71f08910f2f3d443c9ae010f58b3d1a1fa1c..a5136ac00e753038d4a11b48da068aabcfd2398c 100644 (file)
--- 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.
index 1303d69f9593997094be400166b3e813d97daea2..8a73b517eac50b0f6f2c8812c3353d814b12be24 100644 (file)
@@ -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);
 
index 6c6fcbcbf82cf6aea07c3dbdd57d0538b2c9b312..1a630fa7e9a39bff67dafb27aef7f14f16ee0124 100644 (file)
@@ -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);
index 370bb2ae3dea562d68d444a5ad3094a35afe2f90..9474ea8b9fbebdb7ba1ff8bc6845b5698e43668a 100644 (file)
@@ -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 <adapters>   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)
index 1e92497dd34f300a84cc33f094772445eca44b0e..bd76118612de69c6b080faf023855937cf2d2f14 100644 (file)
@@ -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],
index 85f8395f9959a259ffabba3d1f0534b25a70e41e..74b7783412fc5f9e1df9e72cbfe4fd9aeb8232a3 100644 (file)
@@ -15,7 +15,6 @@
  *  You should have received a copy of the GNU General Public License
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-
 #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;
index 118eb0c401b2f406ddc4443304e258ecd2ae3972..9aebe049d8996bbd433846dd6c9e27b15679889b 100644 (file)
@@ -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;
index 2505232f811792d074d9b8cb739081b2093ee29b..c1884d02f829e3f946de6f5c938bd1e685c49fe6 100644 (file)
@@ -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)
                 "<body>\n"
                 "<div id=\"systemlog\"></div>\n"
                 "</body></html>\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)
                 "<div class=\"about-title\">"
                 "HTS Tvheadend %s"
                 "</div><br>"
-                "&copy; 2006 - 2010 Andreas \303\226man, et al.<br><br>"
+                "&copy; 2006 - 2012 Andreas \303\226man, et al.<br><br>"
                 "<img src=\"docresources/tvheadendlogo.png\"><br>"
                 "<a href=\"http://www.lonelycoder.com/hts\">"
                 "http://www.lonelycoder.com/hts</a><br><br>"
@@ -197,8 +194,8 @@ page_about(http_connection_t *hc, const char *remain, void *opaque)
                 "<br><br>"
                 "Build: %s"
                 "</center>",
-                htsversion,
-                htsversion_full);
+                tvheadend_version,
+                tvheadend_version);
 
   http_output_html(hc);
   return 0;
index 911a31ec3e1b427f7babe89c04d433a830664913..4816c65bdcb92a57ce3527b0b8ad6ce4411dd9a6 100644 (file)
@@ -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],
index 98035c6832f76f3c7518a83495ca797196124335..cee649507d350bdf0f249faea0d7dc1e96ce8541 100755 (executable)
@@ -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