From c4c7a186ba4167b510494ee16e994139f82d727b Mon Sep 17 00:00:00 2001 From: Shuotian Cheng Date: Wed, 28 Sep 2016 18:14:25 -0700 Subject: [PATCH] libteam: Adding build.sh script and docker-team --- Makefile | 23 +++++++++++++++++------ dockers/docker-fpm/Dockerfile | 3 +-- dockers/docker-team/Dockerfile | 25 +++++++++++++++++++++++++ dockers/docker-team/start.sh | 24 ++++++++++++++++++++++++ src/Makefile | 18 ++++++++++++------ src/libteam/build.sh | 26 ++++++++++++++++++++++++++ 6 files changed, 105 insertions(+), 14 deletions(-) create mode 100644 dockers/docker-team/Dockerfile create mode 100755 dockers/docker-team/start.sh create mode 100755 src/libteam/build.sh diff --git a/Makefile b/Makefile index 660880ae718a..4241e856246e 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,7 @@ BRCM-SDK-DEBS=$(notdir $(wildcard src/brcm-sdk/*.deb)) CAVM-SDK-DEBS=$(notdir $(wildcard src/cavm-sdk/*.deb)) LIBNL-DEBS=libnl-3-200_3.2.27-1_amd64.deb libnl-genl-3-200_3.2.27-1_amd64.deb libnl-route-3-200_3.2.27-1_amd64.deb +LIBTEAM-DEBS=libteam5_1.26-1_amd64.deb libteam-dev_1.26-1_amd64.deb libteam-utils_1.26-1_amd64.deb libteamdctl0_1.26-1_amd64.deb ## Function: build_docker, image_name save_file ## build a docker image and save to a file @@ -34,6 +35,12 @@ dockers/docker-fpm/deps/fpmsyncd: src/fpmsyncd mkdir -p `dirname $@` && cp $< $(dir $@) dockers/docker-fpm/deps/%.deb: src/%.deb mkdir -p `dirname $@` && cp $< $(dir $@) + +## Rules: docker-team +dockers/docker-team/deps/teamsyncd: src/teamsyncd + mkdir -p `dirname $@` && cp $< $(dir $@) +dockers/docker-team/deps/%.deb: src/%.deb + mkdir -p `dirname $@` && cp $< $(dir $@) ## Rules: docker-orchagent-mlnx dockers/docker-orchagent-mlnx/deps/libsairedis_1.0.0_amd64.deb: src/mlnx/libsairedis_1.0.0_amd64.deb @@ -107,21 +114,25 @@ target/docker-syncd-cavm.gz: target/docker-base.gz $(addprefix dockers/docker-sy docker load < $< $(call build_docker,$(patsubst target/%.gz,%,$@),$@) -target/docker-orchagent.gz: target/docker-base.gz $(addprefix dockers/docker-orchagent/deps/,libhiredis0.13_0.13.3-2_amd64.deb libswsscommon_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb swss_1.0.0_amd64.deb $(LIBNL-DEBS)) +target/docker-orchagent.gz: target/docker-base.gz $(addprefix dockers/docker-orchagent/deps/,libhiredis0.13_0.13.3-2_amd64.deb libswsscommon_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb swss_1.0.0_amd64.deb $(LIBNL-DEBS) $(LIBTEAM-DEBS)) docker load < $< $(call build_docker,$(patsubst target/%.gz,%,$@),$@) -target/docker-orchagent-mlnx.gz: target/docker-base.gz $(addprefix dockers/docker-orchagent-mlnx/deps/,libhiredis0.13_0.13.3-2_amd64.deb libswsscommon_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb swss_1.0.0_amd64.deb $(LIBNL-DEBS)) +target/docker-orchagent-mlnx.gz: target/docker-base.gz $(addprefix dockers/docker-orchagent-mlnx/deps/,libhiredis0.13_0.13.3-2_amd64.deb libswsscommon_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb swss_1.0.0_amd64.deb $(LIBNL-DEBS) $(LIBTEAM-DEBS)) docker load < $< $(call build_docker,$(patsubst target/%.gz,%,$@),$@) -target/docker-orchagent-cavm.gz: target/docker-base.gz $(addprefix dockers/docker-orchagent-cavm/deps/,libhiredis0.13_0.13.3-2_amd64.deb libswsscommon_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb swss_1.0.0_amd64.deb $(LIBNL-DEBS)) +target/docker-orchagent-cavm.gz: target/docker-base.gz $(addprefix dockers/docker-orchagent-cavm/deps/,libhiredis0.13_0.13.3-2_amd64.deb libswsscommon_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb swss_1.0.0_amd64.deb $(LIBNL-DEBS) $(LIBTEAM-DEBS)) docker load < $< $(call build_docker,$(patsubst target/%.gz,%,$@),$@) target/docker-fpm.gz: target/docker-base.gz $(addprefix dockers/docker-fpm/deps/,libswsscommon_1.0.0_amd64.deb libhiredis0.13_0.13.3-2_amd64.deb quagga_0.99.24.1-2_amd64.deb fpmsyncd) docker load < $< $(call build_docker,$(patsubst target/%.gz,%,$@),$@) + +target/docker-team.gz: target/docker-base.gz $(addprefix dockers/docker-team/deps/,libswsscommon_1.0.0_amd64.deb libhiredis0.13_0.13.3-2_amd64.deb $(LIBTEAM-DEBS)) + docker load < $< + $(call build_docker,$(patsubst target/%.gz,%,$@),$@) target/docker-database.gz: target/docker-base.gz docker load < $< @@ -143,12 +154,12 @@ target/sonic-aboot.bin: deps/linux-image-3.16.0-4-amd64_3.16.7-ckt11-2+acs8u2_am ./build_debian.sh "$(USERNAME)" "$(PASSWORD_ENCRYPTED)" && TARGET_MACHINE=aboot ./build_image.sh ## Note: docker-fpm.gz must be the last to build the implicit dependency fpmsyncd -brcm-all: target/sonic-generic.bin $(addprefix target/,docker-syncd.gz docker-orchagent.gz docker-fpm.gz docker-database.gz) +brcm-all: target/sonic-generic.bin $(addprefix target/,docker-syncd.gz docker-orchagent.gz docker-fpm.gz docker-team.gz docker-database.gz) ## Note: docker-fpm.gz must be the last to build the implicit dependency fpmsyncd -mlnx-all: target/sonic-generic.bin $(addprefix target/,docker-syncd-mlnx.gz docker-orchagent-mlnx.gz docker-fpm.gz docker-database.gz) +mlnx-all: target/sonic-generic.bin $(addprefix target/,docker-syncd-mlnx.gz docker-orchagent-mlnx.gz docker-fpm.gz docker-team.gz docker-database.gz) ## Note: docker-fpm.gz must be the last to build the implicit dependency fpmsyncd -cavm-all: $(addprefix target/,docker-syncd-cavm.gz docker-orchagent-cavm.gz docker-fpm.gz docker-database.gz) +cavm-all: target/sonic-generic.bin $(addprefix target/,docker-syncd-cavm.gz docker-orchagent-cavm.gz docker-fpm.gz docker-team.gz docker-database.gz) p4-all: $(addprefix target/,docker-sonic-p4.gz) diff --git a/dockers/docker-fpm/Dockerfile b/dockers/docker-fpm/Dockerfile index d877c408baab..287aba29ec82 100755 --- a/dockers/docker-fpm/Dockerfile +++ b/dockers/docker-fpm/Dockerfile @@ -7,12 +7,11 @@ COPY ["deps/libhiredis0.13*.deb", "deps/libswsscommon_*.deb", "deps/quagga_*", " ## Get fpmsyncd RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; dpkg_apt /deps/libhiredis0.13*.deb RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; dpkg_apt /deps/libswsscommon_*.deb -COPY deps/fpmsyncd /usr/local/bin/ ## Get Quagga RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; dpkg_apt /deps/quagga_*.deb -COPY start.sh /usr/bin/start.sh +COPY ["deps/fpmsyncd", "start.sh", "/usr/bin/"] ## Clean up RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y diff --git a/dockers/docker-team/Dockerfile b/dockers/docker-team/Dockerfile new file mode 100644 index 000000000000..8ba298043be1 --- /dev/null +++ b/dockers/docker-team/Dockerfile @@ -0,0 +1,25 @@ +FROM docker-base + +COPY ["deps/libnl-3-200_*.deb", "deps/libnl-genl-3-200_*.deb", "libnl-route-3-200_*.deb", "deps/libnl-cli-3-200_*.deb", "deps/libteam5_*.deb", "deps/libteam-dev_*.deb", "deps/libteam-utils_*.deb", "deps/libteamdctl0_*.deb", "deps/libhiredis0.13_*.deb", "deps/libswsscommon_*.deb", "/deps/"] + + +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; \ + dpkg_apt /deps/libnl-3-200_*.deb \ + && dpkg_apt /deps/libnl-genl-3-200_*.deb \ + && dpkg_apt /deps/libnl-route-3-200_*.deb \ + && dpkg_apt /deps/libnl-cli-3-200_*.deb \ + && dpkg_apt /deps/libteam5_*.deb \ + && dpkg_apt /deps/libteam-dev_*.deb \ + && dpkg_apt /deps/libteam-utils_*.deb \ + && dpkg_apt /deps/libteamdctl0_*.deb \ + && dpkg_apt /deps/libhiredis0.13_*.deb \ + && dpkg_apt /deps/libswsscommon_*.deb + +COPY ["deps/teamsyncd", "start.sh", "/usr/bin/"] + +RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y +RUN rm -rf /deps + +ENTRYPOINT ["/bin/bash"] +CMD ["/usr/bin/start.sh"] + diff --git a/dockers/docker-team/start.sh b/dockers/docker-team/start.sh new file mode 100755 index 000000000000..61251cd82d86 --- /dev/null +++ b/dockers/docker-team/start.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +TEAMD_CONF_PATH=/etc/teamd + +function clean_up { + pkill -9 teamd + pkill -9 teamsyncd + service rsyslog stop + exit +} + +trap clean_up SIGTERM SIGKILL + +service rsyslog start + +if [ -d $TEAMD_CONF_PATH ]; then + for f in $TEAMD_CONF_PATH/*; do + teamd -f $f -d + done +fi + +teamsyncd & + +read diff --git a/src/Makefile b/src/Makefile index 38bcaf7cfaf1..9dd79d5b9bd6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -22,6 +22,9 @@ install_deb = \ libnl-%.deb: pushd libnl3; ./build.sh; popd +libteam5_1.26-1_amd64.deb libteam-dev_1.26-1_amd64.deb libteam-utils_1.26-1_amd64.deb libteamdctl0_1.26-1_amd64.deb: libnl-%.deb + pushd libteam; ./build.sh; popd + quagga_0.99.24.1-2_amd64.deb: pushd quagga; ./build.sh; popd @@ -80,26 +83,29 @@ p4/syncd_1.0.0_amd64.deb p4/libsairedis_1.0.0_amd64.deb p4/libsairedis-dev_1.0.0 mkdir -p p4 cp syncd_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb libsairedis-dev_1.0.0_amd64.deb p4/ -## Note: fpmsyncd is one implicit target -brcm/swss_1.0.0_amd64.deb brcm/intfsyncd brcm/neighsyncd brcm/orchagent brcm/portsyncd brcm/routeresync brcm/swssconfig: brcm/syncd_1.0.0_amd64.deb brcm/libsairedis_1.0.0_amd64.deb brcm/libsairedis-dev_1.0.0_amd64.deb +## Note: fpmsyncd and teamsyncd are two implicit targets +brcm/swss_1.0.0_amd64.deb: brcm/syncd_1.0.0_amd64.deb brcm/libsairedis_1.0.0_amd64.deb brcm/libsairedis-dev_1.0.0_amd64.deb $(foreach dep, $^, $(call install_deb, $(dep))) $(call build_project, sonic-swss) cp swss_1.0.0_amd64.deb brcm/ cp sonic-swss/debian/swss/usr/bin/fpmsyncd . + cp sonic-swss/debian/swss/usr/bin/teamsyncd . -## Note: fpmsyncd is one implicit target -mlnx/swss_1.0.0_amd64.deb mlnx/intfsyncd mlnx/neighsyncd mlnx/orchagent mlnx/portsyncd mlnx/routeresync mlnx/swssconfig: mlnx/syncd_1.0.0_amd64.deb mlnx/libsairedis_1.0.0_amd64.deb mlnx/libsairedis-dev_1.0.0_amd64.deb +## Note: fpmsyncd and teamsyncd are two implicit targets +mlnx/swss_1.0.0_amd64.deb: mlnx/syncd_1.0.0_amd64.deb mlnx/libsairedis_1.0.0_amd64.deb mlnx/libsairedis-dev_1.0.0_amd64.deb $(foreach dep, $^, $(call install_deb, $(dep))) $(call build_project, sonic-swss) cp swss_1.0.0_amd64.deb mlnx/ cp sonic-swss/debian/swss/usr/bin/fpmsyncd . + cp sonic-swss/debian/swss/usr/bin/teamsyncd . -## Note: fpmsyncd is one implicit target -cavm/swss_1.0.0_amd64.deb cavm/intfsyncd cavm/neighsyncd cavm/orchagent cavm/portsyncd cavm/routeresync cavm/swssconfig: cavm/syncd_1.0.0_amd64.deb cavm/libsairedis_1.0.0_amd64.deb cavm/libsairedis-dev_1.0.0_amd64.deb +## Note: fpmsyncd and teamsyncd are two implicit targets +cavm/swss_1.0.0_amd64.deb: cavm/syncd_1.0.0_amd64.deb cavm/libsairedis_1.0.0_amd64.deb cavm/libsairedis-dev_1.0.0_amd64.deb $(foreach dep, $^, $(call install_deb, $(dep))) $(call build_project, sonic-swss) cp swss_1.0.0_amd64.deb cavm/ cp sonic-swss/debian/swss/usr/bin/fpmsyncd . + cp sonic-swss/debian/swss/usr/bin/teamsyncd . p4/swss_1.0.0_amd64.deb: p4/syncd_1.0.0_amd64.deb p4/libsairedis_1.0.0_amd64.deb p4/libsairedis-dev_1.0.0_amd64.deb $(foreach dep, $^, $(call install_deb, $(dep))) diff --git a/src/libteam/build.sh b/src/libteam/build.sh new file mode 100755 index 000000000000..8a7e69cfb1a2 --- /dev/null +++ b/src/libteam/build.sh @@ -0,0 +1,26 @@ +#!/bin/bash +## This script is to build libteam +## +## USAGE: +## ./build.sh + +# Obtain libteam +rm -rf ./libteam +git clone https://github.com/jpirko/libteam.git +pushd ./libteam +git checkout -f v1.26 +popd + +git clone https://anonscm.debian.org/git/collab-maint/libteam.git tmp +pushd ./tmp +git checkout -f da006f2 # v1.26 +popd +mv tmp/debian libteam/ +rm -rf tmp + +pushd ./libteam +dpkg-buildpackage -rfakeroot -b -us -uc + +popd +cp *.deb .. +