Exercise: Build Multiple Packages Using Separate Install Targets

Build multiple packages using separate install targets.

We'll cover the following

Task

In this exercise, you are required to create multiple binary packages (calculate-average and calculate-average-data) from one source package (calculate-average) using separate install targets.

  • You are given a scores file with the content consisting of numbers on each line.

  • You are also given a calculate-average.c file, which reads the numbers from the scores file and calculates their average. If the scores file is empty, it prints a message informing the user of that and displays the message No file found if no such file exists.

To complete the task, you need to perform the following steps:

  1. In the Makefile, add statements to install the files calculate-average and scores separately to the location where they are expected to be found by dh_builddeb.

  2. Make the necessary changes, if any in the control and rules files of the calculate-average/debian directory to build the packages calculate-average and calculate-average-data.

  3. In the debian/rules file, override the dh_auto_install step to call make install_binary and make install_data with the appropriate install targets and the locations where the files can be found by dh_builddeb.

After these file modifications, perform the following steps:

  1. Build and install the calculate-average-data package and then the calculate-average package.

  2. If your package is built successfully, typing calculate-average will display an average of the scores present in the file scores.

Get hands-on with 1200+ tech skills courses.