Skip to content

Conversation

@Nikhil-4595
Copy link

@Nikhil-4595 Nikhil-4595 commented Dec 8, 2025

Gitlab Username : nikhilnl

This commit completes the mandatory CPack assignment and optional bonus tasks.

Mandatory features:

  • Added full installation targets in CMake:
    • cpackexample → /bin/
    • cpackexamplelib (static/shared) → /lib/
    • public headers → /include/cpackexamplelib/
  • Added cmake/CPackConfig.cmake defining:
    • package metadata (name, maintainer, vendor, homepage, description)
    • TGZ and DEB generators only
    • /usr install prefix for Debian packaging
    • automatic dependency detection (CPACK_DEBIAN_PACKAGE_SHLIBDEPS=YES)
    • stripping of binaries (CPACK_STRIP_FILES=YES)
  • Verified:
    • make install installs correctly
    • make package produces *.tar.gz and *.deb packages
    • Debian package installs via apt install ./pkg.deb
    • Installed binary runs correctly from /usr/bin

Lintian:

  • Resolved major issues: missing maintainer phrase, missing description, unstripped binaries, undeclared ELF dependencies.
  • Remaining warnings (expected for this exercise): no changelog, no copyright, no manpage.
  • Initial and final lintian reports included in this PR.

How to build and test:

  1. Build the Docker image:
docker build -t cpack-exercise .
  1. Manual build/test inside the container (mandatory parts):

Start container interactively:

docker run --rm -it \
  --mount type=bind,source="$(pwd)",target=/mnt/cpack-exercise \
  cpack-exercise /bin/bash

Inside the container:

cd /mnt/cpack-exercise

rm -rf build
mkdir build
cd build

cmake -DCMAKE_INSTALL_PREFIX=/tmp/cpack-install ..
make -j"$(nproc)"

make install
ls -R /tmp/cpack-install

make package
ls cpackexample-0.1.0-Linux.tar.gz
ls cpackexample_0.1.0_arm64.deb
  1. Install and test the Debian package:
apt update
apt install ./cpackexample_0.1.0_arm64.deb

which cpackexample
cpackexample
  1. Lintian check:
apt install -y lintian
lintian ./cpackexample_0.1.0_arm64.deb

Bonus work:

  • Added CMake option CPACKEXAMPLE_BUILD_SHARED to build cpackexamplelib as a shared library.
  • Extended Dockerfile to automatically:
    • configure CMake with shared library mode
    • build and package the project inside a temporary directory
    • export only the generated .tar.gz and .deb into ./packages/ on the host
    • leave no build/ directory or temporary files on the host
  • Added build-and-package.sh entrypoint script.

Automated packaging command:

docker run --rm \
  --mount type=bind,source="$(pwd)",target=/mnt/cpack-exercise \
  cpack-exercise

After container exits on the host:

ls packages

Expected output:

  • cpackexample_0.1.0_arm64.deb
  • cpackexample-0.1.0-Linux.tar.gz

This commit completes all required tasks and implements the full optional automation workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant