Skip to content

Commit

Permalink
libteam: Adding build.sh script and docker-team (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shuotian Cheng authored Oct 7, 2016
1 parent 28fa109 commit 4373c51
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 14 deletions.
23 changes: 17 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 < $<
Expand All @@ -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)
3 changes: 1 addition & 2 deletions dockers/docker-fpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions dockers/docker-team/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

24 changes: 24 additions & 0 deletions dockers/docker-team/start.sh
Original file line number Diff line number Diff line change
@@ -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
18 changes: 12 additions & 6 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)))
Expand Down
26 changes: 26 additions & 0 deletions src/libteam/build.sh
Original file line number Diff line number Diff line change
@@ -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 ..

0 comments on commit 4373c51

Please sign in to comment.