From 53a9792014d4780e7f988bca23e0ac536fdaea00 Mon Sep 17 00:00:00 2001 From: Oleksandr Ivantsiv Date: Tue, 7 Feb 2017 10:33:20 +0200 Subject: [PATCH] [Makefile]: Add possibility for docker containers to install files to base image (#240) - Add vtysh/lldpctl/sensors to baseimage --- dockers/docker-fpm/base_image_files/vtysh | 2 ++ dockers/docker-lldp-sv2/base_image_files/lldpctl | 2 ++ dockers/docker-platform-monitor/base_image_files/sensors | 2 ++ files/build_templates/sonic_debian_extension.j2 | 8 ++++++++ rules/docker-fpm.mk | 2 ++ rules/docker-lldp-sv2.mk | 2 ++ rules/docker-platform-monitor.mk | 2 ++ slave.mk | 1 + 8 files changed, 21 insertions(+) create mode 100755 dockers/docker-fpm/base_image_files/vtysh create mode 100755 dockers/docker-lldp-sv2/base_image_files/lldpctl create mode 100755 dockers/docker-platform-monitor/base_image_files/sensors diff --git a/dockers/docker-fpm/base_image_files/vtysh b/dockers/docker-fpm/base_image_files/vtysh new file mode 100755 index 0000000000..359101c06c --- /dev/null +++ b/dockers/docker-fpm/base_image_files/vtysh @@ -0,0 +1,2 @@ +#!/bin/bash +docker exec -i bgp vtysh "$@" diff --git a/dockers/docker-lldp-sv2/base_image_files/lldpctl b/dockers/docker-lldp-sv2/base_image_files/lldpctl new file mode 100755 index 0000000000..c55e5ce8e2 --- /dev/null +++ b/dockers/docker-lldp-sv2/base_image_files/lldpctl @@ -0,0 +1,2 @@ +#!/bin/bash +docker exec -it lldp lldpctl "$@" diff --git a/dockers/docker-platform-monitor/base_image_files/sensors b/dockers/docker-platform-monitor/base_image_files/sensors new file mode 100755 index 0000000000..af1e579418 --- /dev/null +++ b/dockers/docker-platform-monitor/base_image_files/sensors @@ -0,0 +1,2 @@ +#!/bin/bash +docker exec -i pmon sensors "$@" diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 4cebcb2227..be7f338dae 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -117,3 +117,11 @@ sudo LANG=C chroot $FILESYSTEM_ROOT fuser -km /sys || true sudo LANG=C chroot $FILESYSTEM_ROOT umount -lf /sys {% endif %} +{% for file in installer_extra_files.split(' ') -%} +{% if file.strip() -%} +{% set src = file.split(':')[0] -%} +{% set dst = file.split(':')[1] -%} +sudo cp {{src}} $FILESYSTEM_ROOT/{{dst}} +{% endif -%} +{% endfor -%} + diff --git a/rules/docker-fpm.mk b/rules/docker-fpm.mk index 090c2b61cc..4c9c09ffd4 100644 --- a/rules/docker-fpm.mk +++ b/rules/docker-fpm.mk @@ -11,3 +11,5 @@ $(DOCKER_FPM)_CONTAINER_NAME = bgp $(DOCKER_FPM)_RUN_OPT += --net=host --privileged -t $(DOCKER_FPM)_RUN_OPT += --volumes-from database $(DOCKER_FPM)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro + +$(DOCKER_FPM)_BASE_IMAGE_FILES += vtysh:/usr/bin/vtysh diff --git a/rules/docker-lldp-sv2.mk b/rules/docker-lldp-sv2.mk index 7041a24f81..e9f701a495 100644 --- a/rules/docker-lldp-sv2.mk +++ b/rules/docker-lldp-sv2.mk @@ -11,3 +11,5 @@ SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_LLDP_SV2) $(DOCKER_LLDP_SV2)_CONTAINER_NAME = lldp $(DOCKER_LLDP_SV2)_RUN_OPT += --net=host --privileged -t $(DOCKER_LLDP_SV2)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro + +$(DOCKER_LLDP_SV2)_BASE_IMAGE_FILES += lldpctl:/usr/bin/lldpctl diff --git a/rules/docker-platform-monitor.mk b/rules/docker-platform-monitor.mk index 223e87bfac..92b64bf15b 100644 --- a/rules/docker-platform-monitor.mk +++ b/rules/docker-platform-monitor.mk @@ -11,3 +11,5 @@ SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_PLATFORM_MONITOR) $(DOCKER_PLATFORM_MONITOR)_CONTAINER_NAME = pmon $(DOCKER_PLATFORM_MONITOR)_RUN_OPT += --net=host --privileged -t $(DOCKER_PLATFORM_MONITOR)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro + +$(DOCKER_PLATFORM_MONITOR)_BASE_IMAGE_FILES += sensors:/usr/bin/sensors diff --git a/slave.mk b/slave.mk index 68ed227cdc..e34d932c1a 100644 --- a/slave.mk +++ b/slave.mk @@ -309,6 +309,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : .platform export installer_start_scrips="$(foreach docker, $($*_DOCKERS),$(addsuffix .sh, $($(docker)_CONTAINER_NAME)))" export installer_services="$(foreach docker, $($*_DOCKERS),$(addsuffix .service, $($(docker)_CONTAINER_NAME)))" + export installer_extra_files="$(foreach docker, $($*_DOCKERS), $(foreach file, $($(docker)_BASE_IMAGE_FILES), $($(docker)_PATH)/base_image_files/$(file)))" j2 -f env files/initramfs-tools/union-mount.j2 onie-image.conf > files/initramfs-tools/union-mount j2 -f env files/initramfs-tools/arista-convertfs.j2 onie-image.conf > files/initramfs-tools/arista-convertfs