github.com/walkingsparrow/docker@v1.4.2-0.20151218153551-b708a2249bfa/contrib/builder/deb/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/generate.sh"! 37 # 38 39 FROM $from 40 EOF 41 42 echo >> "$version/Dockerfile" 43 44 extraBuildTags= 45 46 # this list is sorted alphabetically; please keep it that way 47 packages=( 48 apparmor # for apparmor_parser for testing the profile 49 bash-completion # for bash-completion debhelper integration 50 btrfs-tools # for "btrfs/ioctl.h" (and "version.h" if possible) 51 build-essential # "essential for building Debian packages" 52 curl ca-certificates # for downloading Go 53 debhelper # for easy ".deb" building 54 dh-apparmor # for apparmor debhelper 55 dh-systemd # for systemd debhelper integration 56 git # for "git commit" info in "docker -v" 57 libapparmor-dev # for "sys/apparmor.h" 58 libdevmapper-dev # for "libdevmapper.h" 59 libltdl-dev # for pkcs11 "ltdl.h" 60 libsqlite3-dev # for "sqlite3.h" 61 libseccomp-dev # for "seccomp.h" & "libseccomp.so" 62 ) 63 # packaging for "sd-journal.h" and libraries varies 64 case "$suite" in 65 precise) ;; 66 sid|stretch|wily) packages+=( libsystemd-dev );; 67 *) packages+=( libsystemd-journal-dev );; 68 esac 69 70 # debian wheezy & ubuntu precise do not have the right libseccomp libs 71 case "$suite" in 72 precise|wheezy) 73 packages=( "${packages[@]/libseccomp-dev}" ) 74 ;; 75 *) 76 extraBuildTags+=' seccomp' 77 ;; 78 esac 79 80 81 if [ "$suite" = 'precise' ]; then 82 # precise has a few package issues 83 84 # - dh-systemd doesn't exist at all 85 packages=( "${packages[@]/dh-systemd}" ) 86 87 # - libdevmapper-dev is missing critical structs (too old) 88 packages=( "${packages[@]/libdevmapper-dev}" ) 89 extraBuildTags+=' exclude_graphdriver_devicemapper' 90 91 # - btrfs-tools is missing "ioctl.h" (too old), so it's useless 92 # (since kernels on precise are old too, just skip btrfs entirely) 93 packages=( "${packages[@]/btrfs-tools}" ) 94 extraBuildTags+=' exclude_graphdriver_btrfs' 95 fi 96 97 if [ "$suite" = 'wheezy' ]; then 98 # pull btrfs-toold from backports 99 backports="/$suite-backports" 100 packages=( "${packages[@]/btrfs-tools/btrfs-tools$backports}" ) 101 fi 102 103 echo "RUN apt-get update && apt-get install -y ${packages[*]} --no-install-recommends && rm -rf /var/lib/apt/lists/*" >> "$version/Dockerfile" 104 105 echo >> "$version/Dockerfile" 106 107 # debian jessie & ubuntu trusty/vivid do not have a libseccomp.a for compiling static dockerinit 108 # ONLY install libseccomp.a from source, this can be removed once dockerinit is removed 109 # TODO remove this manual seccomp compilation once dockerinit is gone or no longer needs to be statically compiled 110 case "$suite" in 111 jessie|trusty|vivid) 112 awk '$1 == "ENV" && $2 == "SECCOMP_VERSION" { print; exit }' ../../../Dockerfile >> "$version/Dockerfile" 113 cat <<-'EOF' >> "$version/Dockerfile" 114 RUN buildDeps=' \ 115 automake \ 116 libtool \ 117 ' \ 118 && set -x \ 119 && apt-get update && apt-get install -y $buildDeps --no-install-recommends \ 120 && rm -rf /var/lib/apt/lists/* \ 121 && export SECCOMP_PATH=$(mktemp -d) \ 122 && git clone -b "$SECCOMP_VERSION" --depth 1 https://github.com/seccomp/libseccomp.git "$SECCOMP_PATH" \ 123 && ( \ 124 cd "$SECCOMP_PATH" \ 125 && ./autogen.sh \ 126 && ./configure --prefix=/usr \ 127 && make \ 128 && install -c src/.libs/libseccomp.a /usr/lib/libseccomp.a \ 129 && chmod 644 /usr/lib/libseccomp.a \ 130 && ranlib /usr/lib/libseccomp.a \ 131 && ldconfig -n /usr/lib \ 132 ) \ 133 && rm -rf "$SECCOMP_PATH" \ 134 && apt-get purge -y --auto-remove $buildDeps 135 EOF 136 137 echo >> "$version/Dockerfile" 138 ;; 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 "apparmor selinux $extraBuildTags" | xargs -n1 | sort -n | tr '\n' ' ' | sed -e 's/[[:space:]]*$//' ) 154 155 echo "ENV DOCKER_BUILDTAGS $buildTags" >> "$version/Dockerfile" 156 done