github.com/fabiokung/docker@v0.11.2-0.20170222101415-4534dcd49497/contrib/builder/rpm/ppc64le/generate.sh (about)

     1  #!/usr/bin/env 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  		systemd-devel # for "sd-journal.h" and libraries
    64  		tar # older versions of dev-tools do not have tar
    65  		git # required for containerd and runc clone
    66  		cmake # tini build
    67  	)
    68  
    69  	# opensuse does not have the right libseccomp libs
    70  	case "$from" in
    71  		# add opensuse libseccomp package substitution when adding build support
    72  		*)
    73  			extraBuildTags+=' seccomp'
    74  			runcBuildTags="seccomp selinux"
    75  			;;
    76  	esac
    77  
    78  	case "$from" in
    79  		# add opensuse btrfs package substitution when adding build support
    80  		*)
    81  			echo "RUN ${installer} install -y ${packages[*]}" >> "$version/Dockerfile"
    82  			;;
    83  	esac
    84  
    85  	echo >> "$version/Dockerfile"
    86  
    87  	awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../../Dockerfile.ppc64le >> "$version/Dockerfile"
    88  	echo 'RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-ppc64le.tar.gz" | tar xzC /usr/local' >> "$version/Dockerfile"
    89  	echo 'ENV PATH $PATH:/usr/local/go/bin' >> "$version/Dockerfile"
    90  	echo >> "$version/Dockerfile"	
    91  
    92  	echo 'ENV AUTO_GOPATH 1' >> "$version/Dockerfile"
    93  	echo >> "$version/Dockerfile"
    94  
    95  	# print build tags in alphabetical order
    96  	buildTags=$( echo "selinux $extraBuildTags" | xargs -n1 | sort -n | tr '\n' ' ' | sed -e 's/[[:space:]]*$//' )
    97  
    98  	echo "ENV DOCKER_BUILDTAGS $buildTags" >> "$version/Dockerfile"
    99  	echo "ENV RUNC_BUILDTAGS $runcBuildTags" >> "$version/Dockerfile"
   100  	echo >> "$version/Dockerfile"
   101  
   102  done