Skip to content

Commit

Permalink
Adding CMake target to build fdt-viewer Debian package in a Docker co…
Browse files Browse the repository at this point in the history
…ntainer
  • Loading branch information
dmikushin authored and dev-0x7C6 committed Dec 6, 2022
1 parent 6aaa362 commit 93f2a8d
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 7 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
41 changes: 35 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,40 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt5 COMPONENTS Widgets REQUIRED)
find_package(Qt5 COMPONENTS Widgets)
if (Qt5_FOUND)
add_subdirectory("src")

add_subdirectory("src")
if (UNIX)
install(FILES resources/fdt-viewer.svg DESTINATION share/icons/hicolor/scalable/apps)
install(FILES resources/fdt-viewer.desktop DESTINATION share/applications)
endif (UNIX)
endif()

find_package(Git REQUIRED)
# the commit's SHA1, and whether the building workspace was dirty or not
execute_process(COMMAND
"${GIT_EXECUTABLE}" describe --match=NeVeRmAtCh --always --dirty
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_SHA1
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)

set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}-${GIT_SHA1}")
set(CPACK_PACKAGE_VENDOR "Bartłomiej Burdukiewicz")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Dmitry Mikushin <dmitry@kernelgen.org>")
set(CPACK_DEBIAN_PACKAGE_DEPENDS libqt5gui5)
set(CPACK_PACKAGING_INSTALL_PREFIX "usr")

add_custom_target(docker
COMMAND docker build -f docker/Dockerfile -t ${PROJECT_NAME} .
COMMAND docker create --name ${CPACK_PACKAGE_FILE_NAME} ${PROJECT_NAME}
COMMAND docker cp ${CPACK_PACKAGE_FILE_NAME}:/root/build/${CPACK_PACKAGE_FILE_NAME}.deb ${CMAKE_CURRENT_BINARY_DIR}
COMMAND docker rm -f ${CPACK_PACKAGE_FILE_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Building ${PROJECT_NAME} in a Docker container")

include(CPack)

if (UNIX)
install(FILES resources/fdt-viewer.svg DESTINATION share/icons/hicolor/scalable/apps)
install(FILES resources/fdt-viewer.desktop DESTINATION share/applications)
endif (UNIX)
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Options:
-d, --directory <directory> open directory.
```

#### Installation process
#### Installation
```console
user@host # git clone --recursive https://github.com/dev-0x7C6/fdt-viewer.git
user@host # cd fdt-viewer
Expand All @@ -33,6 +33,16 @@ user@host # make -j$(nproc)
root@host # make install
```

#### Packaging with Docker
Create a Debian package of ftd-viewer in a Docker container and install it to the host system:
```console
user@host # git clone --recursive https://github.com/dev-0x7C6/fdt-viewer.git
user@host # cd fdt-viewer
user@host # cmake .
user@host # make docker
root@host # dpkg -i "fdt-viewer*.deb"
```

#### Known bugs
- presentation of data-types is under development

Expand Down
27 changes: 27 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM ubuntu:latest

LABEL maintainer="dmitry@kernelgen.org"

ENV DEBIAN_FRONTEND noninteractive
ENV LC_ALL C.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8

RUN apt-get update && \
apt-get -y --no-install-recommends install \
git \
cmake \
make \
g++ \
qtbase5-dev && \
apt-get clean

COPY . /root/

WORKDIR /root

RUN mkdir build && cd build && \
cmake -DCMAKE_BUILD_TYPE=Release .. && \
cmake --build . && \
cpack

0 comments on commit 93f2a8d

Please sign in to comment.