Commit Graph

428 Commits

Author SHA1 Message Date
nl6720
a0941539c0
Move SYSLINUX directory from /syslinux/ to /boot/syslinux/
This allows to reduce the number of top-level directories by one and
matches with the GRUB directory move.

Most boot loader related things will now be in the /boot/ directory.

Fixes #207
2023-02-24 10:33:37 +02:00
nl6720
c8474f8dbe
Move the .uuid file to /boot/grub/YYYY-mm-dd-HH-MM-SS-00.uuid
To prevent the file from being accidentally missed when someone copies
the ISO's contents, let's not place it in a directory that starts with a
dot. Since all GRUB related files are in /boot/grub/, put it there too.

Instead of using a more unique UUID for the file name, use
`YYYY-mm-dd-HH-MM-SS-00.uuid` which matches the ISO's modification date
in UTC,i.e. its "UUID". If multiple ISOs would be generated in the exact
same second, the ISO 9660 modification date (i.e. its "UUID") would be
the same, so there would be not way to distinguish between the volumes
anyway. This also makes the file look less suspicious to the casual
glance.
2023-02-24 10:22:41 +02:00
nl6720
d96a356995
mkarchiso: write grubenv in _make_common_bootmode_grub_cfg
Add all variables that we replace with values in configuration files.

Keep `${isofs_dir}/${install_dir}/grubenv` with fewer variables for
backwards compatibility. It will be removed in the future.
2023-02-24 10:22:36 +02:00
nl6720
b94d7c4ce5
Move grub files from /EFI/BOOT/ to /boot/grub/ on ISO 9660
Move the location of GRUB files so that there is boot-platform
(BIOS vs EFI) neutral place for GRUB-specific files (e.g. configuration
files, background images, etc.).

The EFI binaries are obviosly staying in the default/fallback boot path
`/EFI/BOOT/BOOT*.EFI`, otherwise there will be no UEFI booting.

The /boot/grub/ directory will be used to store BIOS (i386-pc) GRUB
bootsector images, if we get to that.

It is also a requirement for implementing `loopback.cfg` support, since
the file's path must be `/boot/grub/loopback.cfg`.

Implements #206
2023-02-22 18:28:27 +02:00
nl6720
f5ade898f9
Do not duplicate grub.cfg in efiboot.img
Instruct the embeded grub.cfg to search for a volume with a
`/.disk/%UUID_SEARCH_FILENAME%.uuid` file and load `/EFI/BOOT/grub.cfg`
from it.

This avoid duplicating GRUB configuration files in two places (ISO 9660
and FAT) and ensures there is no confusion about which is the _correct_
configuration file.

Since nothing besides EFI binaries is copied to `efibootimg`, the
`_make_common_bootmode_grub_copy_to_efibootimg` function is removed.

Fixes #208
2023-02-22 18:28:24 +02:00
nl6720
40e09767f0
mkarchiso: add more details to the comment in grub-embed.cfg
Link to the upstream issue report.
2023-02-22 18:27:45 +02:00
nl6720
28d2bc11e3
mkarchiso: do not place memtest86+ in netboot artifacts
Move memtest86+ to `/boot/memtest86+/` on ISO 9660. That directory is
not copied to netboot artifact output.

Netboot boot menu https://ipxe.archlinux.org/releng/netboot/archlinux.ipxe
does not have entries for memtest and archiso-manager removes these files
(not the EFI one, though) before uploading the release files anyway.
2023-02-10 08:29:37 +02:00
nl6720
5587e031f3
Preload GRUB's NTFS, exFAT and UDF modules
There are claims that some UEFI allegedly natively support NTFS.
Preload the required GRUB modules to support booting from NTFS on such
systems.

Additionally preload the exFAT and UEF modules, because, why not?
2023-02-02 11:49:16 +02:00
nl6720
8d7ad3c629
mkarchiso: write a .uuid file to /.disk/ on ISO 9660 to allow GRUB to search for it
Create a `/.disk/INSERT_UUID_HERE.uuid` file to implement something
called "file system transposition".
See https://www.mail-archive.com/grub-devel@gnu.org/msg34346.html for
the proposal of it for grub-mkrescue.

This will allow GRUB to search for the volume containing the file instead
of hardcoding the ISO volume label or another file system or
partition attribute in GRUB configuration.
By only relying on the directory structure simplifies supporting medium
preparation methods with manual partitioning such as
https://wiki.archlinux.org/title/USB_flash_installation_medium#In_GNU/Linux_4
2023-02-02 11:49:15 +02:00
Christian Hesse
6e1be91961 archiso/mkarchiso: write "uninitialized" to /etc/machine-id
This is a new value introduced in systemd v247. It makes sure a new
machine-id is generated, but is handled as first boot as well.

See "First Boot Semantics" in machine-id(5) for details.
2022-12-22 16:41:07 +01:00
nl6720
2da65f64ad
mkarchiso: check if the code signing files specified with option -c exist
Look for the files in `*_validate_options` and error out early if they do
not exist.
2022-12-10 12:08:50 +02:00
nl6720
2c3420204e
mkarchiso: open the ARCHISO_GNUPG_FD, ARCHISO_TLS_FD and ARCHISO_TLSCA_FD file descriptors only for reading
Nothing should ever be written to these files, so let's make sure it cannot happen.
2022-12-06 13:12:53 +02:00
nl6720
d31f38843a
mkarchiso: do not try to use an non existent GPG public key file
The `bootstrap` build mode never calls `_export_gpg_publickey`, so even if
the GPG key is passed with the `-g` option and thus the `gpg_key` variable
is set, the `${work_dir}/pubkey.gpg` file will not exist.
This has not caused any issue so far because the `ARCHISO_GNUPG_FD` file
descriptor opens the file for both reading and writing, which means the
file gets created if it does not exist.

Assign the exported public key file name to a `gpg_publickey` variable in
`_export_gpg_publickey` and check for it when the file is used.

Since the exist status of the gpg command cannot be checked, look for the
exported public key file instead.
2022-12-06 12:55:13 +02:00
nl6720
4ee6fdc1ea
mkarchiso: disable shellcheck warning when searching an array
The warning about SC2076 does not apply here.
2022-12-06 12:27:35 +02:00
Jonathan Liu
9d391c0925 Add Memtest86+ to x86_64 UEFI GRUB boot menu
Implements #203.
2022-12-03 20:56:18 +11:00
nl6720
11971619a6
mkarchiso: do not sign .sig files
Make sure existing sig files are deleted before creating new ones and make sure to not sign any sig files.

This allows retrying failed mkarchiso runs without ending up with files such as vmlinuz.ipxe.sig.ipxe.sig.

Fixes #198
2022-10-13 13:37:14 +03:00
Anton Hvornum
326cfed7cc
Add the ability to generate rootfs signatures using openssl CMS module if `-c` is given.
(gitlab ci)

Added a CA structure to the codesigning certificates.
This to test the functionality of optional CA being in the signing message.

(mkarchiso)
Removed the ``sign_netboot_artifacts`` variable and instead
we'll now rely on ``if [[ -v cert_list ]]; then``.

Added ``ARCHISO_TLS_FD`` and ``ARCHISO_TLSCA_FD`` environment variables
to override the certificates used. This is so that third party CA's can
be used during building in a meaningful way without distrupting the
CA trust that is shipped by default.

_cms_sign_artifact() was added which signs the rootfs using OpenSSL CMS.
The files will be saved as "${artifact}.cms.sig". That would be for instance
"${isofs_dir}/${install_dir}/${arch}/airootfs.sfs.cms.sig".
2022-09-25 19:54:41 +02:00
Christian Hesse
aef242720d mkarchiso: touch clock-epoch for extra hint on date and time
This helps on systems with screwed or broken RTC.
2022-08-26 14:46:59 +02:00
nl6720
7bc4c54245
mkarchiso: preload more GRUB modules and disable shim_lock verifier
--disable-shim-lock is required to support Secure Boot with custom signatures without using shim.
Otherwise GRUB will trow an error when trying to boot a kernel:

    error: shim_lock protocol not found.
    error: you need to load the kernel first.

The modules GRUB will use need to be preloaded otherwise the EFI binaries cannot be signed and used for Secure Boot.
See https://bugs.archlinux.org/task/71382.
GRUB will trow en error:

    error: verification requested but nobody cares

These changes are done to support Secure Boot using custom keys (not shim) by simply extracting the boot loader
(BOOTx64.EFI and BOOTIA32.EFI), kernel, UEFI shell, signing them and then repacking the ISO.

For example.
Extract the files:

    $ osirrox -indev archlinux-YYYY.MM.DD-x86_64.iso \
        -extract_boot_images ./ \
        -extract /EFI/BOOT/BOOTx64.EFI BOOTx64.EFI \
        -extract /EFI/BOOT/BOOTIA32.EFI BOOTIA32.EFI \
        -extract /shellx64.efi shellx64.efi \
        -extract /shellia32.efi shellia32.efi \
        -extract /arch/boot/x86_64/vmlinuz-linux vmlinuz-linux

Make the files writable:

    $ chmod +w BOOTx64.EFI BOOTIA32.EFI shellx64.efi shellia32.efi vmlinuz-linux

Sign the files:

    $ sbsign --key db.key --cert db.crt --output BOOTx64.EFI BOOTx64.EFI
    $ sbsign --key db.key --cert db.crt --output BOOTIA32.EFI BOOTIA32.EFI
    $ sbsign --key db.key --cert db.crt --output shellx64.efi shellx64.efi
    $ sbsign --key db.key --cert db.crt --output shellia32.efi shellia32.efi
    $ sbsign --key db.key --cert db.crt --output vmlinuz-linux vmlinuz-linux

Copy the boot loader and UEFI shell to the EFI system partition image:

    $ mcopy -D oO -i eltorito_img2_uefi.img BOOTx64.EFI BOOTIA32.EFI ::/EFI/BOOT/
    $ mcopy -D oO -i eltorito_img2_uefi.img shellx64.efi shellia32.efi ::/

Repack the ISO using the modified El Torito UEFI boot image and add the signed boot loader files, UEFI shell and
kernel to ISO9660:

    $ xorriso -indev archlinux-YYYY.MM.DD-x86_64.iso \
        -outdev archlinux-YYYY.MM.DD-x86_64-Secure_Boot.iso \
        -boot_image any replay \
        -append_partition 2 0xef eltorito_img2_uefi.img \
        -map BOOTx64.EFI /EFI/BOOT/BOOTx64.EFI \
        -map BOOTIA32.EFI /EFI/BOOT/BOOTIA32.EFI \
        -map shellx64.efi /shellx64.efi \
        -map shellia32.efi /shellia32.efi \
        -map vmlinuz-linux /arch/boot/x86_64/vmlinuz-linux

Boot the resulting archlinux-YYYY.MM.DD-x86_64-Secure_Boot.iso.
2022-08-19 10:22:40 +03:00
nl6720
b13e5e3379
mkarchiso: copy all GRUB files to the ISO
Do not limit file copying to only grub.cfg and instead copy all GRUB configuration files and assets to both the ISO9660 and FAT image.
This will allow for including custom images, fonts, etc.

To easily match all non-configuration files (i.e. files without the .cfg extension), bash's extended glob feature will be enabled.
Actions common to multiple _make_bootmode_uefi-*.grub are split off into dedicated functions:

* _make_common_bootmode_grub_copy_to_efibootimg,
* _make_common_bootmode_grub_copy_to_isofs,
* _make_common_bootmode_grub_cfg.

Use the same du command in all efiboot_imgsize variable assignments.

Fixes #185.
2022-08-17 17:24:01 +03:00
nl6720
6ac2230953
mkarchiso: unset LANGUAGE
LC_ALL=C.UTF-8, unlike LC_ALL=C, does not override LANGUAGE.
See https://sourceware.org/bugzilla/show_bug.cgi?id=16621 and https://savannah.gnu.org/bugs/?62815
2022-08-07 16:16:52 +03:00
Pellegrino Prevete
211572dda2
Add efibootimg variable in place of full path
Update authors

Update CHANGELOG
2022-07-16 12:02:53 +00:00
nl6720
fda1907581
mkarchiso: work arround GRUB's cmdpath having incorect case on some firmware
Fixes #183
2022-06-24 10:38:27 +03:00
nl6720
53a3ad25af
mkarchiso: add SBAT metadata to grub-mkstandalone created EFI binaries
Even though archiso created ISOs do not support Secure Boot, having SBAT would allow users to more easily repack the files in the ISO to add a signed shim.

Fixes #174
2022-06-18 09:59:19 +03:00
nl6720
91b48f82f3
mkarchiso: improve comments
* Fix typos and wording,
* Remove impossible TODO.
2022-06-18 09:53:21 +03:00
plainlinen
550b5be07d Add *_uefi-x64.grub.* functions to mkarchiso 2022-06-09 22:37:10 -07:00
nl6720
de151089ce
mkarchiso: use C.UTF-8
The glibc 2.35-6 package ships with the C.UTF-8 locale included, so mkarchiso does not need to use a non-UTF-8 locale anymore.

Implements #175.
2022-06-09 08:31:41 +03:00
Pellegrino Prevete
2b7e1b4a28
Add support for GRUB ia32 UEFI in mkarchiso, update READMEs. 2022-05-25 14:49:02 +00:00
weltio weltio
742619240c https://gitlab.archlinux.org/archlinux/archiso/-/issues/163 2022-01-21 09:49:49 +00:00
hayao
025d6b828f mkarchiso: Fix mmd-command check
valication_error variable is not changed when mmd and/or mcopy are missing.
2022-01-08 02:18:09 +00:00
nl6720
dae5494ca1
mkarchiso: show "Code signing certificates: None" if no keys/certificates are specified
Fixes #151.
2021-12-10 13:15:13 +02:00
nl6720
a7f879fcdd
mkarchiso: use mkfs.erofs --quiet in quiet mode
erofs-utils 1.4 introduced a --quiet option.

Related to #148.
2021-11-22 12:04:35 +02:00
nl6720
8cfe29043f
mkarchiso: use mksquashfs -quiet instead of redirecting its stdout to /dev/null
mksquashfs supports a -quiet option since squashfs-tools 4.4.
Use this option in non-verbose mode instead of redirecting stdout of the whole command to /dev/null.

This allows to have only one instance of mksquashfs in _run_mksquashfs instead of multiple ones in if-then-else.

Related to #148.
2021-11-05 13:01:28 +02:00
nl6720
009140bd8b
mkarchiso: do not show subdirectory sizes in netboot mode
Only the total size is relevant.

Related to #148.
2021-11-05 12:44:03 +02:00
nl6720
5738f40aa9
mkarchiso: redirect command -v output to /dev/null
The output is irrelevant, we only need the return code.

Related to #148.
2021-11-05 12:44:01 +02:00
nl6720
ad6d65ab87
mkarchiso: silence xorriso's note about SOURCE_DATE_EPOCH
The `xorriso -as mkisofs` option `-quiet` is interpreted too late. Use native xorriso option `-report_about SORRY` instead and ensure it is the first option.

Related to #148.
2021-11-05 12:43:48 +02:00
nl6720
d2addb25c9
mkarchiso: silence mkfs.fat in quiet mode
mkfs.fat does not have a -q/--quiet option, so redirect its stdout to /dev/null instead.
See https://github.com/dosfstools/dosfstools/issues/103 .

Related to #148.
2021-11-04 07:58:12 +02:00
nl6720
662027ef80
mkarchiso: do not require setting boot modes when building only netboot artifacts
netboot does not need any of the boot loaders or their files.

Fixes #150.
2021-11-02 21:10:07 +02:00
nl6720
f8862c2621
mkarchiso: replace external date command with printf
printf is a bash builtin, so by using it an external command can be avoided.
Due to the differences between date(1) and strftime(3), the time zone output will not contain a colon anymore. Fortunately, that is still a supported format according to https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC .
2021-11-02 20:57:47 +02:00
nl6720
d2315bc98d
mkarchiso: error out of iso and netboot build modes if no boot modes are specified 2021-08-25 00:29:35 +03:00
nl6720
f3959d6ef0
mkarchiso: split out build mode specific checks from _validate_options to _validate_requirements_buildmode_*
The bootstrap build mode does not use packages.${arch}, ${bootmodes[@]} or $airootfs_image_type so there's no need to validate them.
Requirements common to iso and netboot are checked with the _validate_common_requirements_buildmode_iso_netboot function.

Fixes #149.

* Rename _validate_requirements_buildmode_all to _validate_common_requirements_buildmode_all to prevent potential conflicts since we are using _validate_requirements_buildmode_${_buildmode} to run the functions.
* Improve searching in an array. See https://stackoverflow.com/a/15394738.
2021-08-25 00:29:35 +03:00
nl6720
8d18d8f745
mkarchiso: fix unbound variable errors in _validate_options
$pkg_list_from_file and $bootstrap_pkg_list_from_file are arrays, they must be referenced as such. Fixes https://bugs.archlinux.org/task/71852.

Remove quotes from arithmetic expressions.
2021-08-25 00:29:35 +03:00
nl6720
59dffcf11a
mkarchiso: support setting gpg sender
Add new -G option to set gpg's --sender. This allows to see who signed the rootfs image without needing to import the gpg key from the keyring in initramfs.
2021-08-25 00:26:07 +03:00
nl6720
ea9572b98e
mkarchiso: add some sane gpg options to override those set in user's gpg.conf
* Add --batch, since gpg is run in a script.
* Add --no-armor (this is the default). Armored output provides no benifit here.
* Add --no-include-key-block (this is the default). There is no need to have the gpg key in the signature. The mkinitcpio hook will verify the signature against the included keyring.

Remove the output files before running gpg. Otherwise gpg --batch will fail if they exist.
2021-08-25 00:26:07 +03:00
nl6720
0a58431dde
mkarchiso: put version files in netboot artifacts
Fixes #147.
2021-08-24 23:47:00 +03:00
nl6720
b040ef1774
mkarchiso: ensure there are no existing image files before trying to create them
This could prevent a few issues when creating an image file when re-running mkarchiso after a failure.

Remove useless test before running rm -f. The command will always succeed.
2021-08-15 16:39:55 +03:00
nl6720
6185448477
mkarchiso: copy files to ext4 image using mkfs.ext4's -d option instead of mounting the file system
mkfs.ext4 with its -d option can "copy the contents of the given directory into the root directory of the filesystem".
This allows to get rid of the last directly used mount and umount commands in mkarchiso.

Additionally try to make the ext4 image somewhat reproducible by setting E2FSPROGS_FAKE_TIME to SOURCE_DATE_EPOCH, clearing the UUID and using a reproducible hash seed.
See https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/commit/?id=e1f7100643a46456be107b33098f6034b0835e6d .

Place mkfs.ext4 options in an array to avoid duplicating the command.

Related to #40.
2021-08-15 16:37:13 +03:00
David Runge
75d36d2124
Remove mkinitcpio-archiso files
archiso/initcpio/*:
Remove mkinitcpio-archiso scripts as they have been split out into a separate project.

docs/README.{altbootmethods,bootparams}:
Remove mkinitcpio-archiso specific documentation.
2021-07-31 16:58:57 +02:00
David Runge
0fa1c0e945
mkarchiso: Do not run _build_iso_base once
archiso/mkarchiso:
Do not run `_build_iso_base` with `_run_once`, as it sets variables which are important to functions that are called
after it.
2021-07-30 15:48:09 +02:00
nl6720
610ff2ac26
mkarchiso: improve functions and comments
* Merge _make_efi_dir_on_iso9660 into _make_bootmode_uefi-x64.systemd-boot.eltorito since it's specific to that boot mode.
* Split off FAT image creation into _make_efibootimg, so it can be reused by other functions.
* Add/improve comments to better document what the script does.
2021-07-29 17:12:47 +03:00