github.com/walkingsparrow/docker@v1.4.2-0.20151218153551-b708a2249bfa/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-20/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" ]] && [[ "$suite" -ge "22" ]]; 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 echo 'RUN yum groupinstall -y "Development Tools"' >> "$version/Dockerfile" 55 ;; 56 opensuse:*) 57 # get rpm-build and curl packages and dependencies 58 echo 'RUN zypper --non-interactive install ca-certificates* curl gzip rpm-build' >> "$version/Dockerfile" 59 ;; 60 *) 61 echo "RUN ${installer} install -y @development-tools fedora-packager" >> "$version/Dockerfile" 62 ;; 63 esac 64 65 # this list is sorted alphabetically; please keep it that way 66 packages=( 67 btrfs-progs-devel # for "btrfs/ioctl.h" (and "version.h" if possible) 68 device-mapper-devel # for "libdevmapper.h" 69 glibc-static 70 libseccomp-devel # for "seccomp.h" & "libseccomp.so" 71 libselinux-devel # for "libselinux.so" 72 libtool-ltdl-devel # for pkcs11 "ltdl.h" 73 selinux-policy 74 selinux-policy-devel 75 sqlite-devel # for "sqlite3.h" 76 tar # older versions of dev-tools do not have tar 77 ) 78 79 case "$from" in 80 oraclelinux:7) 81 # Enable the optional repository 82 packages=( --enablerepo=ol7_optional_latest "${packages[*]}" ) 83 ;; 84 esac 85 86 # opensuse & oraclelinx:6 do not have the right libseccomp libs 87 case "$from" in 88 opensuse:*|oraclelinux:6) 89 packages=( "${packages[@]/libseccomp-devel}" ) 90 ;; 91 *) 92 extraBuildTags+=' seccomp' 93 ;; 94 esac 95 96 case "$from" in 97 opensuse:*) 98 packages=( "${packages[@]/btrfs-progs-devel/libbtrfs-devel}" ) 99 # use zypper 100 echo "RUN zypper --non-interactive install ${packages[*]}" >> "$version/Dockerfile" 101 ;; 102 *) 103 echo "RUN ${installer} install -y ${packages[*]}" >> "$version/Dockerfile" 104 ;; 105 esac 106 107 echo >> "$version/Dockerfile" 108 109 # centos, fedora, & oraclelinux:7 do not have a libseccomp.a for compiling static dockerinit 110 # ONLY install libseccomp.a from source, this can be removed once dockerinit is removed 111 # TODO remove this manual seccomp compilation once dockerinit is gone or no longer needs to be statically compiled 112 case "$from" in 113 opensuse:*|oraclelinux:6) ;; 114 *) 115 awk '$1 == "ENV" && $2 == "SECCOMP_VERSION" { print; exit }' ../../../Dockerfile >> "$version/Dockerfile" 116 cat <<-'EOF' >> "$version/Dockerfile" 117 RUN buildDeps=' \ 118 automake \ 119 libtool \ 120 ' \ 121 && set -x \ 122 && yum install -y $buildDeps \ 123 && export SECCOMP_PATH=$(mktemp -d) \ 124 && git clone -b "$SECCOMP_VERSION" --depth 1 https://github.com/seccomp/libseccomp.git "$SECCOMP_PATH" \ 125 && ( \ 126 cd "$SECCOMP_PATH" \ 127 && ./autogen.sh \ 128 && ./configure --prefix=/usr \ 129 && make \ 130 && install -c src/.libs/libseccomp.a /usr/lib/libseccomp.a \ 131 && chmod 644 /usr/lib/libseccomp.a \ 132 && ranlib /usr/lib/libseccomp.a \ 133 && ldconfig -n /usr/lib \ 134 ) \ 135 && rm -rf "$SECCOMP_PATH" 136 EOF 137 138 echo >> "$version/Dockerfile" 139 ;; 140 esac 141 142 awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../Dockerfile >> "$version/Dockerfile" 143 echo 'RUN curl -fSL "https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local' >> "$version/Dockerfile" 144 echo 'ENV PATH $PATH:/usr/local/go/bin' >> "$version/Dockerfile" 145 146 echo >> "$version/Dockerfile" 147 148 echo 'ENV AUTO_GOPATH 1' >> "$version/Dockerfile" 149 150 echo >> "$version/Dockerfile" 151 152 # print build tags in alphabetical order 153 buildTags=$( echo "selinux $extraBuildTags" | xargs -n1 | sort -n | tr '\n' ' ' | sed -e 's/[[:space:]]*$//' ) 154 155 echo "ENV DOCKER_BUILDTAGS $buildTags" >> "$version/Dockerfile" 156 done