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