github.com/coreos/docker@v1.13.1/contrib/builder/deb/ppc64le/generate.sh (about)

     1  #!/bin/bash
     2  set -e
     3  
     4  # This file is used to auto-generate Dockerfiles for making debs via 'make deb'
     5  #
     6  # usage: ./generate.sh [versions]
     7  #    ie: ./generate.sh
     8  #        to update all Dockerfiles in this directory
     9  #    or: ./generate.sh ubuntu-xenial
    10  #        to only update ubuntu-xenial/Dockerfile
    11  #    or: ./generate.sh ubuntu-newversion
    12  #        to create a new folder and a Dockerfile within it
    13  
    14  cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
    15  
    16  versions=( "$@" )
    17  if [ ${#versions[@]} -eq 0 ]; then
    18  	versions=( */ )
    19  fi
    20  versions=( "${versions[@]%/}" )
    21  
    22  for version in "${versions[@]}"; do
    23  	echo "${versions[@]}"
    24  	distro="${version%-*}"
    25  	suite="${version##*-}"
    26  	from="ppc64le/${distro}:${suite}"
    27  
    28  	mkdir -p "$version"
    29  	echo "$version -> FROM $from"
    30  	cat > "$version/Dockerfile" <<-EOF
    31  		#
    32  		# THIS FILE IS AUTOGENERATED; SEE "contrib/builder/deb/ppc64le/generate.sh"!
    33  		#
    34  
    35  		FROM $from
    36  
    37  	EOF
    38  
    39  	extraBuildTags='pkcs11'
    40  	runcBuildTags=
    41  
    42  	# this list is sorted alphabetically; please keep it that way
    43  	packages=(
    44  		apparmor # for apparmor_parser for testing the profile
    45  		bash-completion # for bash-completion debhelper integration
    46  		btrfs-tools # for "btrfs/ioctl.h" (and "version.h" if possible)
    47  		build-essential # "essential for building Debian packages"
    48  		cmake # tini dep
    49  		curl ca-certificates # for downloading Go
    50  		debhelper # for easy ".deb" building
    51  		dh-apparmor # for apparmor debhelper
    52  		dh-systemd # for systemd debhelper integration
    53  		git # for "git commit" info in "docker -v"
    54  		libapparmor-dev # for "sys/apparmor.h"
    55  		libdevmapper-dev # for "libdevmapper.h"
    56  		libltdl-dev # for pkcs11 "ltdl.h"
    57  		libsqlite3-dev # for "sqlite3.h"
    58  		pkg-config # for detecting things like libsystemd-journal dynamically
    59  		vim-common # tini dep
    60  	)
    61  
    62  	case "$suite" in
    63  		trusty) 
    64  			packages+=( libsystemd-journal-dev )
    65  			;;
    66  		*)
    67  			# libseccomp isn't available until ubuntu xenial and is required for "seccomp.h" & "libseccomp.so"
    68  			packages+=( libseccomp-dev )
    69  			packages+=( libsystemd-dev )
    70  			;;
    71  	esac
    72  
    73  	# buildtags
    74  	case "$suite" in
    75  		# trusty has no seccomp package
    76  		trusty)
    77  			runcBuildTags="apparmor selinux"
    78  		;;
    79  		# ppc64le support was backported into libseccomp 2.2.3-2,
    80  		# so enable seccomp by default
    81  		*)
    82  			extraBuildTags+=' seccomp'
    83  			runcBuildTags="apparmor seccomp selinux"
    84  			;;
    85  	esac
    86  	
    87  	# update and install packages
    88  	echo "RUN apt-get update && apt-get install -y ${packages[*]} --no-install-recommends && rm -rf /var/lib/apt/lists/*" >> "$version/Dockerfile"
    89  	echo >> "$version/Dockerfile"
    90  
    91  	awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../../Dockerfile.ppc64le >> "$version/Dockerfile"
    92  	echo 'RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-ppc64le.tar.gz" | tar xzC /usr/local' >> "$version/Dockerfile"
    93  	echo 'ENV PATH $PATH:/usr/local/go/bin' >> "$version/Dockerfile"
    94  	echo >> "$version/Dockerfile"
    95  
    96  	echo 'ENV AUTO_GOPATH 1' >> "$version/Dockerfile"
    97  	echo >> "$version/Dockerfile"
    98  
    99  	# print build tags in alphabetical order
   100  	buildTags=$( echo "apparmor selinux $extraBuildTags" | xargs -n1 | sort -n | tr '\n' ' ' | sed -e 's/[[:space:]]*$//' )
   101  	echo "ENV DOCKER_BUILDTAGS $buildTags" >> "$version/Dockerfile"
   102  	echo "ENV RUNC_BUILDTAGS $runcBuildTags" >> "$version/Dockerfile"
   103  done