github.com/flavio/docker@v0.1.3-0.20170117145210-f63d1a6eec47/contrib/builder/rpm/ppc64le/generate.sh (about)

     1  #!/bin/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
     8  #        to only update fedora-23/Dockerfile
     9  #    or: ./generate.sh fedora-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  	installer=yum
    25  	if [[ "$distro" == "fedora" ]]; then
    26  		installer=dnf
    27  	fi
    28  
    29  	mkdir -p "$version"
    30  	echo "$version -> FROM $from"
    31  	cat > "$version/Dockerfile" <<-EOF
    32  		#
    33  		# THIS FILE IS AUTOGENERATED; SEE "contrib/builder/rpm/ppc64le/generate.sh"!
    34  		#
    35  
    36  		FROM ppc64le/$from
    37  	EOF
    38  
    39  	echo >> "$version/Dockerfile"
    40  
    41  	extraBuildTags='pkcs11'
    42  	runcBuildTags=
    43  
    44  	case "$from" in
    45  		# add centos and opensuse tools install bits later
    46  		fedora:*)
    47  			echo "RUN ${installer} -y upgrade" >> "$version/Dockerfile"
    48  			echo "RUN ${installer} install -y @development-tools fedora-packager" >> "$version/Dockerfile"
    49  			;;
    50  	esac
    51  
    52  	# this list is sorted alphabetically; please keep it that way
    53  	packages=(
    54  		btrfs-progs-devel # for "btrfs/ioctl.h" (and "version.h" if possible)
    55  		device-mapper-devel # for "libdevmapper.h"
    56  		glibc-static
    57  		libseccomp-devel # for "seccomp.h" & "libseccomp.so"
    58  		libselinux-devel # for "libselinux.so"
    59  		libtool-ltdl-devel # for pkcs11 "ltdl.h"
    60  		pkgconfig # for the pkg-config command
    61  		selinux-policy
    62  		selinux-policy-devel
    63  		sqlite-devel # for "sqlite3.h"
    64  		systemd-devel # for "sd-journal.h" and libraries
    65  		tar # older versions of dev-tools do not have tar
    66  		git # required for containerd and runc clone
    67  		cmake # tini build
    68  	)
    69  
    70  	# opensuse does not have the right libseccomp libs
    71  	case "$from" in
    72  		# add opensuse libseccomp package substitution when adding build support
    73  		*)
    74  			extraBuildTags+=' seccomp'
    75  			runcBuildTags="seccomp selinux"
    76  			;;
    77  	esac
    78  
    79  	case "$from" in
    80  		# add opensuse btrfs package substitution when adding build support
    81  		*)
    82  			echo "RUN ${installer} install -y ${packages[*]}" >> "$version/Dockerfile"
    83  			;;
    84  	esac
    85  
    86  	echo >> "$version/Dockerfile"
    87  
    88  	awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../../Dockerfile.ppc64le >> "$version/Dockerfile"
    89  	echo 'RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-ppc64le.tar.gz" | tar xzC /usr/local' >> "$version/Dockerfile"
    90  	echo 'ENV PATH $PATH:/usr/local/go/bin' >> "$version/Dockerfile"
    91  	echo >> "$version/Dockerfile"	
    92  
    93  	echo 'ENV AUTO_GOPATH 1' >> "$version/Dockerfile"
    94  	echo >> "$version/Dockerfile"
    95  
    96  	# print build tags in alphabetical order
    97  	buildTags=$( echo "selinux $extraBuildTags" | xargs -n1 | sort -n | tr '\n' ' ' | sed -e 's/[[:space:]]*$//' )
    98  
    99  	echo "ENV DOCKER_BUILDTAGS $buildTags" >> "$version/Dockerfile"
   100  	echo "ENV RUNC_BUILDTAGS $runcBuildTags" >> "$version/Dockerfile"
   101  	echo >> "$version/Dockerfile"
   102  
   103  done