Ubuntu 22.04 integration: ShellCheck
- Add new SC2312 global exclude. ``` Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore). [SC2312] ``` - Correct errors detected by new ShellCheck version. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu> Reviewed-by: George Melikov <mail@gmelikov.ru> Signed-off-by: szubersk <szuberskidamian@gmail.com> Closes #14148
This commit is contained in:
parent
c3b6fd3d59
commit
a5087965fe
|
@ -16,7 +16,7 @@ automake --version | awk '{print $NF; exit}' | (
|
|||
dir="${dir%/Makefile.am}"
|
||||
grep -q '%[CD]%' "$dir/Makefile.am" || continue
|
||||
|
||||
reldir="${dir#$root}"
|
||||
reldir="${dir#"$root"}"
|
||||
reldir="${reldir#/}"
|
||||
|
||||
canon_reldir="$(printf '%s' "$reldir" | tr -C 'a-zA-Z0-9@_' '_')"
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# ShellCheck can't follow non-constant source. Use a directive to specify location. [SC1090]
|
||||
# Not following: a was not specified as input (see shellcheck -x). [SC1091]
|
||||
# Prefer putting braces around variable references even when not strictly required. [SC2250]
|
||||
# Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore). [SC2312]
|
||||
# In POSIX sh, 'local' is undefined. [SC2039] # older ShellCheck versions
|
||||
# In POSIX sh, 'local' is undefined. [SC3043] # newer ShellCheck versions
|
||||
|
||||
|
@ -17,7 +18,7 @@ PHONY += shellcheck
|
|||
_STGT = $(subst ^,/,$(subst shellcheck-here-,,$@))
|
||||
shellcheck-here-%:
|
||||
if HAVE_SHELLCHECK
|
||||
shellcheck --format=gcc --enable=all --exclude=SC1090,SC1091,SC2039,SC2250,SC3043 $$([ -n "$(SHELLCHECK_SHELL)" ] && echo "--shell=$(SHELLCHECK_SHELL)") "$$([ -e "$(_STGT)" ] || echo "$(srcdir)/")$(_STGT)"
|
||||
shellcheck --format=gcc --enable=all --exclude=SC1090,SC1091,SC2039,SC2250,SC2312,SC3043 $$([ -n "$(SHELLCHECK_SHELL)" ] && echo "--shell=$(SHELLCHECK_SHELL)") "$$([ -e "$(_STGT)" ] || echo "$(srcdir)/")$(_STGT)"
|
||||
else
|
||||
@echo "skipping shellcheck of" $(_STGT) "because shellcheck is not installed"
|
||||
endif
|
||||
|
|
|
@ -63,11 +63,11 @@ __zfs_list_filesystems()
|
|||
__zfs_match_snapshot()
|
||||
{
|
||||
local base_dataset="${cur%@*}"
|
||||
if [ "$base_dataset" != "$cur" ]
|
||||
if [[ "$base_dataset" != "$cur" ]]
|
||||
then
|
||||
$__ZFS_CMD list -H -o name -s name -t snapshot -d 1 "$base_dataset"
|
||||
else
|
||||
if [ "$cur" != "" ] && __zfs_list_datasets "$cur" &> /dev/null
|
||||
if [[ "$cur" != "" ]] && __zfs_list_datasets "$cur" &> /dev/null
|
||||
then
|
||||
$__ZFS_CMD list -H -o name -s name -t filesystem,volume -r "$cur" | tail -n +2
|
||||
# We output the base dataset name even though we might be
|
||||
|
@ -104,7 +104,7 @@ __zfs_match_snapshot()
|
|||
__zfs_match_snapshot_or_bookmark()
|
||||
{
|
||||
local base_dataset="${cur%[#@]*}"
|
||||
if [ "$base_dataset" != "$cur" ]
|
||||
if [[ "$base_dataset" != "$cur" ]]
|
||||
then
|
||||
if [[ $cur == *@* ]]
|
||||
then
|
||||
|
@ -114,7 +114,7 @@ __zfs_match_snapshot_or_bookmark()
|
|||
fi
|
||||
else
|
||||
$__ZFS_CMD list -H -o name -s name -t filesystem,volume
|
||||
if [ -e "$cur" ] && $__ZFS_CMD list -H -o name -s name -t filesystem,volume "$cur" &> /dev/null
|
||||
if [[ -e "$cur" ]] && $__ZFS_CMD list -H -o name -s name -t filesystem,volume "$cur" &> /dev/null
|
||||
then
|
||||
echo "$cur@"
|
||||
echo "$cur#"
|
||||
|
@ -126,10 +126,10 @@ __zfs_match_multiple_snapshots()
|
|||
{
|
||||
local existing_opts
|
||||
existing_opts="$(expr "$cur" : '\(.*\)[%,]')"
|
||||
if [ -e "$existing_opts" ]
|
||||
if [[ -e "$existing_opts" ]]
|
||||
then
|
||||
local base_dataset="${cur%@*}"
|
||||
if [ "$base_dataset" != "$cur" ]
|
||||
if [[ "$base_dataset" != "$cur" ]]
|
||||
then
|
||||
local cur="${cur##*,}"
|
||||
if [[ $cur =~ ^%|%.*% ]]
|
||||
|
@ -199,7 +199,7 @@ __zfs_complete_multiple_options()
|
|||
|
||||
mapfile -t COMPREPLY < <(compgen -W "$options" -- "${cur##*,}")
|
||||
existing_opts=$(expr "$cur" : '\(.*,\)')
|
||||
if [ -n "$existing_opts" ]
|
||||
if [[ -n "$existing_opts" ]]
|
||||
then
|
||||
COMPREPLY=( "${COMPREPLY[@]/#/${existing_opts}}" )
|
||||
fi
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
get_devtype() {
|
||||
local typ
|
||||
typ=$(udevadm info --query=property --name="$1" | sed -n 's|^ID_FS_TYPE=||p')
|
||||
if [ -z "$typ" ] ; then
|
||||
if [[ -z "$typ" ]] ; then
|
||||
typ=$(blkid -c /dev/null "$1" -o value -s TYPE)
|
||||
fi
|
||||
echo "$typ"
|
||||
|
@ -22,7 +22,7 @@ get_pool_devices() {
|
|||
else
|
||||
awk -F '\t' '/\t\/dev/ { print $2 }' "$poolconfigtemp" | \
|
||||
while read -r pooldev ; do
|
||||
if [ -e "$pooldev" ] ; then
|
||||
if [[ -e "$pooldev" ]] ; then
|
||||
resolved="$(readlink -f "$pooldev")"
|
||||
dinfo "zfsexpandknowledge: pool $1 has device $pooldev (which resolves to $resolved)"
|
||||
echo "$resolved"
|
||||
|
@ -38,15 +38,15 @@ find_zfs_block_devices() {
|
|||
local fstype
|
||||
local _
|
||||
numfields="$(awk '{print NF; exit}' /proc/self/mountinfo)"
|
||||
if [ "$numfields" = "10" ] ; then
|
||||
if [[ "$numfields" = "10" ]] ; then
|
||||
fields="_ _ _ _ mp _ _ fstype dev _"
|
||||
else
|
||||
fields="_ _ _ _ mp _ _ _ fstype dev _"
|
||||
fi
|
||||
# shellcheck disable=SC2086
|
||||
while read -r ${fields?} ; do
|
||||
[ "$fstype" = "zfs" ] || continue
|
||||
[ "$mp" = "$1" ] && get_pool_devices "${dev%%/*}"
|
||||
[[ "$fstype" = "zfs" ]] || continue
|
||||
[[ "$mp" = "$1" ]] && get_pool_devices "${dev%%/*}"
|
||||
done < /proc/self/mountinfo
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ check() {
|
|||
local _depdevtype
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
if [ -n "$hostonly" ]; then
|
||||
if [[ -n "$hostonly" ]]; then
|
||||
|
||||
for mp in \
|
||||
"/" \
|
||||
|
@ -92,7 +92,7 @@ if [ -n "$hostonly" ]; then
|
|||
mp=$(readlink -f "$mp")
|
||||
mountpoint "$mp" >/dev/null 2>&1 || continue
|
||||
blockdevs=$(find_zfs_block_devices "$mp")
|
||||
if [ -z "$blockdevs" ] ; then continue ; fi
|
||||
if [[ -z "$blockdevs" ]] ; then continue ; fi
|
||||
dinfo "zfsexpandknowledge: block devices backing ZFS dataset $mp: ${blockdevs//$'\n'/ }"
|
||||
for dev in $blockdevs
|
||||
do
|
||||
|
@ -100,9 +100,9 @@ if [ -n "$hostonly" ]; then
|
|||
fstype=$(get_devtype "$dev")
|
||||
host_fs_types["$dev"]="$fstype"
|
||||
majmin=$(get_maj_min "$dev")
|
||||
if [ -d "/sys/dev/block/$majmin/slaves" ] ; then
|
||||
if [[ -d "/sys/dev/block/$majmin/slaves" ]] ; then
|
||||
for _depdev in "/sys/dev/block/$majmin/slaves"/*; do
|
||||
[ -f "$_depdev/dev" ] || continue
|
||||
[[ -f "$_depdev/dev" ]] || continue
|
||||
_depdev="/dev/${_depdev##*/}"
|
||||
_depdevname=$(udevadm info --query=property --name="$_depdev" | sed -n 's|^DEVNAME=||p')
|
||||
_depdevtype=$(get_devtype "$_depdevname")
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
check() {
|
||||
# We depend on udev-rules being loaded
|
||||
[ "${1}" = "-d" ] && return 0
|
||||
[[ "${1}" = "-d" ]] && return 0
|
||||
|
||||
# Verify the zfs tool chain
|
||||
for tool in "zgenhostid" "zpool" "zfs" "mount.zfs"; do
|
||||
|
@ -50,7 +50,7 @@ install() {
|
|||
fi
|
||||
|
||||
inst_hook cmdline 95 "${moddir}/parse-zfs.sh"
|
||||
if [ -n "${systemdutildir}" ]; then
|
||||
if [[ -n "${systemdutildir}" ]]; then
|
||||
inst_script "${moddir}/zfs-generator.sh" "${systemdutildir}/system-generators/dracut-zfs-generator"
|
||||
fi
|
||||
inst_hook pre-mount 90 "${moddir}/zfs-load-key.sh"
|
||||
|
@ -68,7 +68,7 @@ install() {
|
|||
|
||||
# Synchronize initramfs and system hostid
|
||||
if ! inst_simple -H @sysconfdir@/hostid; then
|
||||
if HOSTID="$(hostid 2>/dev/null)" && [ "${HOSTID}" != "00000000" ]; then
|
||||
if HOSTID="$(hostid 2>/dev/null)" && [[ "${HOSTID}" != "00000000" ]]; then
|
||||
zgenhostid -o "${initdir}@sysconfdir@/hostid" "${HOSTID}"
|
||||
mark_hostonly @sysconfdir@/hostid
|
||||
fi
|
||||
|
|
|
@ -640,8 +640,8 @@ setup_snapshot_booting()
|
|||
# rpool/ROOT/debian/boot@snap2 => rpool/ROOT/debian_snap2/boot
|
||||
# rpool/ROOT/debian/usr@snap2 => rpool/ROOT/debian_snap2/usr
|
||||
# rpool/ROOT/debian/var@snap2 => rpool/ROOT/debian_snap2/var
|
||||
subfs="${s##$rootfs}"
|
||||
subfs="${subfs%%@$snapname}"
|
||||
subfs="${s##"$rootfs"}"
|
||||
subfs="${subfs%%@"$snapname"}"
|
||||
|
||||
destfs="${rootfs}_${snapname}" # base fs.
|
||||
[ -n "$subfs" ] && destfs="${destfs}$subfs" # + sub fs.
|
||||
|
|
|
@ -8,15 +8,15 @@ export ZTS_DIR=
|
|||
export SCRIPT_DIR=
|
||||
|
||||
# General commands
|
||||
export ZDB=${ZDB:-$SBIN_DIR/zdb}
|
||||
export ZFS=${ZFS:-$SBIN_DIR/zfs}
|
||||
export ZPOOL=${ZPOOL:-$SBIN_DIR/zpool}
|
||||
export ZTEST=${ZTEST:-$SBIN_DIR/ztest}
|
||||
export ZFS_SH=${ZFS_SH:-$SCRIPT_DIR/zfs.sh}
|
||||
export ZDB="${ZDB:-$SBIN_DIR/zdb}"
|
||||
export ZFS="${ZFS:-$SBIN_DIR/zfs}"
|
||||
export ZPOOL="${ZPOOL:-$SBIN_DIR/zpool}"
|
||||
export ZTEST="${ZTEST:-$SBIN_DIR/ztest}"
|
||||
export ZFS_SH="${ZFS_SH:-$SCRIPT_DIR/zfs.sh}"
|
||||
|
||||
# Test Suite
|
||||
export RUNFILE_DIR=${RUNFILE_DIR:-$ZTS_DIR/runfiles}
|
||||
export TEST_RUNNER=${TEST_RUNNER:-$ZTS_DIR/test-runner/bin/test-runner.py}
|
||||
export ZTS_REPORT=${ZTS_REPORT:-$ZTS_DIR/test-runner/bin/zts-report.py}
|
||||
export STF_TOOLS=${STF_TOOLS:-$ZTS_DIR/test-runner}
|
||||
export STF_SUITE=${STF_SUITE:-$ZTS_DIR/zfs-tests}
|
||||
export RUNFILE_DIR="${RUNFILE_DIR:-$ZTS_DIR/runfiles}"
|
||||
export TEST_RUNNER="${TEST_RUNNER:-$ZTS_DIR/test-runner/bin/test-runner.py}"
|
||||
export ZTS_REPORT="${ZTS_REPORT:-$ZTS_DIR/test-runner/bin/zts-report.py}"
|
||||
export STF_TOOLS="${STF_TOOLS:-$ZTS_DIR/test-runner}"
|
||||
export STF_SUITE="${STF_SUITE:-$ZTS_DIR/zfs-tests}"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
# shellcheck disable=SC2086
|
||||
# shellcheck disable=SC2086,SC2295
|
||||
|
||||
# kmodtool - Helper script for building kernel module RPMs
|
||||
# Copyright (c) 2003-2012 Ville Skyttä <ville.skytta@iki.fi>,
|
||||
|
@ -125,10 +125,10 @@ EOF
|
|||
|
||||
print_rpmtemplate_per_kmodpkg ()
|
||||
{
|
||||
if [ "${1}" = "--custom" ]; then
|
||||
if [[ "${1}" = "--custom" ]]; then
|
||||
shift
|
||||
local customkernel=true
|
||||
elif [ "${1}" = "--redhat" ]; then
|
||||
elif [[ "${1}" = "--redhat" ]]; then
|
||||
# this is needed for akmods
|
||||
shift
|
||||
local redhatkernel=true
|
||||
|
@ -139,7 +139,7 @@ print_rpmtemplate_per_kmodpkg ()
|
|||
|
||||
# Detect depmod install location
|
||||
local depmod_path=/sbin/depmod
|
||||
if [ ! -f "${depmod_path}" ]; then
|
||||
if [[ ! -f "${depmod_path}" ]]; then
|
||||
depmod_path=/usr/sbin/depmod
|
||||
fi
|
||||
|
||||
|
@ -163,24 +163,24 @@ Requires(postun): kmod
|
|||
EOF
|
||||
|
||||
# second part
|
||||
if [ -z "${customkernel}" ]; then
|
||||
if [[ -z "${customkernel}" ]]; then
|
||||
cat <<EOF
|
||||
Requires: kernel-uname-r = ${kernel_uname_r}
|
||||
BuildRequires: kernel-devel-uname-r = ${kernel_uname_r}
|
||||
%{?KmodsRequires:Requires: %{KmodsRequires}-uname-r = ${kernel_uname_r}}
|
||||
%{?KmodsRequires:BuildRequires: %{KmodsRequires}-uname-r = ${kernel_uname_r}}
|
||||
%post -n kmod-${kmodname}-${kernel_uname_r}
|
||||
if [ -f "/boot/System.map-${kernel_uname_r}" ]; then
|
||||
if [[ -f "/boot/System.map-${kernel_uname_r}" ]]; then
|
||||
${prefix}${depmod_path} -aeF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} > /dev/null || :
|
||||
elif [ -f "/lib/modules/${kernel_uname_r}/System.map" ]; then
|
||||
elif [[ -f "/lib/modules/${kernel_uname_r}/System.map" ]]; then
|
||||
${prefix}${depmod_path} -aeF /lib/modules/${kernel_uname_r}/System.map ${kernel_uname_r} > /dev/null || :
|
||||
else
|
||||
${prefix}${depmod_path} -ae ${kernel_uname_r} &> /dev/null || :
|
||||
fi
|
||||
%postun -n kmod-${kmodname}-${kernel_uname_r}
|
||||
if [ -f "/boot/System.map-${kernel_uname_r}" ]; then
|
||||
if [[ -f "/boot/System.map-${kernel_uname_r}" ]]; then
|
||||
${prefix}${depmod_path} -aF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} &> /dev/null || :
|
||||
elif [ -f "/lib/modules/${kernel_uname_r}/System.map" ]; then
|
||||
elif [[ -f "/lib/modules/${kernel_uname_r}/System.map" ]]; then
|
||||
${prefix}${depmod_path} -aF /lib/modules/${kernel_uname_r}/System.map ${kernel_uname_r} &> /dev/null || :
|
||||
else
|
||||
${prefix}${depmod_path} -a ${kernel_uname_r} &> /dev/null || :
|
||||
|
@ -213,10 +213,10 @@ EOF
|
|||
|
||||
print_rpmtemplate_kmoddevelpkg ()
|
||||
{
|
||||
if [ "${1}" = "--custom" ]; then
|
||||
if [[ "${1}" = "--custom" ]]; then
|
||||
shift
|
||||
local customkernel=true
|
||||
elif [ "${1}" = "--redhat" ]; then
|
||||
elif [[ "${1}" = "--redhat" ]]; then
|
||||
shift
|
||||
local redhatkernel=true
|
||||
fi
|
||||
|
@ -230,7 +230,7 @@ Group: System Environment/Kernel
|
|||
Provides: ${kmodname}-devel-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
|
||||
EOF
|
||||
|
||||
if [ -z "${customkernel}" ] && [ -z "${redhatkernel}" ]; then
|
||||
if [[ -z "${customkernel}" ]] && [[ -z "${redhatkernel}" ]]; then
|
||||
echo "Requires: kmod-${kmodname}-devel-${kernel_uname_r} >= %{?epoch:%{epoch}:}%{version}-%{release}"
|
||||
fi
|
||||
|
||||
|
@ -256,10 +256,10 @@ EOF
|
|||
|
||||
print_rpmtemplate_per_kmoddevelpkg ()
|
||||
{
|
||||
if [ "${1}" = "--custom" ]; then
|
||||
if [[ "${1}" = "--custom" ]]; then
|
||||
shift
|
||||
local customkernel=true
|
||||
elif [ "${1}" = "--redhat" ]; then
|
||||
elif [[ "${1}" = "--redhat" ]]; then
|
||||
# this is needed for akmods
|
||||
shift
|
||||
local redhatkernel=true
|
||||
|
@ -279,7 +279,7 @@ Provides: kmod-${kmodname}-devel-uname-r = ${kernel_uname_r}
|
|||
EOF
|
||||
|
||||
# second part
|
||||
if [ -z "${customkernel}" ]; then
|
||||
if [[ -z "${customkernel}" ]]; then
|
||||
cat <<EOF
|
||||
Requires: kernel-devel-uname-r = ${kernel_uname_r}
|
||||
BuildRequires: kernel-devel-uname-r = ${kernel_uname_r}
|
||||
|
@ -333,7 +333,7 @@ print_customrpmtemplate ()
|
|||
{
|
||||
for kernel in ${1}
|
||||
do
|
||||
if [ -e "${buildroot}/usr/src/kernels/${kernel}" ] ; then
|
||||
if [[ -e "${buildroot}/usr/src/kernels/${kernel}" ]] ; then
|
||||
# this looks like a Fedora/RH kernel -- print a normal template (which includes the proper BR) and be happy :)
|
||||
kernel_versions="${kernel_versions}${kernel}___${buildroot}%{_usrsrc}/kernels/${kernel} "
|
||||
|
||||
|
@ -342,14 +342,14 @@ print_customrpmtemplate ()
|
|||
print_rpmtemplate_per_kmodpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
|
||||
|
||||
# create development package
|
||||
if [ -n "${devel}" ]; then
|
||||
if [[ -n "${devel}" ]]; then
|
||||
# create devel package including common headers
|
||||
print_rpmtemplate_kmoddevelpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
|
||||
|
||||
# create devel package
|
||||
print_rpmtemplate_per_kmoddevelpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
|
||||
fi
|
||||
elif [ -e "${prefix}/lib/modules/${kernel}/build/Makefile" ]; then
|
||||
elif [[ -e "${prefix}/lib/modules/${kernel}/build/Makefile" ]]; then
|
||||
# likely a user-build-kernel with available buildfiles
|
||||
# fixme: we should check if uname from Makefile is the same as ${kernel}
|
||||
|
||||
|
@ -357,7 +357,7 @@ print_customrpmtemplate ()
|
|||
print_rpmtemplate_per_kmodpkg --custom "${kernel}"
|
||||
|
||||
# create development package
|
||||
if [ -n "${devel}" ]; then
|
||||
if [[ -n "${devel}" ]]; then
|
||||
# create devel package including common headers
|
||||
print_rpmtemplate_kmoddevelpkg --custom "${kernel}"
|
||||
|
||||
|
@ -396,7 +396,7 @@ print_rpmtemplate ()
|
|||
# create package
|
||||
print_rpmtemplate_per_kmodpkg "${kernel}" "${kernel##${kernel_verrelarch}}"
|
||||
|
||||
if [ -n "${devel}" ]; then
|
||||
if [[ -n "${devel}" ]]; then
|
||||
# create devel package including common headers
|
||||
print_rpmtemplate_kmoddevelpkg "${kernel}" "${kernel##${kernel_verrelarch}}"
|
||||
|
||||
|
@ -423,13 +423,13 @@ myprog_help ()
|
|||
echo " --buildroot <dir> -- Build root (place to look for build files)"
|
||||
}
|
||||
|
||||
while [ -n "${1}" ] ; do
|
||||
while [[ -n "${1}" ]] ; do
|
||||
case "${1}" in
|
||||
--filterfile)
|
||||
shift
|
||||
if [ -z "${1}" ] ; then
|
||||
if [[ -z "${1}" ]] ; then
|
||||
error_out 2 "Please provide path to a filter-file together with --filterfile" >&2
|
||||
elif [ ! -e "${1}" ]; then
|
||||
elif [[ ! -e "${1}" ]]; then
|
||||
error_out 2 "Filterfile ${1} not found" >&2
|
||||
fi
|
||||
filterfile="${1}"
|
||||
|
@ -437,7 +437,7 @@ while [ -n "${1}" ] ; do
|
|||
;;
|
||||
--kmodname)
|
||||
shift
|
||||
if [ -z "${1}" ] ; then
|
||||
if [[ -z "${1}" ]] ; then
|
||||
error_out 2 "Please provide the name of the kmod together with --kmodname" >&2
|
||||
fi
|
||||
# strip pending -kmod
|
||||
|
@ -450,7 +450,7 @@ while [ -n "${1}" ] ; do
|
|||
;;
|
||||
--prefix)
|
||||
shift
|
||||
if [ -z "${1}" ] ; then
|
||||
if [[ -z "${1}" ]] ; then
|
||||
error_out 2 "Please provide a prefix with --prefix" >&2
|
||||
fi
|
||||
prefix="${1}"
|
||||
|
@ -458,7 +458,7 @@ while [ -n "${1}" ] ; do
|
|||
;;
|
||||
--repo)
|
||||
shift
|
||||
if [ -z "${1}" ] ; then
|
||||
if [[ -z "${1}" ]] ; then
|
||||
error_out 2 "Please provide the name of the repo together with --repo" >&2
|
||||
fi
|
||||
repo=${1}
|
||||
|
@ -466,7 +466,7 @@ while [ -n "${1}" ] ; do
|
|||
;;
|
||||
--for-kernels)
|
||||
shift
|
||||
if [ -z "${1}" ] ; then
|
||||
if [[ -z "${1}" ]] ; then
|
||||
error_out 2 "Please provide the name of the kmod together with --kmodname" >&2
|
||||
fi
|
||||
for_kernels="${1}"
|
||||
|
@ -514,28 +514,28 @@ while [ -n "${1}" ] ; do
|
|||
esac
|
||||
done
|
||||
|
||||
if [ -e ./kmodtool-kernel-variants ]; then
|
||||
if [[ -e ./kmodtool-kernel-variants ]]; then
|
||||
kernels_known_variants="$(cat ./kmodtool-kernel-variants)"
|
||||
elif [ -e /usr/share/kmodtool/kernel-variants ] ; then
|
||||
elif [[ -e /usr/share/kmodtool/kernel-variants ]] ; then
|
||||
kernels_known_variants="$(cat /usr/share/kmodtool/kernel-variants)"
|
||||
else
|
||||
kernels_known_variants="@(smp?(-debug)|PAE?(-debug)|debug|kdump|xen|kirkwood|highbank|imx|omap|tegra)"
|
||||
fi
|
||||
|
||||
# general sanity checks
|
||||
if [ -z "${target}" ]; then
|
||||
if [[ -z "${target}" ]]; then
|
||||
error_out 2 "please pass target arch with --target"
|
||||
elif [ -z "${kmodname}" ]; then
|
||||
elif [[ -z "${kmodname}" ]]; then
|
||||
error_out 2 "please pass kmodname with --kmodname"
|
||||
elif [ -z "${kernels_known_variants}" ] ; then
|
||||
elif [[ -z "${kernels_known_variants}" ]] ; then
|
||||
error_out 2 "could not determine known variants"
|
||||
fi
|
||||
|
||||
# go
|
||||
if [ -n "${for_kernels}" ]; then
|
||||
if [[ -n "${for_kernels}" ]]; then
|
||||
# this is easy:
|
||||
print_customrpmtemplate "${for_kernels}"
|
||||
elif [ "${build_kernels}" = "akmod" ]; then
|
||||
elif [[ "${build_kernels}" = "akmod" ]]; then
|
||||
# do only a akmod package
|
||||
print_akmodtemplate
|
||||
print_akmodmeta
|
||||
|
@ -543,7 +543,7 @@ else
|
|||
# seems we are on out own to decide for which kernels to build
|
||||
|
||||
# we need more sanity checks in this case
|
||||
if [ -z "${repo}" ]; then
|
||||
if [[ -z "${repo}" ]]; then
|
||||
error_out 2 "please provide repo name with --repo"
|
||||
elif ! command -v "buildsys-build-${repo}-kerneldevpkgs" > /dev/null 2>&1; then
|
||||
error_out 2 "buildsys-build-${repo}-kerneldevpkgs not found"
|
||||
|
@ -553,14 +553,14 @@ else
|
|||
cmdoptions="--target ${target}"
|
||||
|
||||
# filterfile to filter list of kernels?
|
||||
if [ -n "${filterfile}" ] ; then
|
||||
if [[ -n "${filterfile}" ]] ; then
|
||||
cmdoptions="${cmdoptions} --filterfile ${filterfile}"
|
||||
fi
|
||||
|
||||
kernel_versions_to_build_for=$(buildsys-build-${repo}-kerneldevpkgs "--${build_kernels}" ${cmdoptions}) ||
|
||||
error_out 2 "buildsys-build-${repo}-kerneldevpkgs failed: ${kernel_versions_to_build_for}"
|
||||
|
||||
if [ "${build_kernels}" = "current" ] && [ -z "${noakmod}" ]; then
|
||||
if [[ "${build_kernels}" = "current" ]] && [[ -z "${noakmod}" ]]; then
|
||||
print_akmodtemplate
|
||||
fi
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
|
||||
BASE_DIR=$(dirname "$0")
|
||||
SCRIPT_COMMON=common.sh
|
||||
if [ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]; then
|
||||
if [[ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]]; then
|
||||
. "${BASE_DIR}/${SCRIPT_COMMON}"
|
||||
else
|
||||
echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
|
||||
|
@ -188,7 +188,7 @@ populate "$SRC_DIR" 10 100
|
|||
SRC_DIR="$TEST_DIR/src"
|
||||
SRC_DIR_ZFS="$SRC_DIR/zfs"
|
||||
|
||||
if [ "$COLOR" = "no" ]; then
|
||||
if [[ "$COLOR" = "no" ]]; then
|
||||
COLOR_GREEN=""
|
||||
COLOR_BROWN=""
|
||||
COLOR_RED=""
|
||||
|
@ -230,7 +230,7 @@ src_set_vars() {
|
|||
ZFS_DIR="$SRC_DIR_ZFS/$ZFS_TAG"
|
||||
ZFS_URL="$REPO/zfs/tarball/$ZFS_TAG"
|
||||
|
||||
if [ "$TAG" = "installed" ]; then
|
||||
if [[ "$TAG" = "installed" ]]; then
|
||||
ZPOOL_CMD=$(command -v zpool)
|
||||
ZFS_CMD=$(command -v zfs)
|
||||
ZFS_SH="/usr/share/zfs/zfs.sh"
|
||||
|
@ -273,7 +273,7 @@ pool_create() {
|
|||
pool_set_vars "$1"
|
||||
src_set_vars "$1"
|
||||
|
||||
if [ "$POOL_TAG" != "installed" ]; then
|
||||
if [[ "$POOL_TAG" != "installed" ]]; then
|
||||
cd "$POOL_DIR_SRC" || fail "Failed 'cd $POOL_DIR_SRC'"
|
||||
fi
|
||||
|
||||
|
@ -319,7 +319,7 @@ pool_create() {
|
|||
|
||||
# If the zfs-images directory doesn't exist fetch a copy from Github then
|
||||
# cache it in the $TEST_DIR and update $IMAGES_DIR.
|
||||
if [ ! -d "$IMAGES_DIR" ]; then
|
||||
if [[ ! -d "$IMAGES_DIR" ]]; then
|
||||
IMAGES_DIR="$TEST_DIR/zfs-images"
|
||||
mkdir -p "$IMAGES_DIR"
|
||||
curl -sL "$IMAGES_TAR" | \
|
||||
|
@ -331,7 +331,7 @@ fi
|
|||
# list of available images for the reserved keyword 'all'.
|
||||
for TAG in $POOL_TAGS; do
|
||||
|
||||
if [ "$TAG" = "all" ]; then
|
||||
if [[ "$TAG" = "all" ]]; then
|
||||
ALL_TAGS=$(echo "$IMAGES_DIR"/*.tar.bz2 | \
|
||||
sed "s|$IMAGES_DIR/||g;s|.tar.bz2||g")
|
||||
NEW_TAGS="$NEW_TAGS $ALL_TAGS"
|
||||
|
@ -341,7 +341,7 @@ for TAG in $POOL_TAGS; do
|
|||
done
|
||||
POOL_TAGS="$NEW_TAGS"
|
||||
|
||||
if [ "$VERBOSE" = "yes" ]; then
|
||||
if [[ "$VERBOSE" = "yes" ]]; then
|
||||
echo "---------------------------- Options ----------------------------"
|
||||
echo "VERBOSE=$VERBOSE"
|
||||
echo "KEEP=$KEEP"
|
||||
|
@ -353,11 +353,11 @@ if [ "$VERBOSE" = "yes" ]; then
|
|||
echo
|
||||
fi
|
||||
|
||||
if [ ! -d "$TEST_DIR" ]; then
|
||||
if [[ ! -d "$TEST_DIR" ]]; then
|
||||
mkdir -p "$TEST_DIR"
|
||||
fi
|
||||
|
||||
if [ ! -d "$SRC_DIR" ]; then
|
||||
if [[ ! -d "$SRC_DIR" ]]; then
|
||||
mkdir -p "$SRC_DIR"
|
||||
fi
|
||||
|
||||
|
@ -367,9 +367,9 @@ printf "%-16s" " "
|
|||
for TAG in $SRC_TAGS; do
|
||||
src_set_vars "$TAG"
|
||||
|
||||
if [ "$TAG" = "installed" ]; then
|
||||
if [[ "$TAG" = "installed" ]]; then
|
||||
ZFS_VERSION=$(modinfo zfs | awk '/version:/ { print $2; exit }')
|
||||
if [ -n "$ZFS_VERSION" ]; then
|
||||
if [[ -n "$ZFS_VERSION" ]]; then
|
||||
printf "%-16s" "$ZFS_VERSION"
|
||||
else
|
||||
fail "ZFS is not installed"
|
||||
|
@ -388,21 +388,21 @@ printf "%-16s" "Clone ZFS"
|
|||
for TAG in $SRC_TAGS; do
|
||||
src_set_vars "$TAG"
|
||||
|
||||
if [ -d "$ZFS_DIR" ]; then
|
||||
if [[ -d "$ZFS_DIR" ]]; then
|
||||
skip_nonewline
|
||||
elif [ "$ZFS_TAG" = "installed" ]; then
|
||||
elif [[ "$ZFS_TAG" = "installed" ]]; then
|
||||
skip_nonewline
|
||||
else
|
||||
cd "$SRC_DIR" || fail "Failed 'cd $SRC_DIR'"
|
||||
|
||||
if [ ! -d "$SRC_DIR_ZFS" ]; then
|
||||
if [[ ! -d "$SRC_DIR_ZFS" ]]; then
|
||||
mkdir -p "$SRC_DIR_ZFS"
|
||||
fi
|
||||
|
||||
git archive --format=tar --prefix="$ZFS_TAG/ $ZFS_TAG" \
|
||||
-o "$SRC_DIR_ZFS/$ZFS_TAG.tar" &>/dev/null || \
|
||||
rm "$SRC_DIR_ZFS/$ZFS_TAG.tar"
|
||||
if [ -s "$SRC_DIR_ZFS/$ZFS_TAG.tar" ]; then
|
||||
if [[ -s "$SRC_DIR_ZFS/$ZFS_TAG.tar" ]]; then
|
||||
tar -xf "$SRC_DIR_ZFS/$ZFS_TAG.tar" -C "$SRC_DIR_ZFS"
|
||||
rm "$SRC_DIR_ZFS/$ZFS_TAG.tar"
|
||||
echo -n -e "${COLOR_GREEN}Local${COLOR_RESET}\t\t"
|
||||
|
@ -422,9 +422,9 @@ printf "%-16s" "Build ZFS"
|
|||
for TAG in $SRC_TAGS; do
|
||||
src_set_vars "$TAG"
|
||||
|
||||
if [ -f "$ZFS_DIR/module/zfs/zfs.ko" ]; then
|
||||
if [[ -f "$ZFS_DIR/module/zfs/zfs.ko" ]]; then
|
||||
skip_nonewline
|
||||
elif [ "$ZFS_TAG" = "installed" ]; then
|
||||
elif [[ "$ZFS_TAG" = "installed" ]]; then
|
||||
skip_nonewline
|
||||
else
|
||||
cd "$ZFS_DIR" || fail "Failed 'cd $ZFS_DIR'"
|
||||
|
@ -454,15 +454,15 @@ for TAG in $POOL_TAGS; do
|
|||
mkdir -p "$POOL_DIR_PRISTINE"
|
||||
|
||||
# Use the existing compressed image if available.
|
||||
if [ -f "$POOL_BZIP" ]; then
|
||||
if [[ -f "$POOL_BZIP" ]]; then
|
||||
tar -xjf "$POOL_BZIP" -C "$POOL_DIR_PRISTINE" \
|
||||
--strip-components=1 || \
|
||||
fail "Failed 'tar -xjf $POOL_BZIP"
|
||||
# Use the installed version to create the pool.
|
||||
elif [ "$TAG" = "installed" ]; then
|
||||
elif [[ "$TAG" = "installed" ]]; then
|
||||
pool_create "$TAG"
|
||||
# A source build is available to create the pool.
|
||||
elif [ -d "$POOL_DIR_SRC" ]; then
|
||||
elif [[ -d "$POOL_DIR_SRC" ]]; then
|
||||
pool_create "$TAG"
|
||||
else
|
||||
SKIP=1
|
||||
|
@ -471,13 +471,13 @@ for TAG in $POOL_TAGS; do
|
|||
# Verify 'zpool import' works for all listed source versions.
|
||||
for SRC_TAG in $SRC_TAGS; do
|
||||
|
||||
if [ "$SKIP" -eq 1 ]; then
|
||||
if [[ "$SKIP" -eq 1 ]]; then
|
||||
skip_nonewline
|
||||
continue
|
||||
fi
|
||||
|
||||
src_set_vars "$SRC_TAG"
|
||||
if [ "$SRC_TAG" != "installed" ]; then
|
||||
if [[ "$SRC_TAG" != "installed" ]]; then
|
||||
cd "$ZFS_DIR" || fail "Failed 'cd $ZFS_DIR'"
|
||||
fi
|
||||
$ZFS_SH zfs="spa_config_path=$POOL_DIR_COPY"
|
||||
|
@ -505,7 +505,7 @@ for TAG in $POOL_TAGS; do
|
|||
printf "\n"
|
||||
done
|
||||
|
||||
if [ "$KEEP" = "no" ]; then
|
||||
if [[ "$KEEP" = "no" ]]; then
|
||||
rm -Rf "$TEST_DIR"
|
||||
fi
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
BASE_DIR=${0%/*}
|
||||
SCRIPT_COMMON=common.sh
|
||||
if [ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]; then
|
||||
if [[ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]]; then
|
||||
. "${BASE_DIR}/${SCRIPT_COMMON}"
|
||||
else
|
||||
echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
|
||||
|
|
Loading…
Reference in New Issue