From 12749881e074bcea044b0d1cfb3db9ae3fbfa4fb Mon Sep 17 00:00:00 2001 From: Thomas Orozco Date: Mon, 4 May 2015 22:18:55 +0200 Subject: [PATCH] Workaround to ensure compatibility with older CMake Travis uses Ubuntu Precise, which has CMake 3.8. That version does not have support for excluding /usr and /usr/bin from the %files% list (which results in a package that conflicts with the filesystem package and fails to install). This commit: + Builds on Precise instead of Trusty + Adds install tests --- Dockerfile | 4 ++-- ci/run_build.sh | 5 +++++ ci/util/rpmbuild | 21 +++++++++++++++++++++ ddist.sh | 3 +++ test/test.py | 42 ++++++++++++++++++++++++++++-------------- 5 files changed, 59 insertions(+), 16 deletions(-) create mode 100755 ci/util/rpmbuild diff --git a/Dockerfile b/Dockerfile index 6eabe90..cf3eed1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -FROM ubuntu +FROM ubuntu:precise RUN apt-get update \ - && apt-get install --no-install-recommends --yes build-essential git gdb valgrind cmake rpm \ + && apt-get install --no-install-recommends --yes build-essential git gdb valgrind cmake rpm python3 \ && rm -rf /var/lib/apt/lists/* diff --git a/ci/run_build.sh b/ci/run_build.sh index e5012e2..84cfcc8 100755 --- a/ci/run_build.sh +++ b/ci/run_build.sh @@ -7,6 +7,11 @@ set -o nounset : ${DIST_DIR:="${SOURCE_DIR}/dist"} : ${BUILD_DIR:="/tmp/build"} +# Set path to prioritize our utils +export REAL_PATH="${PATH}" +export PATH="${SOURCE_DIR}/ci/util:${PATH}" +echo "PATH IS: $PATH" + # Build cmake -B"${BUILD_DIR}" -H"${SOURCE_DIR}" diff --git a/ci/util/rpmbuild b/ci/util/rpmbuild new file mode 100755 index 0000000..e4bd549 --- /dev/null +++ b/ci/util/rpmbuild @@ -0,0 +1,21 @@ +#!/bin/bash +# Wrapper for rpm build that first removes files that should be in there +# We need this for compatibility with CMake <= 2.8.10 (which is the only version we have in Travis) +# See: http://www.cmake.org/pipermail/cmake-commits/2013-April/014818.html +set -o nounset +set -o errexit +set -o pipefail + +# Remove PATH hack so we can find the real rpmbuild +export PATH="${REAL_PATH}" + +echo "Using local rpmbuild" + +specFile="${!#}" # Last argument + +for removeLine in '"/usr"' '"/usr/bin"'; do + sed -i "s|${removeLine}||g" "${specFile}" +done + +# Passthrough to rpmbuild +exec rpmbuild "${@}" diff --git a/ddist.sh b/ddist.sh index 69a1fd9..d29e2ff 100755 --- a/ddist.sh +++ b/ddist.sh @@ -8,6 +8,9 @@ HERE=$(cd "${REL_HERE}"; pwd) IMG="tini" SRC="/tini" +# Cleanup the build dir +rm -f "${HERE}/dist"/* + # Create the build image docker build -t "${IMG}" . diff --git a/test/test.py b/test/test.py index 15ba04b..de8becc 100644 --- a/test/test.py +++ b/test/test.py @@ -61,36 +61,50 @@ if __name__ == "__main__": root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) + base_cmd = [ + "docker", + "run", + "--rm", + "--volume={0}:/tini".format(root), + "--name={0}".format(name), + ] + + fail_cmd = ["docker", "kill", name] + + + # Funtional tests for entrypoint in ["/tini/dist/tini"]: - base_cmd = [ - "docker", - "run", - "--rm", - "--volume={0}:/tini".format(root), - "--name={0}".format(name), + functional_base_cmd = base_cmd + [ "--entrypoint={0}".format(entrypoint), img, "-vvvv", ] - fail_cmd = ["docker", "kill", name] - # Reaping test - Command(base_cmd + ["/tini/test/reaping/stage_1.py"], fail_cmd).run(timeout=10) + Command(functional_base_cmd + ["/tini/test/reaping/stage_1.py"], fail_cmd).run(timeout=10) # Signals test for sig, retcode in [("INT", 1), ("TERM", 143)]: Command( - base_cmd + ["--", "/tini/test/signals/test.py"], + functional_base_cmd + ["--", "/tini/test/signals/test.py"], fail_cmd, ["docker", "kill", "-s", sig, name], 2 ).run(timeout=10, retcode=retcode) # Exit code test - Command(base_cmd + ["-z"], fail_cmd).run(retcode=1) - Command(base_cmd + ["--", "zzzz"], fail_cmd).run(retcode=1) - Command(base_cmd + ["-h"], fail_cmd).run(retcode=0) + Command(functional_base_cmd + ["-z"], fail_cmd).run(retcode=1) + Command(functional_base_cmd + ["--", "zzzz"], fail_cmd).run(retcode=1) + Command(functional_base_cmd + ["-h"], fail_cmd).run() # Valgrind test - Command(base_cmd + ["--", "valgrind", "--leak-check=full", "--error-exitcode=1", entrypoint, "-v", "--", "ls"], fail_cmd).run() + Command(functional_base_cmd + ["--", "valgrind", "--leak-check=full", "--error-exitcode=1", entrypoint, "-v", "--", "ls"], fail_cmd).run() + + # Install tests (sh -c is used for globbing and &&) + for image, pkg_manager, extension in [ + ["ubuntu:precise", "dpkg", "deb"], + ["ubuntu:trusty", "dpkg", "deb"], + ["centos:6", "rpm", "rpm"], + ["centos:7", "rpm", "rpm"], + ]: + Command(base_cmd + [image, "sh", "-c", "{0} -i /tini/dist/*.{1} && /usr/bin/tini true".format(pkg_manager, extension)], fail_cmd).run()