From d3457c1cfc8d6da5cc5b60570c455fa7f5aa1cff Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Thu, 16 Oct 2025 20:02:53 +0200 Subject: [PATCH] MT#62763 Fix shellcheck issues Warned-by: shellcheck Change-Id: I42a0a4cc60007686b220940c0ddb7dbd0a13038f --- .shellcheckrc | 3 +++ debian/ngcp-rtpengine-daemon.postinst | 1 + debian/ngcp-rtpengine-recording-nfs-setup | 2 ++ el/build-with-mock.sh | 10 ++++++---- el/rtpengine-recording.init | 2 ++ el/rtpengine.init | 3 +++ pkg/deb/backports/bullseye | 2 ++ pkg/deb/backports/focal | 4 ++++ pkg/deb/backports/jammy | 2 ++ pkg/deb/generator.sh | 4 ++-- 10 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 .shellcheckrc diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 000000000..f2d1cbeba --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1,3 @@ +external-sources=true +# Used for jdg-tap integration. +source-path=source diff --git a/debian/ngcp-rtpengine-daemon.postinst b/debian/ngcp-rtpengine-daemon.postinst index fbb2c628c..e4b04a109 100644 --- a/debian/ngcp-rtpengine-daemon.postinst +++ b/debian/ngcp-rtpengine-daemon.postinst @@ -15,6 +15,7 @@ if [ "$VIRT" = "yes" ]; then echo "Container environment detected. Skip kernel module check" else if [ -f $default ]; then + # shellcheck source=debian/ngcp-rtpengine-daemon.default . $default || true fi diff --git a/debian/ngcp-rtpengine-recording-nfs-setup b/debian/ngcp-rtpengine-recording-nfs-setup index 5a9fdef54..a8defaa68 100755 --- a/debian/ngcp-rtpengine-recording-nfs-setup +++ b/debian/ngcp-rtpengine-recording-nfs-setup @@ -6,10 +6,12 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin DEFAULTS=/etc/default/ngcp-rtpengine-recording-daemon DESC="RTP engine recording NFS share" +# shellcheck disable=SC1091 . /lib/lsb/init-functions # Load startup options if available if [ -f "$DEFAULTS" ]; then + # shellcheck source=debian/ngcp-rtpengine-recording-daemon.default . "$DEFAULTS" || true fi diff --git a/el/build-with-mock.sh b/el/build-with-mock.sh index b5be3ec3e..a7548a0fa 100755 --- a/el/build-with-mock.sh +++ b/el/build-with-mock.sh @@ -8,7 +8,7 @@ set -e if [[ -z $1 || -z $2 ]]; then - echo $0: Require package version and git commit + echo "$0: Require package version and git commit" echo "Usage: build-with-mock.sh " exit 1 fi @@ -18,10 +18,12 @@ GIT_COMMIT=$2 mkdir -p rpmbuild/{SOURCES,SPECS} -git archive --format=tar --prefix=ngcp-rtpengine-${RTPENGINE_VERSION}/ $2 | gzip -c > rpmbuild/SOURCES/ngcp-rtpengine-${RTPENGINE_VERSION}.tar.gz +git archive --format=tar --prefix="ngcp-rtpengine-${RTPENGINE_VERSION}/" \ + "${GIT_COMMIT}" \ + | gzip -c >"rpmbuild/SOURCES/ngcp-rtpengine-${RTPENGINE_VERSION}.tar.gz" - -sed /^Version/s"/^Version:.*/Version: ${RTPENGINE_VERSION}/" el/rtpengine.spec > rpmbuild/SPECS/rtpengine.spec +sed /^Version/s"/^Version:.*/Version: ${RTPENGINE_VERSION}/" el/rtpengine.spec \ + >rpmbuild/SPECS/rtpengine.spec rm -f rpmbuild/SRPMS/*.src.rpm rpmbuild --define "_topdir $PWD/rpmbuild" -bs rpmbuild/SPECS/rtpengine.spec diff --git a/el/rtpengine-recording.init b/el/rtpengine-recording.init index 2a4f57134..bd0539c4e 100644 --- a/el/rtpengine-recording.init +++ b/el/rtpengine-recording.init @@ -17,10 +17,12 @@ ### END INIT INFO # Source function library. +# shellcheck disable=SC1091 . /etc/rc.d/init.d/functions if [ -f /etc/sysconfig/rtpengine-recording ] then + # shellcheck source=./rtpengine-recording.sysconfig . /etc/sysconfig/rtpengine-recording else echo "Error: /etc/sysconfig/rtpengine-recording not present" >&2 diff --git a/el/rtpengine.init b/el/rtpengine.init index 2b90c8550..82867fabe 100644 --- a/el/rtpengine.init +++ b/el/rtpengine.init @@ -17,12 +17,14 @@ ### END INIT INFO # Source function library. +# shellcheck disable=SC1091 . /etc/rc.d/init.d/functions # defaults if [ -f /etc/sysconfig/rtpengine ] then + # shellcheck source=./rtpengine.sysconfig . /etc/sysconfig/rtpengine else echo "Error: /etc/sysconfig/rtpengine not present" >&2 @@ -122,6 +124,7 @@ stop() { RETVAL=$? echo if [ -f "$cachefile" ];then + # shellcheck disable=SC1090 . "$cachefile" echo "Unloading module for in-kernel packet forwarding" echo "del $TABLE" > /proc/rtpengine/control diff --git a/pkg/deb/backports/bullseye b/pkg/deb/backports/bullseye index cc91418f4..b7aecd0c6 100755 --- a/pkg/deb/backports/bullseye +++ b/pkg/deb/backports/bullseye @@ -27,6 +27,7 @@ sed -i '/^override_dh_dkms/d' "${DIST}"/rules sed -i '/dh_dkms /d' "${DIST}"/rules sed -i '/^export DEB_VERSION_UPSTREAM/d' "${DIST}"/rules sed -i '/^export DEB_SOURCE/d' "${DIST}"/rules +# shellcheck disable=SC2016 sed -i 's;^include /usr/share/dpkg/pkg-info.mk;include /usr/share/dpkg/pkg-info.mk\ ## kernel package specific stuff\ # Name of the dkms package\ @@ -37,6 +38,7 @@ sname:=rtpengine\ sversion:=$(DEB_VERSION_UPSTREAM)\ ## end of kernel package specific stuff\ ;' "${DIST}"/rules +# shellcheck disable=SC2016 sed -i 's;^execute_before_dh_auto_install-indep:;execute_before_dh_auto_install-indep:\ \t# Create the directories to install the source into\ \tdh_installdirs -p$(pdkms) usr/src/$(sname)-$(sversion)\ diff --git a/pkg/deb/backports/focal b/pkg/deb/backports/focal index 143763a1e..ecfe4735e 100755 --- a/pkg/deb/backports/focal +++ b/pkg/deb/backports/focal @@ -24,8 +24,10 @@ sed -i -e 's/^execute_before_dh_auto_install-indep:/override_dh_auto_install-ind sed -i -e '/^\tgzip -9 < README.md/a\\n\tdh_auto_install' ${DIST}/rules # fix links +# shellcheck disable=SC2016 sed -i -e 's#${env:deb_systemdsystemunitdir}#/lib/systemd/system/#g' \ ${DIST}/rtpengine-recording-daemon.links +# shellcheck disable=SC2016 sed -i -e 's#${env:deb_systemdsystemunitdir}#/lib/systemd/system/#g' \ ${DIST}/rtpengine-daemon.links @@ -49,6 +51,7 @@ sed -i '/^override_dh_dkms/d' "${DIST}"/rules sed -i '/dh_dkms /d' "${DIST}"/rules sed -i '/^export DEB_VERSION_UPSTREAM/d' "${DIST}"/rules sed -i '/^export DEB_SOURCE/d' "${DIST}"/rules +# shellcheck disable=SC2016 sed -i 's;^include /usr/share/dpkg/pkg-info.mk;include /usr/share/dpkg/pkg-info.mk\ ## kernel package specific stuff\ # Name of the dkms package\ @@ -59,6 +62,7 @@ sname:=rtpengine\ sversion:=$(DEB_VERSION_UPSTREAM)\ ## end of kernel package specific stuff\ ;' "${DIST}"/rules +# shellcheck disable=SC2016 sed -i 's;^override_dh_auto_install-indep:;override_dh_auto_install-indep:\ \t# Create the directories to install the source into\ \tdh_installdirs -p$(pdkms) usr/src/$(sname)-$(sversion)\ diff --git a/pkg/deb/backports/jammy b/pkg/deb/backports/jammy index d2320e1cc..eae3282fd 100755 --- a/pkg/deb/backports/jammy +++ b/pkg/deb/backports/jammy @@ -27,6 +27,7 @@ sed -i '/^override_dh_dkms/d' "${DIST}"/rules sed -i '/dh_dkms /d' "${DIST}"/rules sed -i '/^export DEB_VERSION_UPSTREAM/d' "${DIST}"/rules sed -i '/^export DEB_SOURCE/d' "${DIST}"/rules +# shellcheck disable=SC2016 sed -i 's;^include /usr/share/dpkg/pkg-info.mk;include /usr/share/dpkg/pkg-info.mk\ ## kernel package specific stuff\ # Name of the dkms package\ @@ -37,6 +38,7 @@ sname:=rtpengine\ sversion:=$(DEB_VERSION_UPSTREAM)\ ## end of kernel package specific stuff\ ;' "${DIST}"/rules +# shellcheck disable=SC2016 sed -i 's;^execute_before_dh_auto_install-indep:;execute_before_dh_auto_install-indep:\ \t# Create the directories to install the source into\ \tdh_installdirs -p$(pdkms) usr/src/$(sname)-$(sversion)\ diff --git a/pkg/deb/generator.sh b/pkg/deb/generator.sh index fb8f4c8ef..bb56109f1 100755 --- a/pkg/deb/generator.sh +++ b/pkg/deb/generator.sh @@ -21,7 +21,7 @@ find debian -maxdepth 2 -type f -exec \ ## remove same file on links while read -r file; do - file_new=$(echo "${file}" | sed -e 's/ngcp-//g') + file_new=${file//ngcp-/} while read -r line; do sed -i -e "s#${line}\$#HH#g" "${file}" done < <(awk '{print $1}' "${file}") @@ -46,7 +46,7 @@ done < <(grep '^Package:' debian/control | grep -v ' rtpengine-daemon$') echo "- Rename files" while read -r file; do - file_new=$(echo "${file}" | sed -e 's/ngcp-//g') + file_new=${file//ngcp-/} mv "${file}" "${file_new}" done < <(find debian -maxdepth 1 -type f -name 'ngcp-rtpengine*')