From 41c5ff581edb4ec25a7e2fcbf6c5cfd6cbd5db49 Mon Sep 17 00:00:00 2001 From: Jiao Lin Date: Sun, 8 Nov 2015 17:38:15 -0800 Subject: [PATCH] trying to add docker/deb to generate debian package --- CMakeLists.txt | 4 ++-- docker/CMakeLists.txt | 1 + docker/deb/CMakeLists.txt | 30 ++++++++++++++++++++++++++++++ docker/deb/build/Dockerfile.in | 13 +++++++++++++ docker/deb/build/run.in | 5 +++++ docker/deb/prepare/Dockerfile | 8 ++++++++ docker/deb/prepare/run.in | 3 +++ docker/deb/test/Dockerfile.in | 5 +++++ docker/deb/test/run.in | 5 +++++ 9 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 docker/deb/CMakeLists.txt create mode 100644 docker/deb/build/Dockerfile.in create mode 100755 docker/deb/build/run.in create mode 100644 docker/deb/prepare/Dockerfile create mode 100755 docker/deb/prepare/run.in create mode 100644 docker/deb/test/Dockerfile.in create mode 100755 docker/deb/test/run.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 239d80a..0f56db0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,8 +51,8 @@ add_subdirectory(bin) # packaging # CPACK set(CPACK_PACKAGE_VERSION ${VERSION}) -set(CPACK_GENERATOR "RPM") -# set(CPACK_GENERATOR "DEB") +# set(CPACK_GENERATOR "RPM") +set(CPACK_GENERATOR "DEB") set(CPACK_PACKAGE_NAME ${PKG_NAME}) set(CPACK_PACKAGE_SUMMARY ${SUMMARY}) set(CPACK_PACKAGE_LICENSE ${LICENSE}) diff --git a/docker/CMakeLists.txt b/docker/CMakeLists.txt index 2e283fa..c799f0b 100644 --- a/docker/CMakeLists.txt +++ b/docker/CMakeLists.txt @@ -2,3 +2,4 @@ set(DOCKER_ORG_NAME "danseins") add_subdirectory(srpm) +add_subdirectory(deb) diff --git a/docker/deb/CMakeLists.txt b/docker/deb/CMakeLists.txt new file mode 100644 index 0000000..ee886b3 --- /dev/null +++ b/docker/deb/CMakeLists.txt @@ -0,0 +1,30 @@ +# docker + +configure_file(prepare/Dockerfile prepare/Dockerfile) +configure_file(prepare/run.in prepare/run) + +configure_file(build/Dockerfile.in build/Dockerfile) +configure_file(build/run.in build/run) + +configure_file(test/Dockerfile.in test/Dockerfile) +configure_file(test/run.in test/run) + +add_custom_target( + build-deb-deps + COMMAND bash run + WORKING_DIRECTORY prepare + ) + +# output under ..../build/DEB +add_custom_target( + build-deb + COMMAND bash run + WORKING_DIRECTORY build + ) +add_dependencies(build-deb build-deb-deps) + +add_custom_target( + test-deb + COMMAND bash run + WORKING_DIRECTORY test + ) diff --git a/docker/deb/build/Dockerfile.in b/docker/deb/build/Dockerfile.in new file mode 100644 index 0000000..23e7c99 --- /dev/null +++ b/docker/deb/build/Dockerfile.in @@ -0,0 +1,13 @@ +FROM ${DOCKER_ORG_NAME}/${PKG_NAME}-deb-deps + +MAINTAINER "Jiao Lin " + +RUN mkdir /work +WORKDIR /work +RUN git clone ${GITHUB_URL} src +RUN mkdir build +WORKDIR /work/build +RUN cmake ../src -DCMAKE_INSTALL_PREFIX=/opt/danse -DDEPLOYMENT_PREFIX=/opt/danse +RUN make package +RUN mkdir DEB +RUN mv *.deb DEB/ \ No newline at end of file diff --git a/docker/deb/build/run.in b/docker/deb/build/run.in new file mode 100755 index 0000000..950f11f --- /dev/null +++ b/docker/deb/build/run.in @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +IMG=${DOCKER_ORG_NAME}/${PKG_NAME}-deb +docker build -t $IMG --no-cache . +docker run -v $PWD:/OUTPUT $IMG mv /work/build/DEB /OUTPUT diff --git a/docker/deb/prepare/Dockerfile b/docker/deb/prepare/Dockerfile new file mode 100644 index 0000000..09a98a0 --- /dev/null +++ b/docker/deb/prepare/Dockerfile @@ -0,0 +1,8 @@ +FROM ubuntu:14.04 + +MAINTAINER "Jiao Lin " + +RUN apt-get update +RUN apt-get install -y git build-essential +RUN apt-get install -y cmake +RUN apt-get install -y python python-dev diff --git a/docker/deb/prepare/run.in b/docker/deb/prepare/run.in new file mode 100755 index 0000000..b78c387 --- /dev/null +++ b/docker/deb/prepare/run.in @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +docker build -t ${DOCKER_ORG_NAME}/${PKG_NAME}-deb-deps . diff --git a/docker/deb/test/Dockerfile.in b/docker/deb/test/Dockerfile.in new file mode 100644 index 0000000..d2bec98 --- /dev/null +++ b/docker/deb/test/Dockerfile.in @@ -0,0 +1,5 @@ +FROM ${DOCKER_ORG_NAME}/${PKG_NAME}-srpm-deps + +MAINTAINER "Jiao Lin " + +RUN dpkg -i ${GITHUB_URL}/releases/download/v${VERSION}/${PKG_NAME}-${VERSION}-${CPACK_PACKAGE_RELEASE}.x86_64.deb diff --git a/docker/deb/test/run.in b/docker/deb/test/run.in new file mode 100755 index 0000000..23a9444 --- /dev/null +++ b/docker/deb/test/run.in @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +IMG_NAME=${DOCKER_ORG_NAME}/${PKG_NAME}-srpm-test +docker build -t $IMG_NAME --no-cache . \ + && docker run -t $IMG_NAME find /opt/danse