File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 247247# Unmount
248248umount /mnt/rootfs
249249
250+ # Fix ownership to match the calling user
251+ if [ -n "$HOST_UID" ] && [ -n "$HOST_GID" ]; then
252+ chown "$HOST_UID:$HOST_GID" /output/rootfs.ext4
253+ fi
254+
250255echo "Conversion complete"
251256"# ,
252257 size_mb = size_mb
253258 ) ;
254259
260+ // Get the current user's UID and GID for ownership fix
261+ let uid = std:: process:: id ( ) ;
262+ let gid = Command :: new ( "id" )
263+ . arg ( "-g" )
264+ . output ( )
265+ . map ( |o| String :: from_utf8_lossy ( & o. stdout ) . trim ( ) . to_string ( ) )
266+ . unwrap_or_else ( |_| uid. to_string ( ) ) ;
267+
255268 // Get absolute paths for mounts
256269 let image_tar_abs = image_tar
257270 . canonicalize ( )
@@ -275,6 +288,10 @@ echo "Conversion complete"
275288 "run" ,
276289 "--rm" ,
277290 "--privileged" ,
291+ "-e" ,
292+ & format ! ( "HOST_UID={}" , uid) ,
293+ "-e" ,
294+ & format ! ( "HOST_GID={}" , gid) ,
278295 "-v" ,
279296 & format ! ( "{}:/input/image.tar:ro" , image_tar_abs. display( ) ) ,
280297 "-v" ,
You can’t perform that action at this time.
0 commit comments