github.com/lazyboychen7/engine@v17.12.1-ce-rc2+incompatible/contrib/builder/deb/s390x/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="s390x/${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/s390x/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  		libseccomp-dev  # for "seccomp.h" & "libseccomp.so"
    57  		pkg-config # for detecting things like libsystemd-journal dynamically
    58  		libsystemd-dev
    59  		vim-common # tini dep
    60  	)
    61  
    62  	case "$suite" in
    63  		# s390x needs libseccomp 2.3.1
    64  		xenial)
    65  			# Ubuntu Xenial has libseccomp 2.2.3
    66  			runcBuildTags="apparmor selinux"
    67  			;;
    68  		*)
    69  			extraBuildTags+=' seccomp'
    70  			runcBuildTags="apparmor selinux seccomp"
    71  			;;
    72  	esac
    73  
    74  	# update and install packages
    75  	echo "RUN apt-get update && apt-get install -y ${packages[*]} --no-install-recommends && rm -rf /var/lib/apt/lists/*" >> "$version/Dockerfile"
    76  
    77  	echo >> "$version/Dockerfile"
    78  
    79  	awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../../Dockerfile.s390x >> "$version/Dockerfile"
    80  	echo 'RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-s390x.tar.gz" | tar xzC /usr/local' >> "$version/Dockerfile"
    81  	echo 'ENV PATH $PATH:/usr/local/go/bin' >> "$version/Dockerfile"
    82  
    83  	echo >> "$version/Dockerfile"
    84  
    85  	echo 'ENV AUTO_GOPATH 1' >> "$version/Dockerfile"
    86  
    87  	echo >> "$version/Dockerfile"
    88  
    89  	# print build tags in alphabetical order
    90  	buildTags=$( echo "apparmor selinux $extraBuildTags" | xargs -n1 | sort -n | tr '\n' ' ' | sed -e 's/[[:space:]]*$//' )
    91  
    92  	echo "ENV DOCKER_BUILDTAGS $buildTags" >> "$version/Dockerfile"
    93  	echo "ENV RUNC_BUILDTAGS $runcBuildTags" >> "$version/Dockerfile"
    94  done