github.com/coreos/docker@v1.13.1/contrib/builder/deb/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 debian-jessie 8 # to only update debian-jessie/Dockerfile 9 # or: ./generate.sh debian-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 25 case "$from" in 26 debian:wheezy) 27 # add -backports, like our users have to 28 from+='-backports' 29 ;; 30 esac 31 32 mkdir -p "$version" 33 echo "$version -> FROM $from" 34 cat > "$version/Dockerfile" <<-EOF 35 # 36 # THIS FILE IS AUTOGENERATED; SEE "contrib/builder/deb/amd64/generate.sh"! 37 # 38 39 FROM $from 40 EOF 41 42 echo >> "$version/Dockerfile" 43 44 if [ "$distro" = "debian" ]; then 45 cat >> "$version/Dockerfile" <<-'EOF' 46 # allow replacing httpredir or deb mirror 47 ARG APT_MIRROR=deb.debian.org 48 RUN sed -ri "s/(httpredir|deb).debian.org/$APT_MIRROR/g" /etc/apt/sources.list 49 EOF 50 51 if [ "$suite" = "wheezy" ]; then 52 cat >> "$version/Dockerfile" <<-'EOF' 53 RUN sed -ri "s/(httpredir|deb).debian.org/$APT_MIRROR/g" /etc/apt/sources.list.d/backports.list 54 EOF 55 fi 56 57 echo "" >> "$version/Dockerfile" 58 fi 59 60 extraBuildTags='pkcs11' 61 runcBuildTags= 62 63 # this list is sorted alphabetically; please keep it that way 64 packages=( 65 apparmor # for apparmor_parser for testing the profile 66 bash-completion # for bash-completion debhelper integration 67 btrfs-tools # for "btrfs/ioctl.h" (and "version.h" if possible) 68 build-essential # "essential for building Debian packages" 69 cmake # tini dep 70 curl ca-certificates # for downloading Go 71 debhelper # for easy ".deb" building 72 dh-apparmor # for apparmor debhelper 73 dh-systemd # for systemd debhelper integration 74 git # for "git commit" info in "docker -v" 75 libapparmor-dev # for "sys/apparmor.h" 76 libdevmapper-dev # for "libdevmapper.h" 77 libltdl-dev # for pkcs11 "ltdl.h" 78 libseccomp-dev # for "seccomp.h" & "libseccomp.so" 79 libsqlite3-dev # for "sqlite3.h" 80 pkg-config # for detecting things like libsystemd-journal dynamically 81 vim-common # tini dep 82 ) 83 # packaging for "sd-journal.h" and libraries varies 84 case "$suite" in 85 precise|wheezy) ;; 86 jessie|trusty) packages+=( libsystemd-journal-dev );; 87 *) packages+=( libsystemd-dev );; 88 esac 89 90 # debian wheezy & ubuntu precise do not have the right libseccomp libs 91 # debian jessie & ubuntu trusty have a libseccomp < 2.2.1 :( 92 case "$suite" in 93 precise|wheezy|jessie|trusty) 94 packages=( "${packages[@]/libseccomp-dev}" ) 95 runcBuildTags="apparmor selinux" 96 ;; 97 *) 98 extraBuildTags+=' seccomp' 99 runcBuildTags="apparmor seccomp selinux" 100 ;; 101 esac 102 103 104 if [ "$suite" = 'precise' ]; then 105 # precise has a few package issues 106 107 # - dh-systemd doesn't exist at all 108 packages=( "${packages[@]/dh-systemd}" ) 109 110 # - libdevmapper-dev is missing critical structs (too old) 111 packages=( "${packages[@]/libdevmapper-dev}" ) 112 extraBuildTags+=' exclude_graphdriver_devicemapper' 113 114 # - btrfs-tools is missing "ioctl.h" (too old), so it's useless 115 # (since kernels on precise are old too, just skip btrfs entirely) 116 packages=( "${packages[@]/btrfs-tools}" ) 117 extraBuildTags+=' exclude_graphdriver_btrfs' 118 fi 119 120 if [ "$suite" = 'wheezy' ]; then 121 # pull a couple packages from backports explicitly 122 # (build failures otherwise) 123 backportsPackages=( btrfs-tools ) 124 for pkg in "${backportsPackages[@]}"; do 125 packages=( "${packages[@]/$pkg}" ) 126 done 127 echo "RUN apt-get update && apt-get install -y -t $suite-backports ${backportsPackages[*]} --no-install-recommends && rm -rf /var/lib/apt/lists/*" >> "$version/Dockerfile" 128 fi 129 130 echo "RUN apt-get update && apt-get install -y ${packages[*]} --no-install-recommends && rm -rf /var/lib/apt/lists/*" >> "$version/Dockerfile" 131 132 echo >> "$version/Dockerfile" 133 134 awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../../Dockerfile >> "$version/Dockerfile" 135 echo 'RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local' >> "$version/Dockerfile" 136 echo 'ENV PATH $PATH:/usr/local/go/bin' >> "$version/Dockerfile" 137 138 echo >> "$version/Dockerfile" 139 140 echo 'ENV AUTO_GOPATH 1' >> "$version/Dockerfile" 141 142 echo >> "$version/Dockerfile" 143 144 # print build tags in alphabetical order 145 buildTags=$( echo "apparmor selinux $extraBuildTags" | xargs -n1 | sort -n | tr '\n' ' ' | sed -e 's/[[:space:]]*$//' ) 146 147 echo "ENV DOCKER_BUILDTAGS $buildTags" >> "$version/Dockerfile" 148 echo "ENV RUNC_BUILDTAGS $runcBuildTags" >> "$version/Dockerfile" 149 done