#!/usr/bin/with-contenv bash

# Determine if setup is needed
if [ ! -f "/usr/bin/apt" ]; then
    echo "**** Image is not Ubuntu, skipping opencl-intel install ****"
    exit 0
fi

if [ $(uname -m) != "x86_64" ]; then
    echo "**** Opencl-intel only works on X86_64, skipping ****"
    exit 0
fi

if [ -d /opencl-intel-legacy1 ]; then
    echo "**** Installing/updating opencl-intel legacy1 debs and adding clinfo to package install list ****"
    dpkg -i /opencl-intel-legacy1/*.deb
    rm -rf /opencl-intel-legacy1
    echo "clinfo" >> /mod-repo-packages-to-install.list
else
    echo "**** Opencl-intel-legacy1 already installed ****"
fi

if [ -d /opencl-intel ]; then
    echo "**** Installing/updating opencl-intel debs and adding clinfo to package install list ****"
    dpkg -i /opencl-intel/*.deb
    rm -rf /opencl-intel
    echo "clinfo" >> /mod-repo-packages-to-install.list
else
    echo "**** Opencl-intel already installed ****"
fi
