From 178f46aa014fcc53d3760c7665e350e8ce3cea49 Mon Sep 17 00:00:00 2001 From: Thomas Orozco Date: Sun, 15 Mar 2015 18:43:15 +0100 Subject: [PATCH] Convert to out-of-tree builds --- .travis.yml | 2 +- CMakeLists.txt | 2 +- Dockerfile | 9 +-------- ci/run_build.sh | 31 ++++++++++++++++++++----------- ddist.sh | 9 ++++----- test/test.py | 5 +++-- 6 files changed, 30 insertions(+), 28 deletions(-) diff --git a/.travis.yml b/.travis.yml index 73ede53..65fdd44 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ deploy: api_key: secure: Yk90ANpSPv1iJy8QDXCPwfaSmEr/WIJ3bzhQ6X8JvZjfrwTosbh0HrUzQyeac3nyvNwj7YJRssolOFc21IBKPpCFTZqYxSkuLPU6ysG4HGHgN6YJhOMm4mG4KKJ6741q3DJendhZpalBhCEi+NcZK/PCSD97Vl4OqRjBUged0fs= file: - - "./tini" + - "./dist/tini" on: repo: krallin/tini tags: true diff --git a/CMakeLists.txt b/CMakeLists.txt index e398adc..15da4bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ project (tini) set (tini_VERSION_MAJOR 0) set (tini_VERSION_MINOR 3) set (tini_VERSION_PATCH 2) -execute_process (COMMAND git log -n 1 --date=local --pretty=format:"%h" OUTPUT_VARIABLE tini_VERSION_GIT) +execute_process (COMMAND git log -n 1 --date=local --pretty=format:"%h" WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" OUTPUT_VARIABLE tini_VERSION_GIT) # Flags add_definitions (-D_FORTIFY_SOURCE=2) diff --git a/Dockerfile b/Dockerfile index 438fba9..6eabe90 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,5 @@ FROM ubuntu RUN apt-get update \ - && apt-get install --no-install-recommends --yes build-essential git gdb valgrind cmake clang \ + && apt-get install --no-install-recommends --yes build-essential git gdb valgrind cmake rpm \ && rm -rf /var/lib/apt/lists/* - -ADD . /tini -WORKDIR /tini - -RUN ./ci/run_build.sh - -ENTRYPOINT ["/tini/tini"] diff --git a/ci/run_build.sh b/ci/run_build.sh index 9a3e158..cd7d9fc 100755 --- a/ci/run_build.sh +++ b/ci/run_build.sh @@ -1,22 +1,31 @@ #!/bin/bash -# Should be run from the root dir (!) +# Should be run from the root dir, or SOURCE_DIR should be set. set -o errexit set -o nounset +: ${SOURCE_DIR:="."} +: ${DIST_DIR:="${SOURCE_DIR}/dist"} +: ${BUILD_DIR:="/tmp/build"} + # Build -cmake . +cmake -B"${BUILD_DIR}" -H"${SOURCE_DIR}" + +pushd "${BUILD_DIR}" make clean make +popd + # Smoke tests (actual tests need Docker to run; they don't run within the CI environment) +tini="${BUILD_DIR}/tini" +echo "Testing $tini with: true" +$tini -vvvv true -# Success -for tini in ./tini; do - echo "Testing $tini with: true" - $tini -vvvv true +echo "Testing $tini with: false" +if $tini -vvvv false; then + exit 1 +fi - echo "Testing $tini with: false" - if $tini -vvvv false; then - exit 1 - fi -done +# Place files +mkdir -p "${DIST_DIR}" +cp "${BUILD_DIR}"/tini "${DIST_DIR}" diff --git a/ddist.sh b/ddist.sh index 747b30c..69a1fd9 100755 --- a/ddist.sh +++ b/ddist.sh @@ -6,11 +6,10 @@ REL_HERE=$(dirname "${BASH_SOURCE}") HERE=$(cd "${REL_HERE}"; pwd) IMG="tini" -NAME="${IMG}-dist" +SRC="/tini" +# Create the build image docker build -t "${IMG}" . -# Copy the generated README -docker run -it --entrypoint="/bin/true" --name="${NAME}" "${IMG}" -docker cp "${NAME}:/tini/README.md" "${HERE}" -docker rm "${NAME}" +# Run the build +docker run --rm --volume="${HERE}:${SRC}" -e BUILD_DIR=/tmp/tini-build -e SOURCE_DIR="${SRC}" "${IMG}" "${SRC}/ci/run_build.sh" diff --git a/test/test.py b/test/test.py index 6e04bfb..15ba04b 100644 --- a/test/test.py +++ b/test/test.py @@ -61,11 +61,12 @@ if __name__ == "__main__": root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) - for entrypoint in ["/tini/tini"]: + for entrypoint in ["/tini/dist/tini"]: base_cmd = [ "docker", "run", "--rm", + "--volume={0}:/tini".format(root), "--name={0}".format(name), "--entrypoint={0}".format(entrypoint), img, @@ -92,4 +93,4 @@ if __name__ == "__main__": Command(base_cmd + ["-h"], fail_cmd).run(retcode=0) # Valgrind test - Command(base_cmd + ["--", "valgrind", "--leak-check=full", "--error-exitcode=1", "/tini/tini", "-v", "--", "ls"], fail_cmd).run() + Command(base_cmd + ["--", "valgrind", "--leak-check=full", "--error-exitcode=1", entrypoint, "-v", "--", "ls"], fail_cmd).run()