You are on page 1of 20

Advanced 2: Packages

Harrison Kuo
decal.ocf.berkeley.edu/signin | Magic word: Shannon
Overview
1. What is a package?
2. Package management
3. Troubleshooting packages
4. Packaging
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
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
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.
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.


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


DPKG commands
dpkg -i packagefilename

Installs the local .deb file.

dpkg --remove packagename

Removes the package.

dpkg -I packagefilename

Inspects the package.


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.
Example: Installing a package
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/
What just happened (Con’t)
2. apt install then:

a. Reads from the package lists


b. Finds out what dependencies the package needs
c. Checks what packages are already installed
d. Downloads the packages (if not installing a local .deb)
e. Unpacks them and copies the files over
f. Processes any remaining triggers
i. Triggers are events such as scripts that run post-install
An example is starting the application as a service
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.
Example: Installing a package with missing dependencies
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
The Structure of a Package

.deb Metadata
version#, name, etc
/usr

/usr/bin /usr/lib /usr/include /usr/share


Executables/Binaries Libraries Header Files Documentation/Etc
Example: Creating a package
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
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.
Thanks!
The assignment will be up after you get your VMs!

Remember to sign in at:

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

You might also like