1 of 20

Advanced 2: Packages

Harrison Kuo

decal.ocf.berkeley.edu/signin | Magic word: Shannon

2 of 20

Overview

  1. What is a package?
  2. Package management
  3. Troubleshooting packages
  4. Packaging

3 of 20

What is a package?

  • An archive containing binaries and libraries of an application
  • Also includes some other metadata for the system about the application
  • Used to install new applications onto a system
  • Debian uses the .deb format

4 of 20

Package Management

  • Every distribution uses a different package manager
  • Debian uses dpkg as the backend to actually install the packages
  • However, most of the time, you will be using apt to install packages

5 of 20

DPKG vs APT

  • apt is a frontend to dpkg
  • Usually you use apt for 99% of the time. An older version of apt is apt-get. They are mostly the same.
  • Usually use dpkg to install local files, fix broken packages or interrupted installs, or inspect a .deb file.
  • dpkg doesn’t have fancy logic to automatically resolve most trivial problems unlike apt.

6 of 20

APT commands

apt update

Grabs a new list (catalogue) of what packages are available.

apt install packagename

Installs the package.

apt remove

Uninstalls the package.

7 of 20

APT commands (Con’t)

apt upgrade

Updates the packages.

apt-cache search packagesearchterm

Searches for the package in the catalogue

apt-cache depends packagename

Lists the dependencies for the package

8 of 20

DPKG commands

dpkg -i packagefilename

Installs the local .deb file.

dpkg --remove packagename

Removes the package.

dpkg -I packagefilename

Inspects the package.

9 of 20

DPKG commands (Con’t)

dpkg --configure -a

Configures all packages which have been unpacked but have not completed installing. Run this if your install is interrupted and your installation becomes corrupted.

10 of 20

Example: Installing a package

11 of 20

What just happened

  1. apt update reads /etc/apt/sources.list and pulls data from the repositories then updates the package lists in /var/lib/apt/lists/

12 of 20

What just happened (Con’t)

2. apt install then:

    • Reads from the package lists
    • Finds out what dependencies the package needs
    • Checks what packages are already installed
    • Downloads the packages (if not installing a local .deb)
    • Unpacks them and copies the files over
    • Processes any remaining triggers
      1. Triggers are events such as scripts that run post-install�An example is starting the application as a service

13 of 20

Troubleshooting Packages

Usually you will encounter problems with packages in three ways:

  1. You are missing dependencies for the package you’re trying to install.
  2. A package is internally broken.
  3. An installation of a package was interrupted and broken.

14 of 20

Example: Installing a package with missing dependencies

15 of 20

What just happened?

  1. Tried to an application install using dpkg but it gave an error.
  2. Inspected the package to find out more about the missing dependency
  3. Installed the dependency
  4. Installed the package

16 of 20

The Structure of a Package

/usr

/usr/share

Documentation/Etc

/usr/bin

Executables/Binaries

/usr/lib

Libraries

/usr/include

Header Files

.deb

Metadata

version#, name, etc

17 of 20

Example: Creating a package

18 of 20

What just happened?

  1. Code was compiled
    • gcc hellopenguin.c -o testpenguin
  2. Binaries, libraries, header files were copied to their appropriate paths mirroring where they should be on the system
    • Usually there is a make install that copies it correctly to the folder that you specified using ./configure

19 of 20

What just happened? (Con’t)

3. The folder was packaged, using fpm, into a .deb file

  • fpm is an easy to use tool to create packages. However, there is an actual formal way to create packages.

20 of 20

Thanks!

The assignment will be up after you get your VMs!

Remember to sign in at:

decal.ocf.berkeley.edu/signin | Magic word: Shannon