diff --git a/Dockerfile b/Dockerfile index 9382161..27f12cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,8 @@ FROM ubuntu RUN apt-get update && apt-get install --no-install-recommends -y build-essential gdb && rm -rf /var/lib/apt/lists/* +RUN apt-get update +RUN apt-get install --no-install-recommends -y git ADD . /tini RUN cd /tini && make clean && make diff --git a/config.mk b/config.mk index ab95178..0335277 100644 --- a/config.mk +++ b/config.mk @@ -1,10 +1,11 @@ -VERSION = 0.1.0 +VERSION=0.2.0 +GIT_REV=$(shell git log -n 1 --date=local --pretty=format:"%h") # paths PREFIX=/usr/local CC = cc LD = $(CC) -CPPFLAGS=-D_FORTIFY_SOURCE=2 +CPPFLAGS=-D_FORTIFY_SOURCE=2 -DTINI_VERSION="\"$(VERSION) - $(GIT_REV)\"" CFLAGS=-std=gnu99 -Wextra -Wall -pedantic -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-s diff --git a/ddist.sh b/ddist.sh index f5704ed..9ab01f3 100755 --- a/ddist.sh +++ b/ddist.sh @@ -13,6 +13,6 @@ NAME="${IMG}-dist" BIN="tini" docker build -t "${IMG}" . -docker run -it --name="${NAME}" --entrypoint="true" "${IMG}" true +docker run -it --name="${NAME}" "${IMG}" true "-h" docker cp "${NAME}:/tini/${BIN}" "${DIST_DIR}" docker rm "${NAME}" diff --git a/tini.c b/tini.c index 3a408a9..ccd6626 100644 --- a/tini.c +++ b/tini.c @@ -1,4 +1,6 @@ /* See LICENSE file for copyright and license details. */ +#define _GNU_SOURCE + #include #include @@ -11,6 +13,9 @@ #include #include +#ifndef TINI_VERSION +#define TINI_VERSION "???" +#endif #define PRINT_FATAL(...) fprintf(stderr, "[FATAL] "); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); #define PRINT_WARNING(...) if (verbosity > 0) { fprintf(stderr, "[WARN ] "); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); } @@ -51,7 +56,12 @@ int spawn(const sigset_t* const child_sigset_ptr, char (*argv[]), int* const chi void print_usage(char* const name, FILE* const file) { - fprintf(file, "Usage: %s [-h | program arg1 arg2]\n", name); + fprintf(file, "%s (version %s)\n", basename(name), TINI_VERSION); + 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"); + fprintf(file, " -v: Generate more verbose output. Repeat up to 4 times.\n"); + fprintf(file, "\n"); }