aboutgitcode
diff options
context:
space:
mode:
authorSevinj Aghayeva <sevinj.aghayeva@gmail.com>2022-04-15 00:03:12 -0400
committerStefano Brivio <sbrivio@redhat.com>2022-04-15 17:09:09 +0200
commit1cc97f6c01e0d1cb8006fce4198c82ec0efb763e (patch)
tree74955ec3e371c88f2001f9b4080b1e042063bdd3
parent7973b9d099599bdde375065d25514d4f21295bba (diff)
downloadmbuto-1cc97f6c01e0d1cb8006fce4198c82ec0efb763e.tar
mbuto-1cc97f6c01e0d1cb8006fce4198c82ec0efb763e.tar.gz
mbuto-1cc97f6c01e0d1cb8006fce4198c82ec0efb763e.tar.bz2
mbuto-1cc97f6c01e0d1cb8006fce4198c82ec0efb763e.tar.lz
mbuto-1cc97f6c01e0d1cb8006fce4198c82ec0efb763e.tar.xz
mbuto-1cc97f6c01e0d1cb8006fce4198c82ec0efb763e.tar.zst
mbuto-1cc97f6c01e0d1cb8006fce4198c82ec0efb763e.zip
mbuto: add a function to find the difference of two lists
Add a function to find the difference of two lists and use that function to determine the list of missing modules. Signed-off-by: Sevinj Aghayeva <sevinj.aghayeva@gmail.com>
-rwxr-xr-xmbuto26
1 files changed, 17 insertions, 9 deletions
diff --git a/mbuto b/mbuto
index 2c39942..a7babfd 100755
--- a/mbuto
+++ b/mbuto
@@ -245,15 +245,8 @@ profile_kselftests() {
KMODS="$(${BASENAME} -a -s .ko ${KMODS})"
- __kmods_missing=
- for __n in ${__kmods_needed}; do
- __found=0
- for __f in ${KMODS}; do
- [ ${__n} = ${__f} ] && __found=1
- done
- [ ${__found} -eq 0 ] && \
- __kmods_missing="${__n} ${__kmods_missing}"
- done
+ __kmods_missing=$(list_diff "${__kmods_needed}" "${KMODS}")
+
if [ ! -z "${__kmods_missing}" ]; then
notice "WARNING: missing modules: ${__kmods_missing}"
fi
@@ -426,6 +419,21 @@ workers() {
while ! ${RMDIR} "${__sync_dir}" 2>/dev/null; do ${SLEEP} 1; done
}
+# list_diff() - Given two lists, $1 and $2, print tokens from $1 not in $2
+# $1: List with elements to be checked
+# $2: List to check against
+list_diff() {
+ __diff=
+ for __e1 in ${1}; do
+ __found=0
+ for __e2 in ${2}; do
+ [ ${__e1} = ${__e2} ] && __found=1
+ done
+ [ ${__found} -eq 0 ] && __diff="${__e1} ${__diff}"
+ done
+ printf '%s' "${__diff}"
+}
+
################################################################################