1- use std:: fs;
1+ use std:: fs:: { self , Permissions } ;
22use std:: io:: { BufReader , Read , Write } ;
33use std:: path:: { Path , PathBuf } ;
44
@@ -8,7 +8,7 @@ use image::{GenericImageView, ImageFormat, ImageReader};
88use crate :: actions:: { Archiver , CommandRunner , Extractor } ;
99use crate :: config:: Config ;
1010use crate :: { actions, appimage, config, console, files} ;
11- use crate :: console:: { exit_err, print_note, print_significant, print_step, print_step_verbose, print_success, print_warn} ;
11+ use crate :: console:: { exit_err, print_note, print_significant, print_step, print_step_verbose, print_success, print_warn, CommandLineSettings } ;
1212use crate :: deps:: Dependency ;
1313use crate :: project_config:: { self , Package } ;
1414use crate :: deps;
@@ -440,6 +440,26 @@ fn build_linux() {
440440
441441 print_step ( "Embedding created SquashFS into the AppImage" ) ;
442442 appimage:: embed_squashfs ( & app_img, & new_squashfs) ;
443+
444+ #[ cfg( target_family = "unix" ) ]
445+ apply_exec_perms ( & cmd_conf, & app_img) . unwrap_or_else ( |err| {
446+ print_warn ( format ! ( "Failed to assign executable permission: {}" , err) ) ;
447+ } ) ;
448+ }
449+
450+ #[ cfg( target_family = "unix" ) ]
451+ fn apply_exec_perms ( cmd_conf : & CommandLineSettings , exe : & PathBuf ) -> Result < ( ) , String > {
452+ use std:: os:: unix:: fs:: PermissionsExt ;
453+
454+ print_step_verbose ( & cmd_conf, "Assigning exec permissions" ) ;
455+
456+ let meta = fs:: metadata ( & exe) . map_err ( |err| err. to_string ( ) ) ?;
457+ let mut perms = meta. permissions ( ) ;
458+ perms. set_mode ( perms. mode ( ) | 0o755 ) ;
459+
460+ fs:: set_permissions ( & exe, perms) . map_err ( |err| err. to_string ( ) ) ?;
461+
462+ Ok ( ( ) )
443463}
444464
445465fn build_win64 ( ) {
0 commit comments