Cosmetic: Move set_zfs_ppa_requirement forward

In preparation for the next changes.
This commit is contained in:
Saverio Miroddi 2021-04-28 15:38:59 +02:00
parent f7cc468540
commit 2bd5f16cc1

View File

@ -476,46 +476,6 @@ If you think this is a bug, please open an issue on https://github.com/saveriomi
print_variables v_suitable_disks print_variables v_suitable_disks
} }
# REQUIREMENT: it must be ensured that, for any distro, `apt update` is invoked at this step, as
# subsequent steps rely on it.
#
# There are three parameters:
#
# 1. the tools are preinstalled (ie. Ubuntu Desktop based);
# 2. the default repository supports ZFS 0.8 (ie. Ubuntu 20.04+ based);
# 3. the distro provides the precompiled ZFS module (i.e. Ubuntu based, not Debian)
#
# Fortunately, with Debian-specific logic isolated, we need conditionals based only on #2 - see
# install_host_packages() and install_host_packages_UbuntuServer().
#
function set_zfs_ppa_requirement {
apt update
local zfs_package_version
zfs_package_version=$(apt show zfsutils-linux 2> /dev/null | perl -ne 'print /^Version: (\d+\.\d+)/')
# Test returns true if $zfs_package_version is blank.
#
if [[ ${ZFS_USE_PPA:-} == "1" ]] || dpkg --compare-versions "$zfs_package_version" lt 0.8; then
v_use_ppa=1
fi
}
function set_zfs_ppa_requirement_Debian {
# Only update apt; in this case, ZFS packages are handled in a specific way.
apt update
}
# Mint 20 has the CDROM repository enabled, but apt fails when updating due to it (or possibly due
# to it being incorrectly setup).
#
function set_zfs_ppa_requirement_Linuxmint {
perl -i -pe 's/^(deb cdrom)/# $1/' /etc/apt/sources.list
invoke "set_zfs_ppa_requirement"
}
# By using a FIFO, we avoid having to hide statements like `echo $v_passphrase | zpoool create ...` # By using a FIFO, we avoid having to hide statements like `echo $v_passphrase | zpoool create ...`
# from the logs. # from the logs.
# #
@ -571,6 +531,46 @@ export ZFS_FREE_TAIL_SPACE=12
trap _exit_hook EXIT trap _exit_hook EXIT
} }
# REQUIREMENT: it must be ensured that, for any distro, `apt update` is invoked at this step, as
# subsequent steps rely on it.
#
# There are three parameters:
#
# 1. the tools are preinstalled (ie. Ubuntu Desktop based);
# 2. the default repository supports ZFS 0.8 (ie. Ubuntu 20.04+ based);
# 3. the distro provides the precompiled ZFS module (i.e. Ubuntu based, not Debian)
#
# Fortunately, with Debian-specific logic isolated, we need conditionals based only on #2 - see
# install_host_packages() and install_host_packages_UbuntuServer().
#
function set_zfs_ppa_requirement {
apt update
local zfs_package_version
zfs_package_version=$(apt show zfsutils-linux 2> /dev/null | perl -ne 'print /^Version: (\d+\.\d+)/')
# Test returns true if $zfs_package_version is blank.
#
if [[ ${ZFS_USE_PPA:-} == "1" ]] || dpkg --compare-versions "$zfs_package_version" lt 0.8; then
v_use_ppa=1
fi
}
function set_zfs_ppa_requirement_Debian {
# Only update apt; in this case, ZFS packages are handled in a specific way.
apt update
}
# Mint 20 has the CDROM repository enabled, but apt fails when updating due to it (or possibly due
# to it being incorrectly setup).
#
function set_zfs_ppa_requirement_Linuxmint {
perl -i -pe 's/^(deb cdrom)/# $1/' /etc/apt/sources.list
invoke "set_zfs_ppa_requirement"
}
# Whiptail's lack of multiline editing is quite painful. # Whiptail's lack of multiline editing is quite painful.
# #
function install_dialog_package { function install_dialog_package {
@ -1511,9 +1511,9 @@ invoke "display_intro_banner"
invoke "check_system_memory" invoke "check_system_memory"
invoke "save_disks_log" invoke "save_disks_log"
invoke "find_suitable_disks" invoke "find_suitable_disks"
invoke "set_zfs_ppa_requirement"
invoke "register_exit_hook" invoke "register_exit_hook"
invoke "create_passphrase_named_pipe" invoke "create_passphrase_named_pipe"
invoke "set_zfs_ppa_requirement"
invoke "install_dialog_package" invoke "install_dialog_package"
invoke "select_disks" invoke "select_disks"