From f2043be75c0f6c6a3ab1a07540034e6426788380 Mon Sep 17 00:00:00 2001 From: Saverio Miroddi Date: Sat, 24 Apr 2021 12:50:06 +0200 Subject: [PATCH 1/8] Cosmetic: Clean variables subdivision Two groups were actually the same concept. --- install-zfs.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/install-zfs.sh b/install-zfs.sh index d808caaa..443b7480 100755 --- a/install-zfs.sh +++ b/install-zfs.sh @@ -12,11 +12,6 @@ set -o nounset # VARIABLES/CONSTANTS ########################################################## -# Variables set by the script - -v_linux_distribution= # Debian, Ubuntu, ... WATCH OUT: not necessarily from `lsb_release` (ie. UbuntuServer) -v_zfs_08_in_repository= # 1=true, false otherwise (applies only to Ubuntu-based) - # Variables set (indirectly) by the user # # The passphrase has a special workflow - it's sent to a named pipe (see create_passphrase_named_pipe()). @@ -38,6 +33,8 @@ v_free_tail_space= # integer # Variables set during execution +v_linux_distribution= # Debian, Ubuntu, ... WATCH OUT: not necessarily from `lsb_release` (ie. UbuntuServer) +v_zfs_08_in_repository= # 1=true, false otherwise (applies only to Ubuntu-based) v_temp_volume_device= # /dev/zdN; scope: setup_partitions -> sync_os_temp_installation_dir_to_rpool v_suitable_disks=() # (/dev/by-id/disk_id, ...); scope: find_suitable_disks -> select_disk From bf1c5d67accb23c838f4ee839820a43e5532629b Mon Sep 17 00:00:00 2001 From: Saverio Miroddi Date: Sat, 24 Apr 2021 12:40:21 +0200 Subject: [PATCH 2/8] Simplification in ZFS package version logic --- install-zfs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-zfs.sh b/install-zfs.sh index 443b7480..0d71e2fe 100755 --- a/install-zfs.sh +++ b/install-zfs.sh @@ -369,7 +369,7 @@ function find_zfs_package_requirements { apt update local zfs_package_version - zfs_package_version=$(apt show zfsutils-linux 2> /dev/null | perl -ne 'print $1 if /^Version: (\d+\.\d+)\./') + zfs_package_version=$(apt show zfsutils-linux 2> /dev/null | perl -ne 'print /^Version: (\d+\.\d+)/') if [[ -n $zfs_package_version ]]; then if [[ ! $zfs_package_version =~ ^0\. ]]; then From 9cfdb59a28940ca3f6eeafe71645242a74b61f49 Mon Sep 17 00:00:00 2001 From: Saverio Miroddi Date: Sat, 24 Apr 2021 12:42:40 +0200 Subject: [PATCH 3/8] Use more specific and generic way of checking the ZFS package version This is actually required for allowing OpenZFS v2.0. --- install-zfs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-zfs.sh b/install-zfs.sh index 0d71e2fe..b9e171b3 100755 --- a/install-zfs.sh +++ b/install-zfs.sh @@ -375,7 +375,7 @@ function find_zfs_package_requirements { if [[ ! $zfs_package_version =~ ^0\. ]]; then >&2 echo "Unsupported ZFS version!: $zfs_package_version" exit 1 - elif (( $(echo "$zfs_package_version" | cut -d. -f2) >= 8 )); then + elif dpkg --compare-versions "$zfs_package_version" ge 0.8; then v_zfs_08_in_repository=1 fi fi From faa1c3998ff9b21758bdf76b146169422c4aa54d Mon Sep 17 00:00:00 2001 From: Saverio Miroddi Date: Sat, 24 Apr 2021 12:45:53 +0200 Subject: [PATCH 4/8] Remove check for unsupported ZFS versions (and simplify logic) 2.0 is going to be supported in this branch, so non-0.x versions must not raise an error. --- install-zfs.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/install-zfs.sh b/install-zfs.sh index b9e171b3..db28e319 100755 --- a/install-zfs.sh +++ b/install-zfs.sh @@ -371,13 +371,10 @@ function find_zfs_package_requirements { local zfs_package_version zfs_package_version=$(apt show zfsutils-linux 2> /dev/null | perl -ne 'print /^Version: (\d+\.\d+)/') - if [[ -n $zfs_package_version ]]; then - if [[ ! $zfs_package_version =~ ^0\. ]]; then - >&2 echo "Unsupported ZFS version!: $zfs_package_version" - exit 1 - elif dpkg --compare-versions "$zfs_package_version" ge 0.8; then - v_zfs_08_in_repository=1 - fi + # Test returns false if $zfs_package_version is blank. + # + if dpkg --compare-versions "$zfs_package_version" ge 0.8; then + v_zfs_08_in_repository=1 fi } From a9dd106e08686bd006797e1360caddae2f71f281 Mon Sep 17 00:00:00 2001 From: Saverio Miroddi Date: Sat, 24 Apr 2021 12:56:05 +0200 Subject: [PATCH 5/8] Invert ZFS repository logic ("version 0.8 in repo" -> "PPA required") --- install-zfs.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/install-zfs.sh b/install-zfs.sh index db28e319..76a68e3c 100755 --- a/install-zfs.sh +++ b/install-zfs.sh @@ -34,7 +34,7 @@ v_free_tail_space= # integer # Variables set during execution v_linux_distribution= # Debian, Ubuntu, ... WATCH OUT: not necessarily from `lsb_release` (ie. UbuntuServer) -v_zfs_08_in_repository= # 1=true, false otherwise (applies only to Ubuntu-based) +v_use_ppa= # 1=true, false otherwise (applies only to Ubuntu-based). v_temp_volume_device= # /dev/zdN; scope: setup_partitions -> sync_os_temp_installation_dir_to_rpool v_suitable_disks=() # (/dev/by-id/disk_id, ...); scope: find_suitable_disks -> select_disk @@ -363,7 +363,7 @@ If you think this is a bug, please open an issue on https://github.com/saveriomi # Fortunately, with Debian-specific logic isolated, we need conditionals based only on #2 - see # install_host_packages() and install_host_packages_UbuntuServer(). # -function find_zfs_package_requirements { +function set_zfs_ppa_requirement { print_step_info_header apt update @@ -371,14 +371,14 @@ function find_zfs_package_requirements { local zfs_package_version zfs_package_version=$(apt show zfsutils-linux 2> /dev/null | perl -ne 'print /^Version: (\d+\.\d+)/') - # Test returns false if $zfs_package_version is blank. + # Test returns true if $zfs_package_version is blank. # - if dpkg --compare-versions "$zfs_package_version" ge 0.8; then - v_zfs_08_in_repository=1 + if dpkg --compare-versions "$zfs_package_version" lt 0.8; then + v_use_ppa=1 fi } -function find_zfs_package_requirements_Debian { +function set_zfs_ppa_requirement_Debian { # Only update apt; in this case, ZFS packages are handled in a specific way. apt update @@ -387,12 +387,12 @@ function find_zfs_package_requirements_Debian { # Mint 20 has the CDROM repository enabled, but apt fails when updating due to it (or possibly due # to it being incorrectly setup). # -function find_zfs_package_requirements_Linuxmint { +function set_zfs_ppa_requirement_Linuxmint { print_step_info_header perl -i -pe 's/^(deb cdrom)/# $1/' /etc/apt/sources.list - find_zfs_package_requirements + set_zfs_ppa_requirement } # By using a FIFO, we avoid having to hide statements like `echo $v_passphrase | zpoool create ...` @@ -657,7 +657,7 @@ The option `-O devices=off` is already set, and must not be specified.' function install_host_packages { print_step_info_header - if [[ $v_zfs_08_in_repository != "1" ]]; then + if [[ $v_use_ppa == "1" ]]; then if [[ ${ZFS_SKIP_LIVE_ZFS_MODULE_INSTALL:-} != "1" ]]; then add-apt-repository --yes ppa:jonathonf/zfs apt update @@ -724,7 +724,7 @@ function install_host_packages_elementary { function install_host_packages_UbuntuServer { print_step_info_header - if [[ $v_zfs_08_in_repository == "1" ]]; then + if [[ $v_use_ppa != "1" ]]; then apt install --yes zfsutils-linux efibootmgr zfs --version > "$c_zfs_module_version_log" 2>&1 @@ -1103,7 +1103,7 @@ function prepare_jail { function install_jail_zfs_packages { print_step_info_header - if [[ $v_zfs_08_in_repository != "1" ]]; then + if [[ $v_use_ppa == "1" ]]; then chroot_execute "add-apt-repository --yes ppa:jonathonf/zfs" chroot_execute "apt update" @@ -1158,7 +1158,7 @@ function install_jail_zfs_packages_elementary { function install_jail_zfs_packages_UbuntuServer { print_step_info_header - if [[ $v_zfs_08_in_repository == "1" ]]; then + if [[ $v_use_ppa != "1" ]]; then chroot_execute "apt install --yes zfsutils-linux zfs-initramfs grub-efi-amd64-signed shim-signed" else install_jail_zfs_packages @@ -1421,7 +1421,7 @@ store_running_processes check_prerequisites display_intro_banner find_suitable_disks -distro_dependent_invoke "find_zfs_package_requirements" +distro_dependent_invoke "set_zfs_ppa_requirement" create_passphrase_named_pipe select_disks From 55acc65a13eb8b26421e4e0bbb32a023f16f8a65 Mon Sep 17 00:00:00 2001 From: Saverio Miroddi Date: Sat, 24 Apr 2021 13:09:53 +0200 Subject: [PATCH 6/8] Add ZFS_USE_PPA option --- install-zfs.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install-zfs.sh b/install-zfs.sh index 76a68e3c..9e42cf52 100755 --- a/install-zfs.sh +++ b/install-zfs.sh @@ -166,6 +166,7 @@ This script needs to be run with admin permissions, from a Live CD. The procedure can be entirely automated via environment variables: - ZFS_OS_INSTALLATION_SCRIPT : path of a script to execute instead of Ubiquity (see dedicated section below) +- ZFS_USE_PPA : set to 1 to use packages from `ppa:jonathonf/zfs` (automatically set to true if the O/S version doesn'\''t ship at least v0.8) - ZFS_SELECTED_DISKS : full path of the devices to create the pool on, comma-separated - ZFS_BOOT_PARTITION_SIZE : integer number with `M` or `G` suffix (defaults to `'${c_default_boot_partition_size}M'`) - ZFS_PASSPHRASE : set non-blank to encrypt the pool, and blank not to. if unset, it will be asked. @@ -373,7 +374,7 @@ function set_zfs_ppa_requirement { # Test returns true if $zfs_package_version is blank. # - if dpkg --compare-versions "$zfs_package_version" lt 0.8; then + if [[ ${ZFS_USE_PPA:-} == "1" ]] || dpkg --compare-versions "$zfs_package_version" lt 0.8; then v_use_ppa=1 fi } From 7a97c247ad57073a03b7d30c3e9f90dffac3e711 Mon Sep 17 00:00:00 2001 From: Saverio Miroddi Date: Sat, 24 Apr 2021 13:12:00 +0200 Subject: [PATCH 7/8] README: Remove `sh` code block formatting for options section Gets messy in some cases (e.g. with single quotes), and doesn't make much sense, since there is only one command. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6654515c..7f5d2101 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ The installer itself can run over SSH (\[S\]Ubiquity of course needs to be still The program supports unattended installation, via environment variables. The program built-in help explains all the options: -```sh +``` $ wget -qO- https://git.io/JelI5 | bash /dev/stdin --help Usage: install-zfs.sh [-h|--help] From 46f9b652a6aac12704e15a27018c5b83037eebfa Mon Sep 17 00:00:00 2001 From: Saverio Miroddi Date: Sat, 24 Apr 2021 13:14:20 +0200 Subject: [PATCH 8/8] README: Update in relation the the "Use PPA" new option --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7f5d2101..b725bb2a 100644 --- a/README.md +++ b/README.md @@ -43,10 +43,11 @@ The advantages of this project over the Ubuntu installer are: 2. it allows specifying the RAID type; 3. it allows customization of the disk partitions; 4. it supports additional features (e.g. encryption); -5. it supports many more operating systems; -6. it supports unattended installations, via custom scripts; -7. it installs a convenient trimming job for ZFS pools; -8. it's easy to extend. +5. it supports new OpenZFS versions, via PPA `jonathonf/zfs`. +6. it supports many more operating systems; +7. it supports unattended installations, via custom scripts; +8. it installs a convenient trimming job for ZFS pools; +9. it's easy to extend. The disadvantages are: @@ -96,6 +97,7 @@ This script needs to be run with admin permissions, from a Live CD. The procedure can be entirely automated via environment variables: - ZFS_OS_INSTALLATION_SCRIPT : path of a script to execute instead of Ubiquity (see dedicated section below) +- ZFS_USE_PPAS : set to 1 to use packages from `ppa:jonathonf/zfs` (automatically set to true if the O/S version doesn't ship at least v0.8) - ZFS_SELECTED_DISKS : full path of the devices to create the pool on, comma-separated - ZFS_PASSPHRASE - ZFS_BPOOL_NAME