github.com/OpenFlowLabs/moby@v17.12.1-ce-rc2+incompatible/contrib/builder/rpm/s390x/generate.sh (about)

     1  #!/usr/bin/env bash
     2  set -e
     3  
     4  # This file is used to auto-generate Dockerfiles for making rpms via 'make rpm'
     5  #
     6  # usage: ./generate.sh [versions]
     7  #    ie: ./generate.sh
     8  #        to update all Dockerfiles in this directory
     9  #    or: ./generate.sh centos-7
    10  #        to only update centos-7/Dockerfile
    11  #    or: ./generate.sh fedora-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  	case "$distro" in
    27  		*opensuse*)
    28  		from="opensuse/s390x:tumbleweed"
    29  		;;
    30  	*clefos*)
    31  		from="sinenomine/${distro}"
    32  		;;
    33  	*)
    34  		echo No appropriate or supported image available.
    35  		exit 1
    36  		;;
    37      esac
    38  	installer=yum
    39  
    40  	mkdir -p "$version"
    41  	echo "$version -> FROM $from"
    42  	cat > "$version/Dockerfile" <<-EOF
    43  		#
    44  		# THIS FILE IS AUTOGENERATED; SEE "contrib/builder/rpm/s390x/generate.sh"!
    45  		#
    46  
    47  		FROM $from
    48  
    49  	EOF
    50  
    51  	echo >> "$version/Dockerfile"
    52  
    53  	extraBuildTags=''
    54  	runcBuildTags=
    55  
    56  	case "$from" in
    57  		*clefos*)
    58  			# Fix for RHBZ #1213602 + get "Development Tools" packages dependencies
    59  			echo 'RUN touch /var/lib/rpm/* && yum groupinstall -y "Development Tools"' >> "$version/Dockerfile"
    60  			;;
    61  		*opensuse*)
    62  			echo "RUN zypper ar https://download.opensuse.org/ports/zsystems/tumbleweed/repo/oss/ tumbleweed" >> "$version/Dockerfile"
    63  			# get rpm-build and curl packages and dependencies
    64  			echo 'RUN zypper --non-interactive install ca-certificates* curl gzip rpm-build' >> "$version/Dockerfile"
    65  			;;
    66  		*)
    67  			echo No appropriate or supported image available.
    68  			exit 1
    69  			;;
    70  	esac
    71  
    72  	packages=(
    73  		btrfs-progs-devel # for "btrfs/ioctl.h" (and "version.h" if possible)
    74  		device-mapper-devel # for "libdevmapper.h"
    75  		glibc-static
    76  		libseccomp-devel # for "seccomp.h" & "libseccomp.so"
    77  		libselinux-devel # for "libselinux.so"
    78  		pkgconfig # for the pkg-config command
    79  		selinux-policy
    80  		selinux-policy-devel
    81  		sqlite-devel # for "sqlite3.h"
    82  		systemd-devel # for "sd-journal.h" and libraries
    83  		tar # older versions of dev-tools do not have tar
    84  		git # required for containerd and runc clone
    85  		cmake # tini build
    86  		vim-common # tini build
    87  	)
    88  
    89  	case "$from" in
    90  		*clefos*)
    91  			extraBuildTags+=' seccomp'
    92  			runcBuildTags="seccomp selinux"
    93  			;;
    94  		*opensuse*)
    95  			packages=( "${packages[@]/libseccomp-devel}" )
    96  			runcBuildTags="selinux"
    97  			;;
    98  		*)
    99  			echo No appropriate or supported image available.
   100  			exit 1
   101  			;;
   102  	esac
   103  
   104  	case "$from" in
   105  		*clefos*)
   106  			# Same RHBZ fix needed on all yum lines
   107  			echo "RUN touch /var/lib/rpm/* && ${installer} install -y ${packages[*]}" >> "$version/Dockerfile"
   108  			;;
   109  		*opensuse*)
   110  			packages=( "${packages[@]/btrfs-progs-devel/libbtrfs-devel}" )
   111  			packages=( "${packages[@]/pkgconfig/pkg-config}" )
   112  			packages=( "${packages[@]/vim-common/vim}" )
   113  
   114  			packages+=( systemd-rpm-macros ) # for use of >= opensuse:13.*
   115  
   116  			# use zypper
   117  			echo "RUN zypper --non-interactive install ${packages[*]}" >> "$version/Dockerfile"
   118  			;;
   119  		*)
   120  			echo No appropriate or supported image available.
   121  			exit 1
   122  			;;
   123  	esac
   124  
   125  	echo >> "$version/Dockerfile"
   126  
   127  	awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../../Dockerfile.s390x >> "$version/Dockerfile"
   128  	echo 'RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-s390x.tar.gz" | tar xzC /usr/local' >> "$version/Dockerfile"
   129  	echo 'ENV PATH $PATH:/usr/local/go/bin' >> "$version/Dockerfile"
   130  
   131  	echo >> "$version/Dockerfile"
   132  
   133  	echo 'ENV AUTO_GOPATH 1' >> "$version/Dockerfile"
   134  
   135  	echo >> "$version/Dockerfile"
   136  
   137  	# print build tags in alphabetical order
   138  	buildTags=$( echo "selinux $extraBuildTags" | xargs -n1 | sort -n | tr '\n' ' ' | sed -e 's/[[:space:]]*$//' )
   139  
   140  	echo "ENV DOCKER_BUILDTAGS $buildTags" >> "$version/Dockerfile"
   141  	echo "ENV RUNC_BUILDTAGS $runcBuildTags" >> "$version/Dockerfile"
   142  	# TODO: Investigate why "s390x-linux-gnu-gcc" is required
   143  	echo "RUN ln -s /usr/bin/gcc /usr/bin/s390x-linux-gnu-gcc" >> "$version/Dockerfile"
   144  done