From 405eea79416d852d330cbf1d1748dda36dd5c10a Mon Sep 17 00:00:00 2001 From: Thomas Orozco Date: Fri, 16 Oct 2015 15:23:10 -0700 Subject: [PATCH 1/2] More robust git version checking - Check the exit code from git log to check if we have a version. - Add a "-dirty" suffix if the repo is dirty when the build is made. --- CMakeLists.txt | 24 +++++++++++++++++++++++- src/tini.c | 2 +- src/tiniConfig.h.in | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 47fcc7d..9ec0ea1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,29 @@ project (tini C) set (tini_VERSION_MAJOR 0) set (tini_VERSION_MINOR 6) set (tini_VERSION_PATCH 0) -execute_process (COMMAND git log -n 1 --date=local --pretty=format:"%h" WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" OUTPUT_VARIABLE tini_VERSION_GIT) + +# Extract git version and dirty-ness +execute_process ( + COMMAND git log -n 1 --date=local --pretty=format:%h + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" + RESULT_VARIABLE git_version_check_ret + OUTPUT_VARIABLE tini_VERSION_GIT +) + +execute_process( + COMMAND git status --porcelain --untracked-files=no + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" + OUTPUT_VARIABLE git_dirty_check_out +) + +if("${git_version_check_ret}" EQUAL 0) + set(tini_VERSION_GIT " - git.${tini_VERSION_GIT}") + if(NOT "${git_dirty_check_out}" STREQUAL "") + set(tini_VERSION_GIT "${tini_VERSION_GIT}-dirty") + endif() +else() + set(tini_VERSION_GIT "") +endif() # Flags add_definitions (-D_FORTIFY_SOURCE=2) diff --git a/src/tini.c b/src/tini.c index db50711..c307fe3 100644 --- a/src/tini.c +++ b/src/tini.c @@ -81,7 +81,7 @@ int spawn(const sigset_t* const child_sigset_ptr, char* const argv[], int* const void print_usage(char* const name, FILE* const file) { - fprintf(file, "%s (version %s - %s)\n", basename(name), TINI_VERSION, TINI_GIT); + fprintf(file, "%s (version %s%s)\n", basename(name), TINI_VERSION, TINI_GIT); fprintf(file, "Usage: %s [OPTIONS] PROGRAM -- [ARGS]\n\n", basename(name)); fprintf(file, "Execute a program under the supervision of a valid init process (%s)\n\n", basename(name)); fprintf(file, " -h: Show this help message and exit.\n"); diff --git a/src/tiniConfig.h.in b/src/tiniConfig.h.in index 95a5481..516bb68 100644 --- a/src/tiniConfig.h.in +++ b/src/tiniConfig.h.in @@ -1,2 +1,2 @@ #define TINI_VERSION "@tini_VERSION_MAJOR@.@tini_VERSION_MINOR@.@tini_VERSION_PATCH@" -#define TINI_GIT @tini_VERSION_GIT@ +#define TINI_GIT "@tini_VERSION_GIT@" From 7a6105e44db18ffd91595560e04c6b8e86c3659c Mon Sep 17 00:00:00 2001 From: Thomas Orozco Date: Fri, 16 Oct 2015 15:24:22 -0700 Subject: [PATCH 2/2] Add a default for FORCE_SUBREAPER in ddist.sh Usually, we want to have FORCE_SUBREAPER=1. --- ddist.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ddist.sh b/ddist.sh index c744779..eed21f8 100755 --- a/ddist.sh +++ b/ddist.sh @@ -2,6 +2,8 @@ set -o errexit set -o nounset +: ${FORCE_SUBREAPER:="1"} + REL_HERE=$(dirname "${BASH_SOURCE}") HERE=$(cd "${REL_HERE}"; pwd)