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