Skip to content

Commit

Permalink
zfsbootmenu: rename UI library, normalize imports
Browse files Browse the repository at this point in the history
Rename zfsbootmenu-lib to zfsbootmenu-ui-lib to more accurately
represent which functions are contained therein.

Additionally, normalize how libraries are sourced.
  • Loading branch information
zdykstra committed Sep 20, 2023
1 parent 1eec513 commit 7e9e720
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 23 deletions.
2 changes: 1 addition & 1 deletion contrib/keycache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
## If you use different keys, just give them unique paths.)

# shellcheck disable=SC1091
[ -r /lib/zfsbootmenu-lib.sh ] && . /lib/zfsbootmenu-lib.sh
[ -r /lib/zfsbootmenu-core.sh ] && . /lib/zfsbootmenu-core.sh

# Make sure key environment variables are defined
[ -n "${BOOTFS}" ] || exit 0
Expand Down
2 changes: 1 addition & 1 deletion zfsbootmenu/bin/zfsbootmenu
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sources=(
/lib/profiling-lib.sh
/etc/zfsbootmenu.conf
/lib/zfsbootmenu-core.sh
/lib/zfsbootmenu-lib.sh
/lib/zfsbootmenu-ui.sh
/lib/kmsg-log-lib.sh
/etc/profile
/lib/fzf-defaults.sh
Expand Down
16 changes: 14 additions & 2 deletions zfsbootmenu/bin/zlogtail
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
#!/bin/bash

# shellcheck disable=SC1091
source /lib/zfsbootmenu-lib.sh >/dev/null 2>&1 || exit 1
source /lib/kmsg-log-lib.sh >/dev/null 2>&1 || exit 1
sources=(
/lib/kmsg-log-lib.sh
/lib/zfsbootmenu-ui.sh
)

for src in "${sources[@]}"; do
# shellcheck disable=SC1090
if ! source "${src}" >/dev/null 2>&1 ; then
echo "<3>ZFSBootMenu: unable to source '${src}' in $0" > /dev/kmsg
exit 1
fi
done

unset src sources

[ -f "${BASE}/have_errors" ] && rm "${BASE}/have_errors"
[ -f "${BASE}/have_warnings" ] && rm "${BASE}/have_warnings"
Expand Down
6 changes: 4 additions & 2 deletions zfsbootmenu/bin/zsnapshots
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ sources=(
/etc/zfsbootmenu.conf
/lib/kmsg-log-lib.sh
/lib/zfsbootmenu-core.sh
/lib/zfsbootmenu-lib.sh
/lib/zfsbootmenu-ui.sh
/lib/fzf-defaults.sh
)

for src in "${sources[@]}"; do
# shellcheck disable=SC1090
if ! source "${src}" >/dev/null 2>&1 ; then
echo -e "\033[0;31mWARNING: ${src} was not sourced; unable to proceed\033[0m"
exit
exit 1
fi
done

unset src sources

# Replace the global_header function with a stub
global_header() {
echo -n -e "\\033[1;33m[ Recover from snapshot ]"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
# vim: softtabstop=2 shiftwidth=2 expandtab

[ -n "${_ZFSBOOTMENU_LIB}" ] && return
readonly _ZFSBOOTMENU_LIB=1
[ -n "${_ZFSBOOTMENU_UI}" ] && return
readonly _ZFSBOOTMENU_UI=1

# shellcheck disable=SC1091
source /lib/zfsbootmenu-core.sh >/dev/null 2>&1 || exit 1
Expand Down
22 changes: 17 additions & 5 deletions zfsbootmenu/libexec/zfsbootmenu-diff
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@
# vim: softtabstop=2 shiftwidth=2 expandtab

# shellcheck disable=SC1091
source /lib/profiling-lib.sh >/dev/null 2>&1 || true
source /etc/zfsbootmenu.conf >/dev/null 2>&1 || exit 1
source /lib/kmsg-log-lib.sh >/dev/null 2>&1 || exit 1
source /lib/zfsbootmenu-core.sh >/dev/null 2>&1 || exit 1
source /lib/zfsbootmenu-lib.sh >/dev/null 2>&1 || exit 1
sources=(
/lib/profiling-lib.sh
/etc/zfsbootmenu.conf
/lib/kmsg-log-lib.sh
/lib/zfsbootmenu-core.sh
/lib/zfsbootmenu-ui.sh
)

for src in "${sources[@]}"; do
# shellcheck disable=SC1090
if ! source "${src}" >/dev/null 2>&1 ; then
echo "<3>ZFSBootMenu: unable to source '${src}' in $0" > /dev/kmsg
exit 1
fi
done

unset src sources

# prevent ctrl-c from killing us, so that zfs diff can exit cleanly
trap '' SIGINT
Expand Down
22 changes: 17 additions & 5 deletions zfsbootmenu/libexec/zfsbootmenu-help
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@
# vim: softtabstop=2 shiftwidth=2 expandtab

# shellcheck disable=SC1091
source /lib/profiling-lib.sh >/dev/null 2>&1
source /etc/zfsbootmenu.conf 2>&1 || exit 1
source /lib/kmsg-log-lib.sh >/dev/null 2>&1 || exit 1
source /lib/zfsbootmenu-core.sh >/dev/null 2>&1 || exit 1
source /lib/zfsbootmenu-lib.sh >/dev/null 2>&1 || exit 1
sources=(
/lib/profiling-lib.sh
/etc/zfsbootmenu.conf
/lib/kmsg-log-lib.sh
/lib/zfsbootmenu-core.sh
/lib/zfsbootmenu-ui.sh
)

for src in "${sources[@]}"; do
# shellcheck disable=SC1090
if ! source "${src}" >/dev/null 2>&1 ; then
echo "<3>ZFSBootMenu: unable to source '${src}' in $0" > /dev/kmsg
exit
fi
done

unset src sources

# zfsbootmenu-help invokes itself, so the value of $WIDTH depends
# on if $0 is launching fzf (-L) or is being launched inside
Expand Down
22 changes: 17 additions & 5 deletions zfsbootmenu/libexec/zfunc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@
# vim: softtabstop=2 shiftwidth=2 expandtab

# shellcheck disable=SC1091
source /lib/profiling-lib.sh >/dev/null 2>&1
source /etc/zfsbootmenu.conf 2>&1 || exit 1
source /lib/kmsg-log-lib.sh >/dev/null 2>&1 || exit 1
source /lib/zfsbootmenu-lib.sh >/dev/null 2>&1 || exit 1
source /lib/zfsbootmenu-core.sh >/dev/null 2>&1 || exit 1
sources=(
/lib/profiling-lib.sh
/etc/zfsbootmenu.conf
/lib/kmsg-log-lib.sh
/lib/zfsbootmenu-core.sh
/lib/zfsbootmenu-ui.sh
)

for src in "${sources[@]}"; do
# shellcheck disable=SC1090
if ! source "${src}" >/dev/null 2>&1 ; then
echo "<3>ZFSBootMenu: unable to source '${src}' in $0" > /dev/kmsg
exit 1
fi
done

unset src sources

# First argument is the function name
# the rest are positional params
Expand Down

0 comments on commit 7e9e720

Please sign in to comment.