Add package repositories¶
Before you can install packages into your image, either through the overlay file system or after first boot, you’ll need to add the corresponding package repositories. This is done by defining the repository sources on your local machine and copying them to the image with a part.
Define the repository sources¶
In your project directory, create a directory to hold the repository sources:
mkdir apt-config
In this directory, create a .sources file for each desired repository using the
DEB822 format. In each file, define the following fields:
Field |
Value |
|---|---|
Types |
|
URIs |
The package repository’s URIs |
Suites |
The codenames for the desired distributions |
Components |
The repository sections to include (e.g. |
Signed-By |
The path to the repository’s signing key in the image |
For example, the .sources file for the Fish shell PPA would contain:
Types: deb
URIs: https://ppa.launchpadcontent.net/fish-shell/release-4/ubuntu
Suites: noble
Components: main
Signed-By: /etc/apt/keyrings/fish-ppa.gpg
When setting the Signed-By path, consider where you’ll store the signing key in the
final image. When you copy the key to the image later on, its destination must match
this path.
While most .sources files will closely resemble the previous example, the patterns
for your repository may differ. In such cases, refer to the sources.list,
manual page, which contains a complete reference of the DEB822 format.
Download the signing key¶
To download the repository’s signing key, you’ll need its fingerprint. If your PPA is on Launchpad, copy its fingerprint from the “Technical details about this PPA” section.
Next, create another directory to hold the signing key:
mkdir apt-config/keyrings
Then, download the signing key. To download the signing key for the Fish PPA, you’d run:
FINGERPRINT=88421E703EDC7AF54967DED473C9FCC9E2BB48DA
KEY_URL=”https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x$FINGERPRINT”
curl -fsSL $KEY_URL | gpg --dearmor > apt-config/keyrings/fish-ppa.gpg
Replace the fingerprint and destination file name with the values for your desired repository.
Copy the sources to the image¶
Copy the files you created to the image with a new part that uses the dump plugin and the organize key. The part for our Fish example is defined as:
parts:
apt-config:
plugin: dump
source: apt-config/
organize:
fish-ppa.sources: (overlay)/etc/apt/sources.list.d/fish-ppa.sources
keyrings/fish-ppa.gpg: (overlay)/etc/apt/keyrings/fish-ppa.gpg
Packages from the added repository can now be installed into the overlay file system with subsequent parts or after booting the image.