github.com/jiasir/docker@v1.3.3-0.20170609024000-252e610103e7/hack/dockerfile/install-binaries.sh (about)

     1  #!/bin/sh
     2  set -e
     3  set -x
     4  
     5  . $(dirname "$0")/binaries-commits
     6  
     7  RM_GOPATH=0
     8  
     9  TMP_GOPATH=${TMP_GOPATH:-""}
    10  
    11  if [ -z "$TMP_GOPATH" ]; then
    12  	export GOPATH="$(mktemp -d)"
    13  	RM_GOPATH=1
    14  else
    15  	export GOPATH="$TMP_GOPATH"
    16  fi
    17  
    18  # Do not build with ambient capabilities support
    19  RUNC_BUILDTAGS="${RUNC_BUILDTAGS:-"seccomp apparmor selinux"}"
    20  
    21  install_runc() {
    22  	echo "Install runc version $RUNC_COMMIT"
    23  	git clone https://github.com/docker/runc.git "$GOPATH/src/github.com/opencontainers/runc"
    24  	cd "$GOPATH/src/github.com/opencontainers/runc"
    25  	git checkout -q "$RUNC_COMMIT"
    26  	make BUILDTAGS="$RUNC_BUILDTAGS" $1
    27  	cp runc /usr/local/bin/docker-runc
    28  }
    29  
    30  install_containerd() {
    31  	echo "Install containerd version $CONTAINERD_COMMIT"
    32  	git clone https://github.com/containerd/containerd.git "$GOPATH/src/github.com/containerd/containerd"
    33  	cd "$GOPATH/src/github.com/containerd/containerd"
    34  	git checkout -q "$CONTAINERD_COMMIT"
    35  	make $1
    36  	cp bin/containerd /usr/local/bin/docker-containerd
    37  	cp bin/containerd-shim /usr/local/bin/docker-containerd-shim
    38  	cp bin/ctr /usr/local/bin/docker-containerd-ctr
    39  }
    40  
    41  install_proxy() {
    42  	echo "Install docker-proxy version $LIBNETWORK_COMMIT"
    43  	git clone https://github.com/docker/libnetwork.git "$GOPATH/src/github.com/docker/libnetwork"
    44  	cd "$GOPATH/src/github.com/docker/libnetwork"
    45  	git checkout -q "$LIBNETWORK_COMMIT"
    46  	go build -ldflags="$PROXY_LDFLAGS" -o /usr/local/bin/docker-proxy github.com/docker/libnetwork/cmd/proxy
    47  }
    48  
    49  install_bindata() {
    50      echo "Install go-bindata version $BINDATA_COMMIT"
    51      git clone https://github.com/jteeuwen/go-bindata "$GOPATH/src/github.com/jteeuwen/go-bindata"
    52      cd $GOPATH/src/github.com/jteeuwen/go-bindata
    53      git checkout -q "$BINDATA_COMMIT"
    54  	go build -o /usr/local/bin/go-bindata github.com/jteeuwen/go-bindata/go-bindata
    55  }
    56  
    57  install_dockercli() {
    58  	echo "Install docker/cli version $DOCKERCLI_COMMIT"
    59  	git clone "$DOCKERCLI_REPO" "$GOPATH/src/github.com/docker/cli"
    60  	cd "$GOPATH/src/github.com/docker/cli"
    61  	git checkout -q "$DOCKERCLI_COMMIT"
    62  	go build -o /usr/local/bin/docker github.com/docker/cli/cmd/docker
    63  }
    64  
    65  for prog in "$@"
    66  do
    67  	case $prog in
    68  		tomlv)
    69  			echo "Install tomlv version $TOMLV_COMMIT"
    70  			git clone https://github.com/BurntSushi/toml.git "$GOPATH/src/github.com/BurntSushi/toml"
    71  			cd "$GOPATH/src/github.com/BurntSushi/toml" && git checkout -q "$TOMLV_COMMIT"
    72  			go build -v -o /usr/local/bin/tomlv github.com/BurntSushi/toml/cmd/tomlv
    73  			;;
    74  
    75  		runc)
    76  			install_runc static
    77  			;;
    78  
    79  		runc-dynamic)
    80  			install_runc
    81  			;;
    82  
    83  		containerd)
    84  			install_containerd static
    85  			;;
    86  
    87  		containerd-dynamic)
    88  			install_containerd
    89  			;;
    90  
    91  		tini)
    92  			echo "Install tini version $TINI_COMMIT"
    93  			git clone https://github.com/krallin/tini.git "$GOPATH/tini"
    94  			cd "$GOPATH/tini"
    95  			git checkout -q "$TINI_COMMIT"
    96  			cmake .
    97  			make tini-static
    98  			cp tini-static /usr/local/bin/docker-init
    99  			;;
   100  
   101  		proxy)
   102  			(
   103  				export CGO_ENABLED=0
   104  				install_proxy
   105  			)
   106  			;;
   107  
   108  		proxy-dynamic)
   109  			PROXY_LDFLAGS="-linkmode=external" install_proxy
   110  			;;
   111  
   112  		vndr)
   113  			echo "Install vndr version $VNDR_COMMIT"
   114  			git clone https://github.com/LK4D4/vndr.git "$GOPATH/src/github.com/LK4D4/vndr"
   115  			cd "$GOPATH/src/github.com/LK4D4/vndr"
   116  			git checkout -q "$VNDR_COMMIT"
   117  			go build -v -o /usr/local/bin/vndr .
   118  			;;
   119  
   120  		bindata)
   121  			install_bindata
   122  			;;
   123  
   124  		dockercli)
   125  			install_dockercli
   126  			;;
   127  
   128  		*)
   129  			echo echo "Usage: $0 [tomlv|runc|runc-dynamic|containerd|containerd-dynamic|tini|proxy|proxy-dynamic|bindata|vndr|dockercli]"
   130  			exit 1
   131  
   132  	esac
   133  done
   134  
   135  if [ $RM_GOPATH -eq 1 ]; then
   136  	rm -rf "$GOPATH"
   137  fi