From e950f5b74432d1bee148bdf400751b5068bda390 Mon Sep 17 00:00:00 2001 From: Renuka Varry Date: Thu, 9 Apr 2026 18:16:06 +0000 Subject: [PATCH 1/5] RDKEMW-10725:gstreamer-cleanup conditions when cdl_flashed_file_name is missing Reason for change: gstreamer-cleanup is happening on every reboot when /opt/cdl_flashed_file_name is missing Test Procedure: Boot the TV and check for gstreamer-cleanup metrics in rdk_milestones.log Risks: low Signed-off-by: Renuka Varry --- lib/rdk/gstreamer-cleanup.sh | 42 +++++++++++++++++++++++++ systemd_units/gstreamer-cleanup.service | 9 ++---- 2 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 lib/rdk/gstreamer-cleanup.sh diff --git a/lib/rdk/gstreamer-cleanup.sh b/lib/rdk/gstreamer-cleanup.sh new file mode 100644 index 00000000..11e44bcf --- /dev/null +++ b/lib/rdk/gstreamer-cleanup.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# This script checks if the GStreamer registry should be cleared based on +# firmware flash status and cleans it if necessary. + +# Initialize variables safely +CDLFILE="" +PREV_CDLFILE="" +CUR_IMAGE="" + +if [[ -f /opt/cdl_flashed_file_name ]]; then + CDLFILE=$(cat /opt/cdl_flashed_file_name) +fi +if [[ -f /opt/previous_flashed_file_name ]]; then + PREV_CDLFILE=$(cat /opt/previous_flashed_file_name) +fi +if [[ -f /version.txt ]]; then + CUR_IMAGE=$(grep "^imagename:" /version.txt | cut -d":" -f2) +fi + +# Print the variables for debugging - can be removed once the logic is stable +echo "DEBUG: CDLFILE=[${CDLFILE}]" +echo "DEBUG: PREV_CDLFILE=[${PREV_CDLFILE}]" +echo "DEBUG: CUR_IMAGE=[${CUR_IMAGE}]" + +# Check all cleanup conditions in a single if statement using bash syntax +if [[ ! -f /opt/previous_flashed_file_name || \ + ( ! -f /opt/cdl_flashed_file_name && "${PREV_CDLFILE}" != *"${CUR_IMAGE}"* ) || \ + ( -f /opt/cdl_flashed_file_name && "${CDLFILE}" != *"${PREV_CDLFILE}"* ) ]]; then + + echo "Removing gstreamer registry on bootup after CDL" + rm -rf /opt/.gstreamer + GST_REGISTRY_UPDATE=yes gst-inspect-1.0 >/dev/null 2>&1 + +elif [[ ! -f /opt/.gstreamer/registry.bin ]]; then + # Fallback: Clean if registry file is missing anyway + echo "Gstreamer registry empty" + rm -rf /opt/.gstreamer + GST_REGISTRY_UPDATE=yes gst-inspect-1.0 >/dev/null 2>&1 +else + echo "gstreamer registry is not removed, previous reboot is not due to CDL" +fi diff --git a/systemd_units/gstreamer-cleanup.service b/systemd_units/gstreamer-cleanup.service index 30131b16..ecb7e519 100644 --- a/systemd_units/gstreamer-cleanup.service +++ b/systemd_units/gstreamer-cleanup.service @@ -26,12 +26,9 @@ Before=wpeframework.service [Service] Type=oneshot RemainAfterExit=Yes -Environment="CDLFILE=$(cat /opt/cdl_flashed_file_name)" -Environment="PREV_CDLFILE=$(cat /opt/previous_flashed_file_name)" -Environment="GST_REGISTRY=/opt/.gstreamer/registry.bin" -ExecStartPre=/bin/sh -c 'if [ -f /lib/rdk/logMilestone.sh ];then sh /lib/rdk/logMilestone.sh "GST_CLEANUP_START"; fi;' -ExecStart=-/bin/sh -c 'if [[ ! -f /opt/previous_flashed_file_name || ! -f /opt/cdl_flashed_file_name || ${CDLFILE} != *"${PREV_CDLFILE}"* ]]; then echo "Removing gstreamer registry on bootup after CDL"; rm -rf /opt/.gstreamer;GST_REGISTRY_UPDATE=yes gst-inspect-1.0 >/dev/null 2>&1; elif [ ! -f /opt/.gstreamer/registry.bin ]; then echo "Gstreamer registry empty"; rm -rf /opt/.gstreamer; GST_REGISTRY_UPDATE=yes gst-inspect-1.0 >/dev/null 2>&1; else echo "gstreamer registry is not removed, previous reboot is not due to CDL"; fi' -ExecStartPost=/bin/sh -c 'if [ -f /lib/rdk/logMilestone.sh ];then sh /lib/rdk/logMilestone.sh "GST_CLEANUP_COMPLETE"; fi;' +ExecStartPre=/bin/bash -c 'if [ -f /lib/rdk/logMilestone.sh ];then sh /lib/rdk/logMilestone.sh "GST_CLEANUP_START"; fi;' +ExecStart=-/lib/rdk/gstreamer-cleanup.sh +ExecStartPost=/bin/bash -c 'if [ -f /lib/rdk/logMilestone.sh ];then sh /lib/rdk/logMilestone.sh "GST_CLEANUP_COMPLETE"; fi;' ExecStop=/bin/sh -c 'FW_UPDATE_STATE=$(cat /opt/fwdnldstatus.txt | grep FwUpdateState | cut -d "|" -f2); echo "FW_UPDATE_STATE: $FW_UPDATE_STATE"; if [ "$FW_UPDATE_STATE" == "Preparing to reboot" ]; then echo "Removing gstreamer registry after firmware update"; rm -rf /opt/.gstreamer; fi;' [Install] From 9c9690daeeaa21b6d8cd05471d485fbf7f9149cf Mon Sep 17 00:00:00 2001 From: vrenu2018 <136053788+vrenu2018@users.noreply.github.com> Date: Mon, 13 Apr 2026 13:26:59 -0400 Subject: [PATCH 2/5] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- lib/rdk/gstreamer-cleanup.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/rdk/gstreamer-cleanup.sh b/lib/rdk/gstreamer-cleanup.sh index 11e44bcf..e665fc34 100644 --- a/lib/rdk/gstreamer-cleanup.sh +++ b/lib/rdk/gstreamer-cleanup.sh @@ -30,13 +30,15 @@ if [[ ! -f /opt/previous_flashed_file_name || \ echo "Removing gstreamer registry on bootup after CDL" rm -rf /opt/.gstreamer - GST_REGISTRY_UPDATE=yes gst-inspect-1.0 >/dev/null 2>&1 + mkdir -p /opt/.gstreamer + GST_REGISTRY=/opt/.gstreamer/registry.bin GST_REGISTRY_UPDATE=yes gst-inspect-1.0 >/dev/null 2>&1 elif [[ ! -f /opt/.gstreamer/registry.bin ]]; then # Fallback: Clean if registry file is missing anyway echo "Gstreamer registry empty" rm -rf /opt/.gstreamer - GST_REGISTRY_UPDATE=yes gst-inspect-1.0 >/dev/null 2>&1 + mkdir -p /opt/.gstreamer + GST_REGISTRY=/opt/.gstreamer/registry.bin GST_REGISTRY_UPDATE=yes gst-inspect-1.0 >/dev/null 2>&1 else echo "gstreamer registry is not removed, previous reboot is not due to CDL" fi From 9b8dba37e783a797960fc8f61ad8a4aa5c7021b0 Mon Sep 17 00:00:00 2001 From: Renuka Varry Date: Thu, 9 Apr 2026 18:16:06 +0000 Subject: [PATCH 3/5] RDKEMW-10725:gstreamer-cleanup conditions when cdl_flashed_file_name is missing Reason for change: gstreamer-cleanup is happening on every reboot when /opt/cdl_flashed_file_name is missing Test Procedure: Boot the TV and check for gstreamer-cleanup metrics in rdk_milestones.log Risks: low Signed-off-by: Renuka Varry --- lib/rdk/gstreamer-cleanup.sh | 42 +++++++++++++++++++++++++ systemd_units/gstreamer-cleanup.service | 9 ++---- 2 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 lib/rdk/gstreamer-cleanup.sh diff --git a/lib/rdk/gstreamer-cleanup.sh b/lib/rdk/gstreamer-cleanup.sh new file mode 100644 index 00000000..11e44bcf --- /dev/null +++ b/lib/rdk/gstreamer-cleanup.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# This script checks if the GStreamer registry should be cleared based on +# firmware flash status and cleans it if necessary. + +# Initialize variables safely +CDLFILE="" +PREV_CDLFILE="" +CUR_IMAGE="" + +if [[ -f /opt/cdl_flashed_file_name ]]; then + CDLFILE=$(cat /opt/cdl_flashed_file_name) +fi +if [[ -f /opt/previous_flashed_file_name ]]; then + PREV_CDLFILE=$(cat /opt/previous_flashed_file_name) +fi +if [[ -f /version.txt ]]; then + CUR_IMAGE=$(grep "^imagename:" /version.txt | cut -d":" -f2) +fi + +# Print the variables for debugging - can be removed once the logic is stable +echo "DEBUG: CDLFILE=[${CDLFILE}]" +echo "DEBUG: PREV_CDLFILE=[${PREV_CDLFILE}]" +echo "DEBUG: CUR_IMAGE=[${CUR_IMAGE}]" + +# Check all cleanup conditions in a single if statement using bash syntax +if [[ ! -f /opt/previous_flashed_file_name || \ + ( ! -f /opt/cdl_flashed_file_name && "${PREV_CDLFILE}" != *"${CUR_IMAGE}"* ) || \ + ( -f /opt/cdl_flashed_file_name && "${CDLFILE}" != *"${PREV_CDLFILE}"* ) ]]; then + + echo "Removing gstreamer registry on bootup after CDL" + rm -rf /opt/.gstreamer + GST_REGISTRY_UPDATE=yes gst-inspect-1.0 >/dev/null 2>&1 + +elif [[ ! -f /opt/.gstreamer/registry.bin ]]; then + # Fallback: Clean if registry file is missing anyway + echo "Gstreamer registry empty" + rm -rf /opt/.gstreamer + GST_REGISTRY_UPDATE=yes gst-inspect-1.0 >/dev/null 2>&1 +else + echo "gstreamer registry is not removed, previous reboot is not due to CDL" +fi diff --git a/systemd_units/gstreamer-cleanup.service b/systemd_units/gstreamer-cleanup.service index 30131b16..ecb7e519 100644 --- a/systemd_units/gstreamer-cleanup.service +++ b/systemd_units/gstreamer-cleanup.service @@ -26,12 +26,9 @@ Before=wpeframework.service [Service] Type=oneshot RemainAfterExit=Yes -Environment="CDLFILE=$(cat /opt/cdl_flashed_file_name)" -Environment="PREV_CDLFILE=$(cat /opt/previous_flashed_file_name)" -Environment="GST_REGISTRY=/opt/.gstreamer/registry.bin" -ExecStartPre=/bin/sh -c 'if [ -f /lib/rdk/logMilestone.sh ];then sh /lib/rdk/logMilestone.sh "GST_CLEANUP_START"; fi;' -ExecStart=-/bin/sh -c 'if [[ ! -f /opt/previous_flashed_file_name || ! -f /opt/cdl_flashed_file_name || ${CDLFILE} != *"${PREV_CDLFILE}"* ]]; then echo "Removing gstreamer registry on bootup after CDL"; rm -rf /opt/.gstreamer;GST_REGISTRY_UPDATE=yes gst-inspect-1.0 >/dev/null 2>&1; elif [ ! -f /opt/.gstreamer/registry.bin ]; then echo "Gstreamer registry empty"; rm -rf /opt/.gstreamer; GST_REGISTRY_UPDATE=yes gst-inspect-1.0 >/dev/null 2>&1; else echo "gstreamer registry is not removed, previous reboot is not due to CDL"; fi' -ExecStartPost=/bin/sh -c 'if [ -f /lib/rdk/logMilestone.sh ];then sh /lib/rdk/logMilestone.sh "GST_CLEANUP_COMPLETE"; fi;' +ExecStartPre=/bin/bash -c 'if [ -f /lib/rdk/logMilestone.sh ];then sh /lib/rdk/logMilestone.sh "GST_CLEANUP_START"; fi;' +ExecStart=-/lib/rdk/gstreamer-cleanup.sh +ExecStartPost=/bin/bash -c 'if [ -f /lib/rdk/logMilestone.sh ];then sh /lib/rdk/logMilestone.sh "GST_CLEANUP_COMPLETE"; fi;' ExecStop=/bin/sh -c 'FW_UPDATE_STATE=$(cat /opt/fwdnldstatus.txt | grep FwUpdateState | cut -d "|" -f2); echo "FW_UPDATE_STATE: $FW_UPDATE_STATE"; if [ "$FW_UPDATE_STATE" == "Preparing to reboot" ]; then echo "Removing gstreamer registry after firmware update"; rm -rf /opt/.gstreamer; fi;' [Install] From e43c516567226f27be7285c8dbffee7841b28671 Mon Sep 17 00:00:00 2001 From: vrenu2018 <136053788+vrenu2018@users.noreply.github.com> Date: Tue, 14 Apr 2026 10:07:28 -0400 Subject: [PATCH 4/5] License banner addition Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- lib/rdk/gstreamer-cleanup.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/rdk/gstreamer-cleanup.sh b/lib/rdk/gstreamer-cleanup.sh index e665fc34..1c04515f 100644 --- a/lib/rdk/gstreamer-cleanup.sh +++ b/lib/rdk/gstreamer-cleanup.sh @@ -1,5 +1,18 @@ #!/bin/bash +# Copyright 2024 RDK Management +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # This script checks if the GStreamer registry should be cleared based on # firmware flash status and cleans it if necessary. From b6530f1198d54f54a4d9cfc731b0492489f8737d Mon Sep 17 00:00:00 2001 From: Renuka Varry Date: Mon, 20 Apr 2026 20:02:11 +0000 Subject: [PATCH 5/5] RDKEMW-10725:gstreamer-cleanup conditions when cdl_flashed_file_name is missing Reason for change: gstreamer-cleanup is happening on every reboot when /opt/cdl_flashed_file_name is missing Test Procedure: Boot the TV and check for gstreamer-cleanup metrics in rdk_milestones.log Risks: low Signed-off-by: Renuka Varry --- lib/rdk/gstreamer-cleanup.sh | 57 ------------------------- systemd_units/gstreamer-cleanup.service | 35 --------------- 2 files changed, 92 deletions(-) delete mode 100644 lib/rdk/gstreamer-cleanup.sh delete mode 100644 systemd_units/gstreamer-cleanup.service diff --git a/lib/rdk/gstreamer-cleanup.sh b/lib/rdk/gstreamer-cleanup.sh deleted file mode 100644 index 1c04515f..00000000 --- a/lib/rdk/gstreamer-cleanup.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -# Copyright 2024 RDK Management -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# This script checks if the GStreamer registry should be cleared based on -# firmware flash status and cleans it if necessary. - -# Initialize variables safely -CDLFILE="" -PREV_CDLFILE="" -CUR_IMAGE="" - -if [[ -f /opt/cdl_flashed_file_name ]]; then - CDLFILE=$(cat /opt/cdl_flashed_file_name) -fi -if [[ -f /opt/previous_flashed_file_name ]]; then - PREV_CDLFILE=$(cat /opt/previous_flashed_file_name) -fi -if [[ -f /version.txt ]]; then - CUR_IMAGE=$(grep "^imagename:" /version.txt | cut -d":" -f2) -fi - -# Print the variables for debugging - can be removed once the logic is stable -echo "DEBUG: CDLFILE=[${CDLFILE}]" -echo "DEBUG: PREV_CDLFILE=[${PREV_CDLFILE}]" -echo "DEBUG: CUR_IMAGE=[${CUR_IMAGE}]" - -# Check all cleanup conditions in a single if statement using bash syntax -if [[ ! -f /opt/previous_flashed_file_name || \ - ( ! -f /opt/cdl_flashed_file_name && "${PREV_CDLFILE}" != *"${CUR_IMAGE}"* ) || \ - ( -f /opt/cdl_flashed_file_name && "${CDLFILE}" != *"${PREV_CDLFILE}"* ) ]]; then - - echo "Removing gstreamer registry on bootup after CDL" - rm -rf /opt/.gstreamer - mkdir -p /opt/.gstreamer - GST_REGISTRY=/opt/.gstreamer/registry.bin GST_REGISTRY_UPDATE=yes gst-inspect-1.0 >/dev/null 2>&1 - -elif [[ ! -f /opt/.gstreamer/registry.bin ]]; then - # Fallback: Clean if registry file is missing anyway - echo "Gstreamer registry empty" - rm -rf /opt/.gstreamer - mkdir -p /opt/.gstreamer - GST_REGISTRY=/opt/.gstreamer/registry.bin GST_REGISTRY_UPDATE=yes gst-inspect-1.0 >/dev/null 2>&1 -else - echo "gstreamer registry is not removed, previous reboot is not due to CDL" -fi diff --git a/systemd_units/gstreamer-cleanup.service b/systemd_units/gstreamer-cleanup.service deleted file mode 100644 index ecb7e519..00000000 --- a/systemd_units/gstreamer-cleanup.service +++ /dev/null @@ -1,35 +0,0 @@ -############################################################################## -# If not stated otherwise in this file or this component's LICENSE file the -# following copyright and licenses apply: -# -# Copyright 2020 RDK Management -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -############################################################################## - -[Unit] -Description=Cleans up Gstreamer Registry - -After=local-fs.target nvram.service -Before=wpeframework.service - -[Service] -Type=oneshot -RemainAfterExit=Yes -ExecStartPre=/bin/bash -c 'if [ -f /lib/rdk/logMilestone.sh ];then sh /lib/rdk/logMilestone.sh "GST_CLEANUP_START"; fi;' -ExecStart=-/lib/rdk/gstreamer-cleanup.sh -ExecStartPost=/bin/bash -c 'if [ -f /lib/rdk/logMilestone.sh ];then sh /lib/rdk/logMilestone.sh "GST_CLEANUP_COMPLETE"; fi;' -ExecStop=/bin/sh -c 'FW_UPDATE_STATE=$(cat /opt/fwdnldstatus.txt | grep FwUpdateState | cut -d "|" -f2); echo "FW_UPDATE_STATE: $FW_UPDATE_STATE"; if [ "$FW_UPDATE_STATE" == "Preparing to reboot" ]; then echo "Removing gstreamer registry after firmware update"; rm -rf /opt/.gstreamer; fi;' - -[Install] -WantedBy=multi-user.target