1 of 23

Advanced 2: Packages

George Lee

(Based on slides from Harrison Kuo)

2 of 23

Overview

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

3 of 23

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 23

Package Management

  • Every distribution uses a different package manager
    • ex. Arch uses pacman
  • 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 23

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 23

APT commands

apt update

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

apt install [packagename]

Installs the package.

apt remove [packagename]

Uninstalls the package.

7 of 23

APT commands (Con’t)

apt upgrade

Updates the packages.

apt search [searchterm]

Searches for the package in the catalogue

apt depends [packagename]

Lists the dependencies for the package

8 of 23

APT Commands (Con’t)

apt policy [packagename]

Lists potential versions that are available to install

apt -t [releasetarget] install [packagename]

Installs package according to a specified release target

9 of 23

DPKG commands

dpkg -i packagefilename

Installs the local .deb file.

dpkg --remove packagename

Removes the package.

dpkg -I packagefilename

Inspects the package.

10 of 23

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.

11 of 23

Example: Installing a package

12 of 23

What just happened

  1. apt search reads from the package lists returns the relevant information

13 of 23

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

14 of 23

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.

15 of 23

Example: Installing a package with missing dependencies

16 of 23

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
  5. Removed the packages from the system

17 of 23

Example: Debugging packages with mismatched versions

18 of 23

What just happened

  • apt policy reads from the package lists returns the relevant information
  • apt update reads /etc/apt/sources.list and pulls data from the repositories then updates the package lists in /var/lib/apt/lists/
  • apt upgrade fetches data from repositories and updates the packages on the system

19 of 23

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

20 of 23

Example: Creating a package

21 of 23

What just happened?

  1. Code was written/compiled
  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

22 of 23

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.

23 of 23

Thanks!

The assignment will be up after you get your VMs!

Remember to sign in at:

decal.ocf.berkeley.edu/signin

Magic Word is?