github.com/damirazo/docker@v1.9.0/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  	case "$from" in
    26  		debian:wheezy)
    27  			# add -backports, like our users have to
    28  			from+='-backports'
    29  			;;
    30  	esac
    31  
    32  	mkdir -p "$version"
    33  	echo "$version -> FROM $from"
    34  	cat > "$version/Dockerfile" <<-EOF
    35  		#
    36  		# THIS FILE IS AUTOGENERATED; SEE "contrib/builder/deb/generate.sh"!
    37  		#
    38  
    39  		FROM $from
    40  	EOF
    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  	# packaging for "sd-journal.h" and libraries varies
    60  	case "$suite" in
    61  		precise) ;;
    62  		sid|stretch|wily) packages+=( libsystemd-dev );;
    63  		*) packages+=( libsystemd-journal-dev );;
    64  	esac
    65  
    66  	if [ "$suite" = 'precise' ]; then
    67  		# precise has a few package issues
    68  
    69  		# - dh-systemd doesn't exist at all
    70  		packages=( "${packages[@]/dh-systemd}" )
    71  
    72  		# - libdevmapper-dev is missing critical structs (too old)
    73  		packages=( "${packages[@]/libdevmapper-dev}" )
    74  		extraBuildTags+=' exclude_graphdriver_devicemapper'
    75  
    76  		# - btrfs-tools is missing "ioctl.h" (too old), so it's useless
    77  		#   (since kernels on precise are old too, just skip btrfs entirely)
    78  		packages=( "${packages[@]/btrfs-tools}" )
    79  		extraBuildTags+=' exclude_graphdriver_btrfs'
    80  	fi
    81  
    82  	if [ "$suite" = 'wheezy' ]; then
    83  		# pull btrfs-toold from backports
    84  		backports="/$suite-backports"
    85  		packages=( "${packages[@]/btrfs-tools/btrfs-tools$backports}" )
    86  	fi
    87  
    88  	echo "RUN apt-get update && apt-get install -y ${packages[*]} --no-install-recommends && rm -rf /var/lib/apt/lists/*" >> "$version/Dockerfile"
    89  
    90  	echo >> "$version/Dockerfile"
    91  
    92  	awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../Dockerfile >> "$version/Dockerfile"
    93  	echo 'RUN curl -fSL "https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local' >> "$version/Dockerfile"
    94  	echo 'ENV PATH $PATH:/usr/local/go/bin' >> "$version/Dockerfile"
    95  
    96  	echo >> "$version/Dockerfile"
    97  
    98  	echo 'ENV AUTO_GOPATH 1' >> "$version/Dockerfile"
    99  	awk '$1 == "ENV" && $2 == "DOCKER_BUILDTAGS" { print $0 "'"$extraBuildTags"'"; exit }' ../../../Dockerfile >> "$version/Dockerfile"
   100  done