Skip to content

Commit

Permalink
Add version in usage, improve usage
Browse files Browse the repository at this point in the history
  • Loading branch information
krallin committed Mar 1, 2015
1 parent c354968 commit c666a4f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions 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
Expand Down
5 changes: 3 additions & 2 deletions 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
2 changes: 1 addition & 1 deletion ddist.sh
Expand Up @@ -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}"
12 changes: 11 additions & 1 deletion tini.c
@@ -1,4 +1,6 @@
/* See LICENSE file for copyright and license details. */
#define _GNU_SOURCE

#include <sys/types.h>
#include <sys/wait.h>

Expand All @@ -11,6 +13,9 @@
#include <unistd.h>
#include <stdbool.h>

#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"); }
Expand Down Expand Up @@ -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");
}


Expand Down

0 comments on commit c666a4f

Please sign in to comment.