44# This script is to build pouch binaries and execute pouch tests.
55
66TMP=$( mktemp -d /tmp/pouch.XXXXXX)
7+ CONTAINERD_VERSION=
8+ RUNC_VERSION=
9+ NSENTER_VERSION=
10+ DUMB_INIT_VERSION=
711
812DIR=" $( cd " $( dirname " $0 " ) /.." && pwd ) "
913cd $DIR /
@@ -16,26 +20,64 @@ if [[ $SOURCEDIR != $DIR ]];then
1620 ln -sf $DIR / $SOURCEDIR
1721fi
1822
19- # install pouch and essential binaries: containerd, runc and so on
20- function install_pouch ()
23+ function get_containerd_version()
2124{
22- # install containerd
23- echo " Download and install containerd. "
24- wget --quiet https://github.com/containerd/containerd/releases/download/v1.0.3/containerd-1.0.3.linux-amd64.tar.gz -P $TMP
25- tar xf $TMP /containerd-1.0.3.linux-amd64.tar.gz -C $TMP && cp -f $TMP /bin/ * /usr/local/bin/
25+ if which containerd & > /dev/null ; then
26+ CONTAINERD_VERSION= $( containerd -v | cut -d " " -f 3 )
27+ fi
28+ }
2629
27- # install runc
28- echo " Download and install runc."
29- wget --quiet https://github.com/alibaba/runc/releases/download/v1.0.0-rc4-1/runc.amd64 -P /usr/local/bin
30- chmod +x /usr/local/bin/runc.amd64
31- mv /usr/local/bin/runc.amd64 /usr/local/bin/runc
30+ function get_runc_version()
31+ {
32+ if which runc & > /dev/null; then
33+ RUNC_VERSION=$( runc -v| head -1| cut -d " " -f 3)
34+ fi
35+ }
3236
33- # copy pouch daemon and pouch cli to PATH
34- echo " Install pouch."
35- cp -f $DIR /pouch $DIR /pouchd /usr/local/bin/
36-
37- # install lxcfs
38- echo " Install lxcfs"
37+ function get_nsenter_version()
38+ {
39+ if which nsenter & > /dev/null; then
40+ NSENTER_VERSION=$( nsenter -V | cut -d " " -f 4)
41+ fi
42+ }
43+
44+ function get_dumb_init_version()
45+ {
46+ if which dumb-init & > /dev/null; then
47+ DUMB_INIT_VERSION=$( dumb-init -V 2>&1 | cut -d " " -f 2)
48+ fi
49+ }
50+
51+ function install_containerd()
52+ {
53+ echo " Try installing containerd"
54+ get_containerd_version
55+ if [[ " $CONTAINERD_VERSION " == " v1.0.3" ]]; then
56+ echo " Containerd already installed."
57+ else
58+ echo " Download and install containerd."
59+ wget --quiet https://github.com/containerd/containerd/releases/download/v1.0.3/containerd-1.0.3.linux-amd64.tar.gz -P $TMP
60+ tar xf $TMP /containerd-1.0.3.linux-amd64.tar.gz -C $TMP && cp -f $TMP /bin/* /usr/local/bin/
61+ fi ;
62+ }
63+
64+ function install_runc()
65+ {
66+ echo " Try installing runc"
67+ get_runc_version
68+ if [[ " $RUNC_VERSION " == " 1.0.0-rc4-1" ]]; then
69+ echo " Runc already installed."
70+ else
71+ echo " Download and install runc."
72+ wget --quiet https://github.com/alibaba/runc/releases/download/v1.0.0-rc4-1/runc.amd64 -P /usr/local/bin
73+ chmod +x /usr/local/bin/runc.amd64
74+ mv /usr/local/bin/runc.amd64 /usr/local/bin/runc
75+ fi ;
76+ }
77+
78+ function install_lxcfs()
79+ {
80+ echo " Try installing lxcfs"
3981 if grep -qi " ubuntu" /etc/issue ; then
4082 apt-get install -y lxcfs
4183 if (( $? != 0 )) ; then
@@ -46,28 +88,61 @@ function install_pouch ()
4688 else
4789 sh -x $DIR /hack/install_lxcfs_on_centos.sh
4890 fi
91+ }
4992
50- # install nsenter
51- echo " Install nsenter"
93+ function install_nsenter()
94+ {
95+ echo " Try installing nsenter"
96+ get_nsenter_version
5297 if grep -qi " ubuntu" /etc/issue ; then
53- apt-get install libncurses5-dev libslang2-dev gettext zlib1g-dev libselinux1-dev debhelper lsb-release pkg-config po-debconf autoconf automake autopoint libtool
54- wget https://www.kernel.org/pub/linux/utils/util-linux/v2.24/util-linux-2.24.1.tar.gz -P $TMP
55- tar xf $TMP /util-linux-2.24.1.tar.gz -C $TMP && cd $TMP /util-linux-2.24.1
56- ./autogen.sh
57- autoreconf -vfi
58- ./configure && make
59- cp ./nsenter /usr/local/bin
60- cd $DIR /
98+ if [[ " $NSENTER_VERSION " == " 2.24.1" ]]; then
99+ echo " Nsenter already installed."
100+ else
101+ echo " Download and install nsenter."
102+ apt-get -y install libncurses5-dev libslang2-dev gettext zlib1g-dev libselinux1-dev debhelper lsb-release pkg-config po-debconf autoconf automake autopoint libtool
103+ wget --quiet https://www.kernel.org/pub/linux/utils/util-linux/v2.24/util-linux-2.24.1.tar.gz -P $TMP
104+ tar xf $TMP /util-linux-2.24.1.tar.gz -C $TMP && cd $TMP /util-linux-2.24.1
105+ ./autogen.sh
106+ autoreconf -vfi
107+ ./configure && make
108+ cp ./nsenter /usr/local/bin
109+ cd $DIR /
110+ fi
61111 else
62112 yum install -y util-linux
63113 fi
114+
64115}
65116
66117# Install dumb-init by downloading the binary.
67118function install_dumb_init
68119{
69- wget -O /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64 || return 1
70- chmod +x /usr/bin/dumb-init
120+ echo " Try installing dumb-init"
121+ get_dumb_init_version
122+ if [[ " $DUMB_INIT_VERSION " == " v1.2.1" ]]; then
123+ echo " Dumb-init already installed."
124+ else
125+ echo " Download and install dumb-init."
126+ wget --quiet -O /tmp/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64
127+ mv tmp/dumb-init /usr/bin/
128+ chmod +x /usr/bin/dumb-init
129+ fi
130+ }
131+
132+ # install pouch and essential binaries: containerd, runc and so on
133+ function install_pouch ()
134+ {
135+ # install containerd
136+ install_containerd
137+ # install runc
138+ install_runc
139+ # copy pouch daemon and pouch cli to PATH
140+ echo " Install pouch."
141+ cp -f $DIR /pouch $DIR /pouchd /usr/local/bin/
142+ # install lxcfs
143+ install_lxcfs
144+ # install nsenter
145+ install_nsenter
71146}
72147
73148function target()
0 commit comments