github.com/fabiokung/docker@v0.11.2-0.20170222101415-4534dcd49497/contrib/builder/rpm/amd64/generate.sh (about) 1 #!/usr/bin/env 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:*|amazonlinux:latest) 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 systemd-devel # for "sd-journal.h" and libraries 99 tar # older versions of dev-tools do not have tar 100 git # required for containerd and runc clone 101 cmake # tini build 102 vim-common # tini build 103 ) 104 105 case "$from" in 106 oraclelinux:7) 107 # Enable the optional repository 108 packages=( --enablerepo=ol7_optional_latest "${packages[*]}" ) 109 ;; 110 esac 111 112 case "$from" in 113 oraclelinux:6|amazonlinux:latest) 114 # doesn't use systemd, doesn't have a devel package for it 115 packages=( "${packages[@]/systemd-devel}" ) 116 ;; 117 esac 118 119 # opensuse & oraclelinx:6 do not have the right libseccomp libs 120 case "$from" in 121 opensuse:*|oraclelinux:6) 122 packages=( "${packages[@]/libseccomp-devel}" ) 123 runcBuildTags="selinux" 124 ;; 125 *) 126 extraBuildTags+=' seccomp' 127 runcBuildTags="seccomp selinux" 128 ;; 129 esac 130 131 case "$from" in 132 opensuse:*) 133 packages=( "${packages[@]/btrfs-progs-devel/libbtrfs-devel}" ) 134 packages=( "${packages[@]/pkgconfig/pkg-config}" ) 135 packages=( "${packages[@]/vim-common/vim}" ) 136 if [[ "$from" == "opensuse:13."* ]]; then 137 packages+=( systemd-rpm-macros ) 138 fi 139 140 # use zypper 141 echo "RUN zypper --non-interactive install ${packages[*]}" >> "$version/Dockerfile" 142 ;; 143 photon:*) 144 packages=( "${packages[@]/pkgconfig/pkg-config}" ) 145 echo "RUN ${installer} install -y ${packages[*]}" >> "$version/Dockerfile" 146 ;; 147 *) 148 echo "RUN ${installer} install -y ${packages[*]}" >> "$version/Dockerfile" 149 ;; 150 esac 151 152 echo >> "$version/Dockerfile" 153 154 155 awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../../Dockerfile >> "$version/Dockerfile" 156 echo 'RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local' >> "$version/Dockerfile" 157 echo 'ENV PATH $PATH:/usr/local/go/bin' >> "$version/Dockerfile" 158 159 echo >> "$version/Dockerfile" 160 161 echo 'ENV AUTO_GOPATH 1' >> "$version/Dockerfile" 162 163 echo >> "$version/Dockerfile" 164 165 # print build tags in alphabetical order 166 buildTags=$( echo "selinux $extraBuildTags" | xargs -n1 | sort -n | tr '\n' ' ' | sed -e 's/[[:space:]]*$//' ) 167 168 echo "ENV DOCKER_BUILDTAGS $buildTags" >> "$version/Dockerfile" 169 echo "ENV RUNC_BUILDTAGS $runcBuildTags" >> "$version/Dockerfile" 170 echo >> "$version/Dockerfile" 171 172 case "$from" in 173 oraclelinux:6) 174 # We need to set the CGO_CPPFLAGS environment to use the updated UEKR4 headers with all the userns stuff. 175 # The ordering is very important and should not be changed. 176 echo 'ENV CGO_CPPFLAGS -D__EXPORTED_HEADERS__ \' >> "$version/Dockerfile" 177 echo ' -I/usr/src/kernels/4.1.12-32.el6uek.x86_64/arch/x86/include/generated/uapi \' >> "$version/Dockerfile" 178 echo ' -I/usr/src/kernels/4.1.12-32.el6uek.x86_64/arch/x86/include/uapi \' >> "$version/Dockerfile" 179 echo ' -I/usr/src/kernels/4.1.12-32.el6uek.x86_64/include/generated/uapi \' >> "$version/Dockerfile" 180 echo ' -I/usr/src/kernels/4.1.12-32.el6uek.x86_64/include/uapi \' >> "$version/Dockerfile" 181 echo ' -I/usr/src/kernels/4.1.12-32.el6uek.x86_64/include' >> "$version/Dockerfile" 182 echo >> "$version/Dockerfile" 183 ;; 184 *) ;; 185 esac 186 187 188 done