Skip to content

Commit

Permalink
Merge pull request 64kramsystem#174 from saveriomiroddi/make_ppa_user…
Browse files Browse the repository at this point in the history
…_selectable

Make jonathonf PPA user-selectable
  • Loading branch information
64kramsystem authored Apr 24, 2021
2 parents 6181567 + 46f9b65 commit af8dd32
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 28 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -85,7 +86,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]
Expand All @@ -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
Expand Down
41 changes: 18 additions & 23 deletions install-zfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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()).
Expand All @@ -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_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

Expand Down Expand Up @@ -169,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.
Expand Down Expand Up @@ -366,25 +364,22 @@ 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

local zfs_package_version
zfs_package_version=$(apt show zfsutils-linux 2> /dev/null | perl -ne 'print $1 if /^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 (( $(echo "$zfs_package_version" | cut -d. -f2) >= 8 )); then
v_zfs_08_in_repository=1
fi
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 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
Expand All @@ -393,12 +388,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 ...`
Expand Down Expand Up @@ -663,7 +658,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
Expand Down Expand Up @@ -730,7 +725,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
Expand Down Expand Up @@ -1109,7 +1104,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"
Expand Down Expand Up @@ -1164,7 +1159,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
Expand Down Expand Up @@ -1427,7 +1422,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
Expand Down

0 comments on commit af8dd32

Please sign in to comment.