Avoid tricky shell construction

It sometimes failed:

environment: line 4: 1
7+1: syntax error in expression (error token is "7+1")
This commit is contained in:
Mikhail Novosyolov 2019-11-14 01:26:18 +03:00
parent 3eca49b16a
commit 236b8ce3a6

View file

@ -1084,13 +1084,15 @@ cp -a %{temp_root} %{buildroot}
# Multithreaded verification that every kernel module
# has a signature attached to it
mkdir -p "%{certs_dir_rnd}"
echo 0 > %{certs_verify_tmp}
touch %{certs_verify_tmp}
_verify_signature(){
if [ -z "$1" ] || [ ! -f "$1" ]; then return; fi
if hexdump -C "$1" | rev | cut -f 2 -d '|' | rev | tr -d '\n' | \
grep -q '~Module signature appended~'
then
echo $(($(cat %{certs_verify_tmp})+1)) > %{certs_verify_tmp}
if [ -f %{certs_verify_tmp} ]; then
rm -f %{certs_verify_tmp}
fi
else
echo "ERROR: Module $1 has no signature attached to it!"
exit 1
@ -1099,11 +1101,10 @@ _verify_signature(){
export -f _verify_signature
find %{target_modules} -name '*.ko' -print0 | sort -u | \
xargs --null -P "$(nproc)" -I {} "$SHELL" -c '_verify_signature "{}"'
if [ "$(cat %{certs_verify_tmp})" -lt 1 ]; then
if [ -f %{certs_verify_tmp} ]; then
echo "ERROR: seems that signatures of none modules were verified!"
exit 1
fi
cat %{certs_verify_tmp}
rm -f %{certs_verify_tmp}
%endif