@@ -95,7 +95,7 @@ invoke_command()
95
95
wait $( jobs -p) 2> /dev/null
96
96
}
97
97
trap on_exit EXIT
98
- while [ -d /proc/$pid ]; do
98
+ while [[ -d /proc/$pid ] ]; do
99
99
sleep 3 &
100
100
wait $!
101
101
echo -en " ."
@@ -198,7 +198,7 @@ VER()
198
198
get_num_cpus ()
199
199
{
200
200
# use nproc(1) from coreutils 8.1-1+ if available, otherwise single job
201
- if [ -x /usr/bin/nproc ]; then
201
+ if [[ -x /usr/bin/nproc ] ]; then
202
202
nproc
203
203
else
204
204
echo " 1"
@@ -334,20 +334,20 @@ do_depmod()
334
334
return
335
335
fi
336
336
# $1 = kernel version
337
- if [ " ${current_os} " != " Linux" ] ; then
337
+ if [[ ${current_os} != Linux ] ] ; then
338
338
return
339
339
fi
340
340
if [[ -f /boot/System.map-$1 ]]; then
341
341
depmod -a " $1 " -F " /boot/System.map-$1 "
342
342
else
343
343
depmod -a " $1 "
344
344
fi
345
- if [ -f /lib/modules/$1 /modules.dep ] && [ ! -s /lib/modules/$1 /modules.dep ]; then
345
+ if [[ -f /lib/modules/$1 /modules.dep && ! -s /lib/modules/$1 /modules.dep ] ]; then
346
346
# if modules.dep is empty, we just removed the last kernel module from
347
347
# no longer installed kernel $1, so do not leave stale depmod files around
348
348
rm -fv /lib/modules/$1 /modules.{alias,dep,devname,softdep,symbols,* .bin}
349
349
rmdir --ignore-fail-on-non-empty /lib/modules/$1
350
- test -d /lib/modules/$1 || echo $" Removed /lib/modules/$1 "
350
+ [[ -d /lib/modules/$1 ]] || echo $" Removed /lib/modules/$1 "
351
351
fi
352
352
}
353
353
@@ -378,7 +378,7 @@ override_dest_module_location()
378
378
local orig_location=" $1 "
379
379
[[ ${addon_modules_dir} ]] && echo " /${addon_modules_dir} " && return
380
380
381
- if [ " $current_os " = " GNU/kFreeBSD" ] ; then
381
+ if [[ $current_os = GNU/kFreeBSD ] ] ; then
382
382
# Does not support subdirs, regardless of distribution
383
383
echo " " && return
384
384
fi
@@ -481,7 +481,7 @@ read_conf()
481
481
for _conf_file in " $read_conf_file " " /etc/dkms/$module .conf" \
482
482
" /etc/dkms/$module -$module_version .conf" " /etc/dkms/$module -$module_version -$1 .conf" \
483
483
" /etc/dkms/$module -$module_version -$1 -$2 .conf" ; do
484
- [ -e " $_conf_file " ] && safe_source " $_conf_file " $dkms_conf_variables
484
+ [[ -e $_conf_file ] ] && safe_source " $_conf_file " $dkms_conf_variables
485
485
done
486
486
487
487
# Source in the directive_array
@@ -735,7 +735,7 @@ check_version_sanity()
735
735
local lib_tree=" $install_tree /$1 " res=
736
736
echo $" Running module version sanity check."
737
737
local i=0
738
- if [ -n " $3 " ]; then
738
+ if [[ -n $3 ] ]; then
739
739
# Magic split into array syntax saves trivial awk and cut calls.
740
740
local -a obs=(${3// -/ } )
741
741
local -a my=(${1// -/ } )
@@ -770,7 +770,7 @@ check_version_sanity()
770
770
fi
771
771
set_module_suffix " $1 "
772
772
read -a kernels_module < <( find_module " $lib_tree " " ${4} " )
773
- [ -z $kernels_module ] && return 0
773
+ [[ -z $kernels_module ] ] && return 0
774
774
775
775
if [[ " $force_version_override " == " true" ]]; then
776
776
# Skip the following version checking code.
@@ -921,7 +921,7 @@ prepare_signing()
921
921
{
922
922
do_signing=0
923
923
924
- if [[ ! -f " ${kernel_config} " ]]; then
924
+ if [[ ! -f ${kernel_config} ]]; then
925
925
echo " Kernel config ${kernel_config} not found, modules won't be signed"
926
926
return
927
927
fi
@@ -936,7 +936,7 @@ prepare_signing()
936
936
# Lazy source in signing related configuration
937
937
read_framework_conf $dkms_framework_signing_variables
938
938
939
- if [ ! " ${sign_file} " ]; then
939
+ if [[ ! ${sign_file} ] ]; then
940
940
case " $running_distribution " in
941
941
debian* )
942
942
sign_file=" /usr/lib/linux-kbuild-${kernelver% .* } /scripts/sign-file"
@@ -948,13 +948,13 @@ prepare_signing()
948
948
fi
949
949
;;
950
950
esac
951
- if [[ ! -f " ${sign_file} " ]]; then
951
+ if [[ ! -f ${sign_file} ]]; then
952
952
sign_file=" /lib/modules/$kernelver /build/scripts/sign-file"
953
953
fi
954
954
fi
955
955
echo " Sign command: $sign_file "
956
956
957
- if [[ ! -f " ${sign_file} " ]] || [[ ! -x " ${sign_file} " ]]; then
957
+ if [[ ! -f ${sign_file} || ! -x ${sign_file} ]]; then
958
958
echo " Binary ${sign_file} not found, modules won't be signed"
959
959
return
960
960
fi
@@ -967,13 +967,13 @@ prepare_signing()
967
967
mok_signing_key=" /var/lib/shim-signed/mok/MOK.priv"
968
968
mok_certificate=" /var/lib/shim-signed/mok/MOK.der"
969
969
970
- if [[ ! -f " ${mok_signing_key} " ]] || [[ ! -f " ${mok_certificate} " ]]; then
970
+ if [[ ! -f ${mok_signing_key} || ! -f ${mok_certificate} ]]; then
971
971
if [[ ! -x " $( command -v update-secureboot-policy) " ]]; then
972
972
echo " Binary update-secureboot-policy not found, modules won't be signed"
973
973
return
974
974
fi
975
975
# update-secureboot-policy won't create new key if $mok_certificate exists
976
- if [[ -f " ${mok_certificate} " ]]; then
976
+ if [[ -f ${mok_certificate} ]]; then
977
977
rm -f " ${mok_certificate} "
978
978
fi
979
979
echo " Certificate or key are missing, generating them using update-secureboot-policy..."
@@ -985,18 +985,18 @@ prepare_signing()
985
985
esac
986
986
fi
987
987
988
- if [ ! " ${mok_signing_key} " ]; then
988
+ if [[ ! ${mok_signing_key} ] ]; then
989
989
mok_signing_key=" /var/lib/dkms/mok.key"
990
990
fi
991
991
echo " Signing key: $mok_signing_key "
992
992
993
- if [ ! " ${mok_certificate} " ]; then
993
+ if [[ ! ${mok_certificate} ] ]; then
994
994
mok_certificate=" /var/lib/dkms/mok.pub"
995
995
fi
996
996
echo " Public certificate (MOK): $mok_certificate "
997
997
998
998
# scripts/sign-file.c in kernel source also supports using "pkcs11:..." as private key
999
- if [[ " $mok_signing_key " != " pkcs11:" * ]] && ( [ ! -f " $mok_signing_key " ] || [ ! -f " $mok_certificate " ] ); then
999
+ if [[ $mok_signing_key != " pkcs11:" * ]] && ( [[ ! -f $mok_signing_key || ! -f $mok_certificate ] ] ); then
1000
1000
echo " Certificate or key are missing, generating self signed certificate for MOK..."
1001
1001
if ! command -v openssl > /dev/null; then
1002
1002
echo " openssl not found, can't generate key and certificate."
@@ -1005,13 +1005,13 @@ prepare_signing()
1005
1005
openssl req -new -x509 -nodes -days 36500 -subj " /CN=DKMS module signing key" \
1006
1006
-newkey rsa:2048 -keyout " $mok_signing_key " \
1007
1007
-outform DER -out " $mok_certificate " > /dev/null 2>&1
1008
- if [ ! -f " ${mok_signing_key} " ]; then
1008
+ if [[ ! -f ${mok_signing_key} ] ]; then
1009
1009
echo " Key file ${mok_signing_key} not found and can't be generated, modules won't be signed"
1010
1010
return
1011
1011
fi
1012
1012
fi
1013
1013
1014
- if [ ! -f " ${mok_certificate} " ]; then
1014
+ if [[ ! -f ${mok_certificate} ] ]; then
1015
1015
echo " Certificate file ${mok_certificate} not found and can't be generated, modules won't be signed"
1016
1016
return
1017
1017
fi
@@ -1067,7 +1067,7 @@ prepare_build()
1067
1067
$" Check $build_dir for more information."
1068
1068
done
1069
1069
1070
- if [ -f " $kernel_source_dir /.kernelvariables" ]; then
1070
+ if [[ -f $kernel_source_dir /.kernelvariables ] ]; then
1071
1071
export CC=$( echo -e " show-%:\n\t@echo \$ (\$ *)\ninclude $kernel_source_dir /.kernelvariables" | make -f - show-CC)
1072
1072
else
1073
1073
unset CC
@@ -1151,14 +1151,14 @@ actual_build()
1151
1151
" $sign_file " " $sign_hash " " $mok_signing_key " " $mok_certificate " " $built_module "
1152
1152
fi
1153
1153
1154
- if [ " $module_compressed_suffix " = " .gz" ]; then
1154
+ if [[ $module_compressed_suffix = .gz ] ]; then
1155
1155
gzip -9f " $built_module " || compressed_module=" "
1156
- elif [ " $module_compressed_suffix " = " .xz" ]; then
1156
+ elif [[ $module_compressed_suffix = .xz ] ]; then
1157
1157
xz -f " $built_module " || compressed_module=" "
1158
- elif [ " $module_compressed_suffix " = " .zst" ]; then
1158
+ elif [[ $module_compressed_suffix = .zst ] ]; then
1159
1159
zstd -q -f -T0 -20 --ultra " $built_module " || compressed_module=" "
1160
1160
fi
1161
- if [ -n " $compressed_module " ]; then
1161
+ if [[ -n $compressed_module ] ]; then
1162
1162
cp -f " $compressed_module " " $base_dir /module/${dest_module_name[$count]} $module_suffix " > /dev/null
1163
1163
else
1164
1164
cp -f " $built_module " " $base_dir /module/${dest_module_name[$count]} $module_uncompressed_suffix " > /dev/null
@@ -1197,18 +1197,18 @@ force_installation()
1197
1197
{
1198
1198
forced_modules_dir=" /usr/share/dkms/modules_to_force_install"
1199
1199
to_force=" "
1200
- if [ -d $forced_modules_dir ]; then
1200
+ if [[ -d $forced_modules_dir ] ]; then
1201
1201
for elem in $forced_modules_dir /* ; do
1202
- if [ -e $elem ]; then
1202
+ if [[ -e $elem ] ]; then
1203
1203
to_force=" $to_force $( cat $elem ) "
1204
1204
fi
1205
1205
done
1206
1206
1207
1207
for elem in $to_force ; do
1208
- if [ " ${1} " = " ${elem} " ]; then
1208
+ if [[ ${1} = ${elem} ] ]; then
1209
1209
echo " force"
1210
1210
return 0
1211
- elif [ " ${1} _version-override" = " ${elem} " ]; then
1211
+ elif [[ ${1} _version-override = ${elem} ] ]; then
1212
1212
echo " version-override"
1213
1213
return 0
1214
1214
fi
@@ -1359,7 +1359,7 @@ do_install()
1359
1359
ln -s " $module_version /$kernelver /$arch " " $dkms_tree /$module /kernel-$kernelver -$arch " 2> /dev/null
1360
1360
1361
1361
# Add to kabi-tracking
1362
- if [ -z " $NO_WEAK_MODULES " ]; then
1362
+ if [[ -z $NO_WEAK_MODULES ] ]; then
1363
1363
if [[ ${weak_modules} ]]; then
1364
1364
echo $" Adding any weak-modules"
1365
1365
list_each_installed_module " $module " " $kernelver " " $arch " | ${weak_modules} ${weak_modules_no_initrd} --add-modules
@@ -1379,7 +1379,7 @@ do_install()
1379
1379
if [[ $modprobe_on_install ]]; then
1380
1380
# Make the newly installed modules available immediately
1381
1381
find /sys/devices -name modalias -print0 | xargs -0 cat | sort -u | xargs modprobe -a -b -q
1382
- if [ -f /lib/systemd/system/systemd-modules-load.service ]; then
1382
+ if [[ -f /lib/systemd/system/systemd-modules-load.service ] ]; then
1383
1383
systemctl restart systemd-modules-load.service
1384
1384
fi
1385
1385
fi
@@ -1540,7 +1540,7 @@ do_uninstall()
1540
1540
was_active=" true"
1541
1541
echo $" Before uninstall, this module version was ACTIVE on this kernel."
1542
1542
# remove kabi-tracking if last instance removed
1543
- if [ -z " $NO_WEAK_MODULES " ]; then
1543
+ if [[ -z $NO_WEAK_MODULES ] ]; then
1544
1544
if [[ ${weak_modules} ]] && (module_status_built $module $module_version | grep -q " installed" ); then
1545
1545
echo $" Removing any linked weak-modules"
1546
1546
list_each_installed_module " $module " " $1 " " $2 " | ${weak_modules} ${weak_modules_no_initrd} --remove-modules
@@ -1552,11 +1552,11 @@ do_uninstall()
1552
1552
echo $" "
1553
1553
echo $" ${dest_module_name[$count]} $module_suffix :"
1554
1554
echo $" - Uninstallation"
1555
- if [[ " ${real_dest_module_location} " ]]; then
1555
+ if [[ ${real_dest_module_location} ]]; then
1556
1556
echo $" - Deleting from: $install_tree /$1 ${real_dest_module_location} /"
1557
1557
rm -f " $install_tree /$1 ${real_dest_module_location} /${dest_module_name[$count]} $module_uncompressed_suffix " *
1558
1558
dir_to_remove=" ${real_dest_module_location#/ } "
1559
- while [ " ${dir_to_remove} " != " ${dir_to_remove#/ } " ]; do
1559
+ while [[ ${dir_to_remove} != ${dir_to_remove#/ } ] ]; do
1560
1560
dir_to_remove=" ${dir_to_remove#/ } "
1561
1561
done
1562
1562
(if cd " $install_tree /$1 " ; then rpm -qf " ${dir_to_remove} " > /dev/null 2>&1 || rmdir -p --ignore-fail-on-non-empty " ${dir_to_remove} " ; fi || true)
@@ -1565,7 +1565,7 @@ do_uninstall()
1565
1565
fi
1566
1566
echo $" - Original module"
1567
1567
local origmod=$( compressed_or_uncompressed " $dkms_tree /$module /original_module/$1 /$2 " " ${dest_module_name[$count]} " )
1568
- if [[ -n " $origmod " ]]; then
1568
+ if [[ -n $origmod ]]; then
1569
1569
case " $running_distribution " in
1570
1570
debian* | ubuntu* )
1571
1571
;;
@@ -1723,7 +1723,7 @@ find_module_from_ko()
1723
1723
module_status_weak () {
1724
1724
# $1 = module, $2 = module version, $3 = kernel version weak installed to,
1725
1725
# $4 = kernel arch, $5 = kernel version built for
1726
- [ -z " $NO_WEAK_MODULES " ] || return 1
1726
+ [[ -z $NO_WEAK_MODULES ] ] || return 1
1727
1727
[[ $weak_modules ]] || return 1
1728
1728
local m v k a kern weak_ko mod installed_ko f ret=1 oifs=$IFS
1729
1729
local -A already_found
@@ -2112,7 +2112,7 @@ run_match()
2112
2112
report_build_problem ()
2113
2113
{
2114
2114
# If apport is on the system, files a build problem
2115
- if [ -x /usr/share/apport/apport ] && which python3 > /dev/null; then
2115
+ if [[ -x /usr/share/apport/apport ] ] && which python3 > /dev/null; then
2116
2116
python3 /usr/share/apport/package-hooks/dkms_packages.py -m $module -v $module_version -k ${kernelver[0]}
2117
2117
fi
2118
2118
die " $@ "
@@ -2232,9 +2232,9 @@ autoinstall() {
2232
2232
# a list of modules and their latest version.
2233
2233
while read status mvka; do
2234
2234
IFS=' /' read m v k a <<< " $mvka"
2235
- if [[ -z " ${latest["$m"]} " ]]; then
2235
+ if [[ -z ${latest[$m]} ]]; then
2236
2236
known_modules[${# known_modules[@]} ]=" $m "
2237
- latest[" $m " ]=" $v "
2237
+ latest[$m ]=" $v "
2238
2238
elif [[ (" $( VER " $v " ) " > " $( VER " ${latest["$m"]} " ) " ) ]]; then
2239
2239
latest[" $m " ]=" $v "
2240
2240
fi
@@ -2284,13 +2284,13 @@ autoinstall() {
2284
2284
# Step 2: Install modules that have an empty dependency list.
2285
2285
for mv in " ${to_install[@]} " ; do
2286
2286
IFS=/ read m v <<< " $mv"
2287
- if [[ -z " ${build_depends[$m]} " ]]; then
2287
+ if [[ -z ${build_depends[$m]} ]]; then
2288
2288
(module=" $m " module_version=" $v " kernelver=" $kernelver " arch=" $arch " install_module)
2289
2289
status=$?
2290
- if [ " $ status" = 0 ] ; then
2290
+ if (( status == 0 )) ; then
2291
2291
installed_modules[${# installed_modules[@]} ]=" $m "
2292
2292
progress=$(( $progress + 1 ))
2293
- elif [ " $ status" = 77 ] ; then
2293
+ elif (( status == 77 )) ; then
2294
2294
skipped_modules[${# skipped_modules[@]} ]=" $m "
2295
2295
progress=$(( $progress + 1 ))
2296
2296
else
@@ -2309,19 +2309,19 @@ autoinstall() {
2309
2309
2310
2310
# Step 4: Keep going if at least one module was installed during
2311
2311
# this iteration.
2312
- [[ " $ progress" -gt 0 ]] || break ;
2312
+ (( progress > 0 )) || break ;
2313
2313
2314
2314
done
2315
2315
2316
- if [[ " ${# installed_modules[@]} " -gt 0 ]] ; then
2316
+ if (( ${# installed_modules[@]} > 0 )) ; then
2317
2317
echo " dkms autoinstall on $kernelver /$arch succeeded for ${installed_modules[@]} "
2318
2318
fi
2319
2319
2320
- if [[ " ${# skipped_modules[@]} " -gt 0 ]] ; then
2320
+ if (( ${# skipped_modules[@]} > 0 )) ; then
2321
2321
echo " dkms autoinstall on $kernelver /$arch was skipped for ${skipped_modules[@]} "
2322
2322
fi
2323
2323
2324
- if [[ " ${# failed_modules[@]} " -gt 0 ]] ; then
2324
+ if (( ${# failed_modules[@]} > 0 )) ; then
2325
2325
echo " dkms autoinstall on $kernelver /$arch failed for ${failed_modules[@]} "
2326
2326
fi
2327
2327
@@ -2330,7 +2330,7 @@ autoinstall() {
2330
2330
echo " $m /$v autoinstall failed due to missing dependencies: ${build_depends[$m]} "
2331
2331
done
2332
2332
2333
- if [[ " ${# failed_modules[@]} " -gt 0 || " ${# to_install[@]} " -gt 0 ]] ; then
2333
+ if (( ${# failed_modules[@]} > 0 || ${# to_install[@]} > 0 )) ; then
2334
2334
die 11 $" One or more modules failed to install during autoinstall." \
2335
2335
$" Refer to previous errors for more information."
2336
2336
fi
@@ -2363,7 +2363,7 @@ symlink_modules=""
2363
2363
# Check that we can write temporary files
2364
2364
tmpfile=$( mktemp_or_die)
2365
2365
echo " Hello, DKMS!" > " $tmpfile "
2366
- if [ " $( cat " $tmpfile " ) " != " Hello, DKMS!" ]; then
2366
+ if [[ " $( cat " $tmpfile " ) " != " Hello, DKMS!" ] ]; then
2367
2367
warn $" dkms will not function properly without some free space in \$ TMPDIR ($tmp_location )."
2368
2368
fi
2369
2369
rm -f " $tmpfile "
@@ -2542,7 +2542,7 @@ done
2542
2542
2543
2543
# The <(cmd) idiom does not work if /proc is not mounted
2544
2544
read line < <( echo " Hello, DKMS!" )
2545
- if [ " $line " != " Hello, DKMS!" ]; then
2545
+ if [[ $line != " Hello, DKMS!" ] ]; then
2546
2546
warn $" dkms will not function properly if /proc is not mounted."
2547
2547
fi
2548
2548
0 commit comments