github.com/ruphin/docker@v1.10.1/contrib/builder/rpm/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/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 # fedora does not have a libseccomp.a for compiling static dockerinit 126 # ONLY install libseccomp.a from source, this can be removed once dockerinit is removed 127 # TODO remove this manual seccomp compilation once dockerinit is gone or no longer needs to be statically compiled 128 case "$from" in 129 fedora:*) 130 awk '$1 == "ENV" && $2 == "SECCOMP_VERSION" { print; exit }' ../../../Dockerfile >> "$version/Dockerfile" 131 cat <<-'EOF' >> "$version/Dockerfile" 132 RUN buildDeps=' \ 133 automake \ 134 libtool \ 135 ' \ 136 && set -x \ 137 && yum install -y $buildDeps \ 138 && export SECCOMP_PATH=$(mktemp -d) \ 139 && git clone -b "$SECCOMP_VERSION" --depth 1 https://github.com/seccomp/libseccomp.git "$SECCOMP_PATH" \ 140 && ( \ 141 cd "$SECCOMP_PATH" \ 142 && ./autogen.sh \ 143 && ./configure --prefix=/usr \ 144 && make \ 145 && install -c src/.libs/libseccomp.a /usr/lib/libseccomp.a \ 146 && chmod 644 /usr/lib/libseccomp.a \ 147 && ranlib /usr/lib/libseccomp.a \ 148 && ldconfig -n /usr/lib \ 149 ) \ 150 && rm -rf "$SECCOMP_PATH" 151 EOF 152 153 echo >> "$version/Dockerfile" 154 ;; 155 *) ;; 156 esac 157 158 case "$from" in 159 oraclelinux:6) 160 # We need a known version of the kernel-uek-devel headers to set CGO_CPPFLAGS, so grab the UEKR4 GA version 161 # This requires using yum-config-manager from yum-utils to enable the UEKR4 yum repo 162 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" 163 echo "RUN yum install -y kernel-uek-devel-4.1.12-32.el6uek" >> "$version/Dockerfile" 164 echo >> "$version/Dockerfile" 165 ;; 166 *) ;; 167 esac 168 169 170 awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../Dockerfile >> "$version/Dockerfile" 171 echo 'RUN curl -fSL "https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local' >> "$version/Dockerfile" 172 echo 'ENV PATH $PATH:/usr/local/go/bin' >> "$version/Dockerfile" 173 174 echo >> "$version/Dockerfile" 175 176 echo 'ENV AUTO_GOPATH 1' >> "$version/Dockerfile" 177 178 echo >> "$version/Dockerfile" 179 180 # print build tags in alphabetical order 181 buildTags=$( echo "selinux $extraBuildTags" | xargs -n1 | sort -n | tr '\n' ' ' | sed -e 's/[[:space:]]*$//' ) 182 183 echo "ENV DOCKER_BUILDTAGS $buildTags" >> "$version/Dockerfile" 184 echo >> "$version/Dockerfile" 185 186 case "$from" in 187 oraclelinux:6) 188 # We need to set the CGO_CPPFLAGS environment to use the updated UEKR4 headers with all the userns stuff. 189 # The ordering is very important and should not be changed. 190 echo 'ENV CGO_CPPFLAGS -D__EXPORTED_HEADERS__ \' >> "$version/Dockerfile" 191 echo ' -I/usr/src/kernels/4.1.12-32.el6uek.x86_64/arch/x86/include/generated/uapi \' >> "$version/Dockerfile" 192 echo ' -I/usr/src/kernels/4.1.12-32.el6uek.x86_64/arch/x86/include/uapi \' >> "$version/Dockerfile" 193 echo ' -I/usr/src/kernels/4.1.12-32.el6uek.x86_64/include/generated/uapi \' >> "$version/Dockerfile" 194 echo ' -I/usr/src/kernels/4.1.12-32.el6uek.x86_64/include/uapi \' >> "$version/Dockerfile" 195 echo ' -I/usr/src/kernels/4.1.12-32.el6uek.x86_64/include' >> "$version/Dockerfile" 196 echo >> "$version/Dockerfile" 197 ;; 198 *) ;; 199 esac 200 201 202 done