github.com/OpenFlowLabs/moby@v17.12.1-ce-rc2+incompatible/contrib/builder/deb/armhf/generate.sh (about) 1 #!/usr/bin/env 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= 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 libseccomp-dev # for "seccomp.h" & "libseccomp.so" 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 wheezy) ;; 86 jessie|trusty) packages+=( libsystemd-journal-dev ) ;; 87 *) packages+=( libsystemd-dev ) ;; 88 esac 89 90 # debian wheezy does not have the right libseccomp libs 91 # debian jessie & ubuntu trusty have a libseccomp < 2.2.1 :( 92 case "$suite" in 93 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 if [ "$suite" = 'wheezy' ]; then 104 # pull a couple packages from backports explicitly 105 # (build failures otherwise) 106 backportsPackages=( btrfs-tools ) 107 for pkg in "${backportsPackages[@]}"; do 108 packages=( "${packages[@]/$pkg}" ) 109 done 110 echo "RUN apt-get update && apt-get install -y -t $suite-backports ${backportsPackages[*]} --no-install-recommends && rm -rf /var/lib/apt/lists/*" >> "$version/Dockerfile" 111 fi 112 113 echo "RUN apt-get update && apt-get install -y ${packages[*]} --no-install-recommends && rm -rf /var/lib/apt/lists/*" >> "$version/Dockerfile" 114 115 echo >> "$version/Dockerfile" 116 117 awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../../Dockerfile.armhf >> "$version/Dockerfile" 118 if [ "$distro" == 'raspbian' ]; 119 then 120 cat <<EOF >> "$version/Dockerfile" 121 # GOARM is the ARM architecture version which is unrelated to the above Golang version 122 ENV GOARM 6 123 EOF 124 fi 125 echo 'RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-armv6l.tar.gz" | tar xzC /usr/local' >> "$version/Dockerfile" 126 echo 'ENV PATH $PATH:/usr/local/go/bin' >> "$version/Dockerfile" 127 128 echo >> "$version/Dockerfile" 129 130 echo 'ENV AUTO_GOPATH 1' >> "$version/Dockerfile" 131 132 echo >> "$version/Dockerfile" 133 134 # print build tags in alphabetical order 135 buildTags=$( echo "apparmor selinux $extraBuildTags" | xargs -n1 | sort -n | tr '\n' ' ' | sed -e 's/[[:space:]]*$//' ) 136 137 echo "ENV DOCKER_BUILDTAGS $buildTags" >> "$version/Dockerfile" 138 echo "ENV RUNC_BUILDTAGS $runcBuildTags" >> "$version/Dockerfile" 139 done