@@ -48,13 +48,13 @@ impl ReinstallOptsArgs {
4848 let image = if let Some ( image) = self . image {
4949 image
5050 } else {
51- os_release:: get_bootc_image_from_file ( ETC_OS_RELEASE )
52- . ok ( )
53- . flatten ( )
54- . or_else ( || {
55- os_release:: get_bootc_image_from_file ( USR_LIB_OS_RELEASE )
51+ [ ETC_OS_RELEASE , USR_LIB_OS_RELEASE ]
52+ . iter ( )
53+ . find_map ( |path| {
54+ os_release:: get_bootc_image_from_file ( path)
5655 . ok ( )
5756 . flatten ( )
57+ . filter ( |s| !s. is_empty ( ) )
5858 } )
5959 . ok_or_else ( || {
6060 anyhow:: anyhow!(
@@ -72,6 +72,8 @@ impl ReinstallOptsArgs {
7272
7373#[ context( "run" ) ]
7474fn run ( ) -> Result < ( ) > {
75+ let args = ReinstallOptsArgs :: parse ( ) ;
76+
7577 // We historically supported an environment variable providing a config to override the image, so
7678 // keep supporting that. I'm considering deprecating that though.
7779 let opts = if let Some ( config) = config:: ReinstallConfig :: load ( ) . context ( "loading config" ) ? {
@@ -81,7 +83,7 @@ fn run() -> Result<()> {
8183 }
8284 } else {
8385 // Otherwise an image is specified via the CLI or fallback to the os-release
84- ReinstallOptsArgs :: parse ( ) . build ( ) ?
86+ args . build ( ) ?
8587 } ;
8688
8789 bootc_utils:: initialize_tracing ( ) ;
@@ -117,7 +119,7 @@ fn run() -> Result<()> {
117119 let host_root_keys = std:: path:: Path :: new ( "/root/.ssh/authorized_keys" ) ;
118120 if host_root_keys. exists ( ) {
119121 println ! ( "Detected cloud-init and host keys. Inheriting keys automatically." ) ;
120- ssh_key_file_path = Some ( "/target/root/.ssh/authorized_keys" . to_string ( ) ) ;
122+ ssh_key_file_path = Some ( host_root_keys . to_string_lossy ( ) . into_owned ( ) ) ;
121123 } else {
122124 println ! ( "Detected cloud-init. Proceeding without host key inheritance." ) ;
123125 }
0 commit comments