# spec-sw Dockerfile ubuntu 16.04
#
#

# Pull base image.
FROM ubuntu:16.04

# Install.
RUN \
	apt-get update &&\
	apt-get upgrade -y &&\
	apt-get install -y git \
	build-essential \
	python-minimal \
	wget \
	libreadline-dev \
	kmod \
	linux-headers-4.4.0-21-generic \
	linux-headers-4.8.0-34-generic \
	linux-headers-4.10.0-14-generic \
	linux-headers-4.13.0-16-generic \
	linux-headers-4.15.0-13-generic

# Clone repository and detach HEAD
RUN \
	git clone https://ohwr.org/project/wr-starting-kit.git &&\
	cd wr-starting-kit &&\
	# TODO: preliminary commit for wr-starting-kit-v3.0
	git checkout 50f368abff0d4aed8223858f552b3184249695d2

# The kernel version 4.4.0-21-generic does not work

#set enviroment variable for kernel version 4.8.0-34-generic
ENV LINUX /lib/modules/4.8.0-34-generic/build

#construction spec-sw for kernel version 4.8.0-34-generic
RUN \
	cd wr-starting-kit &&\
	make clean &&\
	make &&\
	make install

#set enviroment variable for kernel version 4.10.0-14-generic
ENV LINUX /lib/modules/4.10.0-14-generic/build

#construction spec-sw for kernel version 4.10.0-14-generic
RUN \
	cd wr-starting-kit &&\
	make clean &&\
	make &&\
	make install

#set enviroment variable for kernel version 4.13.0-16-generic
ENV LINUX /lib/modules/4.13.0-16-generic/build

#construction spec-sw for kernel version 4.13.0-16-generic
RUN \
	cd wr-starting-kit &&\
	make clean &&\
	make &&\
	make install

#set enviroment variable for kernel version 4.15.0-13-generic
ENV LINUX /lib/modules/4.15.0-13-generic/build

#construction spec-sw for kernel version 4.15.0-13-generic
RUN \
	cd wr-starting-kit &&\
	make clean &&\
	make &&\
	make install

#create file FRU
RUN \
	cd /wr-starting-kit/spec-sw/fmc-bus/tools &&\
	FRU_VENDOR="CERN" FRU_NAME="FmcDio5cha" FRU_PART="EDA-02408-V2-0" \
	./fru-generator -s  7S-WR-FMCDIO5ch-2.0-Sx.yyy > example.bin

# Define default command.
CMD ["bash"]
