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