Skip to content

Conversation

@BobSolyman
Copy link

Add installation and packaging targets

GitLab username

solymasn

How to Test

  1. Build the Docker image:

    docker build -t cpack-exercise .
  2. Run the container with mounted directory:

    docker run --rm -it --mount type=bind,source="$(pwd)",target=/mnt/cpack-exercise cpack-exercise
  3. Inside the container, build and test:

    cd /mnt/cpack-exercise
    mkdir build && cd build
    cmake ..
    make -j4
    
    # Test install target
    make install DESTDIR=/tmp/test-install
    tree /tmp/test-install
    
    # Create packages
    make package
    
    # Inspect packages
    tar -tzf cpackexample-0.1.0-Linux.tar.gz
    dpkg-deb -c cpackexample_0.1.0_amd64.deb
    
    # Install and run Debian package
    apt install -y ./cpackexample_0.1.0_amd64.deb
    cpackexample
    
    # Check with lintian
    lintian ./cpackexample_0.1.0_amd64.deb

Changes Made

  1. Install targets added to CMakeLists.txt:

    • Executable → <prefix>/bin/
    • Library → <prefix>/lib/
    • Headers → <prefix>/include/cpackexamplelib/
  2. Created cmake/CPackConfig.cmake with:

    • Package metadata (maintainer, contact, vendor, homepage, description)
    • Generates only TGZ and DEB packages
    • Debian naming scheme (DEB-DEFAULT)
    • Binary stripping enabled (CPACK_STRIP_FILES TRUE)

Lintian Output

Initial output (5 issues):

E: cpackexample: no-changelog usr/share/doc/cpackexample/changelog.gz (native package)
E: cpackexample: no-copyright-file
E: cpackexample: no-phrase Maintainer shehabsolyman134@gmail.com
W: cpackexample: extended-description-line-too-long line 2
W: cpackexample: no-manual-page [usr/bin/cpackexample]

Final output (3 issues):

E: cpackexample: no-changelog usr/share/doc/cpackexample/changelog.gz (native package)
E: cpackexample: no-copyright-file
W: cpackexample: no-manual-page [usr/bin/cpackexample]

Fixed:

  • no-phrase Maintainer → Fixed maintainer format to Name <email>
  • extended-description-line-too-long → Shortened package description

Binary Stripping Verification

Build directory (unstripped): 4.4M
Package (stripped):           1.7M

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