Compare commits

..

92 Commits
v1.1.2 ... main

Author SHA1 Message Date
9f5889764f Modificar gentoo.conf.example 2024-02-22 12:04:45 -01:00
ab713b917c Modificar configure 2024-02-22 12:01:52 -01:00
c710af26b6 Modificar configure 2024-02-22 11:58:33 -01:00
oddlama
039d1a8b35
docs: update kernel name in docs 2024-02-05 01:02:18 +01:00
oddlama
93e1aa3a9c
Merge pull request #111 from kasperfm/develop
Add option to enable binary packages in make.conf
2024-02-04 17:17:07 +01:00
Kasper Færch Mikkelsen
87d508455d
Update main.sh
Fixed gnupg key file not readable by portage
2024-02-04 01:09:42 +01:00
Kasper Færch Mikkelsen
248e8cd375 Added support for binary portage packages 2024-02-04 00:30:58 +01:00
oddlama
3daf3132e7
fix: also search for kernel images named kernel-* 2024-02-03 15:58:16 +01:00
oddlama
d1ddab6038
Merge pull request #110 from OskiBoski483/main
Add dracut use flag
2024-02-03 15:56:44 +01:00
Oskar Nizioł
5fc7bfdcab
Add dracut use flag 2024-02-03 13:35:07 +01:00
oddlama
353d4d6af0
Merge pull request #106 from thiblizz/patch-10
fix: minor typos
2023-11-20 02:03:53 +01:00
thiblizz
1ca6b53d0f
fix: minor typos 2023-11-20 01:03:53 +01:00
oddlama
1fe44e7218
Merge pull request #104 from thiblizz/patch-9
fix: musl stage3 installation on the stable branch
2023-11-13 13:41:30 +01:00
thiblizz
d0e8078927
fix: musl stage3 installation on the stable branch 2023-11-12 18:55:36 +01:00
oddlama
403c5ef3d7
Merge pull request #103 from thiblizz/patch-8
fix: "error: format: Identifier id='part_root' not found"
2023-11-12 16:58:27 +01:00
thiblizz
c816559958
fix: "error: format: Identifier id='part_root' not found" 2023-11-12 15:26:01 +01:00
oddlama
1815d710ff
Merge pull request #102 from thiblizz/patch-7
feat: support musl timezone
2023-11-06 11:52:16 +01:00
thiblizz
de8c16211b feat: support musl timezone 2023-11-05 15:51:12 +01:00
oddlama
f5ba6e5147
Merge pull request #101 from thiblizz/patch-6
feat: more flexible default layout
2023-10-29 14:21:58 +01:00
thiblizz
4309e3b17b feat: more flexible default layout 2023-10-23 00:05:27 +02:00
oddlama
f2f3e96211
Merge pull request #99 from thiblizz/patch-5
feat: increase the boot/EFI partition to 1GiB (closes oddlama#98)
2023-10-22 13:02:19 +02:00
thiblizz
7681d73bcb feat: increase the boot/EFI partition to 1GiB (closes oddlama#98) 2023-10-22 12:51:22 +02:00
oddlama
1ea9489566
Merge pull request #97 from thiblizz/main
feat: add raid1 support
2023-10-22 12:49:49 +02:00
thiblizz
d8c8096b85 Revert "feat: increase the boot/EFI partition to 1GiB (closes #98)"
This reverts commit 0c790740f3.
2023-10-21 17:02:59 +02:00
thiblizz
0c790740f3
feat: increase the boot/EFI partition to 1GiB (closes #98) 2023-10-21 16:54:52 +02:00
thiblizz
fa7d0df609
fix: unused variable 2023-10-21 16:45:24 +02:00
thiblizz
647da12b43
fix: address review comments 2023-10-21 16:36:28 +02:00
thiblizz
e5b0fe6313
feat: add raid1 support 2023-10-20 23:39:49 +02:00
oddlama
dfabf41185
Merge pull request #96 from thiblizz/patch-4
fix: minor typos
2023-10-15 14:18:51 +02:00
oddlama
b15f89eec1
Merge branch 'main' into patch-4 2023-10-15 12:28:51 +02:00
oddlama
b2880b08f3
Merge pull request #95 from thiblizz/patch-3
fix: use UTF-8 as the default locale instead of utf8 (closes #92)
2023-10-15 12:26:09 +02:00
oddlama
c8bbcb8333
Merge pull request #94 from thiblizz/patch-2
fix: adjust wrong root_fs check
2023-10-15 12:25:18 +02:00
thiblizz
dcd8b8b5cd
fix: minor typos 2023-10-15 04:01:05 +02:00
thiblizz
0ebe7915a6
fix: use UTF-8 as the default locale instead of utf8 (closes #92) 2023-10-15 02:18:09 +02:00
thiblizz
c6b2d52ff7
fix: adjust wrong root_fs check 2023-10-14 23:47:48 +02:00
oddlama
716e062661
Merge pull request #90 from thiblizz/patch-1
Fix musl stage3 variant
2023-10-13 19:15:52 +02:00
thiblizz
e9f7f6603c
Revert to initial logic 2023-10-13 02:47:14 +02:00
thiblizz
5d27a4c1c9
Make musl variant optional 2023-10-13 02:28:23 +02:00
thiblizz
d7ef780331
Fix musl stage3 variant 2023-10-13 01:18:00 +02:00
Nick Booker
1321769bb5
Fix booting from encrypted root filesystem with systemd (#78)
* Fix booting from encrypted root filesystem with systemd

systemd needs to be built with cryptsetup for it to work

* Limit cryptsetup USE flag and emerge to systemd
2023-03-28 16:10:41 +02:00
Carlos Prado
b2ea9b360d
feat: hooks (#70)
* Hooks

Hook system to allow further customization at specific steps of the installation process.

- before/after_prepare_environment
- before/after_disk_configuration
- before/after_download_stage3
- before/after_extract_stage3

- before/after_install
- before/after_configure_base_system
- before/after_configure_portage
- before/after_install_kernel

* add hook examples

* fix: remove eval
2023-01-07 14:02:15 +01:00
Carlos Prado
e5067f0c43 add all stage3 options available in gentoo.org
Also, variants description are updated to 'explain' the differences between them.
2023-01-05 15:18:09 +01:00
Mathieu Gouttenoire
2036d785f1 Fix stage3 download on other architectures 2022-12-22 15:01:56 +01:00
oddlama
dbb8b81c26
fix: missing /sys prefix when determining partition numbers 2022-12-21 14:10:47 +01:00
oddlama
2a2ef9abd7
fix: more robust way to extract efi partition and parent device (fixes #63) 2022-12-20 13:07:48 +01:00
oddlama
133fe3901a
fix: use 644 permissions on /etc/timezone, apparently some builds depend on it. Fixes #66 2022-12-20 12:51:25 +01:00
oddlama
2397569412
chore: adhere to shellcheck rules 2022-10-05 15:49:37 +02:00
oddlama
6c1a7e846b
fix: disable swap after creating to prevent some live environments from using the swap immediately (fixes #57) 2022-10-05 15:47:48 +02:00
oddlama
8919c61568
chore: clean ouput and add comments to installed scripts 2022-10-05 15:44:52 +02:00
oddlama
551423eb4a
docs: add link to efibootmgr wiki (closes #58) 2022-10-05 15:44:07 +02:00
Min Xu
3888a552fa
fix: Wait for device symlink after partitioning (#56)
Co-authored-by: Min Xu <min.xu.public@gmail.com>
2022-10-05 15:32:02 +02:00
oddlama
d46010ba7b
fix(syntax): missing && (closes #55) 2022-10-01 13:33:55 +02:00
oddlama
7b9586ad30
fix: checkfile set even if tuple is not a expression (fixes #51) 2022-09-28 17:55:13 +02:00
oddlama
1975f75d02
feat: always install linux-firmware (fixes #50) 2022-09-28 17:51:53 +02:00
oddlama
3e18167a06
fix: always use included locale file to prevent mismatches (closes #52) 2022-09-28 17:45:34 +02:00
oddlama
c56f1766cc
chore: update eoli3n zfs init script location
see 4d726eafbb
2022-08-31 20:55:44 +02:00
oddlama
b22ff29173
fix: stage3 menu label confusion (fixes #46) 2022-07-01 20:34:19 +02:00
oddlama
70e51eaad8
fix: change into /tmp before downloading dracut-sshd 2022-07-01 19:55:13 +02:00
oddlama
b78dea2dc7
fix: make all rbound mountpoints also rslaves. 2022-07-01 19:54:26 +02:00
oddlama
b3324498fb
feat: generate ssh keys before generating initramfs in case sshd needs them 2022-07-01 14:10:38 +02:00
oddlama
01c73895dd
chore: clarify that CIDR masks are required for network addresses 2022-07-01 02:11:30 +02:00
oddlama
7efb6886d0
fix: don't wipe inputbox options when cancelling 2022-07-01 02:08:13 +02:00
oddlama
998828fe9a
feat: networkd options and remote crypt unlocking 2022-07-01 02:04:23 +02:00
oddlama
a97fcaabc8
feat: mount /run to suppress warnings (closes #44) 2022-06-30 21:22:57 +02:00
oddlama
0350ada8c3
fix: ZFS compression was not properly enabled on the rpool dataset 2022-06-29 02:15:32 +02:00
oddlama
81fc06784e
chore: add warning about changing mirrors 2022-06-28 17:32:13 +02:00
oddlama
2d5b04dcc7
fix: mirror selections were not applied 2022-06-28 17:29:38 +02:00
oddlama
b8134d4a50
docs: add troubleshooting for ZFS kernel mismatch 2022-06-28 17:29:02 +02:00
oddlama
944c745ce7
chore: enable portage testing after installation to hopefully ensure a better installation experience. 2022-06-09 18:44:08 +02:00
oddlama
e3a45b15ec
chore: update screenshot 2022-06-09 03:39:20 +02:00
oddlama
158d44c6a5
chore: improve readme readability 2022-06-09 02:46:35 +02:00
oddlama
eb11c51b90
chore: REAMDE.md rewrite 2022-06-09 02:31:42 +02:00
oddlama
90fc659b7e
chore: (wip) easy usage ready to copy-and-paste 2022-06-08 02:51:02 +02:00
oddlama
f204711516
feat: (wip) rewrite readme 2022-06-08 02:48:07 +02:00
oddlama
5f36dfb3d0
feat: enable dracut zstd compression by default 2022-06-08 02:47:40 +02:00
oddlama
07799f47b3
fix: temporary workaround for dracut issue:
Dracut changed parameter interpretation in a new version,
causing this script to error out. To properly fix this,
we require a resolution of dracutdevs/dracut#1835.
Meanwhile, this is tracked internally by #41.
2022-06-05 13:20:14 +02:00
oddlama
42bd850351
chore: remove finished todos 2022-05-14 00:52:59 +02:00
oddlama
3c8391789d
fix: remove invalid variable in check for rhash availability 2022-05-14 00:51:28 +02:00
oddlama
38bf1de80c
chore: improve wanted program check (remove array indirection) 2022-05-14 00:48:42 +02:00
oddlama
64218c9a5c
feat: fallback to sha512sum if rhash is not available. closes #36. 2022-05-14 00:29:50 +02:00
oddlama
6a57329962
fix: don't use existing swap when disabled after device selection 2022-05-13 23:16:11 +02:00
oddlama
a73cdcf723
fix: adjust wrong function name 2022-05-13 22:56:25 +02:00
oddlama
6b3f9c2a76
feat: reduce length of device names if under /dev/disk/by-id/ 2022-05-13 22:55:15 +02:00
oddlama
50ec673974
feat: canonicalize devices before use to /dev/disk/by-id/ if possible.
This is beneficial for ZFS pools and for humans to see whether the
correct disk was selected.
2022-05-13 22:48:50 +02:00
oddlama
20a69f41ec
feat: implement better device selection dialog 2022-05-13 22:43:34 +02:00
oddlama
4949293ac1
fix: track whether partitioning is disallowed 2022-05-13 21:32:24 +02:00
oddlama
1dbb0b29d6
feat: add warning message to ensure users have freed devices before partitioning. Closes #22. 2022-05-13 21:28:23 +02:00
oddlama
2003738dca
feat: show added existing disks in action summary 2022-05-13 21:15:09 +02:00
oddlama
93f70f969c
feat: add new dummy partitioning scheme "existing_partitions", which skips all partitioning and formatting operations. 2022-05-13 20:41:24 +02:00
oddlama
8e01c52ed6
feat: show warning when efi is selected but efi support cannot be verified. closes #32. 2022-05-13 00:48:16 +02:00
oddlama
c5cdc21467
feat: allow selection of different initial stage3 tarballs (at own risk).
Closes #39.
2022-05-13 00:24:30 +02:00
oddlama
547ca2e35d
fix: adjust DIGESTS verification for changed gentoo signature format 2022-05-12 23:24:40 +02:00
10 changed files with 1150 additions and 310 deletions

210
README.md
View File

@ -1,71 +1,83 @@
## About gentoo-install
This is an installer for gentoo with a simple configuration TUI inspired by menuconfig.
The configurator is only used to generate a `gentoo.conf` file, which can also be
edited by hand, or reused later if desired. An example configuration is provided with the repository.
This project aspires to be your favourite way to install gentoo.
It aims to provide a smooth installation experience, both for beginners and experts.
You may configure it by using a menuconfig-inspired interface or simply via a config file.
The installer supports the most common disk layouts, different file systems like ext4, ZFS and btrfs as well
It supports the most common disk layouts, different file systems like ext4, ZFS and btrfs as well
as additional layers such as LUKS or mdraid. It also supports both EFI (recommended) and BIOS boot,
and can be used with systemd or OpenRC as the init system.
and can be used with systemd or OpenRC as the init system. SSH can also be configured to allow using an automation framework
like [Ansible](https://github.com/ansible/ansible) or [Fora](https://github.com/oddlama/fora) to automate beyond system installation.
[Usage](#usage) |
[Overview](#overview) |
[Updating the Kernel](#updating-the-kernel) |
[Recommendations](#recommendations) |
[FAQ](#troubleshooting-and-faq)
![](contrib/screenshot_configure.png)
## Quick start
This installer might appeal to you if
First, boot into a live environment of your choice. I recommend using an [Arch Linux](https://www.archlinux.org/download/) live iso,
as the installer will then be able to automatically download required programs or setup zfs support on the fly. After that,
proceed with the following steps:
- you want to try gentoo without initially investing a lot of time, or fully committing to it yet.
- you already are a gentoo expert but want an automatic and repeatable best-practices installation.
1. Either clone this repo or download and extract a copy
1. Run `./configure` and save your desired configuration
1. Begin installation using `./install`
Of course, we do encourage everyone to install gentoo manually. You will learn a lot if you
haven't done so already.
Every option is explained in detail in `gentoo.conf.example` and in the help menu popups in the configurator.
## Usage
First, boot into a live environment of your choice. I recommend using an [Arch Linux](https://www.archlinux.org/download/) live ISO,
as the installer will then be able to automatically download required programs or setup ZFS support on the fly.
Afterwards, proceed with the following steps:
```bash
pacman -Sy git # (Archlinux) Install git in live environment, then clone:
git clone "https://github.com/oddlama/gentoo-install"
cd gentoo-install
./configure # configure to your liking, save as gentoo.conf
./install # begin installation
```
Every option is explained in detail in `gentoo.conf.example` and in the help menus of the TUI configurator.
When installing, you will be asked to review the partitioning before anything critical is done.
The installer should be able to run without any user supervision after partitioning, but depending
on the current state of the gentoo repository, you might need to intervene in case a package fails
to emerge. The critical commands will ask you what to do in case of a failure. If you encounter a
problem you cannot solve, you might want to consider getting in contact with some experienced people
on [IRC](https://www.gentoo.org/get-involved/irc-channels/) or [Discord](https://discord.com/invite/gentoolinux).
If you need to enter an installed system in a chroot to fix something (e.g. after rebooting your live system),
you can always clone the installer, mount your main drive under `/mnt` and use `./install --chroot /mnt` to
just chroot into your system.
## Overview
The system will use `sys-kernel/gentoo-kernel-bin`, which should be suitable
to boot most systems out of the box. It is strongly recommend to replace this kernel
with a custom built one, when the system is functional.
The installer performs the following main steps (in roughly this order),
with some parts depending on the chosen configuration:
The installer should be able to run without any user supervision after partitioning, but depending
on the current state of the gentoo repository you might need to intervene in case a package fails
to emerge. The critical commands will ask you what to do in case of a failure.
Here is an outline of the steps that are carried out:
1. Partition disks (supports gpt, raid, luks)
1. Download and cryptographically verify the newest stage3 tarball
1. Extract the stage3 tarball
1. Sync portage tree
1. Configure portage (create zz-autounmask files, configure `make.conf`)
1. Select the fastest gentoo mirrors if desired
1. Configure the base system (timezone, keymap, locales, ...)
1. Install git and other required tools (e.g. zfs if you have used zfs)
1. Install `sys-kernel/gentoo-kernel-bin` (until you can compile your own)
1. Generate an initramfs with dracut
1. Create efibootmgr entry or install syslinux depending on whether your system uses EFI or BIOS
1. Generate fstab
1. Depending on the configuration:
- (Optional) Install sshd with secure config
- (Optional) Install dhcpcd (if using OpenRC)
1. Partition disks (highly dependent on configuration)
2. Download and extract stage3 tarball (with cryptographic verification)
\[Continues in chroot from here\]
3. Setup portage (initial rsync/git sync, run mirrorselect, create zz-autounmask files)
4. Base system configuration (hostname, timezone, keymap, locales)
5. Install required packages (git, kernel, ...)
6. Make system bootable (generate fstab, build initramfs, create efibootmgr/syslinux boot entry)
7. Ensure minimal working system (automatic wired networking, install eix, set root password)
- (Optional) Install sshd with secure config (no password logins)
- (Optional) Install additional packages provided in config
1. Asks if a root password should be set
Anything else is probably out of scope for this script, but you can obviously do
what you want later on when the system is booted. Here are some things that you probably
want to consider doing after the base system installation is finished:
The goal of the installer is just to setup a minimal gentoo system following best-practices.
Anything beyond that is considered out-of-scope (with the exception of configuring sshd).
Here are some things that you might want to consider doing after the system installation is finished:
1. Read the news with `eselect news read`.
2. Compile a custom kernel and remove `gentoo-kernel-bin`
3. Adjust `/etc/portage/make.conf`
- Set `CFLAGS` to `-O2 -pipe -march=native` for native builds
- Set `CFLAGS` to `<march_native_flags> -O2 -pipe` for native builds by using the `resolve-march-native` tool
- Set `CPU_FLAGS_X86` using the `cpuid2cpuflags` tool
- Set `FEATURES="buildpkg"` if you want to build binary packages
4. Use a safe umask like `umask 0077`
If you are looking for a way to detect and manage your kernel configuration, have a look at [autokernel](https://github.com/oddlama/autokernel).
4. Use a safe umask like `umask 077`
### (Optional) sshd
@ -84,24 +96,124 @@ These will simply be passed to a final `emerge` call before the script is done,
where autounmasking will also be done automatically. It is recommended to keep
this to a minimum, because of the quite "interactive" nature of gentoo package management ;)
## Updating the kernel
By default, the installed system uses gentoo's binary kernel distribution (`sys-kernel/gentoo-kernel-bin`)
together with an initramfs generated by dracut. This ensures that the installed system works on all common hardware configurations.
Feel free to replace this with a custom-built kernel (and possibly remove/adjust the initramfs) when the system is booted.
The installer will provide the convenience script `generate_initramfs.sh` in `/boot/efi/`
or `/boot/bios` which may be used to generate a new initramfs for the given kernel version.
Depending on whether your system uses EFI or BIOS boot, you will also find your kernel and initramfs in different locations:
```bash
# EFI
kernel="/boot/efi/vmlinuz.efi"
initrd="/boot/efi/initramfs.img"
# BIOS
kernel="/boot/bios/vmlinuz-current"
initrd="/boot/bios/initramfs.img"
```
In both cases, the update procedure is as follows:
1. Emerge new kernel
2. `eselect kernel set <kver>`
3. Backup old kernel and initramfs (`mv "$kernel"{,.bak}`, `mv "$initrd"{,.bak}`)
4. Generate new initramfs for this kernel `generate_initramfs.sh <kver> "$initrd"`
5. Copy new kernel `cp /boot/kernel-<kver> "$kernel"` (for systemd) or `cp /boot/vmlinuz-<kver> "$kernel"` (for openrc)
## Recommendations
This project started out as a way of documenting a best-practices installation for myself.
As the project grew larger, I've added more configuration options to suit legacy needs.
Below I've outlined several decisions I've made for this project, or decisions you
have during configuration. If you intend on setting up a modern system, you might want
to check them out. Please keep in mind that those are all based on my personal opinions and
experience. Your mileage may vary.
#### EFI vs BIOS
Use EFI. BIOS is old and deprecated for a long time now.
Only certain VPS hosters may require you to use BIOS still (time to write to them about that!)
#### EFIstub booting
Don't install a bootloader when this script is done, except you absolutely need one.
The kernel can directly be booted by EFI without need for a bootloader.
By default, this script will use efibootmgr to add a bootentry directly to your "mainboard's bootselect" (typically F12).
Nowadays, there's just no reason to use GRUB, syslinux, or similar bootloaders by default.
They only add additional time to your boot, and even dualbooting Windows works just fine without one.
Only if you require frequent editing of kernel parameters, or want kernel autodiscovery from attached media
you might want to consider using one of these. For the average (advanced) user this isn't necessary.
If you want to add more boot options or want to learn about efibootmgr, refer to [this page on the gentoo wiki](https://wiki.gentoo.org/wiki/Efibootmgr).
#### Modern file systems
I recommend using a modern file system like ZFS, both on desktops and servers.
It provides transparent block-level compression, instant snapshots and full-disk encryption.
Generally, encrypting your root fs doesn't cost you anything and protects your data in case you lose your device.
#### Systemd vs OpenRC
I will not entertain the religious eternal debate here. Both are fine init systems, and
I've been using both *a lot*. If you cannot decide, here are some objective facts:
- OpenRC is a service manager. Setting up all the other services is a lot of work, but you will learn a lot.
- Systemd is an OS-level software suite. It brings an insane amount of features with a steep learning curve.
Here's a non-exhaustive list of things you will ~do manually~ learn when using OpenRC,
that are already provided for in systemd: udev, dhcp, acpi events (power/sleep button),
cron jobs, reliable syslog, logrotate, process sandboxing, persistent backlight setting, persistent audio mute-status, user-owned login sessions, ...
Make of this what you will, both have their own quirks. Choose your poison.
#### Miscellaneous
- Use the newer iwd for WiFi instead of wpa_supplicant
- (If systemd) Use timers instead of cron jobs
## Troubleshooting and FAQ
After the initial sanity check, the script should be able to finish unattendedly.
But given the unpredictability of future gentoo versions, you might still run into issues
once in a while.
The script checks every command for success, so if anything fails during installation,
you will be given a proper message of what went wrong. Inside the chroot,
most commands will be executed in a checked loop, and allow you to interactively
fix problems with a shell, to retry, or to skip the command.
fix problems with a shell, to retry, or to skip the command. You can report
issues specific to this script on the issue tracker. To seek help
regarding gentoo in general, visit the official [IRC](https://www.gentoo.org/get-involved/irc-channels/)
or [Discord](https://discord.com/invite/gentoolinux).
If you experience any issues after rebooting and need to fix something inside the chroot,
you can use the installer to chroot into an existing system. Run `./install --help` for more infos.
#### Q: ZFS cannot be installed in the chroot due to an unsupported kernel version
**A:** The newest stable ZFS module may require a kernel version that is newer than what is provided on gentoo stable.
If you encounter this problem, you might be able to fix the problem by switching to testing by dropping to a shell temporarily:
```
# Press S<Enter> when asked about what to do next.
# This opens an emergency shell in the chroot.
echo 'ACCEPT_KEYWORDS="~amd64"' >> /etc/portage/make.conf # Enable testing for your architecture.
emerge -v gentoo-kernel-bin # Update kernel to newest version
exit # Ctrl-D
# Now select 'retry' when asked about what to do next.
```
#### Q: I get errors after partitioning about blkid not being able to find a UUID
**A:** Use `wipefs -a <DEVICE>` on your partitions or fully wipe the disk before use.
**A:** Be sure that all devices are unmounted and not in use before starting the script.
Use `wipefs -a <DEVICE>` on your partitions or fully wipe the disk before use.
The new partitions probably align with previously existing partitions that had
filesystems on them. Some filesystems signatures like those of ZFS can coexist with
other signatures and may cause blkid to find ambiguous information.
## References
* [Sakaki's EFI Install Guide](https://wiki.gentoo.org/wiki/Sakaki%27s_EFI_Install_Guide)
* [Gentoo AMD64 Handbook](https://wiki.gentoo.org/wiki/Handbook:AMD64)
* [Sakaki's EFI Install Guide](https://wiki.gentoo.org/wiki/Sakaki%27s_EFI_Install_Guide)

476
configure vendored
View File

@ -8,8 +8,7 @@ set -uo pipefail
# Find the directory this script is stored in. (from: http://stackoverflow.com/questions/59895)
function get_source_dir() {
local source="${BASH_SOURCE[0]}"
while [[ -h $source ]]
do
while [[ -h $source ]]; do
local tmp
tmp="$(cd -P "$(dirname "${source}")" && pwd)"
source="$(readlink "${source}")"
@ -44,7 +43,13 @@ while [[ $# -gt 0 ]]; do
shift
done
check_has_programs dialog ncurses=ncursesw6-config
check_wanted_programs dialog libncurses-dev=ncursesw6-config
# Determine whether EFI is available
HAS_EFI_SUPPORT=$([[ -d /sys/firmware/efi ]] && echo -n "true" || echo -n "false")
DEFAULT_BOOT_TYPE=$([[ $HAS_EFI_SUPPORT == true ]] && echo -n "efi" || echo -n "bios")
EFI_UNSUPPORTED_MESSAGE_SHORT="Missing EFI support on this system!"
EFI_UNSUPPORTED_MESSAGE="Apparently, your system does NOT support efi. Double-check before proceeding!"
# Wrap dialog in two functions to prevent it from cluttering stderr.
function dialog_wrapper() { dialog_out=$(command dialog --colors "$@" 3>&2 2>&1 1>&3 3>&-); }
@ -62,7 +67,7 @@ function get_timezone() {
timezone=${file#*zoneinfo/}
if [[ $timezone == "$file" ]]; then
# not pointing to expected location or not Region/City
echo "Europe/London"
echo "Atlantic/Azores"
else
echo "$timezone"
fi
@ -103,14 +108,6 @@ function get_all_timezones() {
readarray -t ALL_TIMEZONES < <(find /usr/share/zoneinfo -type f -printf "%P\n" | sort -u)
}
function get_supported_locales() {
if [[ -e /usr/share/i18n/SUPPORTED ]]; then
echo /usr/share/i18n/SUPPORTED
else
echo "$GENTOO_INSTALL_REPO_DIR/contrib/i18n_supported"
fi
}
function recalculate_locales() {
LOCALES=""
N_LOCALES=0
@ -159,11 +156,20 @@ function define_zfs_compression() {
}
function define_disk_layout() {
local swapdev
case "$PARTITIONING_SCHEME" in
"classic_single_disk") define_disk_configuration_function "create_classic_single_disk_layout swap=$(define_swap) type=${PARTITIONING_BOOT_TYPE@Q} luks=${PARTITIONING_USE_LUKS@Q} root_fs=${PARTITIONING_ROOT_FS@Q}" "${PARTITIONING_DEVICE@Q}" ;;
"existing_partitions")
if [[ "$PARTITIONING_USE_SWAP" ]]; then
swapdev=${PARTITIONING_SWAP_DEVICE:-false}
else
swapdev=false
fi
define_disk_configuration_function "create_existing_partitions_layout boot=${PARTITIONING_BOOT_DEVICE@Q} swap=${swapdev@Q} type=${PARTITIONING_BOOT_TYPE@Q}" "${PARTITIONING_DEVICE@Q}" ;;
"zfs_centric") define_disk_configuration_function "create_zfs_centric_layout swap=$(define_swap) type=${PARTITIONING_BOOT_TYPE@Q} encrypt=${PARTITIONING_ZFS_USE_ENCRYPTION@Q} compress=$(define_zfs_compression) pool_type=${PARTITIONING_ZFS_POOL_TYPE@Q}" "${PARTITIONING_DEVICES[@]@Q}" ;;
"btrfs_centric") define_disk_configuration_function "create_btrfs_centric_layout swap=$(define_swap) type=${PARTITIONING_BOOT_TYPE@Q} raid_type=${PARTITIONING_BTRFS_RAID_TYPE@Q} luks=${PARTITIONING_USE_LUKS@Q}" "${PARTITIONING_DEVICES[@]@Q}" ;;
"raid0_luks") define_disk_configuration_function "create_raid0_luks_layout swap=$(define_swap) type=${PARTITIONING_BOOT_TYPE@Q} root_fs=${PARTITIONING_ROOT_FS@Q}" "${PARTITIONING_DEVICES[@]@Q}" ;;
"raid0_luks") define_disk_configuration_function "create_raid0_luks_layout swap=$(define_swap) type=${PARTITIONING_BOOT_TYPE@Q} luks=${PARTITIONING_USE_LUKS@Q} root_fs=${PARTITIONING_ROOT_FS@Q}" "${PARTITIONING_DEVICES[@]@Q}" ;;
"raid1_luks") define_disk_configuration_function "create_raid1_luks_layout swap=$(define_swap) type=${PARTITIONING_BOOT_TYPE@Q} luks=${PARTITIONING_USE_LUKS@Q} root_fs=${PARTITIONING_ROOT_FS@Q}" "${PARTITIONING_DEVICES[@]@Q}" ;;
"custom")
# Show current function declaration, trim trailing whitespace
declare -f disk_configuration \
@ -172,18 +178,45 @@ function define_disk_layout() {
esac
}
INIT_SYSTEMS=("systemd" "OpenRC")
ALL_GENTOO_ARCHS=("x86" "amd64" "arm" "arm64")
ALL_STAGE3_VARIANTS=(
"openrc" "openrc | Minimal OpenRC base (recommended)"
"desktop-openrc" "openrc-desktop | OpenRC, desktop profile, might have blockers"
"systemd" "systemd | Minimal systemd base (recommended)"
"systemd-mergedusr" "systemd-mergedusr | Minimal systemd base with merged filesystem layout"
"desktop-systemd" "systemd-desktop | systemd, desktop profile, might have blockers"
"nomultilib-openrc" "nomultilib-openrc | Minimal OpenRC base without 32bits support (Experimental)"
"nomultilib-systemd" "nomultilib-systemd | Minimal systemd base without 32bits support (Experimental)"
"nomultilib-systemd-mergedusr" "nomultilib-systemd-mergedusr | Minimal systemd base with merged filesystem layout and without 32bits support (Experimental)"
"x32-openrc" "x32-openrc | Minimal OpenRC base without 64bits support (Experimental)"
"x32-systemd" "x32-systemd | Minimal systemd base without 64bits support (Experimental)"
"x32-systemd-mergedusr" "x32-systemd-mergedusr | Minimal systemd base with merged filesystem layout and without 64bits support (Experimental)"
"llvm-openrc" "llvm-openrc | Minimal OpenRC base compiled with LLVM (Experimental)"
"llvm-systemd" "llvm-systemd | Minimal systemd base compiled with LLVM (Experimental)"
"llvm-systemd-mergedusr" "llvm-systemd-mergedusr | Minimal systemd base with merged filesystem layout compiled with LLVM (Experimental)"
"hardened-openrc" "hardened-openrc | Hardened OpenRC base (Experimental)"
"hardened-nomultilib-openrc" "hardened-nomultilib-openrc | Hardened OpenRC base without 32bits support (Experimental)"
"hardened-selinux-openrc" "hardened-selinux-openrc | Hardened OpenRC base with SELinux (Experimental)"
"hardened-nomultilib-selinux-openrc" "hardened-nomultilib-selinux-openrc | Hardened OpenRC base with SELinux and without 32bits support (Experimental)"
"musl" "musl-openrc | Minimal OpenRC base using musl (Experimental)"
"musl-llvm" "musl-llvm-openrc | Minimal OpenRC base using musl compiled with LLVM (Experimental)"
"musl-hardened" "musl-hardened-openrc | Hardened OpenRC base using musl (Experimental)"
)
ALL_PARTITIONING_SCHEMES=(
"classic_single_disk" "Classic single disk layout (boot, swap, root)"
"classic_single_disk" "Classic single disk layout (boot/efi, swap?, root)"
"existing_partitions" "Skip partitioning, use existing pre-formatted partitions"
"zfs_centric" "ZFS centric (optional ZFS compression and encryption)"
"btrfs_centric" "Btrfs centric (optional raid0/1 via btrfs)"
"raid0_luks" "Raid0 (N>=2 disks) and luks for root"
"custom" "Custom (edit the config manually later)"
"raid1_luks" "Raid1 (N>=2 disks) and luks for root"
"custom" "Custom (expert option; edit the config manually later)"
)
PARTITIONING_BOOT_TYPES=("efi" "bios")
PARTITIONING_BOOT_TYPES=(
"efi" "efi$([[ $HAS_EFI_SUPPORT == true ]] && echo -n "" || echo -n " (!! $EFI_UNSUPPORTED_MESSAGE_SHORT !!)")"
"bios" "bios"
)
PARTITIONING_ROOT_FS_TYPES=("ext4" "btrfs")
PARTITIONING_BTRFS_RAID_TYPES=("raid0" "raid1")
PARTITIONING_ZFS_POOL_TYPES=("standard" "custom")
@ -229,16 +262,50 @@ function create_classic_single_disk_layout() {
PARTITIONING_ROOT_FS="${arguments[root_fs]:-ext4}"
}
function create_existing_partitions_layout() {
PARTITIONING_SCHEME="existing_partitions"
local known_arguments=('+swap' '+boot' '?type')
local extra_arguments=()
declare -A arguments; parse_arguments "$@"
PARTITIONING_DEVICE="${extra_arguments[0]}"
if [[ "${arguments[swap]}" == "false" ]]; then
PARTITIONING_USE_SWAP=false
PARTITIONING_SWAP_DEVICE=""
else
PARTITIONING_USE_SWAP=true
PARTITIONING_SWAP_DEVICE="${arguments[swap]}"
fi
PARTITIONING_BOOT_TYPE="${arguments[type]}"
PARTITIONING_BOOT_DEVICE="${arguments[boot]}"
}
function create_raid0_luks_layout() {
PARTITIONING_SCHEME="raid0_luks"
local known_arguments=('+swap' '?type' '?root_fs')
local known_arguments=('+swap' '?type' '?luks' '?root_fs')
local extra_arguments=()
declare -A arguments; parse_arguments "$@"
PARTITIONING_DEVICES=("${extra_arguments[@]}")
parse_swap "${arguments[swap]}"
PARTITIONING_BOOT_TYPE="${arguments[type]}"
PARTITIONING_USE_LUKS="${arguments[luks]:-true}"
PARTITIONING_ROOT_FS="${arguments[root_fs]:-ext4}"
}
function create_raid1_luks_layout() {
PARTITIONING_SCHEME="raid1_luks"
local known_arguments=('+swap' '?type' '?luks' '?root_fs')
local extra_arguments=()
declare -A arguments; parse_arguments "$@"
PARTITIONING_DEVICES=("${extra_arguments[@]}")
parse_swap "${arguments[swap]}"
PARTITIONING_BOOT_TYPE="${arguments[type]}"
PARTITIONING_USE_LUKS="${arguments[luks]:-true}"
PARTITIONING_ROOT_FS="${arguments[root_fs]:-ext4}"
}
@ -282,7 +349,7 @@ function create_btrfs_centric_layout() {
get_all_keymaps
get_all_timezones
readarray -t SUPPORTED_LOCALES < "$(get_supported_locales)"
readarray -t SUPPORTED_LOCALES < "$GENTOO_INSTALL_REPO_DIR/contrib/i18n_supported"
readarray -t LOCALE_A < <(locale -a)
@ -311,12 +378,6 @@ function load_selected_locales() {
function process_config() {
disk_configuration
if [[ "$SYSTEMD" == true ]]; then
INIT_SYSTEM="systemd"
else
INIT_SYSTEM="OpenRC"
fi
if [[ "$KEYMAP" == "$KEYMAP_INITRAMFS" ]]; then
KEYMAP_INITRAMFS_OTHER=false
else
@ -338,7 +399,7 @@ function load_config() {
# shellcheck disable=SC1090
source "$1" || die "Could not load given configuration."
# After loading a config no unsaved changes exist.
# After loading a config, no unsaved changes exist.
UNSAVED_CHANGES=false
}
@ -348,15 +409,21 @@ function load_default_config() {
KEYMAP="$(get_default_keymap)"
KEYMAP_INITRAMFS="$KEYMAP"
LOCALES="C.UTF-8 UTF-8"
LOCALE="C.utf8"
LOCALE="C.UTF-8"
SYSTEMD_NETWORKD=true
SYSTEMD_NETWORKD_INTERFACE_NAME="en*"
SYSTEMD_NETWORKD_DHCP=true
SYSTEMD_NETWORKD_ADDRESSES=("192.168.1.100/32" "fd00::1/64")
SYSTEMD_NETWORKD_GATEWAY="192.168.1.1"
SYSTEMD_INITRAMFS_SSHD=false
function disk_configuration() {
#create_zfs_centric_layout swap=8GiB type=efi encrypt=true compress=zstd pool_type=standard /dev/sdX
create_classic_single_disk_layout swap=8GiB type=efi luks=true root_fs=ext4 /dev/sdX
#create_zfs_centric_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" encrypt=true compress=zstd pool_type=standard /dev/sdX
create_classic_single_disk_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" luks=true root_fs=ext4 /dev/sdX
}
SYSTEMD=true
STAGE3_VARIANT="systemd"
PORTAGE_SYNC_TYPE="git"
PORTAGE_GIT_FULL_HISTORY=false
PORTAGE_GIT_MIRROR="https://anongit.gentoo.org/git/repo/sync/gentoo.git"
@ -369,8 +436,10 @@ function load_default_config() {
SELECT_MIRRORS_LARGE_FILE=false
ADDITIONAL_PACKAGES=()
INSTALL_SSHD=true
ENABLE_SSHD=true
ENABLE_BINPKG=false
ROOT_SSH_AUTHORIZED_KEYS=""
# All settings are unsaved.
UNSAVED_CHANGES=true
@ -427,6 +496,12 @@ function on_off_label() {
on_off_str "$1" "${prefix}[*]" "${prefix}[ ]"
}
function on_off_label_inverted() {
local var=$1
shift
on_off_label "$(is_on "$var" && echo false || echo true)" "$@"
}
function is_on() {
[[ "$1" == true ]]
}
@ -450,7 +525,7 @@ function one_of() {
# $2: description
# $3: space separated index list of selected items (e.g. "0 1 5 6")
# $@: all items
function menu_splitlist() {
function menu_splitlist() {
local title="$1"
local description="$2"
local selected_index_list="$3"
@ -555,7 +630,7 @@ function menu_radiolist_labeled() {
# $2: description
# $3: default item
# $@: items
function menu_radiolist() {
function menu_radiolist() {
local title="$1"
local description="$2"
local default_item="$3"
@ -605,6 +680,52 @@ function menu_radiolist() {
fi
}
# $1: title
# $2: description
# $3: current device (will be canonicalized if possible)
function menu_select_device() {
local title="$1"
local desc="$2"
local prev_selected
prev_selected=$(canonicalize_device "$3")
while true; do
local all_devices=()
for dev in /dev/disk/by-id/*; do
all_devices+=("$dev" "$(basename "$dev")")
done
all_devices+=("/dev/null" "<enter custom path>")
if menu_radiolist_labeled "$title" "$desc" "$prev_selected" "${all_devices[@]}"; then
if [[ "$dialog_out" == "/dev/null" ]]; then
while true; do
if dialog \
--title "$1" \
--inputbox "$([[ -e $prev_selected ]] || echo -n "\Z1The previously selected device $prev_selected does not exist!\Zn ")Enter the path of the desired device." \
"${INPUTBOX_SIZE[@]}" "$prev_selected"
then
# Repeat until selected device exists or cancelled
prev_selected="$dialog_out"
[[ ! -e "$dialog_out" ]] && continue
return 0
else
# <Cancel> -> return to previous menu
break
fi
done
# Return to radiolist
continue
else
return 0
fi
else
# <Cancel>
return 1
fi
done
}
function msgbox_help() {
dialog --msgbox "$1" "${HELP_POPUP_SIZE[@]}"
}
@ -736,8 +857,10 @@ init_menu_size
MENU_ITEMS=(
"PARTITIONING_SCHEME"
"PARTITIONING_BOOT_TYPE"
"PARTITIONING_BOOT_DEVICE"
"PARTITIONING_USE_SWAP"
"PARTITIONING_SWAP"
"PARTITIONING_SWAP_DEVICE"
"PARTITIONING_ROOT_FS"
"PARTITIONING_USE_LUKS"
"PARTITIONING_ZFS_POOL_TYPE"
@ -755,8 +878,14 @@ MENU_ITEMS=(
"KEYMAP_INITRAMFS"
"LOCALES"
"LOCALE"
"SYSTEMD_NETWORKD"
"SYSTEMD_INITRAMFS_SSHD"
"SYSTEMD_NETWORKD_INTERFACE_NAME"
"SYSTEMD_NETWORKD_DHCP"
"SYSTEMD_NETWORKD_ADDRESSES"
"SYSTEMD_NETWORKD_GATEWAY"
"--------"
"INIT_SYSTEM"
"STAGE3_VARIANT"
"PORTAGE_SYNC_TYPE"
"PORTAGE_GIT_FULL_HISTORY"
"PORTAGE_GIT_MIRROR"
@ -766,7 +895,8 @@ MENU_ITEMS=(
"SELECT_MIRRORS"
"SELECT_MIRRORS_LARGE_FILE"
"--------"
"INSTALL_SSHD"
"ENABLE_SSHD"
"ENABLE_BINPKG"
"ROOT_SSH_AUTHORIZED_KEYS"
"ADDITIONAL_PACKAGES"
)
@ -790,10 +920,12 @@ function PARTITIONING_SCHEME_menu() {
then
# Set disk scheme
case "$dialog_out" in
"classic_single_disk") create_classic_single_disk_layout swap=8GiB type=efi luks=false root_fs=ext4 /dev/sdX ;;
"zfs_centric") create_zfs_centric_layout swap=8GiB type=efi encrypt=true compress=zstd pool_type=standard /dev/sdX ;;
"btrfs_centric") create_btrfs_centric_layout swap=8GiB type=efi raid_type=raid0 luks=false /dev/sdX ;;
"raid0_luks") create_raid0_luks_layout swap=8GiB type=efi root_fs=ext4 /dev/sdX /dev/sdY ;;
"classic_single_disk") create_classic_single_disk_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" luks=false root_fs=ext4 /dev/sdX ;;
"existing_partitions") create_existing_partitions_layout boot=/dev/sdA swap=false type="$DEFAULT_BOOT_TYPE" /dev/sdX ;;
"zfs_centric") create_zfs_centric_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" encrypt=true compress=zstd pool_type=standard /dev/sdX ;;
"btrfs_centric") create_btrfs_centric_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" raid_type=raid0 luks=false /dev/sdX ;;
"raid0_luks") create_raid0_luks_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" luks=true root_fs=ext4 /dev/sdX /dev/sdY ;;
"raid1_luks") create_raid1_luks_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" luks=true root_fs=ext4 /dev/sdX /dev/sdY ;;
"custom") PARTITIONING_SCHEME="$dialog_out" ;;
esac
UNSAVED_CHANGES=true
@ -804,17 +936,16 @@ function PARTITIONING_SCHEME_menu() {
}
function PARTITIONING_BOOT_TYPE_tag() { echo " ├ Boot type"; }
function PARTITIONING_BOOT_TYPE_label() { echo " ├ ($PARTITIONING_BOOT_TYPE)"; }
function PARTITIONING_BOOT_TYPE_label() { echo " ├ ($PARTITIONING_BOOT_TYPE)$([[ $PARTITIONING_BOOT_TYPE == efi && $HAS_EFI_SUPPORT == false ]] && echo -n " \Z1$EFI_UNSUPPORTED_MESSAGE_SHORT\Zn" || echo -n "")"; }
function PARTITIONING_BOOT_TYPE_show() { [[ $PARTITIONING_SCHEME != "custom" ]]; }
function PARTITIONING_BOOT_TYPE_help() { echo "Select whether to use EFI or BIOS boot."; }
function PARTITIONING_BOOT_TYPE_menu() {
if menu_radiolist \
if menu_radiolist_labeled \
"Select boot type" \
"Select whether your want to use EFI or BIOS boot." \
"Select whether you want to use EFI or BIOS boot.$(on_off_str "$HAS_EFI_SUPPORT" "" " \Z1$EFI_UNSUPPORTED_MESSAGE\Zn")" \
"$PARTITIONING_BOOT_TYPE" \
"${PARTITIONING_BOOT_TYPES[@]}"
then
# Set timezone
PARTITIONING_BOOT_TYPE="$dialog_out"
UNSAVED_CHANGES=true
else
@ -823,6 +954,32 @@ function PARTITIONING_BOOT_TYPE_menu() {
fi
}
function PARTITIONING_BOOT_DEVICE_tag() { echo " ├ Boot Device"; }
function PARTITIONING_BOOT_DEVICE_label() {
local devshort=$PARTITIONING_BOOT_DEVICE
devshort=$(shorten_device "$devshort")
if [[ -e "$PARTITIONING_BOOT_DEVICE" ]]; then
echo " ├ ($devshort)"
else
echo " ├ (\Z1$devshort\Zn)"
fi
}
function PARTITIONING_BOOT_DEVICE_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "existing_partitions"; }
function PARTITIONING_BOOT_DEVICE_help() { echo "The device to use for the boot partition. For EFI systems this is the efi partition. Must be formatted already."; }
function PARTITIONING_BOOT_DEVICE_menu() {
if menu_select_device \
"Select boot device" \
"Select the device containing the EFI filesystem or /boot partition respectively for systems using efi or bios boot." \
"$PARTITIONING_BOOT_DEVICE"
then
PARTITIONING_BOOT_DEVICE="$dialog_out"
UNSAVED_CHANGES=true
else
# Return to menu
true
fi
}
function PARTITIONING_USE_SWAP_tag() { echo " ├ Use swap"; }
function PARTITIONING_USE_SWAP_label() { on_off_label "$PARTITIONING_USE_SWAP" " ├ "; }
function PARTITIONING_USE_SWAP_show() { [[ $PARTITIONING_SCHEME != "custom" ]]; }
@ -834,20 +991,49 @@ function PARTITIONING_USE_SWAP_menu() {
function PARTITIONING_SWAP_tag() { echo " │ └ Swap amount"; }
function PARTITIONING_SWAP_label() { echo " │ └ ($PARTITIONING_SWAP)"; }
function PARTITIONING_SWAP_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && is_on "$PARTITIONING_USE_SWAP"; }
function PARTITIONING_SWAP_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && is_on "$PARTITIONING_USE_SWAP" && ! one_of "$PARTITIONING_SCHEME" "existing_partitions"; }
function PARTITIONING_SWAP_help() { echo "Select the amount of swap to use."; }
function PARTITIONING_SWAP_menu() {
dialog \
--title "Select swap amount" \
--inputbox "Enter the amount of swap for the new system. Use the correct suffix (e.g. 16GiB, 1000MB)." \
"${INPUTBOX_SIZE[@]}" "$PARTITIONING_SWAP"
"${INPUTBOX_SIZE[@]}" "$PARTITIONING_SWAP" \
|| return 0
PARTITIONING_SWAP="$dialog_out"
UNSAVED_CHANGES=true
}
function PARTITIONING_SWAP_DEVICE_tag() { echo " │ └ Swap Device"; }
function PARTITIONING_SWAP_DEVICE_label() {
local dev=${PARTITIONING_SWAP_DEVICE:-/dev/sdB}
local devshort
devshort=$(shorten_device "$dev")
if [[ -e "$dev" ]]; then
echo " │ └ ($devshort)"
else
echo " │ └ (\Z1$devshort\Zn)"
fi
}
function PARTITIONING_SWAP_DEVICE_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && is_on "$PARTITIONING_USE_SWAP" && one_of "$PARTITIONING_SCHEME" "existing_partitions"; }
function PARTITIONING_SWAP_DEVICE_help() { echo "The device to use as swap."; }
function PARTITIONING_SWAP_DEVICE_menu() {
if menu_select_device \
"Select swap device" \
"Select the device to use as swap." \
"$PARTITIONING_SWAP_DEVICE"
then
PARTITIONING_SWAP_DEVICE="$dialog_out"
UNSAVED_CHANGES=true
else
# Return to menu
true
fi
}
function PARTITIONING_ROOT_FS_tag() { echo " ├ Root filesystem"; }
function PARTITIONING_ROOT_FS_label() { echo " ├ ($PARTITIONING_ROOT_FS)"; }
function PARTITIONING_ROOT_FS_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "classic_single_disk" "raid0_luks"; }
function PARTITIONING_ROOT_FS_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "classic_single_disk" "raid0_luks" "raid1_luks"; }
function PARTITIONING_ROOT_FS_help() { echo "Select the amount of swap to use."; }
function PARTITIONING_ROOT_FS_menu() {
if menu_radiolist \
@ -856,7 +1042,6 @@ function PARTITIONING_ROOT_FS_menu() {
"$PARTITIONING_ROOT_FS" \
"${PARTITIONING_ROOT_FS_TYPES[@]}"
then
# Set timezone
PARTITIONING_ROOT_FS="$dialog_out"
UNSAVED_CHANGES=true
else
@ -906,7 +1091,6 @@ function PARTITIONING_ZFS_COMPRESSION_menu() {
"$PARTITIONING_ZFS_COMPRESSION" \
"${PARTITIONING_ZFS_COMPRESSIONS[@]}"
then
# Set timezone
PARTITIONING_ZFS_COMPRESSION="$dialog_out"
UNSAVED_CHANGES=true
else
@ -926,7 +1110,6 @@ function PARTITIONING_ZFS_POOL_TYPE_menu() {
"$PARTITIONING_ZFS_POOL_TYPE" \
"${PARTITIONING_ZFS_POOL_TYPES[@]}"
then
# Set timezone
PARTITIONING_ZFS_POOL_TYPE="$dialog_out"
UNSAVED_CHANGES=true
else
@ -946,7 +1129,6 @@ function PARTITIONING_BTRFS_RAID_TYPE_menu() {
"$PARTITIONING_BTRFS_RAID_TYPE" \
"${PARTITIONING_BTRFS_RAID_TYPES[@]}"
then
# Set timezone
PARTITIONING_BTRFS_RAID_TYPE="$dialog_out"
UNSAVED_CHANGES=true
else
@ -957,21 +1139,28 @@ function PARTITIONING_BTRFS_RAID_TYPE_menu() {
function PARTITIONING_DEVICE_tag() { echo " └ Device"; }
function PARTITIONING_DEVICE_label() {
local devshort=$PARTITIONING_DEVICE
devshort=$(shorten_device "$devshort")
if [[ -e "$PARTITIONING_DEVICE" ]]; then
echo " └ ($PARTITIONING_DEVICE)"
echo " └ ($devshort)"
else
echo " └ (\Z1$PARTITIONING_DEVICE\Zn)"
echo " └ (\Z1$devshort\Zn)"
fi
}
function PARTITIONING_DEVICE_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "classic_single_disk"; }
function PARTITIONING_DEVICE_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "classic_single_disk" "existing_partitions"; }
function PARTITIONING_DEVICE_help() { echo "The block device to which the layout will be applied."; }
function PARTITIONING_DEVICE_menu() {
dialog \
--title "Select device" \
--inputbox "Enter the path of the device which you want to partition. (e.g. /dev/sda)." \
"${INPUTBOX_SIZE[@]}" "$PARTITIONING_DEVICE"
PARTITIONING_DEVICE="$dialog_out"
UNSAVED_CHANGES=true
if menu_select_device \
"Select root device" \
"Select the device to use as the root device." \
"$PARTITIONING_DEVICE"
then
PARTITIONING_DEVICE="$dialog_out"
UNSAVED_CHANGES=true
else
# Return to menu
true
fi
}
function PARTITIONING_DEVICES_tag() { echo " └ Devices"; }
@ -984,7 +1173,7 @@ function PARTITIONING_DEVICES_label() {
if [[ "$invalid" -gt 0 ]]; then
echo " └ (${#PARTITIONING_DEVICES[@]} devices, \Z1$invalid invalid\Zn)"
elif [[ "${#PARTITIONING_DEVICES[@]}" -eq 1 && "$PARTITIONING_SCHEME" == "raid0_luks" ]]; then
elif [[ "${#PARTITIONING_DEVICES[@]}" -eq 1 && ("$PARTITIONING_SCHEME" == "raid0_luks" || "$PARTITIONING_SCHEME" == "raid1_luks") ]]; then
echo " └ (${#PARTITIONING_DEVICES[@]} devices, \Z1need at least 2\Zn)"
elif [[ "${#PARTITIONING_DEVICES[@]}" -eq 0 ]]; then
echo " └ (${#PARTITIONING_DEVICES[@]} devices, \Z1need at least 1\Zn)"
@ -992,7 +1181,7 @@ function PARTITIONING_DEVICES_label() {
echo " └ (${#PARTITIONING_DEVICES[@]} devices)"
fi
}
function PARTITIONING_DEVICES_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "raid0_luks" "zfs_centric" "btrfs_centric"; }
function PARTITIONING_DEVICES_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "raid0_luks" "raid1_luks" "zfs_centric" "btrfs_centric"; }
function PARTITIONING_DEVICES_help() { echo "The block devices to which the layout will be applied."; }
function PARTITIONING_DEVICES_menu() {
local invalid=()
@ -1009,7 +1198,8 @@ function PARTITIONING_DEVICES_menu() {
dialog \
--title "Select devices" \
--inputbox "Enter the path of all devices which you want to partition, separated by space. (e.g. /dev/sda /dev/sdb).$invalid_line" \
"${INPUTBOX_SIZE[@]}" "${PARTITIONING_DEVICES[*]}"
"${INPUTBOX_SIZE[@]}" "${PARTITIONING_DEVICES[*]}" \
|| return 0
read -ra PARTITIONING_DEVICES <<< "$dialog_out"
UNSAVED_CHANGES=true
}
@ -1022,7 +1212,8 @@ function HOSTNAME_menu() {
dialog \
--title "Select hostname" \
--inputbox "Enter the hostname for your new system." \
"${INPUTBOX_SIZE[@]}" "$HOSTNAME"
"${INPUTBOX_SIZE[@]}" "$HOSTNAME" \
|| return 0
HOSTNAME="$dialog_out"
UNSAVED_CHANGES=true
}
@ -1038,7 +1229,6 @@ function TIMEZONE_menu() {
"$TIMEZONE" \
"${ALL_TIMEZONES[@]}"
then
# Set timezone
TIMEZONE="$dialog_out"
UNSAVED_CHANGES=true
else
@ -1058,7 +1248,6 @@ function KEYMAP_menu() {
"$KEYMAP" \
"${ALL_KEYMAPS[@]}"
then
# Set keymap
KEYMAP="$dialog_out"
UNSAVED_CHANGES=true
else
@ -1089,7 +1278,6 @@ function KEYMAP_INITRAMFS_menu() {
"$KEYMAP_INITRAMFS" \
"${ALL_KEYMAPS[@]}"
then
# Set keymap
KEYMAP_INITRAMFS="$dialog_out"
UNSAVED_CHANGES=true
else
@ -1101,10 +1289,9 @@ function KEYMAP_INITRAMFS_menu() {
function LOCALES_tag() { echo "Locales"; }
function LOCALES_label() { echo "$N_LOCALES selected"; }
function LOCALES_show() { return 0; }
function LOCALES_help() { echo "The locales to generate for the new system. Be careful that the syntax for locales is a different from the resulting name of the genereated locales of locale-gen. For example the locale 'en_US.utf8' is enabled via 'en_US.UTF-8 UTF-8')."; }
function LOCALES_help() { echo "The locales to generate for the new system. Be careful that the syntax for locales is a different from the resulting name of the generated locales of locale-gen. For example, the locale 'en_US.utf8' is enabled via 'en_US.UTF-8 UTF-8')."; }
function LOCALES_menu() {
if menu_splitlist "Select locales" "Select which locales to generate." "$SELECTED_LOCALES" "${SUPPORTED_LOCALES[@]}"; then
# Set locales
SELECTED_LOCALES="$dialog_out"
recalculate_locales
UNSAVED_CHANGES=true
@ -1125,7 +1312,6 @@ function LOCALE_menu() {
"$LOCALE" \
"${LOCALE_A[@]}"
then
# Set locale
LOCALE="$dialog_out"
UNSAVED_CHANGES=true
else
@ -1134,19 +1320,88 @@ function LOCALE_menu() {
fi
}
function INIT_SYSTEM_tag() { echo "Init system"; }
function INIT_SYSTEM_label() { echo "($INIT_SYSTEM)"; }
function INIT_SYSTEM_show() { return 0; }
function INIT_SYSTEM_help() { echo ""; }
function INIT_SYSTEM_menu() {
if menu_radiolist \
"Select init system" \
"Select the init system you want to use." \
"$INIT_SYSTEM" \
"${INIT_SYSTEMS[@]}"
function SYSTEMD_NETWORKD_tag() { echo "Configure network"; }
function SYSTEMD_NETWORKD_label() { on_off_label "$SYSTEMD_NETWORKD"; }
function SYSTEMD_NETWORKD_show() { [[ $STAGE3_VARIANT == *systemd* ]]; }
function SYSTEMD_NETWORKD_help() { echo "Enable systemd-network to configure networking on the new system."; }
function SYSTEMD_NETWORKD_menu() {
on_off_toggle "SYSTEMD_NETWORKD"
UNSAVED_CHANGES=true
}
function SYSTEMD_INITRAMFS_SSHD_tag() { echo " ├ Enable sshd in initramfs"; }
function SYSTEMD_INITRAMFS_SSHD_label() { on_off_label "$SYSTEMD_INITRAMFS_SSHD" " ├ "; }
function SYSTEMD_INITRAMFS_SSHD_show() { [[ $STAGE3_VARIANT == *systemd* ]] && is_on "$SYSTEMD_NETWORKD"; }
function SYSTEMD_INITRAMFS_SSHD_help() { echo "Install and enable sshd in the initramfs. This can be used to unlock encrypted partitions / ZFS via ssh, or to get an emergency shell. Visit https://github.com/gsauthof/dracut-sshd for more information."; }
function SYSTEMD_INITRAMFS_SSHD_menu() {
on_off_toggle "SYSTEMD_INITRAMFS_SSHD"
UNSAVED_CHANGES=true
}
function SYSTEMD_NETWORKD_INTERFACE_NAME_tag() { echo " ├ Interface Name"; }
function SYSTEMD_NETWORKD_INTERFACE_NAME_label() { echo " ├ ($(ellipsis 20 "$SYSTEMD_NETWORKD_INTERFACE_NAME"))"; }
function SYSTEMD_NETWORKD_INTERFACE_NAME_show() { [[ $STAGE3_VARIANT == *systemd* ]] && is_on "$SYSTEMD_NETWORKD"; }
function SYSTEMD_NETWORKD_INTERFACE_NAME_help() { echo "The network interface(s) to configure. Defaults to all interfaces matching en*."; }
function SYSTEMD_NETWORKD_INTERFACE_NAME_menu() {
dialog \
--title "Network Interface Name" \
--inputbox "Enter the network interface name which should be configured. Can include wildcards." \
"${INPUTBOX_SIZE[@]}" "$SYSTEMD_NETWORKD_INTERFACE_NAME" \
|| return 0
SYSTEMD_NETWORKD_INTERFACE_NAME="$dialog_out"
UNSAVED_CHANGES=true
}
function SYSTEMD_NETWORKD_DHCP_tag() { echo " └ Static IP"; }
function SYSTEMD_NETWORKD_DHCP_label() { on_off_label_inverted "$SYSTEMD_NETWORKD_DHCP" " └ "; }
function SYSTEMD_NETWORKD_DHCP_show() { [[ $STAGE3_VARIANT == *systemd* ]] && is_on "$SYSTEMD_NETWORKD"; }
function SYSTEMD_NETWORKD_DHCP_help() { echo "Use DHCP to obtain network configuration."; }
function SYSTEMD_NETWORKD_DHCP_menu() {
on_off_toggle "SYSTEMD_NETWORKD_DHCP"
UNSAVED_CHANGES=true
}
function SYSTEMD_NETWORKD_ADDRESSES_tag() { echo " ├ Addresses"; }
function SYSTEMD_NETWORKD_ADDRESSES_label() { echo " ├ ($(ellipsis 20 "${SYSTEMD_NETWORKD_ADDRESSES[*]}"))"; }
function SYSTEMD_NETWORKD_ADDRESSES_show() { [[ $STAGE3_VARIANT == *systemd* ]] && is_on "$SYSTEMD_NETWORKD" && is_off "$SYSTEMD_NETWORKD_DHCP"; }
function SYSTEMD_NETWORKD_ADDRESSES_help() { echo "A space-separated list of addresses with CIDR mask to assign to the network interface."; }
function SYSTEMD_NETWORKD_ADDRESSES_menu() {
dialog \
--title "Network Addresses" \
--inputbox "A space-separated list of addresses with CIDR mask to assign to the network interface." \
"${INPUTBOX_SIZE[@]}" "${SYSTEMD_NETWORKD_ADDRESSES[*]}" \
|| return 0
# shellcheck disable=SC2206
SYSTEMD_NETWORKD_ADDRESSES=($dialog_out)
UNSAVED_CHANGES=true
}
function SYSTEMD_NETWORKD_GATEWAY_tag() { echo " └ Gateway"; }
function SYSTEMD_NETWORKD_GATEWAY_label() { echo " └ ($(ellipsis 20 "$SYSTEMD_NETWORKD_GATEWAY"))"; }
function SYSTEMD_NETWORKD_GATEWAY_show() { [[ $STAGE3_VARIANT == *systemd* ]] && is_on "$SYSTEMD_NETWORKD" && is_off "$SYSTEMD_NETWORKD_DHCP"; }
function SYSTEMD_NETWORKD_GATEWAY_help() { echo "The gateway address for the network."; }
function SYSTEMD_NETWORKD_GATEWAY_menu() {
dialog \
--title "Network Gateway" \
--inputbox "The gateway address for the network." \
"${INPUTBOX_SIZE[@]}" "$SYSTEMD_NETWORKD_GATEWAY" \
|| return 0
SYSTEMD_NETWORKD_GATEWAY="$dialog_out"
UNSAVED_CHANGES=true
}
function STAGE3_VARIANT_tag() { echo "Stage3 variant & Init system"; }
function STAGE3_VARIANT_label() { echo "($STAGE3_VARIANT)"; }
function STAGE3_VARIANT_show() { return 0; }
function STAGE3_VARIANT_help() { echo "Select which stage3 tarball to use. Implicitly determines whether systemd or OpenRC is used. Not all stage3 variants have been tested with this installer. The basic installation process is always the same, but due to complex profiles, unexpected blockers may arise when emerge is called. Stick to the basic choices and change after bootstrapping, unless you know how to intervene while installing."; }
function STAGE3_VARIANT_menu() {
if menu_radiolist_labeled \
"Select stage3 variant" \
"Select the base stage3 tarball variant to use for bootstrapping the system. Implicitly determines whether systemd or OpenRC is used. Not all stage3 variants have been tested with this installer. The basic installation process is always the same, but due to complex profiles, unexpected blockers may arise when emerge is called. Stick to the basic choices and change after bootstrapping, unless you know how to intervene while installing." \
"$STAGE3_VARIANT" \
"${ALL_STAGE3_VARIANTS[@]}"
then
# Set init system
INIT_SYSTEM="$dialog_out"
STAGE3_VARIANT="$dialog_out"
UNSAVED_CHANGES=true
else
# Return to menu
@ -1165,7 +1420,6 @@ function PORTAGE_SYNC_TYPE_menu() {
"$PORTAGE_SYNC_TYPE" \
"${PORTAGE_SYNC_TYPES[@]}"
then
# Set arch
PORTAGE_SYNC_TYPE="$dialog_out"
UNSAVED_CHANGES=true
else
@ -1186,12 +1440,14 @@ function PORTAGE_GIT_FULL_HISTORY_menu() {
function PORTAGE_GIT_MIRROR_tag() { echo " └ Git mirror"; }
function PORTAGE_GIT_MIRROR_label() { echo " └ ($(ellipsis 20 "$PORTAGE_GIT_MIRROR"))"; }
function PORTAGE_GIT_MIRROR_show() { one_of "$PORTAGE_SYNC_TYPE" "git"; }
function PORTAGE_GIT_MIRROR_help() { echo "The portage git mirror is the git endpoint that is used to sync the portage tree."; }
function PORTAGE_GIT_MIRROR_help() { echo "The portage git mirror is the git endpoint that is used to sync the portage tree. You usually should not need to change this!"; }
function PORTAGE_GIT_MIRROR_menu() {
dialog \
--title "Select portage git mirror" \
--inputbox "Enter the portage git mirror that should be used to sync the portage tree." \
"${INPUTBOX_SIZE[@]}" "$PORTAGE_GIT_MIRROR"
"${INPUTBOX_SIZE[@]}" "$PORTAGE_GIT_MIRROR" \
|| return 0
PORTAGE_GIT_MIRROR="$dialog_out"
UNSAVED_CHANGES=true
}
@ -1202,8 +1458,10 @@ function GENTOO_MIRROR_help() { echo "Enter the initial gentoo mirror that shou
function GENTOO_MIRROR_menu() {
dialog \
--title "Select gentoo mirror" \
--inputbox "Enter the initial gentoo mirror that should be used for the installation process (until mirrorselect is run)." \
"${INPUTBOX_SIZE[@]}" "$GENTOO_MIRROR"
--inputbox "Enter the initial gentoo mirror that should be used for the system (or until mirrorselect is run). You need to enter the FULL PATH to the tree including relevant subdirectories. Leave this as it is if in doubt!" \
"${INPUTBOX_SIZE[@]}" "$GENTOO_MIRROR" \
|| return 0
GENTOO_MIRROR="$dialog_out"
UNSAVED_CHANGES=true
}
@ -1218,7 +1476,6 @@ function GENTOO_ARCH_menu() {
"$GENTOO_ARCH" \
"${ALL_GENTOO_ARCHS[@]}"
then
# Set arch
GENTOO_ARCH="$dialog_out"
UNSAVED_CHANGES=true
else
@ -1254,12 +1511,21 @@ function SELECT_MIRRORS_LARGE_FILE_menu() {
UNSAVED_CHANGES=true
}
function INSTALL_SSHD_tag() { echo "Install sshd"; }
function INSTALL_SSHD_label() { on_off_label "$INSTALL_SSHD"; }
function INSTALL_SSHD_show() { return 0; }
function INSTALL_SSHD_help() { echo "Install and enable sshd on the new system. A reasonably secure sshd configuration will be provided. It will by default only allow ed25519 keys, restrict key exchange algorithms to a reasonable subset, disable any password based authentication, and only allow root to login."; }
function INSTALL_SSHD_menu() {
on_off_toggle "INSTALL_SSHD"
function ENABLE_SSHD_tag() { echo "Enable sshd"; }
function ENABLE_SSHD_label() { on_off_label "$ENABLE_SSHD"; }
function ENABLE_SSHD_show() { return 0; }
function ENABLE_SSHD_help() { echo "Install and enable sshd on the new system. A reasonably secure sshd configuration will be provided. It will by default only allow ed25519 keys, restrict key exchange algorithms to a reasonable subset, disable any password based authentication, and only allow root to login."; }
function ENABLE_SSHD_menu() {
on_off_toggle "ENABLE_SSHD"
UNSAVED_CHANGES=true
}
function ENABLE_BINPKG_tag() { echo "Enable binary packages"; }
function ENABLE_BINPKG_label() { on_off_label "$ENABLE_BINPKG"; }
function ENABLE_BINPKG_show() { return 0; }
function ENABLE_BINPKG_help() { echo "Use binary packages if available."; }
function ENABLE_BINPKG_menu() {
on_off_toggle "ENABLE_BINPKG"
UNSAVED_CHANGES=true
}
@ -1315,12 +1581,6 @@ function save() {
KEYMAP_INITRAMFS="$KEYMAP"
fi
if [[ $INIT_SYSTEM == "systemd" ]]; then
SYSTEMD=true
else
SYSTEMD=false
fi
cat > "$1" <<EOF
# vim: set ft=sh ts=4 sw=4 sts=-1 noet:
# This file will be interpreted by /bin/bash.
@ -1343,27 +1603,37 @@ KEYMAP_INITRAMFS=${KEYMAP_INITRAMFS@Q}
LOCALES=${LOCALES@Q}
LOCALE=${LOCALE@Q}
SYSTEMD_NETWORKD=${SYSTEMD_NETWORKD@Q}
SYSTEMD_NETWORKD_INTERFACE_NAME=${SYSTEMD_NETWORKD_INTERFACE_NAME@Q}
SYSTEMD_NETWORKD_DHCP=${SYSTEMD_NETWORKD_DHCP@Q}
SYSTEMD_NETWORKD_ADDRESSES=${SYSTEMD_NETWORKD_ADDRESSES@Q}
SYSTEMD_NETWORKD_GATEWAY=${SYSTEMD_NETWORKD_GATEWAY@Q}
SYSTEMD_INITRAMFS_SSHD=${SYSTEMD_INITRAMFS_SSHD@Q}
################################################
# Gentoo configuration
SYSTEMD=${SYSTEMD@Q}
PORTAGE_SYNC_TYPE=${PORTAGE_SYNC_TYPE@Q}
PORTAGE_GIT_FULL_HISTORY=${PORTAGE_GIT_FULL_HISTORY@Q}
PORTAGE_GIT_MIRROR=${PORTAGE_GIT_MIRROR@Q}
GENTOO_MIRROR=${GENTOO_MIRROR@Q}
GENTOO_ARCH=${GENTOO_ARCH@Q}
STAGE3_BASENAME="stage3-\$GENTOO_ARCH$([[ $SYSTEMD == true ]] && echo -n "-systemd" || echo -n "-openrc")"
STAGE3_VARIANT=${STAGE3_VARIANT@Q}
STAGE3_BASENAME="stage3-\$GENTOO_ARCH-\$STAGE3_VARIANT"
USE_PORTAGE_TESTING=${USE_PORTAGE_TESTING@Q}
SELECT_MIRRORS=${SELECT_MIRRORS@Q}
SELECT_MIRRORS_LARGE_FILE=${SELECT_MIRRORS_LARGE_FILE@Q}
SYSTEMD=\$([[ \$STAGE3_VARIANT == *systemd* ]] && echo "true" || echo "false")
MUSL=\$([[ \$STAGE3_VARIANT == *musl* ]] && echo "true" || echo "false")
################################################
# Additional (optional) configuration
ADDITIONAL_PACKAGES=(${ADDITIONAL_PACKAGES[@]@Q})
INSTALL_SSHD=${INSTALL_SSHD@Q}
ENABLE_SSHD=${ENABLE_SSHD@Q}
ENABLE_BINPKG=${ENABLE_BINPKG@Q}
ROOT_SSH_AUTHORIZED_KEYS=${ROOT_SSH_AUTHORIZED_KEYS@Q}

View File

@ -1,4 +1,3 @@
C.UTF-8 UTF-8
aa_DJ.UTF-8 UTF-8
aa_DJ ISO-8859-1
aa_ER UTF-8
@ -77,6 +76,7 @@ brx_IN UTF-8
bs_BA.UTF-8 UTF-8
bs_BA ISO-8859-2
byn_ER UTF-8
C.UTF-8 UTF-8
ca_AD.UTF-8 UTF-8
ca_AD ISO-8859-15
ca_ES.UTF-8 UTF-8

BIN
contrib/screenshot_configure.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 131 KiB

View File

@ -35,10 +35,10 @@ function disk_configuration() {
#
# Parameters:
# swap=<size> Create a swap partition with given size, or no swap
# at all if set to false
# at all if set to false.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
# luks=[true|false] Encrypt root partition. Defaults to false if not given.
# root_fs=[ext4|btrfs] Root filesystem
# root_fs=[ext4|btrfs] Root filesystem. Defaults to ext4 if not given.
#create_classic_single_disk_layout swap=8GiB type=efi luks=true root_fs=ext4 /dev/sdX
# 2. create_btrfs_centric_layout
@ -52,7 +52,7 @@ function disk_configuration() {
#
# Parameters:
# swap=<size> Create a swap partition with given size, or no swap
# at all if set to false
# at all if set to false.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
# encrypt=[true|false] Encrypt the zfs datasets. Defaults to false if not given.
# compress=[false|<compression>] Compress the zfs datasets. For valid values visit man zfsprops. Defaults to false if not given.
@ -68,13 +68,30 @@ function disk_configuration() {
#
# Parameters:
# swap=<size> Create a swap partition with given size for each disk,
# or no swap at all if set to false
# or no swap at all if set to false.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
# root_fs=[ext4|btrfs] Root filesystem
# luks=[true|false] Encrypt root partition. Defaults to true if not given.
# root_fs=[ext4|btrfs] Root filesystem. Defaults to ext4 if not given.
# Careful: You will get N times the swap amount, so be sure to divide beforehand.
#create_raid0_luks_layout swap=4GiB type=efi root_fs=ext4 /dev/sd{X,Y}
# 4. create_btrfs_centric_layout
# 4. create_raid1_luks_layout
#
# This layout creates the single disk layout on multiple disks and combines
# the swap and root partitions in separate raid1 arrays. Useful if you e.g. have
# several nvme drives and want data redundancy. Only one boot partition will actually
# be used though.
#
# Parameters:
# swap=<size> Create a swap partition with given size for each disk,
# or no swap at all if set to false.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
# luks=[true|false] Encrypt root partition. Defaults to true if not given.
# root_fs=[ext4|btrfs] Root filesystem. Defaults to ext4 if not given.
# Careful: You will get N times the swap amount, so be sure to divide beforehand.
#create_raid1_luks_layout swap=4GiB type=efi root_fs=ext4 /dev/sd{X,Y}
# 5. create_btrfs_centric_layout
#
# This layout is the same as the single_disk_layout, but uses btrfs as the root
# filesystem and allows you to put additional disks into the btrfs device pool.
@ -85,7 +102,7 @@ function disk_configuration() {
#
# Parameters:
# swap=<size> Create a swap partition with given size, or no swap
# at all if set to false
# at all if set to false.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
# luks=[true|false] Encrypt root partition and btrfs devices. Defaults
# to false if not given.
@ -171,8 +188,7 @@ function disk_configuration() {
HOSTNAME="gentoo"
# The timezone for the new system
TIMEZONE="Europe/London"
#TIMEZONE="Europe/Berlin"
TIMEZONE="Atlantic/Azores"
# The default keymap for the system
KEYMAP="us"
@ -183,29 +199,48 @@ KEYMAP_INITRAMFS="$KEYMAP"
# A list of additional locales to generate. You should only
# add locales here if you really need them and want to localize
# your system. Otherwise, leave this list empty, and use "C.utf8" as the locale.
# your system. Otherwise, leave this list empty, and use "C.UTF-8" as the locale.
# Be careful that the syntax for locales is a bit different from the name of the resulting
# locale. For a list of supported locales, see the file /usr/share/i18n/SUPPORTED.
LOCALES=""
# The locale to set for the system. Be careful, the locale names deviate from the LOCALES
# list entries (e.g. .UTF-8 vs .utf8). See `locale -a` for all available locales.
LOCALE="C.utf8"
# For a german system you could use:
# Although `locale -a` lists the suffix in lower case without any hyphens, it is best to always use UTF-8 in preference to utf8.
LOCALE="C.UTF-8"
# For a PT system you could use:
# LOCALES="
# de_DE.UTF-8 UTF-8
# de_DE ISO-8859-1
# de_DE@euro ISO-8859-15
# pt_PT.UTF-8 UTF-8
# pt_PT ISO-8859-1
# pt_PT@euro ISO-8859-15
# " # End of LOCALES
# LOCALE="de_DE.utf8"
# LOCALE="pt_PT.UTF-8"
################################################
# Network configuration
# The following network configuration only applies to systemd
# configurations and will otherwise be ignored. All OpenRC based
# configurations always just starts dhcpcd.
# Enable systemd-networkd to configure internet
SYSTEMD_NETWORKD=true
# The interfaces to match and configure (systemd [Match] -> Name)
SYSTEMD_NETWORKD_INTERFACE_NAME="en*"
# Whether to use DHCP (systemd [Network] -> DHCP)
SYSTEMD_NETWORKD_DHCP=true
# If DHCP is disabled, assign the given list of addresses including CIDR mask. (systemd [Network] -> Address)
SYSTEMD_NETWORKD_ADDRESSES=("192.168.1.100/32" "fd00::1/64")
# If DHCP is disabled, use the given gateway
SYSTEMD_NETWORKD_GATEWAY="192.168.1.1"
# Enable sshd in initramfs to allow unlocking encrypted devices / enter emergency shell if needed.
# Requires systemd. Visit https://github.com/gsauthof/dracut-sshd for more information.
SYSTEMD_INITRAMFS_SSHD=false
################################################
# Gentoo configuration
# Set to true if the stage3 tarball is based on systemd. In this case
# we need to use slightly different utilities to setup the base system.
SYSTEMD=true
# Choose whether to download the portage tree via git or rsync.
# Git syncing is significantly faster, and generally preferred for new installations.
PORTAGE_SYNC_TYPE="git"
@ -222,17 +257,22 @@ GENTOO_MIRROR="https://mirror.eu.oneandone.net/linux/distributions/gentoo/gentoo
# The architecture of the target system (only tested with amd64)
GENTOO_ARCH="amd64"
# The stage3 tarball to install
STAGE3_BASENAME="stage3-$GENTOO_ARCH-systemd"
#STAGE3_BASENAME="stage3-$GENTOO_ARCH-openrc"
#STAGE3_BASENAME="stage3-$GENTOO_ARCH-desktop-systemd"
#STAGE3_BASENAME="stage3-$GENTOO_ARCH-desktop-openrc"
# The stage3 tarball variant to use. Determines whether systemd
# or OpenRC is used based on whether "systemd" is contained in this string.
STAGE3_VARIANT="systemd"
# The stage3 tarball to download and bootstrap
STAGE3_BASENAME="stage3-$GENTOO_ARCH-$STAGE3_VARIANT"
# Automatically set to true, if the stage3 tarball is based on systemd. In this case
# we need to use slightly different utilities to setup the base system.
SYSTEMD=$([[ $STAGE3_VARIANT == *systemd* ]] && echo "true" || echo "false")
# Automatically set to true, if the stage3 tarball is based on musl.
MUSL=$([[ $STAGE3_VARIANT == *musl* ]] && echo "true" || echo "false")
# If set to true, the installer will add ACCEPT_KEYWORDS="~$GENTOO_ARCH"
# to /etc/portage/make.conf to enable packages in testing.
USE_PORTAGE_TESTING=true
# If set to true, the best best gentoo mirrors will be selected
# If set to true, the best gentoo mirrors will be selected
# automatically by app-portage/mirrorselect
SELECT_MIRRORS=true
@ -251,7 +291,10 @@ ADDITIONAL_PACKAGES=()
# Install and configure sshd (a reasonably secure config is provided, which
# only allows the use of ed25519 keys, and requires pubkey authentication)
INSTALL_SSHD=true
ENABLE_SSHD=true
# Enable binary portage packages where available
ENABLE_BINPKG=false
# An ssh key to add to the authorized_keys file for the root user.
# This variable will become the content of the authorized_keys file,
@ -265,3 +308,76 @@ ROOT_SSH_AUTHORIZED_KEYS=""
# To prove that you have read and edited the config
# properly, set the following value to true.
I_HAVE_READ_AND_EDITED_THE_CONFIG_PROPERLY=false
################################################
# Hooks
# before_prepare_environment() {
# einfo 'before prepare environment'
# }
# after_prepare_environment() {
# einfo 'after prepare environment'
# }
# before_disk_configuration() {
# einfo 'before disk configuration'
# }
# after_disk_configuration() {
# einfo 'after disk configuration'
# }
# before_download_stage3() {
# einfo "stage3 basename: $1"
# einfo 'before download stage3'
# }
# after_download_stage3() {
# einfo "stage3 downloaded file name: $1"
# einfo 'after download stage3'
# }
# before_extract_stage3() {
# einfo "stage3 downloaded file path: $1"
# einfo "root mountpoint: $1"
# einfo 'before extract stage3'
# }
# after_extract_stage3() {
# einfo "stage3 downloaded file path: $1"
# einfo "root mountpoint: $1"
# einfo 'after extract stage3'
# }
# before_install() {
# einfo 'before install'
# }
# after_install() {
# einfo 'after install'
# }
# before_configure_base_system() {
# einfo 'before configure base system'
# }
# after_configure_base_system() {
# einfo 'after configure base system'
# }
# before_configure_portage() {
# einfo 'before configure portage'
# }
# after_configure_portage() {
# einfo 'after configure portage'
# }
# before_install_kernel() {
# einfo 'before install kernel'
# }
# after_install_kernel() {
# einfo 'after install kernel'
# }

View File

@ -96,7 +96,7 @@ while [[ $# -gt 0 ]]; do
done
# Check configuration location
[[ -z "${CONFIG%%$GENTOO_INSTALL_REPO_DIR*}" ]] \
[[ -z "${CONFIG%%"$GENTOO_INSTALL_REPO_DIR"*}" ]] \
|| die "Configuration file must be inside the installation directory. This is needed so it is accessible from within the chroot environment."
if [[ -z "$ACTION" ]]; then
@ -104,7 +104,8 @@ if [[ -z "$ACTION" ]]; then
# Default if configuration exists: Run installer
ACTION="install"
else
# Default if configuration does not exists: Run configurator, and exit afterwards.
# Default if configuration does not exist: Run configurator, and exit afterwards.
echo "You have not created a gentoo.conf. Starting configurator instead of installing."
exec "$GENTOO_INSTALL_REPO_DIR/configure" "$CONFIG"
fi
fi

View File

@ -27,6 +27,8 @@ USED_ZFS=false
USED_BTRFS=false
# Flag to track usage of encryption
USED_ENCRYPTION=false
# Flag to track whether partitioning or formatting is forbidden
NO_PARTITIONING_OR_FORMATTING=false
# An array of disk related actions to perform
DISK_ACTIONS=()
@ -104,6 +106,21 @@ function verify_option() {
die_trace 2 "Invalid option $opt='$arg', must be one of ($*)"
}
# Named arguments:
# new_id: Id for the existing device
# device: The block device
function register_existing() {
local known_arguments=('+new_id' '+device')
local extra_arguments=()
declare -A arguments; parse_arguments "$@"
create_new_id new_id
local new_id="${arguments[new_id]}"
local device="${arguments[device]}"
create_resolve_entry_device "$new_id" "$device"
DISK_ACTIONS+=("action=existing" "$@" ";")
}
# Named arguments:
# new_id: Id for the new gpt table
# device|id: The operand block device or previously allocated id
@ -276,10 +293,10 @@ function expand_ids() {
# Single disk, 3 partitions (efi, swap, root)
# Parameters:
# swap=<size> Create a swap partition with given size, or no swap at all if set to false
# swap=<size> Create a swap partition with given size, or no swap at all if set to false.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
# luks=[true|false] Encrypt root partition. Defaults to false if not given.
# root_fs=[ext4|btrfs] Root filesystem
# root_fs=[ext4|btrfs] Root filesystem. Defaults to ext4 if not given.
function create_classic_single_disk_layout() {
local known_arguments=('+swap' '?type' '?luks' '?root_fs')
local extra_arguments=()
@ -294,7 +311,7 @@ function create_classic_single_disk_layout() {
local root_fs="${arguments[root_fs]:-ext4}"
create_gpt new_id=gpt device="$device"
create_partition new_id="part_$type" id=gpt size=512MiB type="$type"
create_partition new_id="part_$type" id=gpt size=1GiB type="$type"
[[ $size_swap != "false" ]] \
&& create_partition new_id=part_swap id=gpt size="$size_swap" type=swap
create_partition new_id=part_root id=gpt size=remaining type=linux
@ -334,10 +351,45 @@ function create_single_disk_layout() {
die "'create_single_disk_layout' is deprecated, please use 'create_classic_single_disk_layout' instead. It is fully option-compatible to the old version."
}
# Skip partitioning, and use existing pre-formatted partitions. These must be trivially mountable.
# Parameters:
# swap=<device|false> Use the given device as swap, or no swap at all if set to false.
# boot=<device> Use the given device as the bios/efi partition.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
function create_existing_partitions_layout() {
NO_PARTITIONING_OR_FORMATTING=true
local known_arguments=('+swap' '+boot' '?type')
local extra_arguments=()
declare -A arguments; parse_arguments "$@"
[[ ${#extra_arguments[@]} -eq 1 ]] \
|| die_trace 1 "Expected exactly one positional argument (the device)"
local device="${extra_arguments[0]}"
local swap_device="${arguments[swap]}"
local boot_device="${arguments[boot]}"
local type="${arguments[type]:-efi}"
register_existing new_id="part_$type" device="$boot_device"
[[ $swap_device != "false" ]] \
&& register_existing new_id="part_swap" device="$swap_device"
register_existing new_id="part_root" device="$device"
if [[ $type == "efi" ]]; then
DISK_ID_EFI="part_$type"
else
DISK_ID_BIOS="part_$type"
fi
[[ $swap_device != "false" ]] \
&& DISK_ID_SWAP=part_swap
DISK_ID_ROOT="part_root"
DISK_ID_ROOT_TYPE="" # unknown, could be anything. Left empty to skip generating an fstab entry.
}
# Multiple disks, up to 3 partitions on first disk (efi, optional swap, root with zfs).
# Additional devices will be added to the zfs pool.
# Parameters:
# swap=<size> Create a swap partition with given size, or no swap at all if set to false
# swap=<size> Create a swap partition with given size, or no swap at all if set to false.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
# encrypt=[true|false] Encrypt zfs pool. Defaults to false if not given.
# pool_type=[stripe|mirror] Select raid type. Defaults to stripe.
@ -356,7 +408,7 @@ function create_zfs_centric_layout() {
# Create layout on first disk
create_gpt new_id="gpt_dev0" device="${extra_arguments[0]}"
create_partition new_id="part_${type}_dev0" id="gpt_dev0" size=512MiB type="$type"
create_partition new_id="part_${type}_dev0" id="gpt_dev0" size=1GiB type="$type"
[[ $size_swap != "false" ]] \
&& create_partition new_id="part_swap_dev0" id="gpt_dev0" size="$size_swap" type=swap
create_partition new_id="part_root_dev0" id="gpt_dev0" size=remaining type=linux
@ -392,11 +444,12 @@ function create_zfs_centric_layout() {
# - swap: raid 0 → fs
# - root: raid 0 → luks → fs
# Parameters:
# swap=<size> Create a swap partition with given size for each disk, or no swap at all if set to false
# swap=<size> Create a swap partition with given size for each disk, or no swap at all if set to false.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
# root_fs=[ext4|btrfs] Root filesystem
# luks=[true|false] Encrypt root partition. Defaults to true if not given.
# root_fs=[ext4|btrfs] Root filesystem. Defaults to ext4 if not given.
function create_raid0_luks_layout() {
local known_arguments=('+swap' '?type' '?root_fs')
local known_arguments=('+swap' '?type' '?luks' '?root_fs')
local extra_arguments=()
declare -A arguments; parse_arguments "$@"
@ -404,11 +457,12 @@ function create_raid0_luks_layout() {
|| die_trace 1 "Expected at least one positional argument (the devices)"
local size_swap="${arguments[swap]}"
local type="${arguments[type]:-efi}"
local use_luks="${arguments[luks]:-true}"
local root_fs="${arguments[root_fs]:-ext4}"
for i in "${!extra_arguments[@]}"; do
create_gpt new_id="gpt_dev${i}" device="${extra_arguments[$i]}"
create_partition new_id="part_${type}_dev${i}" id="gpt_dev${i}" size=512MiB type="$type"
create_partition new_id="part_${type}_dev${i}" id="gpt_dev${i}" size=1GiB type="$type"
[[ $size_swap != "false" ]] \
&& create_partition new_id="part_swap_dev${i}" id="gpt_dev${i}" size="$size_swap" type=raid
create_partition new_id="part_root_dev${i}" id="gpt_dev${i}" size=remaining type=raid
@ -417,12 +471,17 @@ function create_raid0_luks_layout() {
[[ $size_swap != "false" ]] \
&& create_raid new_id=part_raid_swap name="swap" level=0 ids="$(expand_ids '^part_swap_dev[[:digit:]]$')"
create_raid new_id=part_raid_root name="root" level=0 ids="$(expand_ids '^part_root_dev[[:digit:]]$')"
create_luks new_id=part_luks_root name="root" id=part_raid_root
local root_id="part_raid_root"
if [[ "$use_luks" == "true" ]]; then
create_luks new_id=part_luks_root name="root" id=part_raid_root
root_id="part_luks_root"
fi
format id="part_${type}_dev0" type="$type" label="$type"
[[ $size_swap != "false" ]] \
&& format id=part_raid_swap type=swap label=swap
format id=part_luks_root type="$root_fs" label=root
format id="$root_id" type="$root_fs" label=root
if [[ $type == "efi" ]]; then
DISK_ID_EFI="part_${type}_dev0"
@ -431,12 +490,76 @@ function create_raid0_luks_layout() {
fi
[[ $size_swap != "false" ]] \
&& DISK_ID_SWAP=part_raid_swap
DISK_ID_ROOT=part_luks_root
DISK_ID_ROOT="$root_id"
if [[ $root_fs == "btrfs" ]]; then
DISK_ID_ROOT_TYPE="btrfs"
DISK_ID_ROOT_MOUNT_OPTS="defaults,noatime,compress=zstd,subvol=/root"
elif [[ $root_fs == "btrfs" ]]; then
elif [[ $root_fs == "ext4" ]]; then
DISK_ID_ROOT_TYPE="ext4"
DISK_ID_ROOT_MOUNT_OPTS="defaults,noatime,errors=remount-ro,discard"
else
die "Unsupported root filesystem type"
fi
}
# Multiple disks, with raid 1 and luks
# - efi: partition on all disks, but only first disk used
# - swap: raid 1 → fs
# - root: raid 1 → luks → fs
# Parameters:
# swap=<size> Create a swap partition with given size for each disk, or no swap at all if set to false.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
# luks=[true|false] Encrypt root partition. Defaults to true if not given.
# root_fs=[ext4|btrfs] Root filesystem. Defaults to ext4 if not given.
function create_raid1_luks_layout() {
local known_arguments=('+swap' '?type' '?luks' '?root_fs')
local extra_arguments=()
declare -A arguments; parse_arguments "$@"
[[ ${#extra_arguments[@]} -gt 0 ]] \
|| die_trace 1 "Expected at least one positional argument (the devices)"
local size_swap="${arguments[swap]}"
local type="${arguments[type]:-efi}"
local use_luks="${arguments[luks]:-true}"
local root_fs="${arguments[root_fs]:-ext4}"
for i in "${!extra_arguments[@]}"; do
create_gpt new_id="gpt_dev${i}" device="${extra_arguments[$i]}"
create_partition new_id="part_${type}_dev${i}" id="gpt_dev${i}" size=1GiB type="$type"
[[ $size_swap != "false" ]] \
&& create_partition new_id="part_swap_dev${i}" id="gpt_dev${i}" size="$size_swap" type=raid
create_partition new_id="part_root_dev${i}" id="gpt_dev${i}" size=remaining type=raid
done
[[ $size_swap != "false" ]] \
&& create_raid new_id=part_raid_swap name="swap" level=1 ids="$(expand_ids '^part_swap_dev[[:digit:]]$')"
create_raid new_id=part_raid_root name="root" level=1 ids="$(expand_ids '^part_root_dev[[:digit:]]$')"
local root_id="part_raid_root"
if [[ "$use_luks" == "true" ]]; then
create_luks new_id=part_luks_root name="root" id=part_raid_root
root_id="part_luks_root"
fi
format id="part_${type}_dev0" type="$type" label="$type"
[[ $size_swap != "false" ]] \
&& format id=part_raid_swap type=swap label=swap
format id="$root_id" type="$root_fs" label=root
if [[ $type == "efi" ]]; then
DISK_ID_EFI="part_${type}_dev0"
else
DISK_ID_BIOS="part_${type}_dev0"
fi
[[ $size_swap != "false" ]] \
&& DISK_ID_SWAP=part_raid_swap
DISK_ID_ROOT="$root_id"
if [[ $root_fs == "btrfs" ]]; then
DISK_ID_ROOT_TYPE="btrfs"
DISK_ID_ROOT_MOUNT_OPTS="defaults,noatime,compress=zstd,subvol=/root"
elif [[ $root_fs == "ext4" ]]; then
DISK_ID_ROOT_TYPE="ext4"
DISK_ID_ROOT_MOUNT_OPTS="defaults,noatime,errors=remount-ro,discard"
else
@ -447,7 +570,7 @@ function create_raid0_luks_layout() {
# Multiple disks, up to 3 partitions on first disk (efi, optional swap, root with btrfs).
# Additional devices will be first encrypted and then put directly into btrfs array.
# Parameters:
# swap=<size> Create a swap partition with given size, or no swap at all if set to false
# swap=<size> Create a swap partition with given size, or no swap at all if set to false.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
# luks=[true|false] Encrypt root partition and btrfs devices. Defaults to false if not given.
# raid_type=[raid0|raid1] Select raid type. Defaults to raid0.
@ -466,7 +589,7 @@ function create_btrfs_centric_layout() {
# Create layout on first disk
create_gpt new_id="gpt_dev0" device="${extra_arguments[0]}"
create_partition new_id="part_${type}_dev0" id="gpt_dev0" size=512MiB type="$type"
create_partition new_id="part_${type}_dev0" id="gpt_dev0" size=1GiB type="$type"
[[ $size_swap != "false" ]] \
&& create_partition new_id="part_swap_dev0" id="gpt_dev0" size="$size_swap" type=swap
create_partition new_id="part_root_dev0" id="gpt_dev0" size=remaining type=linux

View File

@ -64,35 +64,40 @@ function preprocess_config() {
}
function prepare_installation_environment() {
maybe_exec 'before_prepare_environment'
einfo "Preparing installation environment"
local needed_programs=(
local wanted_programs=(
gpg
hwclock
lsblk
ntpd
partprobe
python3
rhash
"?rhash"
sha512sum
sgdisk
uuidgen
wget
)
[[ $USED_BTRFS == "true" ]] \
&& needed_programs+=(btrfs)
&& wanted_programs+=(btrfs)
[[ $USED_ZFS == "true" ]] \
&& needed_programs+=(zfs)
&& wanted_programs+=(zfs)
[[ $USED_RAID == "true" ]] \
&& needed_programs+=(mdadm)
&& wanted_programs+=(mdadm)
[[ $USED_LUKS == "true" ]] \
&& needed_programs+=(cryptsetup)
&& wanted_programs+=(cryptsetup)
# Check for existence of required programs
check_has_programs "${needed_programs[@]}"
check_wanted_programs "${wanted_programs[@]}"
# Sync time now to prevent issues later
sync_time
maybe_exec 'after_prepare_environment'
}
function check_encryption_key() {
@ -163,6 +168,14 @@ function summary_color_args() {
done
}
function disk_existing() {
local new_id="${arguments[new_id]}"
if [[ ${disk_action_summarize_only-false} == "true" ]]; then
add_summary_entry __root__ "$new_id" "${arguments[device]}" "(no-format, existing)" ""
fi
# no-op;
}
function disk_create_gpt() {
local new_id="${arguments[new_id]}"
if [[ ${disk_action_summarize_only-false} == "true" ]]; then
@ -230,6 +243,18 @@ function disk_create_partition() {
sgdisk -n "0:0:$arg_size" -t "0:$type" -u "0:$partuuid" $extra_args "$device" >/dev/null \
|| die "Could not create new gpt partition ($new_id) on '$device' ($id)"
partprobe "$device"
# On some system, we need to wait a bit for the partition to show up.
local new_device
new_device="$(resolve_device_by_id "$new_id")" \
|| die "Could not resolve new device with id=$new_id"
for i in {1..10}; do
[[ -e "$new_device" ]] && break
[[ "$i" -eq 1 ]] && printf "Waiting for partition (%s) to appear..." "$new_device"
printf " %s" "$((10 - i + 1))"
sleep 1
[[ "$i" -eq 10 ]] && echo
done
}
function disk_create_raid() {
@ -266,12 +291,19 @@ function disk_create_raid() {
local mddevice="/dev/md/$name"
local uuid="${DISK_ID_TO_UUID[$new_id]}"
extra_args=()
if [[ ${level} == 1 ]]; then
extra_args+=("--metadata=1.0")
else
extra_args+=("--metadata=1.2")
fi
einfo "Creating raid$level ($new_id) on $devices_desc"
mdadm \
--create "$mddevice" \
--verbose \
--homehost="$HOSTNAME" \
--metadata=1.2 \
"${extra_args[@]}" \
--raid-devices="${#devices[@]}" \
--uuid="$uuid" \
--level="$level" \
@ -390,6 +422,9 @@ function disk_format() {
mkswap "$device" \
|| die "Could not format device '$device' ($id)"
fi
# Try to swapoff in case the system enabled swap automatically
swapoff "$device" &>/dev/null
;;
'ext4')
if [[ -v "arguments[label]" ]]; then
@ -430,12 +465,6 @@ function format_zfs_standard() {
einfo "Creating zfs pool on $devices_desc"
if [[ "$compress" != false ]]; then
extra_args+=(
"-O" "compression=$compress"
)
fi
local zfs_stdin=""
if [[ "$encrypt" == true ]]; then
extra_args+=(
@ -464,6 +493,10 @@ function format_zfs_standard() {
<<< "$zfs_stdin" \
|| die "Could not create zfs pool on $devices_desc"
if [[ "$compress" != false ]]; then
zfs set "compression=$compress" rpool \
|| die "Could enable compression on dataset 'rpool'"
fi
zfs create rpool/ROOT \
|| die "Could not create zfs dataset 'rpool/ROOT'"
zfs create -o mountpoint=/ rpool/ROOT/default \
@ -563,6 +596,7 @@ function apply_disk_action() {
unset known_arguments
unset arguments; declare -A arguments; parse_arguments "$@"
case "${arguments[action]}" in
'existing') disk_existing ;;
'create_gpt') disk_create_gpt ;;
'create_partition') disk_create_partition ;;
'create_raid') disk_create_raid ;;
@ -698,10 +732,22 @@ function summarize_disk_actions() {
function apply_disk_configuration() {
summarize_disk_actions
if [[ $NO_PARTITIONING_OR_FORMATTING == true ]]; then
elog "You have chosen an existing disk configuration. No devices will"
elog "actually be re-partitioned or formatted. Please make sure that all"
elog "devices are already formatted."
else
ewarn "Please ensure that all selected devices are fully unmounted and are"
ewarn "not otherwise in use by the system. This includes stopping mdadm arrays"
ewarn "and closing opened luks volumes if applicable for all relevant devices."
ewarn "Otherwise, automatic partitioning may fail."
fi
ask "Do you really want to apply this disk configuration?" \
|| die "Aborted"
countdown "Applying in " 5
maybe_exec 'before_disk_configuration'
einfo "Applying disk configuration"
apply_disk_actions
@ -709,6 +755,8 @@ function apply_disk_configuration() {
elog "New lsblk output:"
for_line_in <(lsblk \
|| die "Error in lsblk") elog
maybe_exec 'after_disk_configuration'
}
function mount_efivars() {
@ -770,7 +818,7 @@ function download_stage3() {
cd "$TMP_DIR" \
|| die "Could not cd into '$TMP_DIR'"
local STAGE3_RELEASES="$GENTOO_MIRROR/releases/amd64/autobuilds/current-$STAGE3_BASENAME/"
local STAGE3_RELEASES="$GENTOO_MIRROR/releases/$GENTOO_ARCH/autobuilds/current-$STAGE3_BASENAME/"
# Download upstream list of files
CURRENT_STAGE3="$(download_stdout "$STAGE3_RELEASES")" \
@ -786,13 +834,15 @@ function download_stage3() {
# File to indiciate successful verification
CURRENT_STAGE3_VERIFIED="${CURRENT_STAGE3}.verified"
maybe_exec 'before_download_stage3' "$STAGE3_BASENAME"
# Download file if not already downloaded
if [[ -e $CURRENT_STAGE3_VERIFIED ]]; then
einfo "$STAGE3_BASENAME tarball already downloaded and verified"
else
einfo "Downloading $STAGE3_BASENAME tarball"
download "$STAGE3_RELEASES/${CURRENT_STAGE3}" "${CURRENT_STAGE3}"
download "$STAGE3_RELEASES/${CURRENT_STAGE3}.asc" "${CURRENT_STAGE3}.asc"
download "$STAGE3_RELEASES/${CURRENT_STAGE3}.DIGESTS" "${CURRENT_STAGE3}.DIGESTS"
# Import gentoo keys
einfo "Importing gentoo gpg key"
@ -804,18 +854,26 @@ function download_stage3() {
# Verify DIGESTS signature
einfo "Verifying tarball signature"
gpg --quiet --verify "${CURRENT_STAGE3}.asc" \
|| die "Signature of '${CURRENT_STAGE3}.asc' invalid!"
gpg --quiet --verify "${CURRENT_STAGE3}.DIGESTS" \
|| die "Signature of '${CURRENT_STAGE3}.DIGESTS' invalid!"
# Check hashes
einfo "Verifying tarball integrity"
# Replace any absolute paths in the digest file with just the stage3 basename, so it will be found by rhash
rhash -P --check <(grep -B 1 'tar.xz$' "${CURRENT_STAGE3}.DIGESTS" | sed -e 's/ .*stage3-/ stage3-/') \
|| die "Checksum mismatch!"
digest_line=$(grep 'tar.xz$' "${CURRENT_STAGE3}.DIGESTS" | sed -e 's/ .*stage3-/ stage3-/')
if type rhash &>/dev/null; then
rhash -P --check <(echo "# SHA512"; echo "$digest_line") \
|| die "Checksum mismatch!"
else
sha512sum --check <<< "$digest_line" \
|| die "Checksum mismatch!"
fi
# Create verification file in case the script is restarted
touch_or_die 0644 "$CURRENT_STAGE3_VERIFIED"
fi
maybe_exec 'after_download_stage3' "${CURRENT_STAGE3}"
}
function extract_stage3() {
@ -826,6 +884,8 @@ function extract_stage3() {
[[ -e "$TMP_DIR/$CURRENT_STAGE3" ]] \
|| die "stage3 file does not exist"
maybe_exec 'before_extract_stage3' "$TMP_DIR/$CURRENT_STAGE3" "$ROOT_MOUNTPOINT"
# Go to root directory
cd "$ROOT_MOUNTPOINT" \
|| die "Could not move to '$ROOT_MOUNTPOINT'"
@ -840,6 +900,8 @@ function extract_stage3() {
|| die "Error while extracting tarball"
cd "$TMP_DIR" \
|| die "Could not cd into '$TMP_DIR'"
maybe_exec 'after_extract_stage3' "$TMP_DIR/$CURRENT_STAGE3" "$ROOT_MOUNTPOINT"
}
function gentoo_umount() {
@ -902,7 +964,12 @@ function gentoo_chroot() {
einfo "Mounting virtual filesystems"
(
mountpoint -q -- "$chroot_dir/proc" || mount -t proc /proc "$chroot_dir/proc" || exit 1
mountpoint -q -- "$chroot_dir/tmp" || mount --rbind /tmp "$chroot_dir/tmp" || exit 1
mountpoint -q -- "$chroot_dir/run" || {
mount --rbind /run "$chroot_dir/run" &&
mount --make-rslave "$chroot_dir/run"; } || exit 1
mountpoint -q -- "$chroot_dir/tmp" || {
mount --rbind /tmp "$chroot_dir/tmp" &&
mount --make-rslave "$chroot_dir/tmp"; } || exit 1
mountpoint -q -- "$chroot_dir/sys" || {
mount --rbind /sys "$chroot_dir/sys" &&
mount --make-rslave "$chroot_dir/sys"; } || exit 1
@ -925,10 +992,8 @@ function gentoo_chroot() {
function enable_service() {
if [[ $SYSTEMD == "true" ]]; then
systemctl enable "$1" \
|| die "Could not enable $1 service"
try systemctl enable "$1"
else
rc-update add "$1" default \
|| die "Could not add $1 to default services"
try rc-update add "$1" default
fi
}

View File

@ -6,8 +6,6 @@ source "$GENTOO_INSTALL_REPO_DIR/scripts/protection.sh" || exit 1
# Functions
function install_stage3() {
[[ $# == 0 ]] || die "Too many arguments"
prepare_installation_environment
apply_disk_configuration
download_stage3
@ -15,11 +13,19 @@ function install_stage3() {
}
function configure_base_system() {
einfo "Generating locales"
echo "$LOCALES" > /etc/locale.gen \
|| die "Could not write /etc/locale.gen"
locale-gen \
|| die "Could not generate locales"
if [[ $MUSL == "true" ]]; then
einfo "Installing musl-locales"
if [[ $USE_PORTAGE_TESTING == "false" ]]; then
echo "sys-apps/musl-locales" >> /etc/portage/package.accept_keywords/musl-locales
fi
try emerge --verbose sys-apps/musl-locales
else
einfo "Generating locales"
echo "$LOCALES" > /etc/locale.gen \
|| die "Could not write /etc/locale.gen"
locale-gen \
|| die "Could not generate locales"
fi
if [[ $SYSTEMD == "true" ]]; then
einfo "Setting machine-id"
@ -51,10 +57,19 @@ function configure_base_system() {
|| die "Could not sed replace in /etc/conf.d/hostname"
# Set timezone
einfo "Selecting timezone"
echo "$TIMEZONE" > /etc/timezone \
|| die "Could not write /etc/timezone"
try emerge -v --config sys-libs/timezone-data
if [[ $MUSL == "true" ]]; then
try emerge -v sys-libs/timezone-data
einfo "Selecting timezone"
echo -e "\nTZ=\"$TIMEZONE\"" >> /etc/env.d/00musl \
|| die "Could not write to /etc/env.d/00musl"
else
einfo "Selecting timezone"
echo "$TIMEZONE" > /etc/timezone \
|| die "Could not write /etc/timezone"
chmod 644 /etc/timezone \
|| die "Could not set correct permissions for /etc/timezone"
try emerge -v --config sys-libs/timezone-data
fi
# Set keymap
einfo "Selecting keymap"
@ -76,6 +91,7 @@ function configure_portage() {
touch_or_die 0644 "/etc/portage/package.use/zz-autounmask"
mkdir_or_die 0755 "/etc/portage/package.keywords"
touch_or_die 0644 "/etc/portage/package.keywords/zz-autounmask"
touch_or_die 0644 "/etc/portage/package.license"
if [[ $SELECT_MIRRORS == "true" ]]; then
einfo "Temporarily installing mirrorselect"
@ -88,22 +104,24 @@ function configure_portage() {
try mirrorselect "${mirrorselect_params[@]}"
fi
if [[ $USE_PORTAGE_TESTING == "true" ]]; then
einfo "Adding ~$GENTOO_ARCH to ACCEPT_KEYWORDS"
echo "ACCEPT_KEYWORDS=\"~$GENTOO_ARCH\"" >> /etc/portage/make.conf \
|| die "Could not modify /etc/portage/make.conf"
if [[ $ENABLE_BINPKG == "true" ]]; then
echo 'FEATURES="getbinpkg"' >> /etc/portage/make.conf
getuto
chmod 644 /etc/portage/gnupg/pubring.kbx
fi
chmod 644 /etc/portage/make.conf \
|| die "Could not chmod 644 /etc/portage/make.conf"
}
function install_sshd() {
einfo "Installing sshd"
function enable_sshd() {
einfo "Installing and enabling sshd"
install -m0600 -o root -g root "$GENTOO_INSTALL_REPO_DIR/contrib/sshd_config" /etc/ssh/sshd_config \
|| die "Could not install /etc/ssh/sshd_config"
enable_service sshd
}
function install_authorized_keys() {
mkdir_or_die 0700 "/root/"
mkdir_or_die 0700 "/root/.ssh"
@ -136,15 +154,29 @@ function generate_initramfs() {
|| die "Could not figure out kernel version from /usr/src/linux symlink."
kver="${kver#linux-}"
dracut_opts=()
if [[ $SYSTEMD == "true" && $SYSTEMD_INITRAMFS_SSHD == "true" ]]; then
cd /tmp || die "Could not change into /tmp"
try git clone https://github.com/gsauthof/dracut-sshd
try cp -r dracut-sshd/46sshd /usr/lib/dracut/modules.d
sed -e 's/^Type=notify/Type=simple/' \
-e 's@^\(ExecStart=/usr/sbin/sshd\) -D@\1 -e -D@' \
-i /usr/lib/dracut/modules.d/46sshd/sshd.service \
|| die "Could not replace sshd options in service file"
dracut_opts+=("--install" "/etc/systemd/network/20-wired.network")
modules+=("systemd-networkd")
fi
# Generate initramfs
# TODO --conf "/dev/null" \
# TODO --confdir "/dev/null" \
try dracut \
--conf "/dev/null" \
--confdir "/dev/null" \
--kver "$kver" \
--no-compress \
--zstd \
--no-hostonly \
--ro-mnt \
--add "bash ${modules[*]}" \
"${dracut_opts[@]}" \
--force \
"$output"
@ -152,17 +184,17 @@ function generate_initramfs() {
cat > "$(dirname "$output")/generate_initramfs.sh" <<EOF
#!/bin/bash
kver="\$1"
[[ -n "\$kver" ]] || { echo "usage \$0 <kernel_version>" >&2; exit 1; }
output="\$2" # At setup time, this was "$output"
[[ -n "\$kver" ]] || { echo "usage \$0 <kernel_version> <output>" >&2; exit 1; }
dracut \\
--conf "/dev/null" \\
--confdir "/dev/null" \\
--kver "\$kver" \\
--no-compress \\
--zstd \\
--no-hostonly \\
--ro-mnt \\
--add "bash ${modules[*]}" \\
${dracut_opts[@]@Q} \\
--force \\
"$output"
"\$output"
EOF
}
@ -182,11 +214,10 @@ function install_kernel_efi() {
# Copy kernel to EFI
local kernel_file
kernel_file="$(find "/boot" -name "vmlinuz-*" -printf '%f\n' | sort -V | tail -n 1)" \
kernel_file="$(find "/boot" \( -name "vmlinuz-*" -or -name 'kernel-*' \) -printf '%f\n' | sort -V | tail -n 1)" \
|| die "Could not list newest kernel file"
cp "/boot/$kernel_file" "/boot/efi/vmlinuz.efi" \
|| die "Could not copy kernel to EFI partition"
try cp "/boot/$kernel_file" "/boot/efi/vmlinuz.efi"
# Generate initramfs
generate_initramfs "/boot/efi/initramfs.img"
@ -198,15 +229,26 @@ function install_kernel_efi() {
|| die "Could not resolve device with id=$DISK_ID_EFI"
efipartdev="$(realpath "$efipartdev")" \
|| die "Error in realpath '$efipartdev'"
local efipartnum="${efipartdev: -1}"
local sys_efipart
sys_efipart="/sys/class/block/$(basename "$efipartdev")" \
|| die "Could not construct /sys path to efi partition"
local efipartnum
efipartnum="$(cat "$sys_efipart/partition")" \
|| die "Failed to find partition number for EFI partition $efipartdev"
local gptdev
gptdev="$(resolve_device_by_id "${DISK_ID_PART_TO_GPT_ID[$DISK_ID_EFI]}")" \
|| die "Could not resolve device with id=${DISK_ID_PART_TO_GPT_ID[$DISK_ID_EFI]}"
gptdev="/dev/$(basename "$(readlink -f "$sys_efipart/..")")" \
|| die "Failed to find parent device for EFI partition $efipartdev"
if [[ ! -e "$gptdev" ]] || [[ -z "$gptdev" ]]; then
gptdev="$(resolve_device_by_id "${DISK_ID_PART_TO_GPT_ID[$DISK_ID_EFI]}")" \
|| die "Could not resolve device with id=${DISK_ID_PART_TO_GPT_ID[$DISK_ID_EFI]}"
fi
try efibootmgr --verbose --create --disk "$gptdev" --part "$efipartnum" --label "gentoo" --loader '\vmlinuz.efi' --unicode 'initrd=\initramfs.img'" $(get_cmdline)"
# Create script to repeat adding efibootmgr entry
cat > "/boot/efi/efibootmgr_add_entry.sh" <<EOF
#!/bin/bash
# This is the command that was used to create the efibootmgr entry when the
# system was installed using gentoo-install.
efibootmgr --verbose --create --disk "$gptdev" --part "$efipartnum" --label "gentoo" --loader '\\vmlinuz.efi' --unicode 'initrd=\\initramfs.img'" $(get_cmdline)"
EOF
}
@ -228,11 +270,10 @@ function install_kernel_bios() {
# Link kernel to known name
local kernel_file
kernel_file="$(find "/boot" -name "vmlinuz-*" -printf '%f\n' | sort -V | tail -n 1)" \
kernel_file="$(find "/boot" \( -name "vmlinuz-*" -or -name 'kernel-*' \) -printf '%f\n' | sort -V | tail -n 1)" \
|| die "Could not list newest kernel file"
cp "/boot/$kernel_file" "/boot/bios/vmlinuz-current" \
|| die "Could copy kernel to /boot/bios/vmlinuz-current"
try cp "/boot/$kernel_file" "/boot/bios/vmlinuz-current"
# Generate initramfs
generate_initramfs "/boot/bios/initramfs.img"
@ -260,13 +301,17 @@ function install_kernel_bios() {
function install_kernel() {
# Install vanilla kernel
einfo "Installing vanilla kernel and related tools"
try emerge --verbose sys-kernel/dracut sys-kernel/gentoo-kernel-bin
if [[ $IS_EFI == "true" ]]; then
install_kernel_efi
else
install_kernel_bios
fi
einfo "Installing linux-firmware"
echo "sys-kernel/linux-firmware linux-fw-redistributable no-source-code" >> /etc/portage/package.license \
|| die "Could not write to /etc/portage/package.license"
try emerge --verbose linux-firmware
}
function add_fstab_entry() {
@ -278,7 +323,7 @@ function generate_fstab() {
einfo "Generating fstab"
install -m0644 -o root -g root "$GENTOO_INSTALL_REPO_DIR/contrib/fstab" /etc/fstab \
|| die "Could not overwrite /etc/fstab"
if [[ $USED_ZFS != "true" ]]; then
if [[ $USED_ZFS != "true" && -n $DISK_ID_ROOT_TYPE ]]; then
add_fstab_entry "UUID=$(get_blkid_uuid_for_id "$DISK_ID_ROOT")" "/" "$DISK_ID_ROOT_TYPE" "$DISK_ID_ROOT_MOUNT_OPTS" "0 1"
fi
if [[ $IS_EFI == "true" ]]; then
@ -294,6 +339,8 @@ function generate_fstab() {
function main_install_gentoo_in_chroot() {
[[ $# == 0 ]] || die "Too many arguments"
maybe_exec 'before_install'
# Remove the root password, making the account accessible for automated
# tasks during the period of installation.
einfo "Clearing root password"
@ -316,9 +363,12 @@ function main_install_gentoo_in_chroot() {
try emerge-webrsync
# Configure basic system things like timezone, locale, ...
maybe_exec 'before_configure_base_system'
configure_base_system
maybe_exec 'after_configure_base_system'
# Prepare portage environment
maybe_exec 'before_configure_portage'
configure_portage
# Install git (for git portage overlays)
@ -346,6 +396,21 @@ EOF
|| die "Could not delete obsolete rsync gentoo repository"
try emerge --sync
fi
maybe_exec 'after_configure_portage'
einfo "Generating ssh host keys"
try ssh-keygen -A
# Install authorized_keys before dracut, which might need them for remote unlocking.
install_authorized_keys
einfo "Enabling dracut USE flag on sys-kernel/installkernel"
echo "sys-kernel/installkernel dracut" > /etc/portage/package.use/installkernel \
|| die "Could not write /etc/portage/package.use/installkernel"
# Install required programs and kernel now, in order to
# prevent emerging module before an imminent kernel upgrade
try emerge --verbose sys-kernel/dracut sys-kernel/gentoo-kernel-bin app-arch/zstd
# Install mdadm if we used raid (needed for uuid resolving)
if [[ $USED_RAID == "true" ]]; then
@ -359,12 +424,22 @@ EOF
try emerge --verbose sys-fs/cryptsetup
fi
if [[ $SYSTEMD == "true" && $USED_LUKS == "true" ]] ; then
einfo "Enabling cryptsetup USE flag on sys-apps/systemd"
echo "sys-apps/systemd cryptsetup" > /etc/portage/package.use/systemd \
|| die "Could not write /etc/portage/package.use/systemd"
einfo "Rebuilding systemd with changed USE flag"
try emerge --verbose --changed-use --oneshot sys-apps/systemd
fi
# Install btrfs-progs if we used btrfs
if [[ $USED_BTRFS == "true" ]]; then
einfo "Installing btrfs-progs"
try emerge --verbose sys-fs/btrfs-progs
fi
try emerge --verbose dev-vcs/git
# Install zfs kernel module and tools if we used zfs
if [[ $USED_ZFS == "true" ]]; then
einfo "Installing zfs"
@ -372,18 +447,20 @@ EOF
einfo "Enabling zfs services"
if [[ $SYSTEMD == "true" ]]; then
systemctl enable zfs.target || die "Could not enable zfs.target service"
systemctl enable zfs-import-cache || die "Could not enable zfs-import-cache service"
systemctl enable zfs-mount || die "Could not enable zfs-mount service"
systemctl enable zfs-import.target || die "Could not enable zfs-import.target service"
try systemctl enable zfs.target
try systemctl enable zfs-import-cache
try systemctl enable zfs-mount
try systemctl enable zfs-import.target
else
rc-update add zfs-import boot || die "Could not add zfs-import to boot services"
rc-update add zfs-mount boot || die "Could not add zfs-mount to boot services"
try rc-update add zfs-import boot
try rc-update add zfs-mount boot
fi
fi
# Install kernel and initramfs
maybe_exec 'before_install_kernel'
install_kernel
maybe_exec 'after_install_kernel'
# Generate a valid fstab file
generate_fstab
@ -392,12 +469,28 @@ EOF
einfo "Installing gentoolkit"
try emerge --verbose app-portage/gentoolkit
# Install and enable sshd
if [[ $INSTALL_SSHD == "true" ]]; then
install_sshd
fi
if [[ $SYSTEMD != "true" ]]; then
if [[ $SYSTEMD == "true" ]]; then
if [[ $SYSTEMD_NETWORKD == "true" ]]; then
# Enable systemd networking and dhcp
enable_service systemd-networkd
enable_service systemd-resolved
if [[ $SYSTEMD_NETWORKD_DHCP == "true" ]]; then
echo -en "[Match]\nName=${SYSTEMD_NETWORKD_INTERFACE_NAME}\n\n[Network]\nDHCP=yes" > /etc/systemd/network/20-wired.network \
|| die "Could not write dhcp network config to '/etc/systemd/network/20-wired.network'"
else
addresses=""
for addr in "${SYSTEMD_NETWORKD_ADDRESSES[@]}"; do
addresses="${addresses}Address=$addr\n"
done
echo -en "[Match]\nName=${SYSTEMD_NETWORKD_INTERFACE_NAME}\n\n[Network]\n${addresses}Gateway=$SYSTEMD_NETWORKD_GATEWAY" > /etc/systemd/network/20-wired.network \
|| die "Could not write dhcp network config to '/etc/systemd/network/20-wired.network'"
fi
chown root:systemd-network /etc/systemd/network/20-wired.network \
|| die "Could not change owner of '/etc/systemd/network/20-wired.network'"
chmod 640 /etc/systemd/network/20-wired.network \
|| die "Could not change permissions of '/etc/systemd/network/20-wired.network'"
fi
else
# Install and enable dhcpcd
einfo "Installing dhcpcd"
try emerge --verbose net-misc/dhcpcd
@ -405,16 +498,8 @@ EOF
enable_service dhcpcd
fi
if [[ $SYSTEMD == "true" ]]; then
# Enable systemd networking and dhcp
enable_service systemd-networkd
enable_service systemd-resolved
echo -en "[Match]\nName=en*\n\n[Network]\nDHCP=yes" > /etc/systemd/network/20-wired-dhcp.network \
|| die "Could not write dhcp network config to '/etc/systemd/network/20-wired-dhcp.network'"
chown root:systemd-network /etc/systemd/network/20-wired-dhcp.network \
|| die "Could not change owner of '/etc/systemd/network/20-wired-dhcp.network'"
chmod 640 /etc/systemd/network/20-wired-dhcp.network \
|| die "Could not change permissions of '/etc/systemd/network/20-wired-dhcp.network'"
if [[ $ENABLE_SSHD == "true" ]]; then
enable_sshd
fi
# Install additional packages, if any.
@ -432,10 +517,22 @@ EOF
ewarn "Root password cleared, set one as soon as possible!"
fi
# If configured, change to gentoo testing at the last moment.
# This is to ensure a smooth installation process. You can deal
# with the blockers after installation ;)
if [[ $USE_PORTAGE_TESTING == "true" ]]; then
einfo "Adding ~$GENTOO_ARCH to ACCEPT_KEYWORDS"
echo "ACCEPT_KEYWORDS=\"~$GENTOO_ARCH\"" >> /etc/portage/make.conf \
|| die "Could not modify /etc/portage/make.conf"
fi
maybe_exec 'after_install'
einfo "Gentoo installation complete."
[[ $USED_LUKS == "true" ]] \
&& einfo "A backup of your luks headers can be found at '$LUKS_HEADER_BACKUP_DIR', in case you want to have a backup."
einfo "You may now reboot your system."
einfo "You may now reboot your system or execute ./install --chroot $ROOT_MOUNTPOINT to enter your system in a chroot."
einfo "Chrooting in this way is always possible in case you need to fix something after rebooting."
}
function main_install() {

View File

@ -239,6 +239,25 @@ function create_resolve_entry_device() {
DISK_ID_TO_RESOLVABLE[$id]="device:$dev"
}
# Returns the basename of the device, if its path starts with /dev/disk/by-id/
function shorten_device() {
echo -n "${1#/dev/disk/by-id/}"
}
# Return matching device from /dev/disk/by-id/ if possible,
# otherwise return the parameter unchanged.
function canonicalize_device() {
given_dev="$(realpath "$1")"
for dev in /dev/disk/by-id/*; do
if [[ "$(realpath "$dev")" == "$given_dev" ]]; then
echo -n "$dev"
return 0
fi
done
echo -n "$1"
}
function resolve_device_by_id() {
local id="$1"
[[ -v DISK_ID_TO_RESOLVABLE[$id] ]] \
@ -247,15 +266,18 @@ function resolve_device_by_id() {
local type="${DISK_ID_TO_RESOLVABLE[$id]%%:*}"
local arg="${DISK_ID_TO_RESOLVABLE[$id]#*:}"
local dev
case "$type" in
'partuuid') get_device_by_partuuid "$arg" ;;
'ptuuid') get_device_by_ptuuid "$arg" ;;
'uuid') get_device_by_uuid "$arg" ;;
'mdadm') get_device_by_mdadm_uuid "$arg" ;;
'luks') get_device_by_luks_name "$arg" ;;
'device') echo -n "$arg" ;;
'partuuid') dev=$(get_device_by_partuuid "$arg") ;;
'ptuuid') dev=$(get_device_by_ptuuid "$arg") ;;
'uuid') dev=$(get_device_by_uuid "$arg") ;;
'mdadm') dev=$(get_device_by_mdadm_uuid "$arg") ;;
'luks') dev=$(get_device_by_luks_name "$arg") ;;
'device') dev="$arg" ;;
*) die "Cannot resolve '$type:$arg' to device (unknown type)"
esac
canonicalize_device "$dev"
}
function load_or_generate_uuid() {
@ -329,31 +351,55 @@ function parse_arguments() {
fi
}
function check_has_programs() {
local failed=()
# $1: program
# $2: checkfile
function has_program() {
local program="$1"
local checkfile="$2"
if [[ -z "$checkfile" ]]; then
type "$program" &>/dev/null \
|| return 1
elif [[ "${checkfile:0:1}" == "/" ]]; then
[[ -e "$checkfile" ]] \
|| return 1
else
type "$checkfile" &>/dev/null \
|| return 1
fi
return 0
}
function check_wanted_programs() {
local missing_required=()
local missing_wanted=()
local tuple
local program
local checkfile
for tuple in "$@"; do
program="${tuple%%=*}"
checkfile="${tuple##*=}"
if [[ -z "$checkfile" ]]; then
type "$program" &>/dev/null \
|| failed+=("$program")
elif [[ "${checkfile:0:1}" == "/" ]]; then
[[ -e "$checkfile" ]] \
|| failed+=("$program")
else
type "$checkfile" &>/dev/null \
|| failed+=("$program")
checkfile=""
[[ "$tuple" == *=* ]] \
&& checkfile="${tuple##*=}"
if ! has_program "${program#"?"}" "$checkfile"; then
if [[ "$program" == "?"* ]]; then
missing_wanted+=("${program#"?"}")
else
missing_required+=("$program")
fi
fi
done
[[ "${#failed[@]}" -eq 0 ]] \
[[ "${#missing_required[@]}" -eq 0 && "${#missing_wanted[@]}" -eq 0 ]] \
&& return
elog "The following programs are required for the installer to work, but are currently missing on your system:" >&2
elog " ${failed[*]}" >&2
if [[ "${#missing_required[@]}" -gt 0 ]]; then
elog "The following programs are required for the installer to work, but are currently missing on your system:" >&2
elog " ${missing_required[*]}" >&2
fi
if [[ "${#missing_wanted[@]}" -gt 0 ]]; then
elog "Missing optional programs:" >&2
elog " ${missing_wanted[*]}" >&2
fi
if type pacman &>/dev/null; then
declare -A pacman_packages
@ -361,18 +407,18 @@ function check_has_programs() {
[ntpd]=ntp
[zfs]=""
)
elog "We have detected that pacman is available."
if ask "Do you want to install the missing programs automatically?"; then
elog "Detected pacman package manager."
if ask "Do you want to install all missing programs automatically?"; then
local packages
local need_zfs=false
for program in "${failed[@]}"; do
for program in "${missing_required[@]}" "${missing_wanted[@]}"; do
[[ "$program" == "zfs" ]] \
&& need_zfs=true
if [[ -v "pacman_packages[$program]" ]]; then
# Assignments to the empty string are explcitly ignored,
# as for example zfs needs to be handeled separately.
# Assignments to the empty string are explicitly ignored,
# as for example, zfs needs to be handled separately.
[[ -n "${pacman_packages[$program]}" ]] \
&& packages+=("${pacman_packages[$program]}")
else
@ -383,9 +429,9 @@ function check_has_programs() {
if [[ "$need_zfs" == true ]]; then
elog "On an Arch live-stick you need the archzfs repository and some tools and modifications to use zfs."
elog "There is an automated installer available at https://eoli3n.github.io/archzfs/init."
elog "There is an automated installer available at https://raw.githubusercontent.com/eoli3n/archiso-zfs/master/init."
if ask "Do you want to automatically download and execute this zfs installation script?"; then
curl -s "https://eoli3n.github.io/archzfs/init" | bash
curl -s "https://raw.githubusercontent.com/eoli3n/archiso-zfs/master/init" | bash
fi
fi
@ -393,5 +439,15 @@ function check_has_programs() {
fi
fi
die "Aborted installer because of missing required programs."
if [[ "${#missing_required[@]}" -gt 0 ]]; then
die "Aborted installer because of missing required programs."
else
ask "Continue without recommended programs?"
fi
}
# exec function if defined
# $@ function name and arguments
function maybe_exec() {
type "$1" &>/dev/null && "$@"
}