How to build the Photon OS ISO file - dcasota/photonos-scripts GitHub Wiki

  1. Prerequisites

    • cpu power e.g. Intel i9
    • 32GB ram and more
    • free disk space e.g. 120GB
  2. Prepare the builder environment

    • Builder environment
      • supported virtual environment: VMware Workstation, VMware ESXi and more
      • technical possible and tested: WSL2, baremetal, Azure VM GenV2
    • Builder os
      • Photon OS 3,4,5
      • Ubuntu
  3. preparation

    Login as root.

    Necessary on Photon 3.0:

    if [ `cat /etc/yum.repos.d/photon.repo | grep -o "packages.vmware.com/photon" | wc -l` -eq 0 ]; then
     cd /etc/yum.repos.d/
     sed -i 's/dl.bintray.com\/vmware/packages.vmware.com\/photon\/$releasever/g' photon.repo photon-updates.repo photon-extras.repo photon- 
    debuginfo.repo
    fi
    

    Prepare the environment.

    tdnf makecache
    tdnf update tdnf
    tdnf distro-sync -y
    tdnf install -y kpartx git bc build-essential createrepo_c texinfo wget python3-pip tar dosfstools cdrkit rpm-build
    python -m pip install --upgrade pip
    pip3 install --upgrade pip
    pip3 install setuptools ez_setup
    pip3 install docker==2.3.0
    
    # use latest photon-os-installer
    cd $HOME
    PHOTON_RELEASE="5.0"
    pip3 install git+https://github.com/vmware/photon-os-installer.git
    # specify the photon os branch
    git clone -b $PHOTON_RELEASE https://github.com/vmware/photon.git
    cd photon/
    
    # new findings June 26th 2024
    sudo python3 -m venv .venv
    source .venv/bin/activate
    sudo pip3 install docker
    sudo pip3 install pyOpenSSL
    
    # new findings December 13th 2024
    PHOTONROOT=~/photon
    cp $PHOTONROOT/SPECS/openjdk/openjdk17.spec $PHOTONROOT/openjdk17.spec.tmp
    sed "s/--disable-warnings-as-errors/--disable-warnings-as-errors --build=x86_64-unknown-linux-gnu/" $PHOTONROOT/openjdk17.spec.tmp > \
    $PHOTONROOT/SPECS/openjdk/openjdk17.spec
    rm $PHOTONROOT/openjdk17.spec.tmp
    
    # new findings January 31st 2025
    PHOTONROOT=~/photon
    cp $PHOTONROOT/SPECS/openjdk/openjdk21.spec $PHOTONROOT/openjdk21.spec.tmp
    sed "s/--disable-warnings-as-errors/--disable-warnings-as-errors --build=x86_64-unknown-linux-gnu/" $PHOTONROOT/openjdk21.spec.tmp > \
    $PHOTONROOT/SPECS/openjdk/openjdk21.spec
    rm $PHOTONROOT/openjdk21.spec.tmp
    

    December 31st 2024

    The build process of llvm uses all ram and creates an out of memory situation. After som research I've found out with respect to https://stackoverflow.com/questions/71992377/building-llvm-eats-up-all-the-ram, that this misbehavior can be avoided by installing clang package before starting the make image process.

    tdnf install -y clang
    

    January 3rd 2025

    The build process of nodejs on a system with only 8gb ram stops because of lack of free memory. This can be avoided accordingly to https://github.com/nodejs/node/issues/45949#issuecomment-1364561543. Add LINK=flock /tmp $(CXX) to the make command.

    make image IMG_NAME=iso LINK=flock /tmp $(CXX)
    

    The build process of llvm-15 fails because of a ninja-15.0.7-4.ph5 fails with 'collect2: fatal error: ld terminated with signal 9 [Killed]' Accordingly to https://stackoverflow.com/questions/46259776/collect2-fatal-error-ld-terminated-with-signal-9-killed this still is a not enough ram issue. I've added a swapfile of 32gb.

    fallocate -l 32G /swapfile
    dd if=/dev/zero of=/swapfile bs=1024 count=33554432
    chmod 600 /swapfile
    mkswap /swapfile
    swapon /swapfile
    

    Add in /etc/fstab: /swapfile swap swap defaults 0 0

    January 13th 2025

    The build process of arm64 linux-esx fails with a warning 'Could not canonicalize hostname'. Install libevent package. tdnf install -y libevent.

    Start make build

    Sometimes the process breaks and can be restarted by a loop to finish a few more packages.

    for i in {1..10}; do make -j$((`nproc`-1)) image IMG_NAME=iso LINK=flock /tmp $(CXX) THREADS=$((`nproc`-1)); done
    

Troubleshooting

"Failed during building package"

This occured eg. on 'Building rpm is failed /usr/src/photon/SPECS/kafka.spec'. The workaround is to restart the process with less parallel threads. make -j4 image IMG_NAME=iso THREADS=4

"error: metadata-generation-failed"

This version conflict caused issue occured on pip3 install photon-os-installer.git and ended with error: invalid command 'egg_info'. Try this if not already applied:

python -m pip install --upgrade pip
pip3 install --upgrade pip
pip3 install setuptools ez_setup

error openjdk17 build during make build of Photon OS iso on WSL2

Package build openjdk17-17.0.8 fails when using Photon OS on WSL2 as make build environment. The logfile indicates the reason.

checking for cygpath... [not found]
checking for wslpath... [not found]
checking for cmd.exe... [not found]

Solution or workaround: none Remarks: The root cause hasn't been identified yet. /bin/wslpath is present. Accordingly to the logfile, the installation meccano can detect wsl, but identified the environment as wsl1.

update sources

To update the source e.g. Photon OS 4.0, run the following commands:

cd /photon
git fetch
git merge origin/4.0

Post-Installation issues