github.com/OpenFlowLabs/moby@v17.12.1-ce-rc2+incompatible/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 centos-7
     8  #        to only update centos-7/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="ppc64le/${distro}:${suite}"
    24  	installer=yum
    25  
    26  	if [[ "$distro" == "fedora" ]]; then
    27  		installer=dnf
    28  	fi
    29  
    30  	mkdir -p "$version"
    31  	echo "$version -> FROM $from"
    32  	cat > "$version/Dockerfile" <<-EOF
    33  		#
    34  		# THIS FILE IS AUTOGENERATED; SEE "contrib/builder/rpm/ppc64le/generate.sh"!
    35  		#
    36  
    37  		FROM $from
    38  	EOF
    39  
    40  	echo >> "$version/Dockerfile"
    41  
    42  	extraBuildTags=
    43  	runcBuildTags=
    44  
    45  	case "$from" in
    46  		ppc64le/fedora:*)
    47  			echo "RUN ${installer} -y upgrade" >> "$version/Dockerfile"
    48  			;;
    49  		*) ;;
    50  	esac
    51  
    52  	case "$from" in
    53  		ppc64le/centos:*)
    54  			# get "Development Tools" packages dependencies
    55  			echo 'RUN yum groupinstall -y "Development Tools"' >> "$version/Dockerfile"
    56  
    57  			if [[ "$version" == "centos-7" ]]; then
    58  				echo 'RUN yum -y swap -- remove systemd-container systemd-container-libs -- install systemd systemd-libs' >> "$version/Dockerfile"
    59  			fi
    60  			;;
    61  		ppc64le/opensuse:*)
    62  			# Add the ppc64le repo (hopefully the image is updated soon)
    63  			# get rpm-build and curl packages and dependencies
    64  			echo "RUN zypper addrepo -n ppc64le-oss -f https://download.opensuse.org/ports/ppc/distribution/leap/${suite}/repo/oss/ ppc64le-oss"  >> "$version/Dockerfile"
    65  			echo "RUN zypper addrepo -n ppc64le-updates -f https://download.opensuse.org/ports/update/${suite}/ ppc64le-updates" >> "$version/Dockerfile"
    66  			echo 'RUN zypper --non-interactive install ca-certificates* curl gzip rpm-build' >> "$version/Dockerfile"
    67  			;;
    68  		*)
    69  			echo "RUN ${installer} install -y @development-tools fedora-packager" >> "$version/Dockerfile"
    70  			;;
    71  	esac
    72  
    73  	packages=(
    74  		btrfs-progs-devel # for "btrfs/ioctl.h" (and "version.h" if possible)
    75  		device-mapper-devel # for "libdevmapper.h"
    76  		glibc-static
    77  		libseccomp-devel # for "seccomp.h" & "libseccomp.so"
    78  		libselinux-devel # for "libselinux.so"
    79  		pkgconfig # for the pkg-config command
    80  		selinux-policy
    81  		selinux-policy-devel
    82  		sqlite-devel # for "sqlite3.h"
    83  		systemd-devel # for "sd-journal.h" and libraries
    84  		tar # older versions of dev-tools do not have tar
    85  		git # required for containerd and runc clone
    86  		cmake # tini build
    87  		vim-common # tini build
    88  	)
    89  
    90  	# opensuse does not have the right libseccomp libs
    91  	case "$from" in
    92  		ppc64le/opensuse:*)
    93  			packages=( "${packages[@]/libseccomp-devel}" )
    94  			runcBuildTags="selinux"
    95  			;;
    96  		*)
    97  			extraBuildTags+=' seccomp'
    98  			runcBuildTags="seccomp selinux"
    99  			;;
   100  	esac
   101  
   102  	case "$from" in
   103  		ppc64le/opensuse:*)
   104  			packages=( "${packages[@]/btrfs-progs-devel/libbtrfs-devel}" )
   105  			packages=( "${packages[@]/pkgconfig/pkg-config}" )
   106  			packages=( "${packages[@]/vim-common/vim}" )
   107  			if [[ "$from" == "ppc64le/opensuse:13."* ]]; then
   108  				packages+=( systemd-rpm-macros )
   109  			fi
   110  
   111  			# use zypper
   112  			echo "RUN zypper --non-interactive install ${packages[*]}" >> "$version/Dockerfile"
   113  			;;
   114  		*)
   115  			echo "RUN ${installer} install -y ${packages[*]}" >> "$version/Dockerfile"
   116  			;;
   117  	esac
   118  
   119  	echo >> "$version/Dockerfile"
   120  
   121  
   122  	awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../../Dockerfile.ppc64le >> "$version/Dockerfile"
   123  	echo 'RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-ppc64le.tar.gz" | tar xzC /usr/local' >> "$version/Dockerfile"
   124  	echo 'ENV PATH $PATH:/usr/local/go/bin' >> "$version/Dockerfile"
   125  
   126  	echo >> "$version/Dockerfile"
   127  
   128  	echo 'ENV AUTO_GOPATH 1' >> "$version/Dockerfile"
   129  
   130  	echo >> "$version/Dockerfile"
   131  
   132  	# print build tags in alphabetical order
   133  	buildTags=$( echo "selinux $extraBuildTags" | xargs -n1 | sort -n | tr '\n' ' ' | sed -e 's/[[:space:]]*$//' )
   134  
   135  	echo "ENV DOCKER_BUILDTAGS $buildTags" >> "$version/Dockerfile"
   136  	echo "ENV RUNC_BUILDTAGS $runcBuildTags" >> "$version/Dockerfile"
   137  	echo >> "$version/Dockerfile"
   138  
   139  done