github.com/lazyboychen7/engine@v17.12.1-ce-rc2+incompatible/contrib/builder/deb/ppc64le/generate.sh (about)

     1  #!/usr/bin/env 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=
    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  		pkg-config # for detecting things like libsystemd-journal dynamically
    57  		vim-common # tini dep
    58  	)
    59  
    60  	case "$suite" in
    61  		trusty)
    62  			packages+=( libsystemd-journal-dev )
    63  			;;
    64  		*)
    65  			# libseccomp isn't available until ubuntu xenial and is required for "seccomp.h" & "libseccomp.so"
    66  			packages+=( libseccomp-dev )
    67  			packages+=( libsystemd-dev )
    68  			;;
    69  	esac
    70  
    71  	# buildtags
    72  	case "$suite" in
    73  		# trusty has no seccomp package
    74  		trusty)
    75  			runcBuildTags="apparmor selinux"
    76  		;;
    77  		# ppc64le support was backported into libseccomp 2.2.3-2,
    78  		# so enable seccomp by default
    79  		*)
    80  			extraBuildTags+=' seccomp'
    81  			runcBuildTags="apparmor seccomp selinux"
    82  			;;
    83  	esac
    84  
    85  	# update and install packages
    86  	echo "RUN apt-get update && apt-get install -y ${packages[*]} --no-install-recommends && rm -rf /var/lib/apt/lists/*" >> "$version/Dockerfile"
    87  	echo >> "$version/Dockerfile"
    88  
    89  	awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../../Dockerfile.ppc64le >> "$version/Dockerfile"
    90  	echo 'RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-ppc64le.tar.gz" | tar xzC /usr/local' >> "$version/Dockerfile"
    91  	echo 'ENV PATH $PATH:/usr/local/go/bin' >> "$version/Dockerfile"
    92  	echo >> "$version/Dockerfile"
    93  
    94  	echo 'ENV AUTO_GOPATH 1' >> "$version/Dockerfile"
    95  	echo >> "$version/Dockerfile"
    96  
    97  	# print build tags in alphabetical order
    98  	buildTags=$( echo "apparmor selinux $extraBuildTags" | xargs -n1 | sort -n | tr '\n' ' ' | sed -e 's/[[:space:]]*$//' )
    99  	echo "ENV DOCKER_BUILDTAGS $buildTags" >> "$version/Dockerfile"
   100  	echo "ENV RUNC_BUILDTAGS $runcBuildTags" >> "$version/Dockerfile"
   101  done