-
Notifications
You must be signed in to change notification settings - Fork 35
Add installation and packaging targets #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Nikhil-4595
wants to merge
1
commit into
Simulation-Software-Engineering:main
Choose a base branch
from
Nikhil-4595:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,28 +1,75 @@ | ||||||||
| From ubuntu:24.04 | ||||||||
| FROM ubuntu:24.04 | ||||||||
|
|
||||||||
| # Install a few dependencies | ||||||||
| # Install dependencies (incl. dpkg-dev for shlibdeps) | ||||||||
| RUN apt-get -qq update && \ | ||||||||
| apt-get -qq -y install \ | ||||||||
| build-essential \ | ||||||||
| cmake \ | ||||||||
| git \ | ||||||||
| libboost-all-dev \ | ||||||||
| wget \ | ||||||||
| libdeal.ii-dev \ | ||||||||
| vim \ | ||||||||
| tree \ | ||||||||
| lintian \ | ||||||||
| unzip | ||||||||
|
|
||||||||
| # Get, unpack, build, and install yaml-cpp | ||||||||
| RUN mkdir software && cd software && \ | ||||||||
| wget https://github.com/jbeder/yaml-cpp/archive/refs/tags/yaml-cpp-0.6.3.zip && unzip yaml-cpp-0.6.3.zip && \ | ||||||||
| cd yaml-cpp-yaml-cpp-0.6.3 && mkdir build && cd build && \ | ||||||||
| cmake -DYAML_BUILD_SHARED_LIBS=ON .. && make -j4 && make install | ||||||||
|
|
||||||||
| # This is some strange Docker feature. Normally, you don't need to add /usr/local to these | ||||||||
| ENV LIBRARY_PATH $LIBRARY_PATH:/usr/local/lib/ | ||||||||
| ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/local/lib/ | ||||||||
| ENV PATH $PATH:/usr/local/bin/ | ||||||||
|
|
||||||||
| CMD ["/bin/bash"] | ||||||||
| build-essential \ | ||||||||
| cmake \ | ||||||||
| git \ | ||||||||
| libboost-all-dev \ | ||||||||
| wget \ | ||||||||
| libdeal.ii-dev \ | ||||||||
| vim \ | ||||||||
| tree \ | ||||||||
| lintian \ | ||||||||
| unzip \ | ||||||||
| dpkg-dev && \ | ||||||||
| rm -rf /var/lib/apt/lists/* | ||||||||
|
|
||||||||
| # Get, unpack, build, and install yaml-cpp (shared) | ||||||||
| RUN mkdir /software && cd /software && \ | ||||||||
| wget https://github.com/jbeder/yaml-cpp/archive/refs/tags/yaml-cpp-0.6.3.zip && \ | ||||||||
| unzip yaml-cpp-0.6.3.zip && \ | ||||||||
| cd yaml-cpp-yaml-cpp-0.6.3 && \ | ||||||||
| mkdir build && cd build && \ | ||||||||
| cmake -DYAML_BUILD_SHARED_LIBS=ON .. && \ | ||||||||
| make -j4 && \ | ||||||||
| make install | ||||||||
|
|
||||||||
| # Make sure /usr/local is visible | ||||||||
| ENV LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib/ | ||||||||
| ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/ | ||||||||
| 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' | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Did your code work for you? |
||||||||
| #!/bin/bash | ||||||||
| set -euo pipefail | ||||||||
|
|
||||||||
| SRC_DIR=/mnt/cpack-exercise | ||||||||
| BUILD_DIR=$(mktemp -d /tmp/cpack-build-XXXXXX) | ||||||||
| INSTALL_PREFIX=/tmp/cpack-install | ||||||||
| OUT_DIR=${CPACK_OUTPUT_DIR:-$SRC_DIR/packages} | ||||||||
|
|
||||||||
| echo "Using source directory: $SRC_DIR" | ||||||||
| echo "Using build directory: $BUILD_DIR" | ||||||||
| echo "Using install prefix: $INSTALL_PREFIX" | ||||||||
| echo "Using output directory: $OUT_DIR" | ||||||||
|
|
||||||||
| mkdir -p "$OUT_DIR" | ||||||||
|
|
||||||||
| # Configure: shared library + install prefix | ||||||||
| cmake -S "$SRC_DIR" -B "$BUILD_DIR" \ | ||||||||
| -DCPACKEXAMPLE_BUILD_SHARED=ON \ | ||||||||
| -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" | ||||||||
|
|
||||||||
| # Build | ||||||||
| cmake --build "$BUILD_DIR" -- -j"$(nproc)" | ||||||||
|
|
||||||||
| # Create packages (TGZ + DEB) | ||||||||
| cmake --build "$BUILD_DIR" --target package | ||||||||
|
|
||||||||
| # Copy only the final packages to the mounted output directory | ||||||||
| cp "$BUILD_DIR"/cpackexample-*.tar.gz "$OUT_DIR"/ | ||||||||
| cp "$BUILD_DIR"/cpackexample_*.deb "$OUT_DIR"/ | ||||||||
|
|
||||||||
| # Clean up temporary build and install dirs (container only) | ||||||||
| rm -rf "$BUILD_DIR" "$INSTALL_PREFIX" | ||||||||
|
|
||||||||
| echo "Packages copied to: $OUT_DIR" | ||||||||
| EOF | ||||||||
|
|
||||||||
| RUN chmod +x /usr/local/bin/build-and-package.sh | ||||||||
|
|
||||||||
| # Default: run the automated build-and-package script | ||||||||
| CMD ["/usr/local/bin/build-and-package.sh"] | ||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Basic package information | ||
| set(CPACK_PACKAGE_NAME "cpackexample") | ||
| set(CPACK_PACKAGE_VENDOR "Nikhil / University Of Stuttgart") | ||
| set(CPACK_PACKAGE_CONTACT "n.k.2449837@gmail.com") | ||
| set(CPACK_PACKAGE_DESCRIPTION_SUMMARY | ||
| "Finite Element / Boost / YAML example packaged with CPack" | ||
| ) | ||
|
|
||
| # Debian wants an extended description (not empty) | ||
| set(CPACK_DEBIAN_PACKAGE_DESCRIPTION | ||
| "Finite element demo application | ||
| This package contains a small FEM-based example using deal.II, Boost | ||
| and yaml-cpp, packaged with CMake and CPack for the SSE exercise." | ||
| ) | ||
|
|
||
| # Version | ||
| 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}" | ||
| ) | ||
|
Comment on lines
+18
to
+23
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better take the versions from the project, don't hard-code here. |
||
|
|
||
| # Homepage / project URL (your fork) | ||
| set(CPACK_PACKAGE_HOMEPAGE_URL | ||
| "https://github.com/Nikhil-4595/cpack-exercise-wt2526" | ||
| ) | ||
|
|
||
| # Only create TGZ and DEB binaries | ||
| set(CPACK_GENERATOR "TGZ;DEB") | ||
|
|
||
| # Install into /usr so binary ends up in /usr/bin, etc. | ||
| set(CPACK_PACKAGING_INSTALL_PREFIX "/usr") | ||
|
|
||
| # Debian-specific fields | ||
| # Lintian wants a 'phrase' (Name <email>) as maintainer | ||
| set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Nikhil <${CPACK_PACKAGE_CONTACT}>") | ||
| set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "${CPACK_PACKAGE_HOMEPAGE_URL}") | ||
| set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) | ||
|
|
||
| # Strip binaries in packages -> fixes 'unstripped-binary-or-object' | ||
| set(CPACK_STRIP_FILES YES) | ||
|
|
||
| # Let Debian tools detect shared-library dependencies | ||
| # -> fixes 'undeclared-elf-prerequisites' and adds proper Depends: | ||
| set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS YES) | ||
|
|
||
| # Enable CPack | ||
| include(CPack) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is the variable different to
BUILD_SHARED_LIBS?