@@ -48,7 +48,8 @@ use ostree_ext::composefs::{
48
48
util:: Sha256Digest ,
49
49
} ;
50
50
use ostree_ext:: composefs_boot:: {
51
- bootloader:: BootEntry , write_boot:: write_boot_simple as composefs_write_boot_simple, BootOps ,
51
+ bootloader:: BootEntry as ComposefsBootEntry ,
52
+ write_boot:: write_boot_simple as composefs_write_boot_simple, BootOps ,
52
53
} ;
53
54
use ostree_ext:: composefs_oci:: {
54
55
image:: create_filesystem as create_composefs_filesystem, pull as composefs_oci_pull,
@@ -66,6 +67,7 @@ use ostree_ext::{
66
67
use rustix:: fs:: FileTypeExt ;
67
68
use rustix:: fs:: MetadataExt as _;
68
69
use serde:: { Deserialize , Serialize } ;
70
+ use schemars:: JsonSchema ;
69
71
70
72
#[ cfg( feature = "install-to-disk" ) ]
71
73
use self :: baseline:: InstallBlockDeviceOpts ;
@@ -236,20 +238,45 @@ pub(crate) struct InstallConfigOpts {
236
238
pub ( crate ) stateroot : Option < String > ,
237
239
}
238
240
239
- #[ derive( ValueEnum , Debug , Copy , Clone , PartialEq , Eq , Serialize , Deserialize , Default ) ]
240
- pub ( crate ) enum BootType {
241
+ #[ derive(
242
+ ValueEnum , Debug , Copy , Clone , PartialEq , Eq , Serialize , Deserialize , Default , JsonSchema ,
243
+ ) ]
244
+ pub enum BootType {
241
245
#[ default]
242
246
Bls ,
243
247
Uki ,
244
248
}
245
249
246
- impl From < & BootEntry < Sha256HashValue > > for BootType {
247
- fn from ( entry : & BootEntry < Sha256HashValue > ) -> Self {
250
+ impl :: std:: fmt:: Display for BootType {
251
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
252
+ let s = match self {
253
+ BootType :: Bls => "bls" ,
254
+ BootType :: Uki => "uki" ,
255
+ } ;
256
+
257
+ write ! ( f, "{}" , s)
258
+ }
259
+ }
260
+
261
+ impl TryFrom < & str > for BootType {
262
+ type Error = anyhow:: Error ;
263
+
264
+ fn try_from ( value : & str ) -> std:: result:: Result < Self , Self :: Error > {
265
+ match value {
266
+ "bls" => Ok ( Self :: Bls ) ,
267
+ "uki" => Ok ( Self :: Uki ) ,
268
+ unrecognized => Err ( anyhow:: anyhow!( "Unrecognized boot option: '{unrecognized}'" ) ) ,
269
+ }
270
+ }
271
+ }
272
+
273
+ impl From < & ComposefsBootEntry < Sha256HashValue > > for BootType {
274
+ fn from ( entry : & ComposefsBootEntry < Sha256HashValue > ) -> Self {
248
275
match entry {
249
- BootEntry :: Type1 ( ..) => Self :: Bls ,
250
- BootEntry :: Type2 ( ..) => Self :: Uki ,
251
- BootEntry :: UsrLibModulesUki ( ..) => Self :: Uki ,
252
- BootEntry :: UsrLibModulesVmLinuz ( ..) => Self :: Bls ,
276
+ ComposefsBootEntry :: Type1 ( ..) => Self :: Bls ,
277
+ ComposefsBootEntry :: Type2 ( ..) => Self :: Uki ,
278
+ ComposefsBootEntry :: UsrLibModulesUki ( ..) => Self :: Uki ,
279
+ ComposefsBootEntry :: UsrLibModulesVmLinuz ( ..) => Self :: Bls ,
253
280
}
254
281
}
255
282
}
@@ -1828,6 +1855,7 @@ fn setup_composefs_boot(root_setup: &RootSetup, state: &State, image_id: &str) -
1828
1855
signature : None ,
1829
1856
} ,
1830
1857
false ,
1858
+ composefs_opts. boot ,
1831
1859
) ?;
1832
1860
1833
1861
Ok ( ( ) )
@@ -1838,13 +1866,17 @@ pub(crate) const COMPOSEFS_STAGED_DEPLOYMENT_PATH: &str = "/run/composefs/staged
1838
1866
/// Relative to /sysroot
1839
1867
pub ( crate ) const STATE_DIR_RELATIVE : & str = "state/deploy" ;
1840
1868
1869
+ pub ( crate ) const ORIGIN_KEY_BOOT : & str = "boot" ;
1870
+ pub ( crate ) const ORIGIN_KEY_BOOT_TYPE : & str = "boot_type" ;
1871
+
1841
1872
/// Creates and populates /sysroot/state/deploy/image_id
1842
1873
#[ context( "Writing composefs state" ) ]
1843
1874
pub ( crate ) fn write_composefs_state (
1844
1875
root_path : & Utf8PathBuf ,
1845
1876
deployment_id : Sha256HashValue ,
1846
1877
imgref : & ImageReference ,
1847
1878
staged : bool ,
1879
+ boot_type : BootType ,
1848
1880
) -> Result < ( ) > {
1849
1881
let state_path = root_path. join ( format ! ( "{STATE_DIR_RELATIVE}/{}" , deployment_id. to_hex( ) ) ) ;
1850
1882
@@ -1863,11 +1895,15 @@ pub(crate) fn write_composefs_state(
1863
1895
..
1864
1896
} = & imgref;
1865
1897
1866
- let config = tini:: Ini :: new ( ) . section ( "origin" ) . item (
1898
+ let mut config = tini:: Ini :: new ( ) . section ( "origin" ) . item (
1867
1899
ORIGIN_CONTAINER ,
1868
- format ! ( "ostree-unverified-image:{transport}: {image_name}" ) ,
1900
+ format ! ( "ostree-unverified-image:{transport}{image_name}" ) ,
1869
1901
) ;
1870
1902
1903
+ config = config
1904
+ . section ( ORIGIN_KEY_BOOT )
1905
+ . item ( ORIGIN_KEY_BOOT_TYPE , boot_type) ;
1906
+
1871
1907
let mut origin_file =
1872
1908
std:: fs:: File :: create ( state_path. join ( format ! ( "{}.origin" , deployment_id. to_hex( ) ) ) )
1873
1909
. context ( "Failed to open .origin file" ) ?;
0 commit comments