github.com/reds/docker@v1.11.2-rc1/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 extraBuildTags='pkcs11' 45 runcBuildTags= 46 47 # this list is sorted alphabetically; please keep it that way 48 packages=( 49 apparmor # for apparmor_parser for testing the profile 50 bash-completion # for bash-completion debhelper integration 51 btrfs-tools # for "btrfs/ioctl.h" (and "version.h" if possible) 52 build-essential # "essential for building Debian packages" 53 curl ca-certificates # for downloading Go 54 debhelper # for easy ".deb" building 55 dh-apparmor # for apparmor debhelper 56 dh-systemd # for systemd debhelper integration 57 git # for "git commit" info in "docker -v" 58 libapparmor-dev # for "sys/apparmor.h" 59 libdevmapper-dev # for "libdevmapper.h" 60 libltdl-dev # for pkcs11 "ltdl.h" 61 libseccomp-dev # for "seccomp.h" & "libseccomp.so" 62 libsqlite3-dev # for "sqlite3.h" 63 pkg-config # for detecting things like libsystemd-journal dynamically 64 ) 65 # packaging for "sd-journal.h" and libraries varies 66 case "$suite" in 67 precise|wheezy) ;; 68 sid|stretch|wily|xenial) packages+=( libsystemd-dev );; 69 *) packages+=( libsystemd-journal-dev );; 70 esac 71 72 # debian wheezy & ubuntu precise do not have the right libseccomp libs 73 # debian jessie & ubuntu trusty have a libseccomp < 2.2.1 :( 74 case "$suite" in 75 precise|wheezy|jessie|trusty) 76 packages=( "${packages[@]/libseccomp-dev}" ) 77 runcBuildTags="apparmor selinux" 78 ;; 79 *) 80 extraBuildTags+=' seccomp' 81 runcBuildTags="apparmor seccomp selinux" 82 ;; 83 esac 84 85 86 if [ "$suite" = 'precise' ]; then 87 # precise has a few package issues 88 89 # - dh-systemd doesn't exist at all 90 packages=( "${packages[@]/dh-systemd}" ) 91 92 # - libdevmapper-dev is missing critical structs (too old) 93 packages=( "${packages[@]/libdevmapper-dev}" ) 94 extraBuildTags+=' exclude_graphdriver_devicemapper' 95 96 # - btrfs-tools is missing "ioctl.h" (too old), so it's useless 97 # (since kernels on precise are old too, just skip btrfs entirely) 98 packages=( "${packages[@]/btrfs-tools}" ) 99 extraBuildTags+=' exclude_graphdriver_btrfs' 100 fi 101 102 if [ "$suite" = 'wheezy' ]; then 103 # pull a couple packages from backports explicitly 104 # (build failures otherwise) 105 backportsPackages=( btrfs-tools ) 106 for pkg in "${backportsPackages[@]}"; do 107 packages=( "${packages[@]/$pkg}" ) 108 done 109 echo "RUN apt-get update && apt-get install -y -t $suite-backports ${backportsPackages[*]} --no-install-recommends && rm -rf /var/lib/apt/lists/*" >> "$version/Dockerfile" 110 fi 111 112 echo "RUN apt-get update && apt-get install -y ${packages[*]} --no-install-recommends && rm -rf /var/lib/apt/lists/*" >> "$version/Dockerfile" 113 114 echo >> "$version/Dockerfile" 115 116 awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../../Dockerfile >> "$version/Dockerfile" 117 echo 'RUN curl -fSL "https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local' >> "$version/Dockerfile" 118 echo 'ENV PATH $PATH:/usr/local/go/bin' >> "$version/Dockerfile" 119 120 echo >> "$version/Dockerfile" 121 122 echo 'ENV AUTO_GOPATH 1' >> "$version/Dockerfile" 123 124 echo >> "$version/Dockerfile" 125 126 # print build tags in alphabetical order 127 buildTags=$( echo "apparmor selinux $extraBuildTags" | xargs -n1 | sort -n | tr '\n' ' ' | sed -e 's/[[:space:]]*$//' ) 128 129 echo "ENV DOCKER_BUILDTAGS $buildTags" >> "$version/Dockerfile" 130 echo "ENV RUNC_BUILDTAGS $runcBuildTags" >> "$version/Dockerfile" 131 done