github.com/openshift/moby@v1.13.1/contrib/builder/rpm/amd64/generate.sh (about)

     1  #!/bin/bash
     2  set -e
     3  
     4  # usage: ./generate.sh [versions]
     5  #    ie: ./generate.sh
     6  #        to update all Dockerfiles in this directory
     7  #    or: ./generate.sh centos-7
     8  #        to only update centos-7/Dockerfile
     9  #    or: ./generate.sh fedora-newversion
    10  #        to create a new folder and a Dockerfile within it
    11  
    12  cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
    13  
    14  versions=( "$@" )
    15  if [ ${#versions[@]} -eq 0 ]; then
    16  	versions=( */ )
    17  fi
    18  versions=( "${versions[@]%/}" )
    19  
    20  for version in "${versions[@]}"; do
    21  	distro="${version%-*}"
    22  	suite="${version##*-}"
    23  	from="${distro}:${suite}"
    24  	installer=yum
    25  
    26  	if [[ "$distro" == "fedora" ]]; then
    27  		installer=dnf
    28  	fi
    29  	if [[ "$distro" == "photon" ]]; then
    30  		installer=tdnf
    31  	fi
    32  
    33  	mkdir -p "$version"
    34  	echo "$version -> FROM $from"
    35  	cat > "$version/Dockerfile" <<-EOF
    36  		#
    37  		# THIS FILE IS AUTOGENERATED; SEE "contrib/builder/rpm/amd64/generate.sh"!
    38  		#
    39  
    40  		FROM $from
    41  	EOF
    42  
    43  	echo >> "$version/Dockerfile"
    44  
    45  	extraBuildTags='pkcs11'
    46  	runcBuildTags=
    47  
    48  	case "$from" in
    49  		oraclelinux:6)
    50  			# We need a known version of the kernel-uek-devel headers to set CGO_CPPFLAGS, so grab the UEKR4 GA version
    51  			# This requires using yum-config-manager from yum-utils to enable the UEKR4 yum repo
    52  			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"
    53  			echo "RUN yum install -y kernel-uek-devel-4.1.12-32.el6uek"  >> "$version/Dockerfile"
    54  			echo >> "$version/Dockerfile"
    55  			;;
    56  		fedora:*)
    57  			echo "RUN ${installer} -y upgrade" >> "$version/Dockerfile"
    58  			;;
    59  		*) ;;
    60  	esac
    61  
    62  	case "$from" in
    63  		centos:*)
    64  			# get "Development Tools" packages dependencies
    65  			echo 'RUN yum groupinstall -y "Development Tools"' >> "$version/Dockerfile"
    66  
    67  			if [[ "$version" == "centos-7" ]]; then
    68  				echo 'RUN yum -y swap -- remove systemd-container systemd-container-libs -- install systemd systemd-libs' >> "$version/Dockerfile"
    69  			fi
    70  			;;
    71  		oraclelinux:*)
    72  			# get "Development Tools" packages and dependencies
    73  			# we also need yum-utils for yum-config-manager to pull the latest repo file
    74  			echo 'RUN yum groupinstall -y "Development Tools"' >> "$version/Dockerfile"
    75  			;;
    76  		opensuse:*)
    77  			# get rpm-build and curl packages and dependencies
    78  			echo 'RUN zypper --non-interactive install ca-certificates* curl gzip rpm-build' >> "$version/Dockerfile"
    79  			;;
    80  		photon:*)
    81  			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"
    82  			;;
    83  		*)
    84  			echo "RUN ${installer} install -y @development-tools fedora-packager" >> "$version/Dockerfile"
    85  			;;
    86  	esac
    87  
    88  	packages=(
    89  		btrfs-progs-devel # for "btrfs/ioctl.h" (and "version.h" if possible)
    90  		device-mapper-devel # for "libdevmapper.h"
    91  		glibc-static
    92  		libseccomp-devel # for "seccomp.h" & "libseccomp.so"
    93  		libselinux-devel # for "libselinux.so"
    94  		libtool-ltdl-devel # for pkcs11 "ltdl.h"
    95  		pkgconfig # for the pkg-config command
    96  		selinux-policy
    97  		selinux-policy-devel
    98  		sqlite-devel # for "sqlite3.h"
    99  		systemd-devel # for "sd-journal.h" and libraries
   100  		tar # older versions of dev-tools do not have tar
   101  		git # required for containerd and runc clone
   102  		cmake # tini build
   103  		vim-common # tini build
   104  	)
   105  
   106  	case "$from" in
   107  		oraclelinux:7)
   108  			# Enable the optional repository
   109  			packages=( --enablerepo=ol7_optional_latest "${packages[*]}" )
   110  			;;
   111  	esac
   112  
   113  	case "$from" in
   114  		oraclelinux:6)
   115  			# doesn't use systemd, doesn't have a devel package for it
   116  			packages=( "${packages[@]/systemd-devel}" )
   117  			;;
   118  	esac
   119  
   120  	# opensuse & oraclelinx:6 do not have the right libseccomp libs
   121  	case "$from" in
   122  		opensuse:*|oraclelinux:6)
   123  			packages=( "${packages[@]/libseccomp-devel}" )
   124  			runcBuildTags="selinux"
   125  			;;
   126  		*)
   127  			extraBuildTags+=' seccomp'
   128  			runcBuildTags="seccomp selinux"
   129  			;;
   130  	esac
   131  
   132  	case "$from" in
   133  		opensuse:*)
   134  			packages=( "${packages[@]/btrfs-progs-devel/libbtrfs-devel}" )
   135  			packages=( "${packages[@]/pkgconfig/pkg-config}" )
   136  			packages=( "${packages[@]/vim-common/vim}" )
   137  			if [[ "$from" == "opensuse:13."* ]]; then
   138  				packages+=( systemd-rpm-macros )
   139  			fi
   140  
   141  			# use zypper
   142  			echo "RUN zypper --non-interactive install ${packages[*]}" >> "$version/Dockerfile"
   143  			;;
   144  		photon:*)
   145  			packages=( "${packages[@]/pkgconfig/pkg-config}" )
   146  			echo "RUN ${installer} install -y ${packages[*]}" >> "$version/Dockerfile"
   147  			;;
   148  		*)
   149  			echo "RUN ${installer} install -y ${packages[*]}" >> "$version/Dockerfile"
   150  			;;
   151  	esac
   152  
   153  	echo >> "$version/Dockerfile"
   154  
   155  
   156  	awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../../Dockerfile >> "$version/Dockerfile"
   157  	echo 'RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local' >> "$version/Dockerfile"
   158  	echo 'ENV PATH $PATH:/usr/local/go/bin' >> "$version/Dockerfile"
   159  
   160  	echo >> "$version/Dockerfile"
   161  
   162  	echo 'ENV AUTO_GOPATH 1' >> "$version/Dockerfile"
   163  
   164  	echo >> "$version/Dockerfile"
   165  
   166  	# print build tags in alphabetical order
   167  	buildTags=$( echo "selinux $extraBuildTags" | xargs -n1 | sort -n | tr '\n' ' ' | sed -e 's/[[:space:]]*$//' )
   168  
   169  	echo "ENV DOCKER_BUILDTAGS $buildTags" >> "$version/Dockerfile"
   170  	echo "ENV RUNC_BUILDTAGS $runcBuildTags" >> "$version/Dockerfile"
   171  	echo >> "$version/Dockerfile"
   172  
   173  	case "$from" in
   174                  oraclelinux:6)
   175                          # We need to set the CGO_CPPFLAGS environment to use the updated UEKR4 headers with all the userns stuff.
   176                          # The ordering is very important and should not be changed.
   177                          echo 'ENV CGO_CPPFLAGS -D__EXPORTED_HEADERS__ \'  >> "$version/Dockerfile"
   178                          echo '                 -I/usr/src/kernels/4.1.12-32.el6uek.x86_64/arch/x86/include/generated/uapi \'  >> "$version/Dockerfile"
   179                          echo '                 -I/usr/src/kernels/4.1.12-32.el6uek.x86_64/arch/x86/include/uapi \'  >> "$version/Dockerfile"
   180                          echo '                 -I/usr/src/kernels/4.1.12-32.el6uek.x86_64/include/generated/uapi \'  >> "$version/Dockerfile"
   181                          echo '                 -I/usr/src/kernels/4.1.12-32.el6uek.x86_64/include/uapi \'  >> "$version/Dockerfile"
   182                          echo '                 -I/usr/src/kernels/4.1.12-32.el6uek.x86_64/include'  >> "$version/Dockerfile"
   183                          echo >> "$version/Dockerfile"
   184                          ;;
   185                  *) ;;
   186          esac
   187  
   188  
   189  done