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