Alter where the version number comes from.

Now if we are a git repo we fetch the branch name and
commitid to build the version string. If there is no
git repo we'll look at the RELEASE file.
This commit is contained in:
Joris Vink 2018-06-19 19:05:55 +02:00
parent d5ca2b42c6
commit 8aaf7aaf79
6 changed files with 27 additions and 14 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@ obj
.lvimrc .lvimrc
kodev/kodev kodev/kodev
kore.features kore.features
src/version.c

View File

@ -1,6 +1,6 @@
# Kore Makefile # Kore Makefile
CC?=gcc CC?=cc
PREFIX?=/usr/local PREFIX?=/usr/local
OBJDIR?=obj OBJDIR?=obj
KORE=kore KORE=kore
@ -10,10 +10,12 @@ MAN_DIR=$(PREFIX)/share/man
SHARE_DIR=$(PREFIX)/share/kore SHARE_DIR=$(PREFIX)/share/kore
INCLUDE_DIR=$(PREFIX)/include/kore INCLUDE_DIR=$(PREFIX)/include/kore
VERSION=src/version.c
S_SRC= src/kore.c src/buf.c src/config.c src/connection.c \ S_SRC= src/kore.c src/buf.c src/config.c src/connection.c \
src/domain.c src/mem.c src/msg.c src/module.c src/net.c \ src/domain.c src/mem.c src/msg.c src/module.c src/net.c \
src/pool.c src/runtime.c src/timer.c src/utils.c src/worker.c \ src/pool.c src/runtime.c src/timer.c src/utils.c src/worker.c \
src/keymgr.c src/keymgr.c $(VERSION)
FEATURES= FEATURES=
FEATURES_INC= FEATURES_INC=
@ -114,7 +116,22 @@ endif
S_OBJS= $(S_SRC:src/%.c=$(OBJDIR)/%.o) S_OBJS= $(S_SRC:src/%.c=$(OBJDIR)/%.o)
all: $(KORE) $(KODEV) all: $(VERSION) $(KORE) $(KODEV)
$(VERSION): force
@if [ -d .git ]; then \
GIT_REVISION=`git rev-parse --short=8 HEAD`; \
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`; \
rm -f $(VERSION); \
printf "const char *kore_version = \"%s-%s\";\n" \
$$GIT_BRANCH $$GIT_REVISION > $(VERSION); \
elif [ -f RELEASE ]; then \
printf "const char *kore_version = \"%s\";\n" \
`cat RELEASE` > $(VERSION); \
else \
echo "No version information found (no .git or RELEASE)"; \
exit 1; \
fi
$(KODEV): $(KODEV):
$(MAKE) -C kodev $(MAKE) -C kodev
@ -151,8 +168,9 @@ $(OBJDIR)/%.o: src/%.c
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
clean: clean:
rm -f $(VERSION); \
find . -type f -name \*.o -exec rm {} \; find . -type f -name \*.o -exec rm {} \;
rm -rf $(KORE) $(OBJDIR) kore.features rm -rf $(KORE) $(OBJDIR) kore.features
$(MAKE) -C kodev clean $(MAKE) -C kodev clean
.PHONY: all clean .PHONY: all clean force

View File

@ -57,11 +57,6 @@ extern int daemon(int, int);
#define KORE_RESULT_OK 1 #define KORE_RESULT_OK 1
#define KORE_RESULT_RETRY 2 #define KORE_RESULT_RETRY 2
#define KORE_VERSION_MAJOR 3
#define KORE_VERSION_MINOR 0
#define KORE_VERSION_PATCH 0
#define KORE_VERSION_STATE "devel"
#define KORE_TLS_VERSION_1_2 0 #define KORE_TLS_VERSION_1_2 0
#define KORE_TLS_VERSION_1_0 1 #define KORE_TLS_VERSION_1_0 1
#define KORE_TLS_VERSION_BOTH 2 #define KORE_TLS_VERSION_BOTH 2
@ -473,6 +468,7 @@ extern char *rand_file;
extern u_int8_t nlisteners; extern u_int8_t nlisteners;
extern u_int16_t cpu_count; extern u_int16_t cpu_count;
extern u_int8_t worker_count; extern u_int8_t worker_count;
extern const char *kore_version;
extern u_int8_t worker_set_affinity; extern u_int8_t worker_set_affinity;
extern u_int32_t worker_rlimit_nofiles; extern u_int32_t worker_rlimit_nofiles;
extern u_int32_t worker_max_connections; extern u_int32_t worker_max_connections;

View File

@ -1,6 +1,6 @@
# kodev Makefile # kodev Makefile
CC?=gcc CC?=cc
PREFIX?=/usr/local PREFIX?=/usr/local
OBJDIR?=obj OBJDIR?=obj
KODEV=kodev KODEV=kodev

View File

@ -95,8 +95,7 @@ http_init(void)
ckhdr_buf = kore_buf_alloc(HTTP_COOKIE_BUFSIZE); ckhdr_buf = kore_buf_alloc(HTTP_COOKIE_BUFSIZE);
l = snprintf(http_version, sizeof(http_version), l = snprintf(http_version, sizeof(http_version),
"server: kore (%d.%d.%d-%s)\r\n", KORE_VERSION_MAJOR, "server: kore (%s)\r\n", kore_version);
KORE_VERSION_MINOR, KORE_VERSION_PATCH, KORE_VERSION_STATE);
if (l == -1 || (size_t)l >= sizeof(http_version)) if (l == -1 || (size_t)l >= sizeof(http_version))
fatal("http_init(): http_version buffer too small"); fatal("http_init(): http_version buffer too small");

View File

@ -89,8 +89,7 @@ usage(void)
static void static void
version(void) version(void)
{ {
printf("%d.%d.%d-%s ", KORE_VERSION_MAJOR, KORE_VERSION_MINOR, printf("%s ", kore_version);
KORE_VERSION_PATCH, KORE_VERSION_STATE);
#if defined(KORE_NO_TLS) #if defined(KORE_NO_TLS)
printf("no-tls "); printf("no-tls ");
#endif #endif