@@ -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
}
@@ -1826,6 +1853,7 @@ fn setup_composefs_boot(root_setup: &RootSetup, state: &State, image_id: &str) -
1826
1853
signature : None ,
1827
1854
} ,
1828
1855
false ,
1856
+ composefs_opts. boot ,
1829
1857
) ?;
1830
1858
1831
1859
Ok ( ( ) )
@@ -1836,13 +1864,17 @@ pub(crate) const COMPOSEFS_STAGED_DEPLOYMENT_PATH: &str = "/run/composefs/staged
1836
1864
/// Relative to /sysroot
1837
1865
pub ( crate ) const STATE_DIR_RELATIVE : & str = "state/deploy" ;
1838
1866
1867
+ pub ( crate ) const ORIGIN_KEY_BOOT : & str = "boot" ;
1868
+ pub ( crate ) const ORIGIN_KEY_BOOT_TYPE : & str = "boot_type" ;
1869
+
1839
1870
/// Creates and populates /sysroot/state/deploy/image_id
1840
1871
#[ context( "Writing composefs state" ) ]
1841
1872
pub ( crate ) fn write_composefs_state (
1842
1873
root_path : & Utf8PathBuf ,
1843
1874
deployment_id : Sha256HashValue ,
1844
1875
imgref : & ImageReference ,
1845
1876
staged : bool ,
1877
+ boot_type : BootType ,
1846
1878
) -> Result < ( ) > {
1847
1879
let state_path = root_path. join ( format ! ( "{STATE_DIR_RELATIVE}/{}" , deployment_id. to_hex( ) ) ) ;
1848
1880
@@ -1861,11 +1893,15 @@ pub(crate) fn write_composefs_state(
1861
1893
..
1862
1894
} = & imgref;
1863
1895
1864
- let config = tini:: Ini :: new ( ) . section ( "origin" ) . item (
1896
+ let mut config = tini:: Ini :: new ( ) . section ( "origin" ) . item (
1865
1897
ORIGIN_CONTAINER ,
1866
- format ! ( "ostree-unverified-image:{transport}: {image_name}" ) ,
1898
+ format ! ( "ostree-unverified-image:{transport}{image_name}" ) ,
1867
1899
) ;
1868
1900
1901
+ config = config
1902
+ . section ( ORIGIN_KEY_BOOT )
1903
+ . item ( ORIGIN_KEY_BOOT_TYPE , boot_type) ;
1904
+
1869
1905
let mut origin_file =
1870
1906
std:: fs:: File :: create ( state_path. join ( format ! ( "{}.origin" , deployment_id. to_hex( ) ) ) )
1871
1907
. context ( "Failed to open .origin file" ) ?;
0 commit comments