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