Add installation and packaging targets#19
Add installation and packaging targets#19Nikhil-4595 wants to merge 2 commits intoSimulation-Software-Engineering:mainfrom
Conversation
…mated Docker packaging
uekerman
left a comment
There was a problem hiding this comment.
I was not able to run your code. Parts of your solution seem generated, are they?
CMakeLists.txt
Outdated
| # Option for bonus task: allow building the library as shared | ||
| option(CPACKEXAMPLE_BUILD_SHARED "Build cpackexamplelib as a shared library" OFF) | ||
|
|
||
| if (CPACKEXAMPLE_BUILD_SHARED) |
There was a problem hiding this comment.
How is the variable different to BUILD_SHARED_LIBS?
cmake/CPackConfig.cmake
Outdated
| set(CPACK_PACKAGE_VERSION_MAJOR 0) | ||
| set(CPACK_PACKAGE_VERSION_MINOR 1) | ||
| set(CPACK_PACKAGE_VERSION_PATCH 0) | ||
| set(CPACK_PACKAGE_VERSION | ||
| "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}" | ||
| ) |
There was a problem hiding this comment.
Better take the versions from the project, don't hard-code here.
There was a problem hiding this comment.
Okay, Sure. Will take care of it next time.
Dockerfile
Outdated
| ENV PATH=$PATH:/usr/local/bin/ | ||
|
|
||
| # Script to configure, build (shared), and create packages automatically | ||
| RUN cat > /usr/local/bin/build-and-package.sh << 'EOF' |
There was a problem hiding this comment.
| RUN cat > /usr/local/bin/build-and-package.sh << 'EOF' | |
| RUN <<'EOF' | |
| cat > /usr/local/bin/build-and-package.sh |
Did your code work for you?
There was a problem hiding this comment.
It did, as per my knowledge. What is the issue @uekerman ?
There was a problem hiding this comment.
docker build -t cpack-exercise .
[+] Building 0.1s (2/2) FINISHED docker:default
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 2.15kB 0.0s
Dockerfile:37
--------------------
35 | RUN cat > /usr/local/bin/build-and-package.sh << 'EOF'
36 | #!/bin/bash
37 | >>> set -euo pipefail
38 |
39 | SRC_DIR=/mnt/cpack-exercise
--------------------
ERROR: failed to solve: dockerfile parse error on line 37: unknown instruction: set (did you mean user?)
I am using:
docker --version
Docker version 24.0.6, build ed223bc
There was a problem hiding this comment.
Hey @uekerman,
I tried to reproduce the Docker build error (unknown instruction: set) on my side but was not able to get it.
On my machine, I am using Docker Desktop 28.5.1. I tested the Dockerfile both with BuildKit enabled and disabled (using DOCKER_BUILDKIT=0), and in both cases it builds successfully, including the RUN cat > … << 'EOF' block with indented content.
I believe the build failure you're experiencing is due to a Docker version difference. You mentioned using Docker 24.0.6, which appears to have stricter parsing rules for heredoc syntax in Dockerfiles. In older Docker versions, the heredoc content (the lines between << 'EOF' and EOF) must start at the beginning of the line with no leading whitespace. When indentation is present, the legacy parser interprets those indented lines as Dockerfile instructions rather than heredoc content, which causes the error: unknown instruction: set.
Newer Docker versions (25.0+) introduced support for indented heredoc content, making the syntax more flexible and readable. Docker Desktop 28.5.1 supports this feature regardless of whether BuildKit is explicitly enabled or disabled.
There was a problem hiding this comment.
I am getting the same problem with Docker version 28.1.1 :/
There was a problem hiding this comment.
Oh, that's strange. What shall I do now? Shall I make the changes in the docker file as others?
There was a problem hiding this comment.
Hey @uekerman, I updated the CMake setup to avoid hard-coding the package version in CPackConfig.cmake. I also switched to the standard BUILD_SHARED_LIBS mechanism instead of a custom variable, so the shared/static behavior follows common CMake practice.
Additionally, I simplified the Docker automation to follow the expected workflow: the project is built and packaged in a temporary directory inside the container, and only the final .deb and .tar.gz artifacts are copied back to the host. With this setup, the heredoc-related build issue should no longer occur.
Please, have a look and then let me know :)
There was a problem hiding this comment.
Works now, thanks for following up 👍
Gitlab Username : nikhilnl
This commit completes the mandatory CPack assignment and optional bonus tasks.
Mandatory features:
Lintian:
How to build and test:
Run the container:
Behavior:
After the container exits on the host:
Expected output:
This commit completes all required tasks and implements the full optional automation workflow.