From a8242cd4fa005358470732f83374d40981ea4773 Mon Sep 17 00:00:00 2001 From: Jannik Date: Wed, 3 Dec 2025 20:16:24 +0000 Subject: [PATCH 1/4] exercise dont README.md updated to conatin all information needed for test and executions by the TA, CMakeLists.txt updated to automate packaging, cmake dir created containing CPackConfig.cmake file --- CMakeLists.txt | 22 +++++++++++++++ README.md | 62 +++++++++++++++++++++++++++++++++++++++++ cmake/CPackConfig.cmake | 17 +++++++++++ 3 files changed, 101 insertions(+) create mode 100644 cmake/CPackConfig.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 94d6c2c..348e755 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,3 +20,25 @@ target_link_libraries(cpackexamplelib Boost::filesystem ${YAML_CPP_LIBRARIES}) DEAL_II_SETUP_TARGET("${PROJECT_NAME}") DEAL_II_SETUP_TARGET(cpackexamplelib) + +include(GNUInstallDirs) + +install(TARGETS cpackexample + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +install(TARGETS cpackexamplelib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +install(FILES + fem/fem.hpp + filesystem/filesystem.hpp + flatset/flatset.hpp + yamlParser/yamlParser.hpp + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cpackexamplelib) + +# Include our packaging module +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +include(CPackConfig) + + diff --git a/README.md b/README.md index 8e950e4..15607c6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,65 @@ # Packaging with CPack Repository for the [CPack exercise](https://github.com/Simulation-Software-Engineering/Lecture-Material/blob/main/03_building_and_packaging/cpack_exercise.md). The code is a slightly modified version of the [code used in the CMake exercise](https://github.com/Simulation-Software-Engineering/cmake-exercise). + +## How to Test the Code + +To test the changes made for the CPack exercise, follow these steps: + +1. **Build the Docker Image:** + First, build the Docker image which provides the necessary build environment. + ```bash + docker build -t cpack-exercise . + ``` + +2. **Run the Docker Container:** + Run the Docker container, mounting the current directory to `/mnt/cpack-exercise`. + ```bash + docker run --rm -it --mount type=bind,source="$(pwd)",target=/mnt/cpack-exercise cpack-exercise + ``` + +3. **Configure and Build the Project (Inside the Container):** + Once inside the container, configure CMake and build the project. + ```bash + cmake -B build -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release + cmake --build build + ``` + +4. **Install the Project (Inside the Container):** + Run the install target to place the executable, library, and headers in the designated installation directories. + ```bash + cmake --install build + ``` + You can verify the installation by checking the `/usr/local/bin`, `/usr/local/lib`, and `/usr/local/include/cpackexamplelib` directories. + +5. **Generate Packages (Inside the Container):** + Build the `package` target to generate both `.tar.gz` and Debian (`.deb`) packages. + ```bash + cmake --build build --target package + ``` + The generated packages will be in the `build/` directory, e.g., `cpackexample-0.1.0-Linux.tar.gz` and `cpackexample_0.1.0_amd64.deb`. + +6. **Install the Debian Package (Inside the Container):** + Install the generated Debian package using `apt`. + ```bash + sudo apt install ./build/cpackexample_0.1.0_amd64.deb + ``` + +7. **Run the Installed Executable (Inside the Container):** + Verify that the executable is in the system's PATH and runs correctly. + ```bash + which cpackexample + cpackexample yamlParser/config.yml + ``` + The output should show the program executing its various modules. + +8. **Check the Debian Package with Lintian (Inside the Container):** + Inspect the generated Debian package for common errors and policy violations using `lintian`. + ```bash + lintian build/cpackexample_0.1.0_amd64.deb + ``` + *Note: Several warnings and errors are expected from `lintian` as per the exercise instructions, and no fixes for these were implemented as they were optional tasks.* + +## Optional Tasks + +No optional tasks were completed as part of this exercise. \ No newline at end of file diff --git a/cmake/CPackConfig.cmake b/cmake/CPackConfig.cmake new file mode 100644 index 0000000..da50351 --- /dev/null +++ b/cmake/CPackConfig.cmake @@ -0,0 +1,17 @@ +set(CPACK_PACKAGE_NAME "${PROJECT_NAME}") +set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}") +set(CPACK_PACKAGE_VENDOR "Gemini") +set(CPACK_PACKAGE_CONTACT "gemini@google.com") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A CPack exercise to demonstrate packaging a C++ application.") +set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/Simulation-Software-Engineering/cpack-exercise-wt2526") + +set(CPACK_GENERATOR "TGZ;DEB") + +# Debian packaging section +set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) +set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS YES) + +# strip really all Debug symbols +set(CPACK_STRIP_FILES TRUE) + +include(CPack) From c8ed52937140eb84c0cc3c0f5ba1bb25b352d41b Mon Sep 17 00:00:00 2001 From: jkhanGitHub <93975447+jkhanGitHub@users.noreply.github.com> Date: Wed, 3 Dec 2025 21:29:04 +0100 Subject: [PATCH 2/4] updated with step 0 --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 15607c6..d911367 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,12 @@ Repository for the [CPack exercise](https://github.com/Simulation-Software-Engin ## How to Test the Code +0. **Clone the directory and go inside the root of the directory** + ```bash + git clone https://github.com/jkhanGitHub/cpack-exercise-wt2526.git + cd cpack-exercise-wt2526 + ``` + To test the changes made for the CPack exercise, follow these steps: 1. **Build the Docker Image:** @@ -62,4 +68,4 @@ To test the changes made for the CPack exercise, follow these steps: ## Optional Tasks -No optional tasks were completed as part of this exercise. \ No newline at end of file +No optional tasks were completed as part of this exercise. From d229a97925f38c85d372b05ed03b0138d67a9d9d Mon Sep 17 00:00:00 2001 From: jkhanGitHub <93975447+jkhanGitHub@users.noreply.github.com> Date: Wed, 3 Dec 2025 21:32:36 +0100 Subject: [PATCH 3/4] added cd /mnt/cpack-exercise step, necessary for the Build to work Updated step numbers in the README for clarity. --- README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d911367..4232eda 100644 --- a/README.md +++ b/README.md @@ -23,35 +23,39 @@ To test the changes made for the CPack exercise, follow these steps: ```bash docker run --rm -it --mount type=bind,source="$(pwd)",target=/mnt/cpack-exercise cpack-exercise ``` + inside the Docker container cd into `/mnt/cpack-exercise`. + ```bash + cd /mnt/cpack-exercise + ``` -3. **Configure and Build the Project (Inside the Container):** +4. **Configure and Build the Project (Inside the Container):** Once inside the container, configure CMake and build the project. ```bash cmake -B build -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release cmake --build build ``` -4. **Install the Project (Inside the Container):** +5. **Install the Project (Inside the Container):** Run the install target to place the executable, library, and headers in the designated installation directories. ```bash cmake --install build ``` You can verify the installation by checking the `/usr/local/bin`, `/usr/local/lib`, and `/usr/local/include/cpackexamplelib` directories. -5. **Generate Packages (Inside the Container):** +6. **Generate Packages (Inside the Container):** Build the `package` target to generate both `.tar.gz` and Debian (`.deb`) packages. ```bash cmake --build build --target package ``` The generated packages will be in the `build/` directory, e.g., `cpackexample-0.1.0-Linux.tar.gz` and `cpackexample_0.1.0_amd64.deb`. -6. **Install the Debian Package (Inside the Container):** +7. **Install the Debian Package (Inside the Container):** Install the generated Debian package using `apt`. ```bash sudo apt install ./build/cpackexample_0.1.0_amd64.deb ``` -7. **Run the Installed Executable (Inside the Container):** +8. **Run the Installed Executable (Inside the Container):** Verify that the executable is in the system's PATH and runs correctly. ```bash which cpackexample @@ -59,7 +63,7 @@ To test the changes made for the CPack exercise, follow these steps: ``` The output should show the program executing its various modules. -8. **Check the Debian Package with Lintian (Inside the Container):** +9. **Check the Debian Package with Lintian (Inside the Container):** Inspect the generated Debian package for common errors and policy violations using `lintian`. ```bash lintian build/cpackexample_0.1.0_amd64.deb From db1145b90741e341f6162f6709660aa2330d7000 Mon Sep 17 00:00:00 2001 From: jkhanGitHub <93975447+jkhanGitHub@users.noreply.github.com> Date: Wed, 3 Dec 2025 21:35:50 +0100 Subject: [PATCH 4/4] removed sudo since it was not even installed --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4232eda..434754d 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ To test the changes made for the CPack exercise, follow these steps: 7. **Install the Debian Package (Inside the Container):** Install the generated Debian package using `apt`. ```bash - sudo apt install ./build/cpackexample_0.1.0_amd64.deb + apt install ./build/cpackexample_0.1.0_amd64.deb ``` 8. **Run the Installed Executable (Inside the Container):**