Skip to content

Commit 951d93e

Browse files
xumiaqiluo-msft
authored andcommitted
Reduce image size for lazy installation packages (#10775)
Why I did it The image size is too large, when there are multiple lazy packages and multiple platforms. It is not necessary to keep the lazy installation packages in multiple copies. For cisco image, the image size will reduce from 3.5G to 1.7G. How I did it Use symbol links to only keep one package for each of the lazy package. Make a new folder fsroot/platform/common Copy the lazy packages into the folder. When using a package in each of the platform, such as x86_64-grub, x86_64-8800_rp-r0, x86_64-8201_on-r0, etc, only make a symbol link to the package in the common folder.
1 parent a296267 commit 951d93e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

build_debian.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -610,5 +610,5 @@ fi
610610
pushd $FILESYSTEM_ROOT && sudo tar czf $OLDPWD/$FILESYSTEM_DOCKERFS -C ${DOCKERFS_PATH}var/lib/docker .; popd
611611

612612
## Compress together with /boot, /var/lib/docker and $PLATFORM_DIR as an installer payload zip file
613-
pushd $FILESYSTEM_ROOT && sudo zip $OLDPWD/$ONIE_INSTALLER_PAYLOAD -r boot/ $PLATFORM_DIR/; popd
613+
pushd $FILESYSTEM_ROOT && sudo zip --symlinks $OLDPWD/$ONIE_INSTALLER_PAYLOAD -r boot/ $PLATFORM_DIR/; popd
614614
sudo zip -g -n .squashfs:.gz $ONIE_INSTALLER_PAYLOAD $FILESYSTEM_SQUASHFS $FILESYSTEM_DOCKERFS

files/build_templates/sonic_debian_extension.j2

+3-1
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,9 @@ sudo LANG=C chroot $FILESYSTEM_ROOT depmod -a {{kversion}}
590590
sudo dpkg --root=$FILESYSTEM_ROOT -i {{deb}} || sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f --download-only
591591

592592
sudo mkdir -p $FILESYSTEM_ROOT/$PLATFORM_DIR/{{dev}}
593-
sudo cp {{ deb }} $FILESYSTEM_ROOT/$PLATFORM_DIR/{{dev}}/
593+
sudo mkdir -p $FILESYSTEM_ROOT/$PLATFORM_DIR/common
594+
sudo cp {{ deb }} $FILESYSTEM_ROOT/$PLATFORM_DIR/common/
595+
sudo ln -sf "../common/{{ debfilename }}" "$FILESYSTEM_ROOT/$PLATFORM_DIR/{{dev}}/{{ debfilename }}"
594596
for f in $(find $FILESYSTEM_ROOT/var/cache/apt/archives -name "*.deb"); do
595597
sudo mv $f $FILESYSTEM_ROOT/$PLATFORM_DIR/{{dev}}/
596598
done

0 commit comments

Comments
 (0)