mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-18 20:57:56 +00:00
Servald version string from git describe
This commit is contained in:
parent
1d1f7a37a4
commit
b17f5a6f63
@ -82,7 +82,7 @@ $(MDPCLIENTOBJS): $(HDRS)
|
||||
|
||||
servald: $(OBJS)
|
||||
@echo LINK $@
|
||||
@$(CC) $(CFLAGS) -Wall -o $@ $(OBJS) $(LDFLAGS)
|
||||
@v=`./version_string.sh` && $(CC) $(CFLAGS) -Wall -o $@ -DSERVALD_VERSION="\"$$v\"" version_servald.c $(OBJS) $(LDFLAGS)
|
||||
|
||||
directory_service: $(MDPCLIENTOBJS) directory_service.o
|
||||
@echo LINK $@
|
||||
|
@ -49,7 +49,7 @@ extern struct cli_schema command_line_options[];
|
||||
|
||||
int commandline_usage(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
printf("Serval Mesh version <version>.\n");
|
||||
printf("Serval DNA version %s\n", version_servald);
|
||||
return cli_usage(command_line_options);
|
||||
}
|
||||
|
||||
|
3
serval.h
3
serval.h
@ -141,6 +141,9 @@ struct in_addr {
|
||||
/* Limit packet payloads to minimise packet loss of big packets in mesh networks */
|
||||
#define MAX_DATA_BYTES 256
|
||||
|
||||
|
||||
extern const char version_servald[];
|
||||
|
||||
/*
|
||||
* INSTANCE_PATH can be set via the ./configure option --enable-instance-path=<path>
|
||||
*/
|
||||
|
5
version_servald.c
Normal file
5
version_servald.c
Normal file
@ -0,0 +1,5 @@
|
||||
#ifndef SERVALD_VERSION
|
||||
#error "SERVALD_VERSION is not defined"
|
||||
#endif
|
||||
|
||||
const char version_servald[] = SERVALD_VERSION;
|
63
version_string.sh
Executable file
63
version_string.sh
Executable file
@ -0,0 +1,63 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Serval Project Serval DNA version string generator
|
||||
# Copyright 2013 Serval Project, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
set -e
|
||||
|
||||
get_author_label() {
|
||||
# See git-commit-tree(1) for the semantics of working out the author's email
|
||||
# address when committing.
|
||||
local email
|
||||
email="${GIT_AUTHOR_EMAIL:-${GIT_COMMITTER_EMAIL:-${EMAIL:-$(git config --get user.email)}}}"
|
||||
# Serval Project email addresses get special treatment, to reduce day-to-day
|
||||
# version string verbosity.
|
||||
case "$email" in
|
||||
*@servalproject.org) author_label="${email%@*}";;
|
||||
*) author_label="$email";;
|
||||
esac
|
||||
}
|
||||
|
||||
dirty=
|
||||
dirtyfiles=$(git status --short --untracked-files=no)
|
||||
if [ -n "$dirtyfiles" ]; then
|
||||
get_author_label
|
||||
dirty="+$author_label-$(date '+%Y%m%d%H%M%S')"
|
||||
fi
|
||||
|
||||
if ! git describe "${dirty:+--dirty=$dirty}" 2>/dev/null; then
|
||||
original_commit=$(git rev-list --reverse --max-parents=0 --abbrev-commit HEAD 2>/dev/null | head -n 1)
|
||||
if [ -n "$original_commit" ]; then
|
||||
original_commit=$(git rev-list --reverse --abbrev-commit HEAD | head -n 1)
|
||||
fi
|
||||
if [ -z "$original_commit" ]; then
|
||||
echo "$0: original commit unknown" >&2
|
||||
exit 1
|
||||
fi
|
||||
existing_start_tag="$(git tag --points-at $original_commit --list START)"
|
||||
if [ -n "$(git tag --list START)" -a -z "$existing_start_tag" ]; then
|
||||
echo "$0: tag 'START' is already in use" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$existing_start_tag" ]; then
|
||||
git tag START $original_commit
|
||||
fi
|
||||
git describe --dirty="$dirty" --tags
|
||||
if [ -z "$existing_start_tag" ]; then
|
||||
git tag -d START >/dev/null
|
||||
fi
|
||||
fi
|
Loading…
Reference in New Issue
Block a user