2015-04-30 22:30:42 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# usage: ./generate.sh [versions]
|
|
|
|
# ie: ./generate.sh
|
|
|
|
# to update all Dockerfiles in this directory
|
|
|
|
# or: ./generate.sh
|
2015-12-19 23:27:02 +00:00
|
|
|
# to only update fedora-23/Dockerfile
|
2015-04-30 22:30:42 +00:00
|
|
|
# or: ./generate.sh fedora-newversion
|
|
|
|
# to create a new folder and a Dockerfile within it
|
|
|
|
|
|
|
|
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
|
|
|
|
|
|
|
|
versions=( "$@" )
|
|
|
|
if [ ${#versions[@]} -eq 0 ]; then
|
|
|
|
versions=( */ )
|
|
|
|
fi
|
|
|
|
versions=( "${versions[@]%/}" )
|
|
|
|
|
|
|
|
for version in "${versions[@]}"; do
|
|
|
|
distro="${version%-*}"
|
|
|
|
suite="${version##*-}"
|
|
|
|
from="${distro}:${suite}"
|
2015-10-27 17:25:39 +00:00
|
|
|
installer=yum
|
2016-11-09 17:16:13 +00:00
|
|
|
|
|
|
|
# TODO remove when offical image is available
|
|
|
|
if [[ "$from" == "fedora:25" ]]; then
|
|
|
|
from="andrewh5u/fedora-docker-base-25_beta:1.1"
|
|
|
|
fi
|
|
|
|
|
2015-12-19 23:27:02 +00:00
|
|
|
if [[ "$distro" == "fedora" ]]; then
|
2015-10-27 17:25:39 +00:00
|
|
|
installer=dnf
|
|
|
|
fi
|
2016-02-08 17:03:08 +00:00
|
|
|
if [[ "$distro" == "photon" ]]; then
|
|
|
|
installer=tdnf
|
|
|
|
fi
|
2015-04-30 22:30:42 +00:00
|
|
|
|
|
|
|
mkdir -p "$version"
|
|
|
|
echo "$version -> FROM $from"
|
|
|
|
cat > "$version/Dockerfile" <<-EOF
|
|
|
|
#
|
2015-11-23 19:00:43 +00:00
|
|
|
# THIS FILE IS AUTOGENERATED; SEE "contrib/builder/rpm/amd64/generate.sh"!
|
2015-04-30 22:30:42 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
FROM $from
|
|
|
|
EOF
|
|
|
|
|
|
|
|
echo >> "$version/Dockerfile"
|
|
|
|
|
2016-04-14 00:55:50 +00:00
|
|
|
extraBuildTags='pkcs11'
|
2016-03-22 00:37:31 +00:00
|
|
|
runcBuildTags=
|
2015-11-15 02:02:08 +00:00
|
|
|
|
2016-05-05 18:57:29 +00:00
|
|
|
case "$from" in
|
|
|
|
oraclelinux:6)
|
|
|
|
# We need a known version of the kernel-uek-devel headers to set CGO_CPPFLAGS, so grab the UEKR4 GA version
|
|
|
|
# This requires using yum-config-manager from yum-utils to enable the UEKR4 yum repo
|
|
|
|
echo "RUN yum install -y yum-utils && curl -o /etc/yum.repos.d/public-yum-ol6.repo http://yum.oracle.com/public-yum-ol6.repo && yum-config-manager -q --enable ol6_UEKR4" >> "$version/Dockerfile"
|
|
|
|
echo "RUN yum install -y kernel-uek-devel-4.1.12-32.el6uek" >> "$version/Dockerfile"
|
|
|
|
echo >> "$version/Dockerfile"
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
|
2015-04-30 22:30:42 +00:00
|
|
|
case "$from" in
|
|
|
|
centos:*)
|
|
|
|
# get "Development Tools" packages dependencies
|
|
|
|
echo 'RUN yum groupinstall -y "Development Tools"' >> "$version/Dockerfile"
|
2015-07-06 21:14:26 +00:00
|
|
|
|
|
|
|
if [[ "$version" == "centos-7" ]]; then
|
|
|
|
echo 'RUN yum -y swap -- remove systemd-container systemd-container-libs -- install systemd systemd-libs' >> "$version/Dockerfile"
|
|
|
|
fi
|
2015-04-30 22:30:42 +00:00
|
|
|
;;
|
2015-07-08 06:12:19 +00:00
|
|
|
oraclelinux:*)
|
|
|
|
# get "Development Tools" packages and dependencies
|
2016-01-07 21:09:47 +00:00
|
|
|
# we also need yum-utils for yum-config-manager to pull the latest repo file
|
2015-07-08 06:12:19 +00:00
|
|
|
echo 'RUN yum groupinstall -y "Development Tools"' >> "$version/Dockerfile"
|
|
|
|
;;
|
2015-09-15 20:13:22 +00:00
|
|
|
opensuse:*)
|
|
|
|
# get rpm-build and curl packages and dependencies
|
2015-09-23 11:48:06 +00:00
|
|
|
echo 'RUN zypper --non-interactive install ca-certificates* curl gzip rpm-build' >> "$version/Dockerfile"
|
2015-09-15 20:13:22 +00:00
|
|
|
;;
|
2016-02-08 17:03:08 +00:00
|
|
|
photon:*)
|
|
|
|
echo "RUN ${installer} install -y wget curl ca-certificates gzip make rpm-build sed gcc linux-api-headers glibc-devel binutils libseccomp libltdl-devel elfutils" >> "$version/Dockerfile"
|
|
|
|
;;
|
2015-04-30 22:30:42 +00:00
|
|
|
*)
|
2015-10-27 17:25:39 +00:00
|
|
|
echo "RUN ${installer} install -y @development-tools fedora-packager" >> "$version/Dockerfile"
|
2015-04-30 22:30:42 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
packages=(
|
|
|
|
btrfs-progs-devel # for "btrfs/ioctl.h" (and "version.h" if possible)
|
|
|
|
device-mapper-devel # for "libdevmapper.h"
|
|
|
|
glibc-static
|
2015-11-15 02:02:08 +00:00
|
|
|
libseccomp-devel # for "seccomp.h" & "libseccomp.so"
|
2015-04-30 22:30:42 +00:00
|
|
|
libselinux-devel # for "libselinux.so"
|
2015-11-14 16:04:41 +00:00
|
|
|
libtool-ltdl-devel # for pkcs11 "ltdl.h"
|
2016-01-22 23:38:38 +00:00
|
|
|
pkgconfig # for the pkg-config command
|
2015-08-25 19:34:25 +00:00
|
|
|
selinux-policy
|
|
|
|
selinux-policy-devel
|
2015-04-30 22:30:42 +00:00
|
|
|
sqlite-devel # for "sqlite3.h"
|
2016-01-22 23:38:38 +00:00
|
|
|
systemd-devel # for "sd-journal.h" and libraries
|
2015-07-09 21:34:39 +00:00
|
|
|
tar # older versions of dev-tools do not have tar
|
2016-03-22 00:37:31 +00:00
|
|
|
git # required for containerd and runc clone
|
2016-11-09 19:33:35 +00:00
|
|
|
cmake # tini build
|
2016-11-09 18:34:08 +00:00
|
|
|
vim-common # tini build
|
2015-04-30 22:30:42 +00:00
|
|
|
)
|
2015-07-09 21:34:39 +00:00
|
|
|
|
|
|
|
case "$from" in
|
|
|
|
oraclelinux:7)
|
|
|
|
# Enable the optional repository
|
|
|
|
packages=( --enablerepo=ol7_optional_latest "${packages[*]}" )
|
|
|
|
;;
|
|
|
|
esac
|
2015-09-15 20:13:22 +00:00
|
|
|
|
2016-01-22 23:38:38 +00:00
|
|
|
case "$from" in
|
|
|
|
oraclelinux:6)
|
|
|
|
# doesn't use systemd, doesn't have a devel package for it
|
|
|
|
packages=( "${packages[@]/systemd-devel}" )
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2015-11-15 02:02:08 +00:00
|
|
|
# opensuse & oraclelinx:6 do not have the right libseccomp libs
|
|
|
|
case "$from" in
|
2016-04-26 21:09:00 +00:00
|
|
|
opensuse:*|oraclelinux:6)
|
2015-11-15 02:02:08 +00:00
|
|
|
packages=( "${packages[@]/libseccomp-devel}" )
|
2016-03-22 00:37:31 +00:00
|
|
|
runcBuildTags="selinux"
|
2015-11-15 02:02:08 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
extraBuildTags+=' seccomp'
|
2016-03-22 00:37:31 +00:00
|
|
|
runcBuildTags="seccomp selinux"
|
2015-11-15 02:02:08 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2015-09-15 20:13:22 +00:00
|
|
|
case "$from" in
|
|
|
|
opensuse:*)
|
|
|
|
packages=( "${packages[@]/btrfs-progs-devel/libbtrfs-devel}" )
|
2016-01-22 23:38:38 +00:00
|
|
|
packages=( "${packages[@]/pkgconfig/pkg-config}" )
|
2016-11-10 23:44:29 +00:00
|
|
|
packages=( "${packages[@]/vim-common/vim}" )
|
2016-01-15 23:46:56 +00:00
|
|
|
if [[ "$from" == "opensuse:13."* ]]; then
|
|
|
|
packages+=( systemd-rpm-macros )
|
|
|
|
fi
|
|
|
|
|
2015-09-15 20:13:22 +00:00
|
|
|
# use zypper
|
2015-09-23 11:48:06 +00:00
|
|
|
echo "RUN zypper --non-interactive install ${packages[*]}" >> "$version/Dockerfile"
|
2015-09-15 20:13:22 +00:00
|
|
|
;;
|
2016-02-08 17:03:08 +00:00
|
|
|
photon:*)
|
|
|
|
packages=( "${packages[@]/pkgconfig/pkg-config}" )
|
|
|
|
echo "RUN ${installer} install -y ${packages[*]}" >> "$version/Dockerfile"
|
|
|
|
;;
|
2015-09-15 20:13:22 +00:00
|
|
|
*)
|
2015-10-27 17:25:39 +00:00
|
|
|
echo "RUN ${installer} install -y ${packages[*]}" >> "$version/Dockerfile"
|
2015-09-15 20:13:22 +00:00
|
|
|
;;
|
|
|
|
esac
|
2015-04-30 22:30:42 +00:00
|
|
|
|
|
|
|
echo >> "$version/Dockerfile"
|
|
|
|
|
2016-01-07 21:09:47 +00:00
|
|
|
|
2015-11-23 19:00:43 +00:00
|
|
|
awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../../Dockerfile >> "$version/Dockerfile"
|
2016-11-04 14:03:41 +00:00
|
|
|
echo 'RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local' >> "$version/Dockerfile"
|
2015-04-30 22:30:42 +00:00
|
|
|
echo 'ENV PATH $PATH:/usr/local/go/bin' >> "$version/Dockerfile"
|
|
|
|
|
|
|
|
echo >> "$version/Dockerfile"
|
|
|
|
|
|
|
|
echo 'ENV AUTO_GOPATH 1' >> "$version/Dockerfile"
|
|
|
|
|
2015-11-15 02:02:08 +00:00
|
|
|
echo >> "$version/Dockerfile"
|
|
|
|
|
|
|
|
# print build tags in alphabetical order
|
|
|
|
buildTags=$( echo "selinux $extraBuildTags" | xargs -n1 | sort -n | tr '\n' ' ' | sed -e 's/[[:space:]]*$//' )
|
|
|
|
|
|
|
|
echo "ENV DOCKER_BUILDTAGS $buildTags" >> "$version/Dockerfile"
|
2016-03-22 00:37:31 +00:00
|
|
|
echo "ENV RUNC_BUILDTAGS $runcBuildTags" >> "$version/Dockerfile"
|
2016-01-07 21:09:47 +00:00
|
|
|
echo >> "$version/Dockerfile"
|
|
|
|
|
|
|
|
case "$from" in
|
|
|
|
oraclelinux:6)
|
|
|
|
# We need to set the CGO_CPPFLAGS environment to use the updated UEKR4 headers with all the userns stuff.
|
|
|
|
# The ordering is very important and should not be changed.
|
|
|
|
echo 'ENV CGO_CPPFLAGS -D__EXPORTED_HEADERS__ \' >> "$version/Dockerfile"
|
|
|
|
echo ' -I/usr/src/kernels/4.1.12-32.el6uek.x86_64/arch/x86/include/generated/uapi \' >> "$version/Dockerfile"
|
|
|
|
echo ' -I/usr/src/kernels/4.1.12-32.el6uek.x86_64/arch/x86/include/uapi \' >> "$version/Dockerfile"
|
|
|
|
echo ' -I/usr/src/kernels/4.1.12-32.el6uek.x86_64/include/generated/uapi \' >> "$version/Dockerfile"
|
|
|
|
echo ' -I/usr/src/kernels/4.1.12-32.el6uek.x86_64/include/uapi \' >> "$version/Dockerfile"
|
|
|
|
echo ' -I/usr/src/kernels/4.1.12-32.el6uek.x86_64/include' >> "$version/Dockerfile"
|
|
|
|
echo >> "$version/Dockerfile"
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
2015-04-30 22:30:42 +00:00
|
|
|
done
|