github.com/iaintshine/docker@v1.8.2/contrib/builder/deb/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 debian-jessie
     8  #        to only update debian-jessie/Dockerfile
     9  #    or: ./generate.sh debian-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  
    25  	mkdir -p "$version"
    26  	echo "$version -> FROM $from"
    27  	cat > "$version/Dockerfile" <<-EOF
    28  		#
    29  		# THIS FILE IS AUTOGENERATED; SEE "contrib/builder/deb/generate.sh"!
    30  		#
    31  
    32  		FROM $from
    33  	EOF
    34  
    35  	case "$from" in
    36  		debian:wheezy)
    37  			# add -backports, like our users have to
    38  			echo "RUN echo deb http://http.debian.net/debian $suite-backports main > /etc/apt/sources.list.d/$suite-backports.list" >> "$version/Dockerfile"
    39  			;;
    40  	esac
    41  
    42  	echo >> "$version/Dockerfile"
    43  
    44  	extraBuildTags=
    45  
    46  	# this list is sorted alphabetically; please keep it that way
    47  	packages=(
    48  		bash-completion # for bash-completion debhelper integration
    49  		btrfs-tools # for "btrfs/ioctl.h" (and "version.h" if possible)
    50  		build-essential # "essential for building Debian packages"
    51  		curl ca-certificates # for downloading Go
    52  		debhelper # for easy ".deb" building
    53  		dh-systemd # for systemd debhelper integration
    54  		git # for "git commit" info in "docker -v"
    55  		libapparmor-dev # for "sys/apparmor.h"
    56  		libdevmapper-dev # for "libdevmapper.h"
    57  		libsqlite3-dev # for "sqlite3.h"
    58  	)
    59  
    60  	if [ "$suite" = 'precise' ]; then
    61  		# precise has a few package issues
    62  
    63  		# - dh-systemd doesn't exist at all
    64  		packages=( "${packages[@]/dh-systemd}" )
    65  
    66  		# - libdevmapper-dev is missing critical structs (too old)
    67  		packages=( "${packages[@]/libdevmapper-dev}" )
    68  		extraBuildTags+=' exclude_graphdriver_devicemapper'
    69  
    70  		# - btrfs-tools is missing "ioctl.h" (too old), so it's useless
    71  		#   (since kernels on precise are old too, just skip btrfs entirely)
    72  		packages=( "${packages[@]/btrfs-tools}" )
    73  		extraBuildTags+=' exclude_graphdriver_btrfs'
    74  	fi
    75  
    76  	echo "RUN apt-get update && apt-get install -y ${packages[*]} --no-install-recommends && rm -rf /var/lib/apt/lists/*" >> "$version/Dockerfile"
    77  
    78  	echo >> "$version/Dockerfile"
    79  
    80  	awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../Dockerfile >> "$version/Dockerfile"
    81  	echo 'RUN curl -fSL "https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local' >> "$version/Dockerfile"
    82  	echo 'ENV PATH $PATH:/usr/local/go/bin' >> "$version/Dockerfile"
    83  
    84  	echo >> "$version/Dockerfile"
    85  
    86  	echo 'ENV AUTO_GOPATH 1' >> "$version/Dockerfile"
    87  	awk '$1 == "ENV" && $2 == "DOCKER_BUILDTAGS" { print $0 "'"$extraBuildTags"'"; exit }' ../../../Dockerfile >> "$version/Dockerfile"
    88  done