2017-01-29 13:33:33 -06:00
|
|
|
#!/bin/bash
|
|
|
|
## This script is to automate loading of vendor specific docker images
|
|
|
|
## and instalation of configuration files and vendor specific packages
|
|
|
|
## to debian file system.
|
|
|
|
##
|
|
|
|
## USAGE:
|
2017-02-27 15:08:41 -06:00
|
|
|
## ./sonic_debian_extension.sh FILESYSTEM_ROOT PLATFORM_DIR
|
2017-01-29 13:33:33 -06:00
|
|
|
## PARAMETERS:
|
|
|
|
## FILESYSTEM_ROOT
|
|
|
|
## Path to debian file system root directory
|
|
|
|
|
|
|
|
FILESYSTEM_ROOT=$1
|
|
|
|
[ -n "$FILESYSTEM_ROOT" ] || {
|
|
|
|
echo "Error: no or empty FILESYSTEM_ROOT argument"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2017-02-27 15:08:41 -06:00
|
|
|
PLATFORM_DIR=$2
|
|
|
|
[ -n "$PLATFORM_DIR" ] || {
|
|
|
|
echo "Error: no or empty PLATFORM_DIR argument"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
## Enable debug output for script
|
|
|
|
set -x -e
|
|
|
|
|
2019-07-26 00:06:41 -05:00
|
|
|
CONFIGURED_ARCH=$([ -f .arch ] && cat .arch || echo amd64)
|
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
. functions.sh
|
2020-06-24 17:25:16 -05:00
|
|
|
BUILD_SCRIPTS_DIR=files/build_scripts
|
2017-01-29 13:33:33 -06:00
|
|
|
BUILD_TEMPLATES=files/build_templates
|
|
|
|
IMAGE_CONFIGS=files/image_config
|
2018-08-22 15:02:32 -05:00
|
|
|
SCRIPTS_DIR=files/scripts
|
2017-01-29 13:33:33 -06:00
|
|
|
|
2018-02-27 14:15:56 -06:00
|
|
|
# Define target fold macro
|
|
|
|
FILESYSTEM_ROOT_USR="$FILESYSTEM_ROOT/usr"
|
2020-05-30 15:46:44 -05:00
|
|
|
FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM="$FILESYSTEM_ROOT/usr/lib/systemd/system"
|
2018-02-27 14:15:56 -06:00
|
|
|
FILESYSTEM_ROOT_USR_SHARE="$FILESYSTEM_ROOT_USR/share"
|
|
|
|
FILESYSTEM_ROOT_USR_SHARE_SONIC="$FILESYSTEM_ROOT_USR_SHARE/sonic"
|
|
|
|
FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES="$FILESYSTEM_ROOT_USR_SHARE_SONIC/templates"
|
2019-12-15 18:48:48 -06:00
|
|
|
FILESYSTEM_ROOT_ETC="$FILESYSTEM_ROOT/etc"
|
|
|
|
FILESYSTEM_ROOT_ETC_SONIC="$FILESYSTEM_ROOT_ETC/sonic"
|
2018-02-27 14:15:56 -06:00
|
|
|
|
2019-07-29 17:52:15 -05:00
|
|
|
GENERATED_SERVICE_FILE="$FILESYSTEM_ROOT/etc/sonic/generated_services.conf"
|
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
clean_sys() {
|
|
|
|
sudo umount $FILESYSTEM_ROOT/sys/fs/cgroup/* \
|
|
|
|
$FILESYSTEM_ROOT/sys/fs/cgroup \
|
|
|
|
$FILESYSTEM_ROOT/sys || true
|
|
|
|
}
|
|
|
|
trap_push clean_sys
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT mount sysfs /sys -t sysfs
|
|
|
|
|
2019-01-04 22:47:43 -06:00
|
|
|
sudo bash -c "echo \"DOCKER_OPTS=\"--storage-driver=overlay2\"\" >> $FILESYSTEM_ROOT/etc/default/docker"
|
|
|
|
sudo cp files/docker/docker $FILESYSTEM_ROOT/etc/init.d/
|
2019-07-26 00:06:41 -05:00
|
|
|
if [[ $CONFIGURED_ARCH == armhf || $CONFIGURED_ARCH == arm64 ]]; then
|
|
|
|
SONIC_NATIVE_DOCKERD_FOR_DOCKERFS=" -H unix:///dockerfs/var/run/docker.sock "
|
|
|
|
SONIC_NATIVE_DOCKERD_FOR_DOCKERFS_PID="cat `pwd`/dockerfs/var/run/docker.pid"
|
|
|
|
else
|
|
|
|
sudo chroot $FILESYSTEM_ROOT service docker start
|
|
|
|
fi
|
2017-01-29 13:33:33 -06:00
|
|
|
|
|
|
|
# Apply apt configuration files
|
|
|
|
sudo cp $IMAGE_CONFIGS/apt/sources.list $FILESYSTEM_ROOT/etc/apt/
|
2019-07-26 00:06:41 -05:00
|
|
|
sudo mkdir -p $FILESYSTEM_ROOT/etc/apt/sources.list.d/
|
|
|
|
sudo cp -R $IMAGE_CONFIGS/apt/sources.list.d/${CONFIGURED_ARCH}/* $FILESYSTEM_ROOT/etc/apt/sources.list.d/
|
2017-01-29 13:33:33 -06:00
|
|
|
cat $IMAGE_CONFIGS/apt/sonic-dev.gpg.key | sudo LANG=C chroot $FILESYSTEM_ROOT apt-key add -
|
|
|
|
|
2017-02-27 02:13:36 -06:00
|
|
|
# Update apt's snapshot of its repos
|
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get update
|
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
# Apply environtment configuration files
|
|
|
|
sudo cp $IMAGE_CONFIGS/environment/environment $FILESYSTEM_ROOT/etc/
|
|
|
|
sudo cp $IMAGE_CONFIGS/environment/motd $FILESYSTEM_ROOT/etc/
|
|
|
|
|
2017-02-27 02:13:36 -06:00
|
|
|
# Create all needed directories
|
|
|
|
sudo mkdir -p $FILESYSTEM_ROOT/etc/sonic/
|
2018-11-21 10:08:37 -06:00
|
|
|
sudo mkdir -p $FILESYSTEM_ROOT/etc/modprobe.d/
|
2018-07-06 04:50:42 -05:00
|
|
|
sudo mkdir -p $FILESYSTEM_ROOT/var/cache/sonic/
|
2018-02-27 14:15:56 -06:00
|
|
|
sudo mkdir -p $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
2020-06-17 11:16:58 -05:00
|
|
|
# This is needed for Stretch and might not be needed for Buster where Linux create this directory by default.
|
|
|
|
# Keeping it generic. It should not harm anyways.
|
|
|
|
sudo mkdir -p $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
2017-02-27 02:13:36 -06:00
|
|
|
|
2019-07-20 01:09:14 -05:00
|
|
|
# Install a more recent version of ifupdown2 (and its dependencies via 'apt-get -y install -f')
|
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/ifupdown2_*.deb || \
|
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
|
|
|
|
|
2020-01-29 19:40:43 -06:00
|
|
|
# Install ipables (and its dependencies via 'apt-get -y install -f')
|
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/iptables_*.deb || \
|
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
|
|
|
|
|
2018-11-20 21:27:56 -06:00
|
|
|
# Install dependencies for SONiC config engine
|
2017-02-27 02:13:36 -06:00
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install \
|
2017-03-17 16:51:42 -05:00
|
|
|
python-dev \
|
2017-02-27 02:13:36 -06:00
|
|
|
python-lxml \
|
2017-03-17 16:51:42 -05:00
|
|
|
python-yaml \
|
|
|
|
python-bitarray
|
2017-02-27 02:13:36 -06:00
|
|
|
|
2017-04-04 01:56:15 -05:00
|
|
|
# Install SONiC config engine Python package
|
|
|
|
CONFIG_ENGINE_WHEEL_NAME=$(basename {{config_engine_wheel_path}})
|
|
|
|
sudo cp {{config_engine_wheel_path}} $FILESYSTEM_ROOT/$CONFIG_ENGINE_WHEEL_NAME
|
2017-12-24 01:34:15 -06:00
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install $CONFIG_ENGINE_WHEEL_NAME
|
2017-04-04 01:56:15 -05:00
|
|
|
sudo rm -rf $FILESYSTEM_ROOT/$CONFIG_ENGINE_WHEEL_NAME
|
2017-03-23 14:18:52 -05:00
|
|
|
|
|
|
|
# Install Python client for Redis
|
2018-11-19 14:03:15 -06:00
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install "redis==2.10.6"
|
2018-11-20 21:27:56 -06:00
|
|
|
|
|
|
|
# Install redis-dump-load Python 2 package
|
|
|
|
REDIS_DUMP_LOAD_PY2_WHEEL_NAME=$(basename {{redis_dump_load_py2_wheel_path}})
|
|
|
|
sudo cp {{redis_dump_load_py2_wheel_path}} $FILESYSTEM_ROOT/$REDIS_DUMP_LOAD_PY2_WHEEL_NAME
|
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install $REDIS_DUMP_LOAD_PY2_WHEEL_NAME
|
|
|
|
sudo rm -rf $FILESYSTEM_ROOT/$REDIS_DUMP_LOAD_PY2_WHEEL_NAME
|
2017-02-27 02:13:36 -06:00
|
|
|
|
2019-03-18 13:12:47 -05:00
|
|
|
# Install Python module for ipaddress
|
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install ipaddress
|
|
|
|
|
2017-04-04 01:56:15 -05:00
|
|
|
# Install SwSS SDK Python 2 package
|
|
|
|
SWSSSDK_PY2_WHEEL_NAME=$(basename {{swsssdk_py2_wheel_path}})
|
|
|
|
sudo cp {{swsssdk_py2_wheel_path}} $FILESYSTEM_ROOT/$SWSSSDK_PY2_WHEEL_NAME
|
2017-12-24 01:34:15 -06:00
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install $SWSSSDK_PY2_WHEEL_NAME
|
2017-04-04 01:56:15 -05:00
|
|
|
sudo rm -rf $FILESYSTEM_ROOT/$SWSSSDK_PY2_WHEEL_NAME
|
|
|
|
|
2018-01-17 19:11:31 -06:00
|
|
|
# Install sonic-platform-common Python 2 package
|
|
|
|
PLATFORM_COMMON_PY2_WHEEL_NAME=$(basename {{platform_common_py2_wheel_path}})
|
|
|
|
sudo cp {{platform_common_py2_wheel_path}} $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY2_WHEEL_NAME
|
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install $PLATFORM_COMMON_PY2_WHEEL_NAME
|
|
|
|
sudo rm -rf $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY2_WHEEL_NAME
|
|
|
|
|
2019-09-25 13:00:24 -05:00
|
|
|
# Install sonic-daemon-base Python 2 package
|
|
|
|
DAEMON_BASE_PY2_WHEEL_NAME=$(basename {{daemon_base_py2_wheel_path}})
|
|
|
|
sudo cp {{daemon_base_py2_wheel_path}} $FILESYSTEM_ROOT/$DAEMON_BASE_PY2_WHEEL_NAME
|
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install $DAEMON_BASE_PY2_WHEEL_NAME
|
|
|
|
sudo rm -rf $FILESYSTEM_ROOT/$DAEMON_BASE_PY2_WHEEL_NAME
|
|
|
|
|
2018-06-29 11:59:46 -05:00
|
|
|
# Install built Python Click package (and its dependencies via 'apt-get -y install -f')
|
|
|
|
# Do this before installing sonic-utilities so that it doesn't attempt to install
|
|
|
|
# an older version as part of its dependencies
|
2019-02-05 00:06:37 -06:00
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/python-click*_all.deb || \
|
2018-06-29 11:59:46 -05:00
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
|
|
|
|
|
2018-08-15 23:41:12 -05:00
|
|
|
# Install python pexpect used by sonic-utilities consutil
|
|
|
|
# using pip install instead to get a more recent version than is available through debian
|
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install pexpect
|
2019-05-27 17:50:51 -05:00
|
|
|
# Install python click-default-group by sonic-utilities
|
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install click-default-group==1.2
|
2018-08-15 23:41:12 -05:00
|
|
|
|
2018-10-08 20:36:37 -05:00
|
|
|
# Install tabulate >= 0.8.1 via pip in order to support multi-line row output for sonic-utilities
|
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install tabulate==0.8.2
|
|
|
|
|
2017-10-06 14:46:47 -05:00
|
|
|
# Install SONiC Utilities (and its dependencies via 'apt-get -y install -f')
|
2019-02-05 00:06:37 -06:00
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -i $python_debs_path/python-sonic-utilities_*.deb || \
|
2017-10-06 14:46:47 -05:00
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
|
2017-02-27 02:13:36 -06:00
|
|
|
|
2019-12-04 06:50:56 -06:00
|
|
|
{% if enable_ztp == "y" %}
|
|
|
|
# Install ZTP (and its dependencies via 'apt-get -y install -f')
|
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/sonic-ztp_*.deb || \
|
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
|
|
|
|
{% endif %}
|
|
|
|
|
2017-03-02 14:17:04 -06:00
|
|
|
# SONiC utilities installs bash-completion as a dependency. However, it is disabled by default
|
|
|
|
# in bash.bashrc, so we copy a version of the file with it enabled here.
|
|
|
|
sudo cp -f $IMAGE_CONFIGS/bash/bash.bashrc $FILESYSTEM_ROOT/etc/
|
|
|
|
|
2017-02-27 02:13:36 -06:00
|
|
|
# Install SONiC Device Data (and its dependencies via 'apt-get -y install -f')
|
2019-02-05 00:06:37 -06:00
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/sonic-device-data_*.deb || \
|
2017-02-27 02:13:36 -06:00
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
|
|
|
|
|
2017-12-07 05:36:17 -06:00
|
|
|
# Install pam-tacplus and nss-tacplus
|
2019-02-05 00:06:37 -06:00
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/libtac2_*.deb || \
|
2017-12-11 13:05:03 -06:00
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
|
2019-02-05 00:06:37 -06:00
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/libpam-tacplus_*.deb || \
|
2017-12-11 13:05:03 -06:00
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
|
2019-02-05 00:06:37 -06:00
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/libnss-tacplus_*.deb || \
|
2017-12-11 13:05:03 -06:00
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
|
2017-12-07 05:36:17 -06:00
|
|
|
# Disable tacplus by default
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT pam-auth-update --remove tacplus
|
|
|
|
sudo sed -i -e '/^passwd/s/ tacplus//' $FILESYSTEM_ROOT/etc/nsswitch.conf
|
|
|
|
|
2019-11-09 01:08:42 -06:00
|
|
|
# Install a custom version of kdump-tools (and its dependencies via 'apt-get -y install -f')
|
2020-01-29 11:07:12 -06:00
|
|
|
if [[ $CONFIGURED_ARCH == amd64 ]]; then
|
2019-11-09 01:08:42 -06:00
|
|
|
sudo DEBIAN_FRONTEND=noninteractive dpkg --root=$FILESYSTEM_ROOT -i $debs_path/kdump-tools_*.deb || \
|
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=truechroot $FILESYSTEM_ROOT apt-get -q --no-install-suggests --no-install-recommends --force-no install
|
2020-01-29 11:07:12 -06:00
|
|
|
fi
|
2019-11-09 01:08:42 -06:00
|
|
|
|
2019-12-30 20:25:57 -06:00
|
|
|
# Install custom-built monit package and SONiC configuration files
|
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/monit_*.deb || \
|
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
|
|
|
|
sudo cp $IMAGE_CONFIGS/monit/monitrc $FILESYSTEM_ROOT/etc/monit/
|
|
|
|
sudo chmod 600 $FILESYSTEM_ROOT/etc/monit/monitrc
|
|
|
|
sudo cp $IMAGE_CONFIGS/monit/conf.d/* $FILESYSTEM_ROOT/etc/monit/conf.d/
|
|
|
|
sudo chmod 600 $FILESYSTEM_ROOT/etc/monit/conf.d/*
|
|
|
|
|
2017-04-21 10:22:44 -05:00
|
|
|
# Copy crontabs
|
|
|
|
sudo cp -f $IMAGE_CONFIGS/cron.d/* $FILESYSTEM_ROOT/etc/cron.d/
|
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
# Copy NTP configuration files and templates
|
2020-05-30 15:46:44 -05:00
|
|
|
sudo cp $IMAGE_CONFIGS/ntp/ntp-config.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
2019-07-29 17:52:15 -05:00
|
|
|
echo "ntp-config.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
2017-01-29 13:33:33 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/ntp/ntp-config.sh $FILESYSTEM_ROOT/usr/bin/
|
2018-02-27 14:15:56 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/ntp/ntp.conf.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
2017-01-29 13:33:33 -06:00
|
|
|
|
2019-04-12 17:45:58 -05:00
|
|
|
# Copy warmboot-finalizer files
|
|
|
|
sudo LANG=C cp $IMAGE_CONFIGS/warmboot-finalizer/finalize-warmboot.sh $FILESYSTEM_ROOT/usr/local/bin/finalize-warmboot.sh
|
2020-05-30 15:46:44 -05:00
|
|
|
sudo LANG=C cp $IMAGE_CONFIGS/warmboot-finalizer/warmboot-finalizer.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
2019-07-29 17:52:15 -05:00
|
|
|
echo "warmboot-finalizer.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
2019-04-12 17:45:58 -05:00
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
# Copy rsyslog configuration files and templates
|
2020-05-30 15:46:44 -05:00
|
|
|
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog-config.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
2017-01-29 13:33:33 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog-config.sh $FILESYSTEM_ROOT/usr/bin/
|
2018-02-27 14:15:56 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog.conf.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
2020-06-30 08:29:20 -05:00
|
|
|
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog-container.conf.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
2017-01-29 13:33:33 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog.d/* $FILESYSTEM_ROOT/etc/rsyslog.d/
|
2019-07-29 17:52:15 -05:00
|
|
|
echo "rsyslog-config.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
2017-01-29 13:33:33 -06:00
|
|
|
|
2017-04-21 10:22:44 -05:00
|
|
|
# Copy logrotate.d configuration files
|
2017-08-10 18:24:57 -05:00
|
|
|
sudo cp -f $IMAGE_CONFIGS/logrotate/logrotate.d/* $FILESYSTEM_ROOT/etc/logrotate.d/
|
2017-04-21 10:22:44 -05:00
|
|
|
|
|
|
|
# Copy systemd-journald configuration files
|
|
|
|
sudo cp -f $IMAGE_CONFIGS/systemd/journald.conf $FILESYSTEM_ROOT/etc/systemd/
|
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
# Copy interfaces configuration files and templates
|
2020-05-30 15:46:44 -05:00
|
|
|
sudo cp $IMAGE_CONFIGS/interfaces/interfaces-config.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
2017-01-29 13:33:33 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/interfaces/interfaces-config.sh $FILESYSTEM_ROOT/usr/bin/
|
2018-02-27 14:15:56 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/interfaces/*.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
2019-07-29 17:52:15 -05:00
|
|
|
echo "interfaces-config.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
2017-01-29 13:33:33 -06:00
|
|
|
|
2019-12-10 10:16:56 -06:00
|
|
|
# Copy dhcp client configuration template and create an initial configuration
|
|
|
|
sudo cp files/dhcp/dhclient.conf.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
|
|
|
j2 files/dhcp/dhclient.conf.j2 | sudo tee $FILESYSTEM_ROOT/etc/dhcp/dhclient.conf
|
|
|
|
sudo cp files/dhcp/ifupdown2_policy.json $FILESYSTEM_ROOT/etc/network/ifupdown2/policy.d
|
|
|
|
sudo cp files/dhcp/90-dhcp6-systcl.conf.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
|
|
|
|
2017-02-17 15:47:01 -06:00
|
|
|
# Copy initial interfaces configuration file, will be overwritten on first boot
|
2018-11-27 16:35:17 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/interfaces/init_interfaces $FILESYSTEM_ROOT/etc/network/interfaces
|
2019-03-09 08:22:32 -06:00
|
|
|
sudo mkdir -p $FILESYSTEM_ROOT/etc/network/interfaces.d
|
2017-02-17 15:47:01 -06:00
|
|
|
|
2017-12-12 05:45:44 -06:00
|
|
|
# Copy hostcfgd files
|
2020-05-30 15:46:44 -05:00
|
|
|
sudo cp $IMAGE_CONFIGS/hostcfgd/hostcfgd.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
2019-07-29 17:52:15 -05:00
|
|
|
echo "hostcfgd.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
2017-12-12 05:45:44 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/hostcfgd/hostcfgd $FILESYSTEM_ROOT/usr/bin/
|
2018-02-27 14:15:56 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/hostcfgd/*.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
|
|
|
|
2019-12-15 18:48:48 -06:00
|
|
|
# copy core file uploader files
|
2020-05-30 15:46:44 -05:00
|
|
|
sudo cp $IMAGE_CONFIGS/corefile_uploader/core_uploader.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
2019-12-15 18:48:48 -06:00
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl disable core_uploader.service
|
|
|
|
sudo cp $IMAGE_CONFIGS/corefile_uploader/core_uploader.py $FILESYSTEM_ROOT/usr/bin/
|
|
|
|
sudo cp $IMAGE_CONFIGS/corefile_uploader/core_analyzer.rc.json $FILESYSTEM_ROOT_ETC_SONIC/
|
|
|
|
sudo chmod og-rw $FILESYSTEM_ROOT_ETC_SONIC/core_analyzer.rc.json
|
2020-05-12 01:17:47 -05:00
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install azure-storage==0.36.0
|
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install watchdog==0.10.2
|
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install futures==3.3.0
|
2019-12-15 18:48:48 -06:00
|
|
|
|
2020-04-16 23:54:45 -05:00
|
|
|
{% if install_kubernetes == "y" %}
|
|
|
|
# Copy kubelet service files
|
|
|
|
# Keep it disabled until join, else it continuously restart and as well spew too many
|
|
|
|
# non-required log lines wasting syslog resources.
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl disable kubelet.service
|
|
|
|
{% endif %}
|
|
|
|
|
2018-02-27 14:15:56 -06:00
|
|
|
# Copy the buffer configuration template
|
|
|
|
sudo cp $BUILD_TEMPLATES/buffers_config.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
2017-12-12 05:45:44 -06:00
|
|
|
|
2018-10-17 16:10:34 -05:00
|
|
|
# Copy the qos configuration template
|
|
|
|
sudo cp $BUILD_TEMPLATES/qos_config.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
|
|
|
|
2017-11-22 16:36:25 -06:00
|
|
|
# Copy hostname configuration scripts
|
2020-05-30 15:46:44 -05:00
|
|
|
sudo cp $IMAGE_CONFIGS/hostname/hostname-config.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
2019-07-29 17:52:15 -05:00
|
|
|
echo "hostname-config.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
2017-11-22 16:36:25 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/hostname/hostname-config.sh $FILESYSTEM_ROOT/usr/bin/
|
|
|
|
|
2019-11-09 12:26:39 -06:00
|
|
|
# Copy miscellaneous scripts
|
|
|
|
sudo cp $IMAGE_CONFIGS/misc/docker-wait-any $FILESYSTEM_ROOT/usr/bin/
|
|
|
|
|
2020-01-26 15:56:42 -06:00
|
|
|
# Copy internal topology configuration scripts
|
|
|
|
{%- if sonic_asic_platform == "vs" %}
|
2020-05-30 15:46:44 -05:00
|
|
|
sudo cp $IMAGE_CONFIGS/topology/topology.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
2020-01-26 15:56:42 -06:00
|
|
|
echo "topology.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
|
|
|
sudo cp $IMAGE_CONFIGS/topology/topology.sh $FILESYSTEM_ROOT/usr/bin
|
|
|
|
{%- endif %}
|
|
|
|
|
2017-02-17 15:47:01 -06:00
|
|
|
# Copy updategraph script and service file
|
2020-05-30 15:46:44 -05:00
|
|
|
j2 files/build_templates/updategraph.service.j2 | sudo tee $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM/updategraph.service
|
2017-02-17 15:47:01 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/updategraph/updategraph $FILESYSTEM_ROOT/usr/bin/
|
2019-07-29 17:52:15 -05:00
|
|
|
echo "updategraph.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
2017-02-17 15:47:01 -06:00
|
|
|
{% if enable_dhcp_graph_service == "y" %}
|
|
|
|
sudo bash -c "echo enabled=true > $FILESYSTEM_ROOT/etc/sonic/updategraph.conf"
|
|
|
|
sudo bash -c "echo src=dhcp >> $FILESYSTEM_ROOT/etc/sonic/updategraph.conf"
|
|
|
|
sudo bash -c "echo dhcp_as_static=true >> $FILESYSTEM_ROOT/etc/sonic/updategraph.conf"
|
|
|
|
{% else %}
|
|
|
|
sudo bash -c "echo enabled=false > $FILESYSTEM_ROOT/etc/sonic/updategraph.conf"
|
|
|
|
{% endif %}
|
2020-02-07 14:35:35 -06:00
|
|
|
|
|
|
|
# Generate initial SONiC configuration file
|
|
|
|
j2 files/build_templates/init_cfg.json.j2 | sudo tee $FILESYSTEM_ROOT/etc/sonic/init_cfg.json
|
2018-03-06 01:55:37 -06:00
|
|
|
|
2019-12-04 09:15:58 -06:00
|
|
|
# Copy config-setup script and service file
|
2020-05-30 15:46:44 -05:00
|
|
|
j2 files/build_templates/config-setup.service.j2 | sudo tee $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM/config-setup.service
|
2019-12-04 09:15:58 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/config-setup/config-setup $FILESYSTEM_ROOT/usr/bin/config-setup
|
2020-03-31 12:06:19 -05:00
|
|
|
echo "config-setup.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
2019-12-04 09:15:58 -06:00
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable config-setup.service
|
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
# Copy SNMP configuration files
|
|
|
|
sudo cp $IMAGE_CONFIGS/snmp/snmp.yml $FILESYSTEM_ROOT/etc/sonic/
|
|
|
|
|
2017-06-21 20:52:50 -05:00
|
|
|
# Copy ASN configuration files
|
2019-11-06 18:07:28 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/constants/constants.yml $FILESYSTEM_ROOT/etc/sonic/
|
2017-06-21 20:52:50 -05:00
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
# Copy sudoers configuration file
|
|
|
|
sudo cp $IMAGE_CONFIGS/sudoers/sudoers $FILESYSTEM_ROOT/etc/
|
2018-06-21 12:41:50 -05:00
|
|
|
sudo cp $IMAGE_CONFIGS/sudoers/sudoers.lecture $FILESYSTEM_ROOT/etc/
|
2017-01-29 13:33:33 -06:00
|
|
|
|
2018-01-09 19:55:10 -06:00
|
|
|
# Copy control plane ACL management daemon files
|
2020-05-30 15:46:44 -05:00
|
|
|
sudo cp $IMAGE_CONFIGS/caclmgrd/caclmgrd.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
2019-07-29 17:52:15 -05:00
|
|
|
echo "caclmgrd.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
2018-01-09 19:55:10 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/caclmgrd/caclmgrd $FILESYSTEM_ROOT/usr/bin/
|
|
|
|
|
2019-11-27 17:35:41 -06:00
|
|
|
# Copy process/docker cpu/memory utilization data export daemon
|
2020-05-30 15:46:44 -05:00
|
|
|
sudo cp $IMAGE_CONFIGS/procdockerstatsd/procdockerstatsd.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
2019-11-27 17:35:41 -06:00
|
|
|
echo "procdockerstatsd.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
|
|
|
sudo cp $IMAGE_CONFIGS/procdockerstatsd/procdockerstatsd $FILESYSTEM_ROOT/usr/bin/
|
|
|
|
|
2020-01-10 11:47:13 -06:00
|
|
|
# Copy systemd timer configuration
|
|
|
|
# It implements delayed start of services
|
2020-05-30 15:46:44 -05:00
|
|
|
sudo cp $BUILD_TEMPLATES/process-reboot-cause.timer $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
2020-01-10 11:47:13 -06:00
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable process-reboot-cause.timer
|
|
|
|
|
2019-07-03 12:38:20 -05:00
|
|
|
# Copy process-reboot-cause service files
|
2020-05-30 15:46:44 -05:00
|
|
|
sudo cp $IMAGE_CONFIGS/process-reboot-cause/process-reboot-cause.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
2019-07-29 17:52:15 -05:00
|
|
|
echo "process-reboot-cause.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
2019-07-03 12:38:20 -05:00
|
|
|
sudo cp $IMAGE_CONFIGS/process-reboot-cause/process-reboot-cause $FILESYSTEM_ROOT/usr/bin/
|
|
|
|
|
2017-02-10 09:39:05 -06:00
|
|
|
## Install package without starting service
|
|
|
|
## ref: https://wiki.debian.org/chroot
|
|
|
|
sudo tee -a $FILESYSTEM_ROOT/usr/sbin/policy-rc.d > /dev/null <<EOF
|
|
|
|
#!/bin/sh
|
|
|
|
exit 101
|
|
|
|
EOF
|
|
|
|
sudo chmod a+x $FILESYSTEM_ROOT/usr/sbin/policy-rc.d
|
|
|
|
|
2017-02-27 15:08:41 -06:00
|
|
|
{% if installer_debs.strip() -%}
|
2017-01-29 13:33:33 -06:00
|
|
|
{% for deb in installer_debs.strip().split(' ') -%}
|
2017-02-10 09:39:05 -06:00
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -i {{deb}} || sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
|
2017-01-29 13:33:33 -06:00
|
|
|
{% endfor %}
|
2017-02-27 15:08:41 -06:00
|
|
|
{% endif %}
|
2017-02-10 09:39:05 -06:00
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
## Run depmod command for target kernel modules
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT depmod -a {{kversion}}
|
2017-02-27 15:08:41 -06:00
|
|
|
|
|
|
|
## download all dependency packages for platform debian packages
|
|
|
|
{% if lazy_installer_debs.strip() -%}
|
|
|
|
{% for file in lazy_installer_debs.strip().split(' ') -%}
|
|
|
|
|
|
|
|
{% set dev = file.split('@')[0] -%}
|
|
|
|
{% set deb = file.split('@')[1] -%}
|
|
|
|
{% set debfilename = deb.split('/')|last -%}
|
|
|
|
{% set debname = debfilename.split('_')|first -%}
|
|
|
|
|
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -i {{deb}} || sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f --download-only
|
|
|
|
|
|
|
|
sudo mkdir -p $FILESYSTEM_ROOT/$PLATFORM_DIR/{{dev}}
|
|
|
|
sudo cp {{ deb }} $FILESYSTEM_ROOT/$PLATFORM_DIR/{{dev}}/
|
2017-04-04 01:56:15 -05:00
|
|
|
for f in $(find $FILESYSTEM_ROOT/var/cache/apt/archives -name "*.deb"); do
|
2017-02-27 15:08:41 -06:00
|
|
|
sudo mv $f $FILESYSTEM_ROOT/$PLATFORM_DIR/{{dev}}/
|
|
|
|
done
|
|
|
|
|
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -P {{ debname }}
|
|
|
|
|
|
|
|
{% endfor %}
|
2017-01-29 13:33:33 -06:00
|
|
|
{% endif %}
|
2017-02-27 15:08:41 -06:00
|
|
|
|
|
|
|
sudo rm -f $FILESYSTEM_ROOT/usr/sbin/policy-rc.d
|
|
|
|
|
2019-04-21 16:21:16 -05:00
|
|
|
# Copy fstrim service and timer file, enable fstrim timer
|
2020-05-30 15:46:44 -05:00
|
|
|
sudo cp $IMAGE_CONFIGS/fstrim/* $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
2019-04-21 16:21:16 -05:00
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable fstrim.timer
|
|
|
|
|
2017-02-27 15:08:41 -06:00
|
|
|
## copy platform rc.local
|
|
|
|
sudo cp $IMAGE_CONFIGS/platform/rc.local $FILESYSTEM_ROOT/etc/
|
|
|
|
|
2018-11-21 10:08:37 -06:00
|
|
|
## copy blacklist file
|
|
|
|
sudo cp $IMAGE_CONFIGS/platform/linux_kernel_bde.conf $FILESYSTEM_ROOT/etc/modprobe.d/
|
|
|
|
|
2019-09-14 22:27:09 -05:00
|
|
|
# Enable psample drivers to support sFlow on vs
|
|
|
|
{% if sonic_asic_platform == "vs" %}
|
|
|
|
sudo tee -a $FILESYSTEM_ROOT/etc/modules-load.d/modules.conf > /dev/null <<EOF
|
|
|
|
psample
|
|
|
|
act_sample
|
|
|
|
EOF
|
|
|
|
{% endif %}
|
|
|
|
|
2019-07-26 00:06:41 -05:00
|
|
|
## Bind docker path
|
|
|
|
if [[ $CONFIGURED_ARCH == armhf || $CONFIGURED_ARCH == arm64 ]]; then
|
|
|
|
sudo mkdir -p $FILESYSTEM_ROOT/dockerfs
|
2019-12-16 11:07:05 -06:00
|
|
|
sudo mount --bind dockerfs $FILESYSTEM_ROOT/dockerfs
|
2019-07-26 00:06:41 -05:00
|
|
|
fi
|
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
{% if installer_images.strip() -%}
|
2019-07-26 00:06:41 -05:00
|
|
|
sudo chroot $FILESYSTEM_ROOT docker $SONIC_NATIVE_DOCKERD_FOR_DOCKERFS info
|
2017-01-29 13:33:33 -06:00
|
|
|
{% for image in installer_images.strip().split(' ') -%}
|
2017-10-08 04:10:14 -05:00
|
|
|
{% set imagefilename = image.split('/')|last -%}
|
|
|
|
{% set imagename = imagefilename.split('.')|first -%}
|
2019-07-26 00:06:41 -05:00
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT docker $SONIC_NATIVE_DOCKERD_FOR_DOCKERFS load < {{image}}
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT docker $SONIC_NATIVE_DOCKERD_FOR_DOCKERFS tag {{imagename}}:latest {{imagename}}:$(sonic_get_version)
|
[build]: Build sonic-broadcom.bin using debug dockers for all stretch based dockers (#2833)
* Updated Makefile infrastructure to build debug images.
As a sample, platform/broadcom/docker-orchagent-brcm.mk is updated to add a docker-orchagent-brcm-dbg.gz target.
Now "BLDENV=stretch make target/docker-orchagent-brcm-dbg.gz" will build the debug image.
NOTE: If you don't specify NOSTRETcH=1, it implicitly calls "make stretch", which builds all stretch targets and that would include debug dockers too.
This debug image can be used in any linux box to inspect core file. If your module's external dependency can be suitably mocked, you my even manually run it inside.
"docker run -it --entrypoint=/bin/bash e47a8fb8ed38"
You may map the core file path to this docker run.
* Dropped the regular binary using DBG_PACKAGES and a small name change to help readability.
* Tweaked the changes to retain the existing behavior w.r.t INSTALL_DEBUG_TOOLS=y.
When this change ('building debug docker image transparently') is extended to all dockers, this flag would become redundant. Yet, there can be some test based use cases that rely on this flag.
Until after all the dockers gets their debug images by default and we switch all use cases of this flag to use the newly built debug images, we need to maintain the existing behavior.
* 1) slave.mk - Dropped unused Docker build args
2) Debug template builder: renamed build_dbg_j2.sh to build_debug_docker_j2.sh
3) Dropped insignifcant statement CMD from debug Docker file, as base docker has Entrypoint.
* Reverted some changes, per review comments.
"User, uid, guid, frr-uid & frr-guid" are required for all docker images, with exception of debug images.
* Get in sync with the new update that filters out dockers to be built (SONIC_STRETCH_DOCKERS_FOR_INSTALLERS) and build debug-dockers only for those to be built and debug target is available.
* Mkae a template for each target that can be shared by all platforms.
Where needed a platform entry can override the template.
This avoids duplication, hence easier to maintain.
* A small change, that can fit better with other targets too.
Just take the platform code and do the rest in template.
* Extended debug to all stretch based docker images
* 1) Combined all orchagent makefiles into one platform independent make under rules/docker-orchagent.mk
2) Extened debug image to all stretch dockers
* Changes per review comments:
1) Dropped LIBSAIREDIS_DBG from database, teamd, router-advertiser, telemetry, and platform-monitor docker*.mk files from _DBG_DEPENDS list
2) W.r.t docker make for syncd, moved DEPENDS from template to specific makefile and let the template has stuff that is applicable to all.
* 1) Corrected a copy/paste mistake
* Fixed a copy/paste bug
* The base syncd dockers follow a template, which defines the base docker as DOCKER_SYNCD_BASE instead of DOCKER_SYNCD_<platform code>. Fix the docker-syncd-<mlnx, bfn>.mk to use the new one.
[Yet to be tested locally]
* Fixed spelling mistake
* Enable build of dbg-sonic-broadcom.bin, which uses dbg-dockers in place of regular dockers, for dockers that build debug version. For dockers that do not build debug version, it uses the regular docker.
This debug bin is installable and usable in a DUT, just like a regular bin.
* Per review comments:
1) Share a single rule for final image for normal & debug flavors (e.g. sonic-broadcom.bin & sonic-broadcom-dbg.bin)
2) Put dbg as suffix in final image name.
3) Compared target/sonic-broadcom.bin.logs with & w/o fix to verify integrity of sonic-broadcom.bin
4) Compared target/sonic-broadcom.bin.logs with sonic-broadcom-dbg.bin.log for verification
This fix takes care of ONIE image only. The next PR will cover the rest.
The next PR, will also make debug image conditional with flag.
* Updated per comments.
Now that debug dockers are available, do not need a way to install debug symbols in regular dockers.
With this commit, when INSTALL_DEBUG_TOOLS=y is set, it builds debug dockers (for dockers that enable debug build) and the final image uses debug dockers. For dockers that do not enable debug build, regular dockers get used in the final image.
Note:
The debug dockers are explicitly named as <docker name>-dbg.gz. But there is no "-dbg" suffix for image.
Hence if you make two runs with and w/o INSTALL_DEBUG_TOOLS=y, you have complete set of regular dockers + debug dockers. But the image gets overwritten.
Hence if both regular & debug images are needed, make two runs, as one with INSTALL_DEBUG_TOOLS=y and one w/o. Make sure to copy/rename the final image, before making the second run.
2019-06-12 03:36:21 -05:00
|
|
|
{% if imagename.endswith('-dbg') %}
|
|
|
|
{% set imagebasename = imagename.replace('-dbg', '') -%}
|
2019-07-26 00:06:41 -05:00
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT docker $SONIC_NATIVE_DOCKERD_FOR_DOCKERFS tag {{imagename}}:latest {{imagebasename}}:$(sonic_get_version)
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT docker $SONIC_NATIVE_DOCKERD_FOR_DOCKERFS tag {{imagename}}:latest {{imagebasename}}:latest
|
[build]: Build sonic-broadcom.bin using debug dockers for all stretch based dockers (#2833)
* Updated Makefile infrastructure to build debug images.
As a sample, platform/broadcom/docker-orchagent-brcm.mk is updated to add a docker-orchagent-brcm-dbg.gz target.
Now "BLDENV=stretch make target/docker-orchagent-brcm-dbg.gz" will build the debug image.
NOTE: If you don't specify NOSTRETcH=1, it implicitly calls "make stretch", which builds all stretch targets and that would include debug dockers too.
This debug image can be used in any linux box to inspect core file. If your module's external dependency can be suitably mocked, you my even manually run it inside.
"docker run -it --entrypoint=/bin/bash e47a8fb8ed38"
You may map the core file path to this docker run.
* Dropped the regular binary using DBG_PACKAGES and a small name change to help readability.
* Tweaked the changes to retain the existing behavior w.r.t INSTALL_DEBUG_TOOLS=y.
When this change ('building debug docker image transparently') is extended to all dockers, this flag would become redundant. Yet, there can be some test based use cases that rely on this flag.
Until after all the dockers gets their debug images by default and we switch all use cases of this flag to use the newly built debug images, we need to maintain the existing behavior.
* 1) slave.mk - Dropped unused Docker build args
2) Debug template builder: renamed build_dbg_j2.sh to build_debug_docker_j2.sh
3) Dropped insignifcant statement CMD from debug Docker file, as base docker has Entrypoint.
* Reverted some changes, per review comments.
"User, uid, guid, frr-uid & frr-guid" are required for all docker images, with exception of debug images.
* Get in sync with the new update that filters out dockers to be built (SONIC_STRETCH_DOCKERS_FOR_INSTALLERS) and build debug-dockers only for those to be built and debug target is available.
* Mkae a template for each target that can be shared by all platforms.
Where needed a platform entry can override the template.
This avoids duplication, hence easier to maintain.
* A small change, that can fit better with other targets too.
Just take the platform code and do the rest in template.
* Extended debug to all stretch based docker images
* 1) Combined all orchagent makefiles into one platform independent make under rules/docker-orchagent.mk
2) Extened debug image to all stretch dockers
* Changes per review comments:
1) Dropped LIBSAIREDIS_DBG from database, teamd, router-advertiser, telemetry, and platform-monitor docker*.mk files from _DBG_DEPENDS list
2) W.r.t docker make for syncd, moved DEPENDS from template to specific makefile and let the template has stuff that is applicable to all.
* 1) Corrected a copy/paste mistake
* Fixed a copy/paste bug
* The base syncd dockers follow a template, which defines the base docker as DOCKER_SYNCD_BASE instead of DOCKER_SYNCD_<platform code>. Fix the docker-syncd-<mlnx, bfn>.mk to use the new one.
[Yet to be tested locally]
* Fixed spelling mistake
* Enable build of dbg-sonic-broadcom.bin, which uses dbg-dockers in place of regular dockers, for dockers that build debug version. For dockers that do not build debug version, it uses the regular docker.
This debug bin is installable and usable in a DUT, just like a regular bin.
* Per review comments:
1) Share a single rule for final image for normal & debug flavors (e.g. sonic-broadcom.bin & sonic-broadcom-dbg.bin)
2) Put dbg as suffix in final image name.
3) Compared target/sonic-broadcom.bin.logs with & w/o fix to verify integrity of sonic-broadcom.bin
4) Compared target/sonic-broadcom.bin.logs with sonic-broadcom-dbg.bin.log for verification
This fix takes care of ONIE image only. The next PR will cover the rest.
The next PR, will also make debug image conditional with flag.
* Updated per comments.
Now that debug dockers are available, do not need a way to install debug symbols in regular dockers.
With this commit, when INSTALL_DEBUG_TOOLS=y is set, it builds debug dockers (for dockers that enable debug build) and the final image uses debug dockers. For dockers that do not enable debug build, regular dockers get used in the final image.
Note:
The debug dockers are explicitly named as <docker name>-dbg.gz. But there is no "-dbg" suffix for image.
Hence if you make two runs with and w/o INSTALL_DEBUG_TOOLS=y, you have complete set of regular dockers + debug dockers. But the image gets overwritten.
Hence if both regular & debug images are needed, make two runs, as one with INSTALL_DEBUG_TOOLS=y and one w/o. Make sure to copy/rename the final image, before making the second run.
2019-06-12 03:36:21 -05:00
|
|
|
{% endif %}
|
2017-01-29 13:33:33 -06:00
|
|
|
{% endfor %}
|
2020-04-16 23:54:45 -05:00
|
|
|
|
|
|
|
{% if install_kubernetes == "y" %}
|
|
|
|
## Pull in kubernetes docker images
|
|
|
|
echo "pulling universal k8s images ..."
|
2020-06-12 20:06:08 -05:00
|
|
|
FLANNEL_ARCH=$([ "${CONFIGURED_ARCH}" == "armhf" ] && echo "arm64" || echo "${CONFIGURED_ARCH}")
|
2020-04-16 23:54:45 -05:00
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT docker pull k8s.gcr.io/pause:${K8s_GCR_IO_PAUSE_VERSION}
|
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT docker pull k8s.gcr.io/kube-proxy:v${KUBERNETES_VERSION}
|
2020-06-12 20:06:08 -05:00
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT docker pull quay.io/coreos/flannel:${K8s_CNI_FLANNEL_VERSION}-${FLANNEL_ARCH}
|
2020-04-16 23:54:45 -05:00
|
|
|
echo "docker images pull complete"
|
|
|
|
{% endif %}
|
|
|
|
|
2019-07-26 00:06:41 -05:00
|
|
|
if [[ $CONFIGURED_ARCH == armhf || $CONFIGURED_ARCH == arm64 ]]; then
|
2019-12-16 11:07:05 -06:00
|
|
|
sudo umount $FILESYSTEM_ROOT/dockerfs
|
2019-07-26 00:06:41 -05:00
|
|
|
sudo rm -fr $FILESYSTEM_ROOT/dockerfs
|
|
|
|
sudo kill -9 `sudo $SONIC_NATIVE_DOCKERD_FOR_DOCKERFS_PID` || true
|
|
|
|
else
|
|
|
|
sudo chroot $FILESYSTEM_ROOT service docker stop
|
|
|
|
fi
|
2019-01-04 22:47:43 -06:00
|
|
|
sudo rm $FILESYSTEM_ROOT/etc/init.d/docker
|
2017-04-04 01:56:15 -05:00
|
|
|
{% for script in installer_start_scripts.split(' ') -%}
|
2017-01-29 13:33:33 -06:00
|
|
|
sudo cp {{script}} $FILESYSTEM_ROOT/usr/bin/
|
|
|
|
{% endfor %}
|
|
|
|
{% for service in installer_services.split(' ') -%}
|
2017-03-01 12:57:35 -06:00
|
|
|
if [ -f {{service}} ]; then
|
2020-05-30 15:46:44 -05:00
|
|
|
sudo cp {{service}} $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
2020-01-26 15:56:42 -06:00
|
|
|
|
|
|
|
{% if "@" in service %}
|
|
|
|
MULTI_INSTANCE="{{service}}"
|
|
|
|
SINGLE_INSTANCE=${MULTI_INSTANCE/"@"}
|
2020-05-30 15:46:44 -05:00
|
|
|
sudo cp $SINGLE_INSTANCE $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
2020-01-26 15:56:42 -06:00
|
|
|
{% endif %}
|
|
|
|
|
2019-07-29 17:52:15 -05:00
|
|
|
echo "{{service}}" | sudo tee -a $GENERATED_SERVICE_FILE
|
2017-03-01 12:57:35 -06:00
|
|
|
fi
|
2017-01-29 13:33:33 -06:00
|
|
|
{% endfor %}
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT fuser -km /sys || true
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT umount -lf /sys
|
|
|
|
{% endif %}
|
|
|
|
|
2018-09-24 18:35:01 -05:00
|
|
|
# Copy swss and syncd service script
|
2018-08-22 15:02:32 -05:00
|
|
|
sudo LANG=C cp $SCRIPTS_DIR/swss.sh $FILESYSTEM_ROOT/usr/local/bin/swss.sh
|
2018-09-24 18:35:01 -05:00
|
|
|
sudo LANG=C cp $SCRIPTS_DIR/syncd.sh $FILESYSTEM_ROOT/usr/local/bin/syncd.sh
|
2018-08-22 15:02:32 -05:00
|
|
|
|
2020-03-31 12:06:19 -05:00
|
|
|
# Copy sonic-netns-exec script
|
|
|
|
sudo LANG=C cp $SCRIPTS_DIR/sonic-netns-exec $FILESYSTEM_ROOT/usr/bin/sonic-netns-exec
|
|
|
|
|
2018-06-22 21:53:51 -05:00
|
|
|
# Copy systemd timer configuration
|
|
|
|
# It implements delayed start of services
|
2020-05-30 15:46:44 -05:00
|
|
|
sudo cp $BUILD_TEMPLATES/snmp.timer $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
2020-06-29 11:39:23 -05:00
|
|
|
echo "snmp.timer" | sudo tee -a $GENERATED_SERVICE_FILE
|
2019-12-16 11:07:05 -06:00
|
|
|
{% if enable_system_telemetry == 'y' %}
|
2020-05-30 15:46:44 -05:00
|
|
|
sudo cp $BUILD_TEMPLATES/telemetry.timer $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
2020-06-29 11:39:23 -05:00
|
|
|
echo "telemetry.timer" | sudo tee -a $GENERATED_SERVICE_FILE
|
2019-12-16 11:07:05 -06:00
|
|
|
{% endif %}
|
2018-06-22 21:53:51 -05:00
|
|
|
|
2019-04-29 19:21:24 -05:00
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get purge -y python-dev
|
2017-03-17 16:51:42 -05:00
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get clean -y
|
2018-11-20 21:27:56 -06:00
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get autoremove -y
|
2017-03-17 16:51:42 -05:00
|
|
|
|
2017-02-07 02:33:20 -06:00
|
|
|
{% 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 -%}
|
2017-07-28 12:57:51 -05:00
|
|
|
|
|
|
|
{% if sonic_asic_platform == "mellanox" %}
|
|
|
|
sudo mkdir -p $FILESYSTEM_ROOT/etc/mlnx/
|
2019-05-27 17:50:51 -05:00
|
|
|
sudo cp $files_path/$MLNX_SPC_FW_FILE $FILESYSTEM_ROOT/etc/mlnx/fw-SPC.mfa
|
|
|
|
sudo cp $files_path/$MLNX_SPC2_FW_FILE $FILESYSTEM_ROOT/etc/mlnx/fw-SPC2.mfa
|
2020-03-28 13:45:38 -05:00
|
|
|
sudo cp $files_path/$MLNX_SPC3_FW_FILE $FILESYSTEM_ROOT/etc/mlnx/fw-SPC3.mfa
|
2019-05-27 17:50:51 -05:00
|
|
|
sudo cp $files_path/$ISSU_VERSION_FILE $FILESYSTEM_ROOT/etc/mlnx/issu-version
|
|
|
|
sudo cp $files_path/$MLNX_FFB_SCRIPT $FILESYSTEM_ROOT/usr/bin/mlnx-ffb.sh
|
2020-04-13 10:13:19 -05:00
|
|
|
sudo cp $files_path/$MLNX_ONIE_FW_UPDATE $FILESYSTEM_ROOT/usr/bin/$MLNX_ONIE_FW_UPDATE
|
|
|
|
sudo cp $files_path/$MLNX_SSD_FW_UPDATE $FILESYSTEM_ROOT/usr/bin/$MLNX_SSD_FW_UPDATE
|
2017-08-22 10:08:07 -05:00
|
|
|
j2 platform/mellanox/mlnx-fw-upgrade.j2 | sudo tee $FILESYSTEM_ROOT/usr/bin/mlnx-fw-upgrade.sh
|
|
|
|
sudo chmod 755 $FILESYSTEM_ROOT/usr/bin/mlnx-fw-upgrade.sh
|
2019-09-25 13:00:24 -05:00
|
|
|
|
|
|
|
# Install mlnx-sonic-platform-common Python 2 package
|
|
|
|
MLNX_PLATFORM_COMMON_PY2_WHEEL_NAME=$(basename {{mlnx_platform_api_py2_wheel_path}})
|
|
|
|
sudo cp {{mlnx_platform_api_py2_wheel_path}} $FILESYSTEM_ROOT/$MLNX_PLATFORM_COMMON_PY2_WHEEL_NAME
|
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install $MLNX_PLATFORM_COMMON_PY2_WHEEL_NAME
|
|
|
|
sudo rm -rf $FILESYSTEM_ROOT/$MLNX_PLATFORM_COMMON_PY2_WHEEL_NAME
|
2017-07-28 12:57:51 -05:00
|
|
|
{% endif %}
|
2018-11-26 20:19:12 -06:00
|
|
|
|
|
|
|
{%- if SONIC_ROUTING_STACK == "frr" %}
|
|
|
|
sudo mkdir $FILESYSTEM_ROOT/etc/sonic/frr
|
|
|
|
sudo touch $FILESYSTEM_ROOT/etc/sonic/frr/frr.conf
|
|
|
|
sudo touch $FILESYSTEM_ROOT/etc/sonic/frr/vtysh.conf
|
|
|
|
sudo chown -R $FRR_USER_UID:$FRR_USER_GID $FILESYSTEM_ROOT/etc/sonic/frr
|
|
|
|
sudo chmod -R 640 $FILESYSTEM_ROOT/etc/sonic/frr/
|
2019-02-19 23:50:19 -06:00
|
|
|
sudo chmod 750 $FILESYSTEM_ROOT/etc/sonic/frr
|
2018-11-26 20:19:12 -06:00
|
|
|
{%- endif %}
|
2020-06-24 17:25:16 -05:00
|
|
|
|
|
|
|
# Mask services which are disabled by default
|
|
|
|
sudo cp $BUILD_SCRIPTS_DIR/mask_disabled_services.py $FILESYSTEM_ROOT/tmp/
|
|
|
|
sudo chmod a+x $FILESYSTEM_ROOT/tmp/mask_disabled_services.py
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT /tmp/mask_disabled_services.py
|
|
|
|
sudo rm -rf $FILESYSTEM_ROOT/tmp/mask_disabled_services.py
|