From 1277c7ed3b5537b7441387c1dc9be894e3ce9737 Mon Sep 17 00:00:00 2001 From: Saikrishna Arcot Date: Tue, 22 Mar 2022 21:57:15 -0700 Subject: [PATCH] Check to see that the py2 and py3 version files exist before trying to sort them (#10325) For Bullseye, Python 2 isn't present at all. This means that in certain build cases (such as building something only for Bullseye), the version file may not exist, and so the sort command would fail. For most normal build commands, this probably won't be an issue, because the SONiC build will start with Buster (which has both Python 2 and Python 3 wheels built), and so the py2 and py3 files will be present even during the Bullseye builds. Signed-off-by: Saikrishna Arcot --- src/sonic-build-hooks/scripts/collect_version_files | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sonic-build-hooks/scripts/collect_version_files b/src/sonic-build-hooks/scripts/collect_version_files index 570883701e..a4b33eeaa8 100755 --- a/src/sonic-build-hooks/scripts/collect_version_files +++ b/src/sonic-build-hooks/scripts/collect_version_files @@ -20,7 +20,11 @@ dpkg-query -W -f '${Package}==${Version}\n' >> "${TARGET_PATH}/versions-deb-${DI ## Print the unique and sorted result sort -u "${TARGET_PATH}/versions-deb-${DIST}-${ARCH}" -o "${TARGET_PATH}/versions-deb-${DIST}-${ARCH}" -sort -u "${TARGET_PATH}/versions-py2-${DIST}-${ARCH}" -o "${TARGET_PATH}/versions-py2-${DIST}-${ARCH}" -sort -u "${TARGET_PATH}/versions-py3-${DIST}-${ARCH}" -o "${TARGET_PATH}/versions-py3-${DIST}-${ARCH}" +if [ -e "${TARGET_PATH}/versions-py2-${DIST}-${ARCH}" ]; then + sort -u "${TARGET_PATH}/versions-py2-${DIST}-${ARCH}" -o "${TARGET_PATH}/versions-py2-${DIST}-${ARCH}" +fi +if [ -e "${TARGET_PATH}/versions-py3-${DIST}-${ARCH}" ]; then + sort -u "${TARGET_PATH}/versions-py3-${DIST}-${ARCH}" -o "${TARGET_PATH}/versions-py3-${DIST}-${ARCH}" +fi exit 0