You can build an ISO from the source code and other images for Photon OS. This section describes how to build the ISO, build other images, use the cached toolchain and RPMS, and cached sources. You can use this method as an alternative to downloading a pre-built version.
For information on how to install and build a package on Photon OS from the package’s source RPM, see the Photon OS Administration Guide.
1 - Folder Layout
The structure of the directories on GitHub that contain the source code for Photon OS is as follows:
Before you build the ISO, verify that you have the performed the following tasks:
Installed a build operating system running the 64-bit version of Ubuntu 14.04 or later version.
Downloaded and installed the following packages for Ubuntu:
bison
gawk
g++
createrepo
python-aptdaemon
genisoimage
texinfo
python-requests
libfuse-dev
libssl-dev
uuid-dev
libreadline-dev
kpartx
git
bc
Downloaded and installed the following packages for Photon OS: “rsync”
“docker-18.09.9”
“docker-py3”
“python3-pyOpenSSL”
“python3-six”
“python3-pip”
“cdrkit”
“createrepo_c”
“dosfstools”
“openssl-devel”
“python3-curses”
“zlib-devel”
“util-linux-devel”
Installed Docker
Downloaded the source code from the Photon OS repository on GitHub into $HOME/workspaces/photon.
3 - Build an ISO from the Source Code for Photon OS
You can build an ISO from the source code for Photon OS. This section describes how to build the ISO, use the cached toolchain and RPMS, and cached sources. You can use this method as an alternative to downloading a pre-built version.
For information on how to install and build a package on Photon OS from the package’s source RPM, see the Photon OS Administration Guide.
3.1 - Building the ISO
Perform the following steps to install the packages on Ubuntu:
The default configuration parameters are available in config.json. If you want to customize them, then the configuration information is available at the following location:
This command first builds all RPMs corresponding to the SPEC files in your Photon repository and then builds a bootable ISO containing those RPMs.
The RPMs thus built are stored under stage/RPMS/ directory within the repository, using the following directory hierarchy:
$HOME/workspaces/photon/stage/:
├──RPMS/:
├──noarch/*.noarch.rpm [Architecture-independent RPMs]
├──x86_64/*.x86_64.rpm [RPMs built for the x86-64 architecture]
├──aarch64/*.aarch64.rpm [RPMs built for the aarch64 (ARM64) architecture]
The ISO is created at $HOME/workspaces/photon/stage/photon.iso.
4 - Build Other Images for Photon OS
This section describes how to build the cloud images, OVA, and RPM.
For information on how to install and build a package on Photon OS from the package’s source RPM, see the Photon OS Administration Guide.
4.1 - Building Cloud Images
Perform the following steps to build the cloud images on Ubuntu:
This command first builds all RPMs corresponding to the SPEC files in your Photon repository and then builds a bootable ISO containing those RPMs.
The RPMs thus built are stored under stage/RPMS/ directory within the repository, using the following directory hierarchy:
$HOME/workspaces/photon/stage/:
├──RPMS/:
├──noarch/*.noarch.rpm [Architecture-independent RPMs]
├──x86_64/*.x86_64.rpm [RPMs built for the x86-64 architecture]
├──aarch64/*.aarch64.rpm [RPMs built for the aarch64 (ARM64) architecture]
The cloud image is created at `$HOME/workspaces/photon.
4.2 - Building OVA image
Perform the following steps to build OVA on Ubuntu:
sudo apt install python3-pip
pip3 install git+https://github.com/vmware/photon-os-installer.git
git clone https://github.com/vmware/photon.git
If you encounter an error for LOCALE when you run these commands, then export the following variables in the terminal:
export LC_ALL="en_US.UTF-8"
`export LC_CTYPE="en_US.UTF-8"`
For VDDK, if the downloaded file is VMware-vix-disklib-6.7.0-8173251.x86_64.tar.gz, untar the downloaded tarball:
$ tar xf VMware-vix-disklib-6.7.0-8173251.x86_64.tar.gz
Navigate to extracted directory.
Move the header files to /usr/include
$ sudo mv include/*.h /usr/include
Move the shared libs to /usr/lib/vmware
$ sudo mkdir -p /usr/lib/vmware && sudo mv lib64/* /usr/lib/vmware && sudo rm /usr/lib/vmware/libstdc++.so*
Export /usr/lib/vmware library path(only for current session). Do this step every time you try to build an ova image.
$ export LD_LIBRARY_PATH=/usr/lib/vmware
Navigate to your intended Photon source repository and run the following command.
`sudo make image IMG_NAME=ova`
Make the image for OVA UEFI
sudo make image IMG_NAME=ova_uefi
Result
This command first builds all RPMs corresponding to the SPEC files in your Photon repository and then builds a bootable ISO containing those RPMs.
The RPMs thus built are stored under stage/RPMS/ directory within the repository, using the following directory hierarchy:
$HOME/workspaces/photon/stage/:
├──RPMS/:
├──noarch/*.noarch.rpm [Architecture-independent RPMs]
├──x86_64/*.x86_64.rpm [RPMs built for the x86-64 architecture]
├──aarch64/*.aarch64.rpm [RPMs built for the aarch64 (ARM64) architecture]
The cloud image is created at `$HOME/workspaces/photon.
5 - Use the Cached Toolchain and RPMS
When the necessary RPMs are available under the stage/RPMS/ directory, the commands that you use to create any Photon artifact such as, ISO or OVA will reuse those RPMs to create the specified image.
If you already have the Photon RPMs available elsewhere, and not under stage/RPMS/ in the Photon repository, you can build Photon artifacts using those cached RPMs by setting the PHOTON_CACHE_PATH variable to point to the directory containing those RPMs.
For example, if your RPMs are located under $HOME/photon-cache/, then use the following command to build an ISO:
sudo make iso PHOTON_CACHE_PATH=$HOME/photon-cache
The $HOME/photon-cache/ directory should follow the same structure as the stage/RPMS/ directory:
You can use the custom-iso tool to create images such as a custom ISO, Initrd, and RPM-OSTree. To generate an image, you must provide the necessary inputs in the form of arguments. The custom-iso tool creates images based on the inputs you provide.
You can use the following functions to generate the required images:
build-initrd generates a custom Initrd image
build-initrd generates a custom ISO image.
build-rpm-ostree-iso generates a custom RPM-OSTree ISO.
As an input to the tool, you must provide the list of all the necessary packages for the custom ISO in a JSON file. The tool only uses the minimal list of packages and their dependencies that you specify.
You can customize the following files and configurations:
List of packages to install
Kickstart file
Boot command line
Repo to download the packages
Installer initrd package list
Custom ostree tar archive
Note that when you use the Custom ISO builder to build the ISO and the Installer initrd, the ISO and initrd files are generated with the following naming conventions:
ISO: photon-<photon-release-version>.iso
Initrd: initrd.img
Prerequisite
To generate a custom ISO, ensure that you provide the following required parameters:
List of custom packages in JSON format
Photon Release Version
Generating Function: For example, build-iso, build-initrd, and build-rpm-ostree-iso
Path to OSTree tar archive (required only if function is set to build-rpm-ostree-iso)
Note: You must provide the additional repository if you want to include a package that the Photon OS official repository does not provide.
You can also provide the following optional parameters:
Custom Kickstart file
Additional repositories
Boot command line parameters
Custom Initrd package list file
Artifact path
Preparing for Custom Image Generation
Install the following prerequisite packages:
python3-pip
git
tar
createrepo_c
binutils
dosfstools
cdrkit
docker
i. To install the specified packages on Photon OS, use the following command:
tdnf install -y python3-pip git tar createrepo_c binutils dosfstools cdrkit
Run following command to install photon-os-installer python library:
Note: packages_x86_64 and packages_aarch64 are optional keys. The packages_minimal.json file is a sample file. You can create your own JSON file with the list of custom packages that you want, and provide the directory path for the file in the command to generate the iso/initrd.
Generating a Custom Image
You can use the respective commands to generate the custom images for the following use cases.
Before you generate the custom image using default installation as RPM-OStree, you need to generate ostree tar archive. Perform the following steps to generate the ostree tar archive:
tar -czf </path/to/>ostree-repo.tar.gz -C </path/to/repotree>/repo
Example: repo tree resides inside the following directory my-repo like /root/my-repo/repo
tar -zcf /root/ostree-repo.tar.gz -C /root/my-repo/repo .
Once the tar archive is generated, generate the custom image.
To generate the custom image using default installation as RPM-OStree, execute the following command: