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