parent | nav_order |
---|---|
How To |
2 |
By default, the image customizer tool uses the base image's inbuilt repo files for where to source RPMs from. The Azure Linux default repos typically point to packages.microsoft.com (PMC).
PMC is regularly updated with bug fixes and feature updates for packages. So, if an image customization config includes package install or updates, then a run on one day may produce a different result than a run on another day since PMC might have been updated in between runs. This behavior may be perfectly fine (or even desirable) for some users. However, other users may require more stable builds that don't change based on the state of an external resource (e.g. PMC). For such users, it can be useful to make a clone of PMC.
-
Acquire the
dnf reposync
anddnf download
commands.Azure Linux 2.0 and 3.0:
sudo tdnf -y install dnf-utils
Ubuntu 24.04:
sudo apt update -y sudo apt install -y dnf-plugins-core
-
Select the repo URL:
Azure Linux Version Arch URL 2.0 x86_64 https://packages.microsoft.com/cbl-mariner/2.0/prod/base/x86_64/ 2.0 ARM64 https://packages.microsoft.com/cbl-mariner/2.0/prod/base/aarch64/ 3.0 x86_64 https://packages.microsoft.com/azurelinux/3.0/prod/base/x86_64/ 3.0 ARM64 https://packages.microsoft.com/azurelinux/3.0/prod/base/aarch64/ For example:
REPO_URL="https://packages.microsoft.com/azurelinux/3.0/prod/base/x86_64/"
-
Clone PMC.
If you want to clone all of PMC, then run:
dnf reposync --repofrompath "azurelinux,$REPO_URL" --repo azurelinux --newest-only
If you want to only clone a subset of packages (and their dependencies), then run:
PACKAGE_LIST="vim nano" dnf download --repofrompath "azurelinux,$REPO_URL" --repo azurelinux --resolve --alldeps --destdir azurelinux $PACKAGE_LIST
This will download the RPMs into a directory named
azurelinux
. -
Cache the downloaded RPMs somewhere.
-
Use cached RPMs with the image customizer tool.
sudo ./imagecustomizer \ --build-dir ./build \ --image-file <base-image-file> \ --output-image-file ./out/image.vhdx \ --output-image-format vhdx \ --config-file <config-file> \ --disable-base-image-rpm-repos \ --rpm-source <rpms-dir>
where:
<base-image-file>
: The base image file.<config-file>
: The image customizer config file.<rpms-dir>
: The local directory that contains the downloaded RPMs.
It may be desirable to host the downloaded RPMs in a common location so that it can be used by both builds and developers.
An RPM server is simply a HTTP server that hosts static files. There is no dynamic content. So, pretty much any HTTP server application or provider can be used. The files served by the HTTP server are the RPM files themselves and a few metadata files that document what RPMs are available.
Example RPM server using httpd/apache2:
-
Install prerequisites:
Azure Linux 2.0 and 3.0:
sudo tdnf -y install createrepo_c httpd sudo systemctl enable --now httpd
Ubuntu 22.04:
sudo apt update -y sudo apt install -y createrepo-c apache2
-
Download the cached RPMs to a local directory.
-
Create the metadata files:
createrepo_c --compatibility --update <rpms-dir>
where:
<rpms-dir>
: The directory you downloaded the RPMs to.
-
Move the RPMs directory:
sudo mkdir -p /var/www sudo mv -T <rpms-dir> /var/www/rpms
-
Configure the HTTP server:
Azure Linux 2.0 and 3.0:
sudo sed -i 's|"/etc/httpd/htdocs"|"/var/www/rpms"|' /etc/httpd/conf/httpd.conf sudo systemctl reload httpd
Ubuntu 22.04:
sudo sed -i 's|/var/www/html|/var/www/rpms|' /etc/apache2/sites-available/000-default.conf sudo systemctl reload httpd
-
Create a file called
rpms.repo
with the following contents:[rpmshost] name=rpmshost baseurl=http://<ip-address> enabled=1
where:
<ip-address>
: The IP address of the HTTP server hosting the RPM files.
-
Use the
rpms.repo
file with the image customizer tool:sudo ./imagecustomizer \ --build-dir ./build \ --image-file <base-image-file> \ --output-image-file ./out/image.vhdx \ --output-image-format vhdx \ --config-file <config-file> \ --disable-base-image-rpm-repos \ --rpm-source rpms.repo
where:
<base-image-file>
: The base image file.<config-file>
: The image customizer config file.