| 1 |
#!/bin/bash |
| 2 |
# shellcheck disable=SC1091 |
| 3 |
############################################################################### |
| 4 |
# Copyright (C) Intel Corporation |
| 5 |
# |
| 6 |
# SPDX-License-Identifier: MIT |
| 7 |
############################################################################### |
| 8 |
# Install dependencies. |
| 9 |
# |
| 10 |
# This script should not call other scripts in the repository so that it can |
| 11 |
# potentialy be an argument to the COPY command in a Dockerfile |
| 12 |
|
| 13 |
set -o errexit |
| 14 |
|
| 15 |
if [ -f "/etc/os-release" ]; then |
| 16 |
. /etc/os-release |
| 17 |
fi |
| 18 |
if [ -z "$ID_LIKE" ]; then |
| 19 |
ID_LIKE="$ID" |
| 20 |
fi |
| 21 |
if [ "$ID_LIKE" == "debian" ]; then |
| 22 |
apt-get update |
| 23 |
# basic build tools |
| 24 |
apt-get install -y --no-install-recommends \ |
| 25 |
build-essential \ |
| 26 |
cmake \ |
| 27 |
pkg-config |
| 28 |
# tool build dependencies |
| 29 |
apt-get install -y --no-install-recommends \ |
| 30 |
libdrm-dev \ |
| 31 |
libva-dev \ |
| 32 |
libx11-dev \ |
| 33 |
libx11-xcb-dev \ |
| 34 |
libxcb-present-dev \ |
| 35 |
libxcb-dri3-dev \ |
| 36 |
libwayland-dev \ |
| 37 |
wayland-protocols |
| 38 |
|
| 39 |
# lint prerequisites |
| 40 |
apt-get install -y --no-install-recommends \ |
| 41 |
git \ |
| 42 |
pipx |
| 43 |
pipx ensurepath --force |
| 44 |
pipx install pre-commit |
| 45 |
elif [ "$ID_LIKE" == "fedora" ]; then |
| 46 |
# Add media driver repositories |
| 47 |
dnf install -y 'dnf-command(config-manager)' |
| 48 |
dnf config-manager --add-repo \ |
| 49 |
https://repositories.intel.com/gpu/rhel/${VERSION_ID}/lts/2350/unified/intel-gpu-${VERSION_ID}.repo |
| 50 |
dnf clean all && dnf makecache && dnf upgrade -y |
| 51 |
# basic build tools |
| 52 |
dnf install -y cmake gcc-c++ |
| 53 |
# prerequsites to build examples |
| 54 |
dnf install -y libva-devel |
| 55 |
dnf install -y libX11-devel |
| 56 |
dnf install -y wayland-protocols-devel |
| 57 |
dnf install -y python3-pip |
| 58 |
# libdrm from source |
| 59 |
dnf install -y python3-pip git |
| 60 |
pip3 install meson ninja |
| 61 |
pushd /tmp |
| 62 |
if [ ! "$(pkg-config --modversion pciaccess)" = "0.17" ]; then |
| 63 |
git clone -b libpciaccess-0.17 https://gitlab.freedesktop.org/xorg/lib/libpciaccess.git |
| 64 |
pushd libpciaccess |
| 65 |
meson builddir --prefix=/usr |
| 66 |
ninja -C builddir install |
| 67 |
popd |
| 68 |
rm -rf /libpciaccess |
| 69 |
fi |
| 70 |
if [ ! "$(pkg-config --modversion libdrm)" = "2.4.113" ]; then |
| 71 |
git clone -b libdrm-2.4.113 https://gitlab.freedesktop.org/mesa/drm.git |
| 72 |
pushd drm |
| 73 |
meson builddir --prefix=/usr |
| 74 |
ninja -C builddir install |
| 75 |
popd |
| 76 |
rm -rf drm |
| 77 |
fi |
| 78 |
popd |
| 79 |
# lint dependencies |
| 80 |
pip3 install pre-commit |
| 81 |
elif [ "$ID_LIKE" == "rhel fedora" ]; then |
| 82 |
# basic build tools |
| 83 |
yum install -y centos-release-scl |
| 84 |
yum-config-manager --enable rhel-server-rhscl-7-rpms |
| 85 |
yum install -y devtoolset-9 |
| 86 |
|
| 87 |
# cmake |
| 88 |
if [ ! "$(cmake --version |head -1|cut -f3 -d' ')" = "3.22.1" ]; then |
| 89 |
yum install -y openssl-devel |
| 90 |
cd /tmp |
| 91 |
rm -rf cmake-3.* |
| 92 |
curl -O -L --retry 5 \ |
| 93 |
https://github.com/Kitware/CMake/releases/download/v3.22.1/cmake-3.22.1.tar.gz |
| 94 |
tar zxvf cmake-3.* |
| 95 |
cd cmake-3.* |
| 96 |
source /opt/rh/devtoolset-9/enable |
| 97 |
./bootstrap --prefix=/usr/local --parallel="$(nproc)" |
| 98 |
make -j"$(nproc)" |
| 99 |
make install |
| 100 |
fi |
| 101 |
|
| 102 |
# xcb and wayland |
| 103 |
yum -y update |
| 104 |
yum -y install wayland-devel libX11-devel libXext-devel libXfixes-devel libpciaccess-devel |
| 105 |
if [ ! "$(pkg-config --modversion wayland-protocols)" = "1.15" ]; then |
| 106 |
cd /tmp |
| 107 |
rm -rf wayland-protocols-1.15 |
| 108 |
curl -O -L --retry 5 \ |
| 109 |
https://wayland.freedesktop.org/releases/wayland-protocols-1.15.tar.xz |
| 110 |
tar -xJf wayland-protocols-1.15.tar.xz |
| 111 |
cd wayland-protocols-1.15 |
| 112 |
./configure --prefix="/usr" --bindir="/usr/bin" --libdir="/usr/lib64" |
| 113 |
make install |
| 114 |
fi |
| 115 |
|
| 116 |
# libva |
| 117 |
yum install -y \ |
| 118 |
bzip2 \ |
| 119 |
libdrm-devel |
| 120 |
if [ ! "$(pkg-config --variable=libva_version libva)" = "2.10.0" ]; then |
| 121 |
cd /tmp |
| 122 |
rm -rf libva-2.10.0 |
| 123 |
curl -O -L --retry 5 \ |
| 124 |
https://github.com/intel/libva/releases/download/2.10.0/libva-2.10.0.tar.bz2 |
| 125 |
tar xjf libva-2.10.0.tar.bz2 |
| 126 |
source /opt/rh/devtoolset-9/enable |
| 127 |
cd libva-2.10.0 |
| 128 |
./configure --prefix="/usr" --enable-wayland --enable-x11 --bindir="/usr/bin" --libdir="/usr/lib64" |
| 129 |
make |
| 130 |
make install |
| 131 |
fi |
| 132 |
|
| 133 |
# pre-commit prerequisites |
| 134 |
yum install -y git |
| 135 |
yum install -y \ |
| 136 |
openssl-devel \ |
| 137 |
bzip2-devel \ |
| 138 |
libffi-devel \ |
| 139 |
sqlite-devel |
| 140 |
if [ ! "$(python3 --version |head -1|cut -f2 -d' ')" == "3.8.9" ]; then |
| 141 |
cd /tmp |
| 142 |
rm -rf Python-3.* |
| 143 |
curl -O -L --retry 5 \ |
| 144 |
https://www.python.org/ftp/python/3.8.9/Python-3.8.9.tgz |
| 145 |
tar xvf Python-3.8.9.tgz |
| 146 |
source /opt/rh/devtoolset-9/enable |
| 147 |
cd Python-3.*/ |
| 148 |
./configure --enable-optimizations --enable-loadable-sqlite-extensions \ |
| 149 |
--prefix=/usr --with-openssl=/etc/pki/tls --with-openssl-rpath=auto |
| 150 |
./configure --enable-optimizations --enable-loadable-sqlite-extensions |
| 151 |
make install |
| 152 |
fi |
| 153 |
# lint dependencies |
| 154 |
pip3 install pre-commit |
| 155 |
else |
| 156 |
if [ -z ${ID_LIKE+x} ]; then |
| 157 |
echo "Error: unknown OS distribution" |
| 158 |
else |
| 159 |
echo "Error: unknown OS distribution '$ID_LIKE'" |
| 160 |
fi |
| 161 |
exit 1 |
| 162 |
fi |