1
1
use anyhow:: Result ;
2
- use camino:: Utf8Path ;
2
+ use camino:: { Utf8Path , Utf8PathBuf } ;
3
3
use fn_error_context:: context;
4
4
5
5
use crate :: blockdev:: PartitionTable ;
6
6
use crate :: task:: Task ;
7
7
8
8
/// The name of the mountpoint for efi (as a subdirectory of /boot, or at the toplevel)
9
9
pub ( crate ) const EFI_DIR : & str = "efi" ;
10
+ pub ( crate ) const PREPBOOT_GUID : & str = "9E1A2D38-C612-4316-AA26-8B49521E5A8B" ;
11
+ pub ( crate ) const PREPBOOT_LABEL : & str = "PowerPC-PReP-boot" ;
12
+
13
+ /// Find the device to pass to bootupd. Only on powerpc64 right now
14
+ /// we explicitly find one with a specific label.
15
+ ///
16
+ /// This should get fixed once we execute on https://github.com/coreos/bootupd/issues/432
17
+ fn get_bootupd_device ( device : & PartitionTable ) -> Result < Utf8PathBuf > {
18
+ #[ cfg( target_arch = "powerpc64" ) ]
19
+ {
20
+ return device
21
+ . partitions
22
+ . iter ( )
23
+ . find ( |p| p. parttype . as_str ( ) == PREPBOOT_GUID )
24
+ . ok_or_else ( || {
25
+ anyhow:: anyhow!( "Failed to find PReP partition with GUID {PREPBOOT_GUID}" )
26
+ } )
27
+ . map ( |dev| dev. node . as_str ( ) . into ( ) ) ;
28
+ }
29
+ #[ cfg( not( target_arch = "powerpc64" ) ) ]
30
+ return Ok ( device. path ( ) . into ( ) ) ;
31
+ }
10
32
11
33
#[ context( "Installing bootloader" ) ]
12
34
pub ( crate ) fn install_via_bootupd (
@@ -17,7 +39,8 @@ pub(crate) fn install_via_bootupd(
17
39
let verbose = std:: env:: var_os ( "BOOTC_BOOTLOADER_DEBUG" ) . map ( |_| "-vvvv" ) ;
18
40
// bootc defaults to only targeting the platform boot method.
19
41
let bootupd_opts = ( !configopts. generic_image ) . then_some ( [ "--update-firmware" , "--auto" ] ) ;
20
- let devpath = device. path ( ) ;
42
+
43
+ let devpath = get_bootupd_device ( device) ?;
21
44
let args = [ "backend" , "install" , "--write-uuid" ]
22
45
. into_iter ( )
23
46
. chain ( verbose)
0 commit comments