github.com/lazyboychen7/engine@v17.12.1-ce-rc2+incompatible/contrib/builder/deb/amd64/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 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= 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 libseccomp-dev # for "seccomp.h" & "libseccomp.so" 78 pkg-config # for detecting things like libsystemd-journal dynamically 79 vim-common # tini dep 80 ) 81 # packaging for "sd-journal.h" and libraries varies 82 case "$suite" in 83 wheezy) ;; 84 jessie|trusty) packages+=( libsystemd-journal-dev ) ;; 85 *) packages+=( libsystemd-dev ) ;; 86 esac 87 88 # debian wheezy does not have the right libseccomp libs 89 # debian jessie & ubuntu trusty have a libseccomp < 2.2.1 :( 90 case "$suite" in 91 wheezy|jessie|trusty) 92 packages=( "${packages[@]/libseccomp-dev}" ) 93 runcBuildTags="apparmor selinux" 94 ;; 95 *) 96 extraBuildTags+=' seccomp' 97 runcBuildTags="apparmor seccomp selinux" 98 ;; 99 esac 100 101 if [ "$suite" = 'wheezy' ]; then 102 # pull a couple packages from backports explicitly 103 # (build failures otherwise) 104 backportsPackages=( btrfs-tools ) 105 for pkg in "${backportsPackages[@]}"; do 106 packages=( "${packages[@]/$pkg}" ) 107 done 108 echo "RUN apt-get update && apt-get install -y -t $suite-backports ${backportsPackages[*]} --no-install-recommends && rm -rf /var/lib/apt/lists/*" >> "$version/Dockerfile" 109 fi 110 111 echo "RUN apt-get update && apt-get install -y ${packages[*]} --no-install-recommends && rm -rf /var/lib/apt/lists/*" >> "$version/Dockerfile" 112 113 echo >> "$version/Dockerfile" 114 115 awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../../Dockerfile >> "$version/Dockerfile" 116 echo 'RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local' >> "$version/Dockerfile" 117 echo 'ENV PATH $PATH:/usr/local/go/bin' >> "$version/Dockerfile" 118 119 echo >> "$version/Dockerfile" 120 121 echo 'ENV AUTO_GOPATH 1' >> "$version/Dockerfile" 122 123 echo >> "$version/Dockerfile" 124 125 # print build tags in alphabetical order 126 buildTags=$( echo "apparmor selinux $extraBuildTags" | xargs -n1 | sort -n | tr '\n' ' ' | sed -e 's/[[:space:]]*$//' ) 127 128 echo "ENV DOCKER_BUILDTAGS $buildTags" >> "$version/Dockerfile" 129 echo "ENV RUNC_BUILDTAGS $runcBuildTags" >> "$version/Dockerfile" 130 done