Ver Fonte

* Use git-describe to determine the version number.

If based on a release, the tag will be used auto.
Otherwise, the last tagged release and the number of commits
since then will be used.
Bryan Drewery há 17 anos atrás
pai
commit
52144d7319
7 ficheiros alterados com 19 adições e 19 exclusões
  1. 5 3
      Makefile.in
  2. 1 1
      src/Makefile.in
  3. 6 6
      src/botnet.c
  4. 1 1
      src/cmds.c
  5. 1 1
      src/dcc.c
  6. 4 6
      src/main.c
  7. 1 1
      src/main.h

+ 5 - 3
Makefile.in

@@ -22,8 +22,9 @@ EXCLUDES = pack/pack.cfg $(CONFIGFILES) $(STATICMAKEFILES)
 
 COMMIT_FULL 	:= $(shell git log -1 --pretty=format:%H HEAD)
 COMMIT_SHORT 	:= $(shell git log -1 --pretty=format:%h HEAD)
-BRANCH 		:= $(shell git branch --no-color | grep "^*" | sed -e 's/^\* //')
+BRANCH		:= := $(shell git branch --no-color | grep "^*" | sed -e 's/^\* //')
 BUILDTS 	:= $(shell git log -1 --pretty=format:%ct HEAD)
+VERSION		:= $(shell git describe)
 
 HELPFILE = doc/help.txt
 SETTINGSFILE = doc/settings.txt
@@ -57,12 +58,12 @@ _CFLGS = -fno-strict-aliasing -W -Wformat \
 MAKEFLAGS = -s -j4
 
 MAKE_BIN = $(MAKE) 'MAKE=$(MAKE)' 'CXX=$(CXX)' 'LD=$(LD)' \
-'CCDEPMODE=$(CCDEPMODE)' 'BRANCH=$(BRANCH)' 'COMMIT=$(COMMIT_SHORT)' 'BUILDTS=$(BUILDTS)' \
+'CCDEPMODE=$(CCDEPMODE)' 'BRANCH=$(BRANCH)' 'COMMIT=$(COMMIT_SHORT)' 'BUILDTS=$(BUILDTS)' 'VERSION=$(VERSION)' \
 'STRIP=$(STRIP)' 'CFLGS=$(CFLGS)' \
 'LIBS=$(LIBS)' 'EGGEXEC=$(BINEXEC)' 'EGGBUILD=(wraith)'
 
 MAKE_DEBUG = $(MAKE) 'MAKE=$(MAKE)' 'CXX=$(CCDEBUG)' 'LD=$(LDDEBUG) -g' \
-'CCDEPMODE=$(CCDEPMODE)' 'BRANCH=$(BRANCH)' 'COMMIT=$(COMMIT_SHORT)' 'BUILDTS=$(BUILDTS)' \
+'CCDEPMODE=$(CCDEPMODE)' 'BRANCH=$(BRANCH)' 'COMMIT=$(COMMIT_SHORT)' 'BUILDTS=$(BUILDTS)' 'VERSION=$(VERSION)' \
 'STRIP=touch' 'CFLGS=$(CFLGS) $(DEBCXXFLAGS)' \
 'LIBS=$(LIBS)' 'EGGEXEC=$(BINEXEC)' 'EGGBUILD=(debug)' 
 
@@ -112,6 +113,7 @@ distrib: clean
 	  -e 's/^COMMIT_SHORT .*/COMMIT_SHORT = $(COMMIT_SHORT)/' \
 	  -e 's/^BRANCH .*/BRANCH = $(BRANCH)/' \
 	  -e 's/^BUILDTS .*/BUILDTS = $(BUILDTS)/' \
+	  -e 's/^VERSION .*/VERSION = $(VERSION)/' \
 	  $(DISTRIB)/Makefile.in > Makefile.in.tmp && mv Makefile.in.tmp $(DISTRIB)/Makefile.in
 #	@for s in `find $(DISTRIB)/src/ -name '*.h' -or -name '*.c'`; do mangle -rnw $$s > /dev/null 2>&1; done
 

+ 1 - 1
src/Makefile.in

@@ -8,7 +8,7 @@ depcomp = /bin/sh $(top_srcdir)/autotools/depcomp
 
 @SET_MAKE@
 
-CXXFLAGS = @CXXFLAGS@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_srcdir)/pack @DEFS@ $(CFLGS) '-DCOMMIT="$(COMMIT)"' '-DBRANCH="$(BRANCH)"' -DBUILDTS=$(BUILDTS)
+CXXFLAGS = @CXXFLAGS@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_srcdir)/pack @DEFS@ $(CFLGS) '-DCOMMIT="$(COMMIT)"' '-DBRANCH="$(BRANCH)"' -DBUILDTS=$(BUILDTS) '-DVERSION="$(VERSION)"'
 CPPFLAGS = @CPPFLAGS@
 
 OBJCOPY = @OBJCOPY@

+ 6 - 6
src/botnet.c

@@ -638,10 +638,10 @@ void tell_bottree(int idx)
 
   if (s[0])
     dprintf(idx, "(%s %s)\n", "No trace info for:", s);
-  dprintf(idx, "%s%s%s (%s %s)\n", color_str ? color_str : "",
+  dprintf(idx, "%s%s%s (%s)\n", color_str ? color_str : "",
                                     conf.bot->nick,
                                     color_str ? COLOR_END(idx) : "",
-                                    egg_version, commit);
+                                    egg_version);
 
   thisbot = (tand_t *) 1;
   work[0] = 0;
@@ -685,10 +685,10 @@ void tell_bottree(int idx)
             i = simple_snprintf(s, sizeof(s), "%c", bot->share);
           else
             i = simple_snprintf(s, sizeof(s), "-");
-          i = simple_snprintf(s + 1, sizeof(s) - 1, "%s%s%s (%s %s)", color_str ? color_str : "",
+          i = simple_snprintf(s + 1, sizeof(s) - 1, "%s%s%s (%s)", color_str ? color_str : "",
                                                 bot->bot,
                                                 color_str ? COLOR_END(idx) : "",
-                                                bot->version, bot->commit);
+                                                bot->version);
 	} else
 	  bot = bot->next;
       }
@@ -731,10 +731,10 @@ void tell_bottree(int idx)
                   i = simple_snprintf(s, sizeof(s), "%c", bot->share);
                 else
                   i = simple_snprintf(s, sizeof(s), "-");
-                i = simple_snprintf(s + 1, sizeof(s) - 1, "%s%s%s (%s %s)", color_str ? color_str : "",
+                i = simple_snprintf(s + 1, sizeof(s) - 1, "%s%s%s (%s)", color_str ? color_str : "",
                                                       bot->bot,
                                                       color_str ? COLOR_END(idx) : "",
-                                                      bot->version, bot->commit);
+                                                      bot->version);
 	      }
 	    }
 	  }

+ 1 - 1
src/cmds.c

@@ -386,7 +386,7 @@ static void cmd_about(int idx, char *par)
   dprintf(idx, STR("Wraith botpack by bryan\n"));
   dprintf(idx, STR("http://wraith.botpack.net\n"));
   egg_strftime(c, sizeof c, "%c %Z", gmtime(&buildts));
-  dprintf(idx, "Version: %s\n", git_version);
+  dprintf(idx, "Version: %s\n", egg_version);
   dprintf(idx, "Build: %s (%li)\n", c, (long)buildts);
   dprintf(idx, "Commit: %s\n", commit);
   dprintf(idx, STR("(written from a base of Eggdrop 1.6.12)\n"));

+ 1 - 1
src/dcc.c

@@ -224,7 +224,7 @@ greet_new_bot(int idx)
     dcc[idx].status |= STAT_LEAF;
   dcc[idx].status |= STAT_LINKING;
 
-  dprintf(idx, "v 1001500 %d Wraith %s <%s> %d %li %s %s\n", HANDLEN, egg_version, "-", conf.bot->localhub, (long)buildts, commit, git_version);
+  dprintf(idx, "v 1001500 %d Wraith %s <%s> %d %li %s %s\n", HANDLEN, egg_version, "-", conf.bot->localhub, (long)buildts, commit, egg_version);
 
   for (int i = 0; i < dcc_total; i++) {
     if (dcc[i].type && dcc[i].type == &DCC_FORK_BOT) {

+ 4 - 6
src/main.c

@@ -91,7 +91,7 @@ extern int		optind;
 const time_t 	buildts = BUILDTS;		/* build timestamp (UTC) */
 const char	*commit = COMMIT;
 const char	*branch = BRANCH;
-const char	*egg_version = "1.2.16";
+const char	*egg_version = VERSION;
 char	git_version[50] = "";
 
 bool	used_B = 0;		/* did we get started with -B? */
@@ -114,7 +114,7 @@ bool	restart_was_update = 0;
 bool    restarting = 0;
 
 char	owner[121] = "";	/* Permanent owner(s) of the bot */
-char	version[81] = "";	/* Version info (long form) */
+char	version[121] = "";	/* Version info (long form) */
 char	ver[41] = "";		/* Version info (short form) */
 bool	use_stderr = 1;		/* Send stuff to stderr instead of logfiles? */
 char	quit_msg[1024];		/* quit message */
@@ -427,7 +427,6 @@ static void dtx_arg(int& argc, char *argv[])
 
         egg_strftime(date, sizeof date, "%c %Z", gmtime(&buildts));
 	printf(STR("%s\nBuild Date: %s (%s%lu%s)\n"), version, date, BOLD(-1), buildts, BOLD_END(-1));
-        printf(STR("Commit: %s\n"), commit);
         printf(STR("BuildOS: %s%s%s BuildArch: %s%s%s\n"), BOLD(-1), BUILD_OS, BOLD_END(-1), BOLD(-1), BUILD_ARCH, BOLD_END(-1));
 	printf(STR("pack: %d conf: %d settings_t: %d prefix: %d pad: %d\n"), SIZE_PACK, SIZE_CONF, sizeof(settings_t), PREFIXLEN, SIZE_PAD);
         if (settings.uname[0]) {
@@ -790,9 +789,8 @@ printf("out: %s\n", out);
   init_conf();			/* establishes conf and sets to defaults */
 
   /* Version info! */
-  simple_snprintf(git_version, sizeof(git_version), "%s-%s", egg_version, branch);
-  simple_snprintf(ver, sizeof(ver), STR("[%s] Wraith %s"), settings.packname, git_version);
-  simple_snprintf(version, sizeof(version), STR("%s (%lu:%s)"), ver, buildts, commit);
+  simple_snprintf(ver, sizeof(ver), STR("[%s] Wraith %s"), settings.packname, egg_version);
+  simple_snprintf(version, sizeof(version), STR("%s (%lu)"), ver, buildts);
 
   egg_memcpy(&nowtm, gmtime(&now), sizeof(struct tm));
   lastmin = nowtm.tm_min;

+ 1 - 1
src/main.h

@@ -16,7 +16,7 @@ enum {
 extern int		role, default_flags, default_uflags, do_confedit,
 			updating, do_restart;
 extern bool		use_stderr, backgrd, used_B, term_z, loading, restart_was_update, restarting;
-extern char		tempdir[], *binname, owner[], version[], ver[], quit_msg[], *socksfile, git_version[50];
+extern char		tempdir[], *binname, owner[], version[121], ver[], quit_msg[], *socksfile;
 extern time_t		online_since, now, restart_time;
 extern uid_t		myuid;
 extern pid_t            mypid;