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