# common script for all images
.run-scripts: &run-scripts
  - export LINUX=/lib/modules/$KVERSION/build
  - export BUILD_DIR=$(mktemp -d)
  - echo "Building under $BUILD_DIR"
  - cd scripts
  - bash wrtd_ref_spec150t_adc_install.sh
  - bash wrtd_ref_svec_tdc_fd_install.sh
  - for script in *.sh; do bash $script; done

#Arch Linux:
#  image: archlinux:latest
#  script:
#    - >
#      pacman --noconfirm -Sy && pacman --noconfirm -S
#      patch sudo gcc make git lua51
#      linux linux-headers
#      python-setuptools python-yaml python-decorator
#    - ln -s /usr/bin/lua5.1 /usr/local/bin/lua
#    - echo "search extra" > /etc/depmod.d/ohwr_extra.conf
#    - export KVERSION=$(basename /lib/modules/*)
#    - export LINUX=/lib/modules/$KVERSION/build
#    - export BUILD_DIR=$(mktemp -d)
#    - echo "Building under $BUILD_DIR"
#    - cd scripts
#    - for script in *.sh; do bash $script; done

# Ubuntu 18.04 LTS:
#   image: ubuntu:18.04
#   script:
#     - export KVERSION="5.0.0-31-generic"
#     - >
#       apt-get update && apt-get --no-install-recommends -qy install
#       ca-certificates sudo git build-essential
#       linux-image-$KVERSION linux-modules-extra-$KVERSION linux-headers-$KVERSION python
#       python-setuptools python-yaml python-decorator
#       lua5.1 curl libreadline-dev
#     - *run-scripts

# Debian Buster:
#   image: debian:buster
#   script:
#     - >
#       apt-get update && apt-get --no-install-recommends -qy install
#       ca-certificates sudo git build-essential
#       linux-image-amd64 linux-headers-amd64 python
#       python-setuptools python-yaml python-decorator
#       lua5.1 curl libreadline-dev
#     - export KVERSION=$(ls /lib/modules/)
#     - *run-scripts

Debian Bullseye:
  image: debian:bullseye
  script:
    - >
      apt update && apt-get --no-install-recommends -qy install
      ca-certificates sudo git build-essential
      linux-image-amd64 linux-headers-amd64 python3
      python3-setuptools python3-yaml python3-decorator
      lua5.1 curl libreadline-dev
    - ln -sf /usr/bin/python3 /usr/local/bin/python
    - export KVERSION=$(ls /lib/modules/)
    - *run-scripts

CentOS 7:
  image: centos:7
  script:
    - sed -i 's/plugins=.*/plugins=1/' /etc/yum.conf
    - sed -i '/gpgcheck=1/ a priority=1' /etc/yum.repos.d/CentOS-Base.repo
    - sed -i '/^[centosplus]/,/^$/ {s/enabled=.*$/enabled=1/}' /etc/yum.repos.d/CentOS-Base.repo
    - sed -i '/^[centosplus]/,/^$/ {s/priority=.*$/priority=5/}' /etc/yum.repos.d/CentOS-Base.repo
    - >
      yum install -q -y
      kernel-plus kernel-plus-devel kernel-plus-headers
      git sudo gcc make readline-devel patch
      python-setuptools python-yaml python-decorator
    - export KVERSION=$(basename /lib/modules/*plus*)
    - *run-scripts
