How to Install PureBasic in a Photon Container on Red Hat Linux

Share your advanced PureBasic knowledge/code with the community.
User avatar
Stefan Schnell
User
User
Posts: 85
Joined: Wed May 07, 2003 2:53 pm
Location: Germany - Oberirsen
Contact:

How to Install PureBasic in a Photon Container on Red Hat Linux

Post by Stefan Schnell »

I have been working in infrastructure automation for some time now. We use VMware Cloud Foundation (VCF) Automation (formerly VMware Aria Automation) there. VCF Automation offers various runtime environments for executing code, including Python. The runtime environments are executed in containers based on VMware Photon OS. Photon OS is a Linux based, security-hardened, enterprise grade appliance operating system that is built for Cloud and Edge applications. Recently I asked myself if it is possible to create Shared Objects for Photon OS with PureBasic.

At the beginning I built Shared Objects with other Linux derivatives. Then I realized that the environmental conditions, like compiler version, libraries and packages etc., had to be identical to use the library with Photon OS, which is not always so easy because you must install it. So I came up with the idea of compiling my library directly with Photon OS. So there are no expected difficulties, because the compilation system is identical to the target system on which the library is used. Here is a short description how to install PureBasic in a Photon OS 4.0 container under Red Hat Linux.
  1. Load the Photon image from the repository.

    Code: Select all

    podman pull photon:4.0
  2. Runs an interactive process in a new container.

    Code: Select all

    podman run -it --name photon photon:4.0
  3. From another terminal copy PureBasic to the Photon container.

    Code: Select all

    podman cp ./PureBasic_Linux2_X64_LTS_6.12.tar photon:/home
  4. Install the necessary packages in the Photon container.

    Code: Select all

    tdnf install gcc glibc-devel binutils vim phyton3
    Hint: The Vim editor and Python are not necessary, but they can be used to edit the PureBasic source code or to test the shared object, which can be very helpful.
  5. Extract the archive in the home directory of the Photon container.

    Code: Select all

    tar -xf ./PureBasic_Linux2_X64_LTS_6.12.tar
  6. Set in the Photon container the PUREBASIC_HOME environment variable.

    Code: Select all

    export PUREBASIC_HOME=/home/purebasic
  7. Check the PureBasic compiler.

    Code: Select all

    ./purebasic/compilers/pbcompiler
Image

The charm of this approach is that I don't have to worry about whether the library can actually be executed on the target system, I'm sure.
Of course there are other ways, but on this way I can test in a system that is equivalent to the target system, namely that of VCF Automation. I have already successfully used this approach to test several libraries via the Python execution environment in VCF Automation. This integration scenario opens up many new perspectives, but of course also challenges. But first it's good to know that it works and how it works.