@@ -4,7 +4,7 @@ use std::{
44 self ,
55 consts:: { ARCH , OS } ,
66 } ,
7- fs:: { self , File } ,
7+ fs,
88 io:: { BufRead , BufReader } ,
99 os:: unix:: fs:: symlink,
1010 path:: { Path , PathBuf } ,
@@ -14,13 +14,11 @@ use std::{
1414 time:: Duration ,
1515} ;
1616
17- use goblin:: elf:: Elf ;
18- use memmap2:: Mmap ;
1917use sbuild_linter:: {
2018 build_config:: BuildConfig , license:: License , logger:: TaskLogger , BuildAsset , Linter ,
2119} ;
2220use squishy:: {
23- appimage:: { get_offset, is_static_appimage , AppImage } ,
21+ appimage:: { get_offset, AppImage } ,
2422 EntryKind ,
2523} ;
2624
@@ -31,7 +29,9 @@ use crate::{
3129 SVG_MAGIC_BYTES , XML_MAGIC_BYTES ,
3230 } ,
3331 types:: { OutputStream , PackageType , SoarEnv } ,
34- utils:: { calc_magic_bytes, download, extract_filename, pack_appimage, temp_file} ,
32+ utils:: {
33+ calc_magic_bytes, download, extract_filename, is_static_elf, pack_appimage, temp_file,
34+ } ,
3535} ;
3636
3737pub struct BuildContext {
@@ -443,12 +443,7 @@ impl Builder {
443443
444444 self . setup_cmd_logging ( & mut child) ;
445445
446- let status = child. wait ( ) . unwrap ( ) ;
447- if !status. success ( ) {
448- self . logger
449- . error ( format ! ( "Build failed with status: {}" , status) ) ;
450- return false ;
451- }
446+ let _ = child. wait ( ) . unwrap ( ) ;
452447
453448 if let Some ( entrypoint) = build_config
454449 . x_exec
@@ -632,17 +627,23 @@ impl Builder {
632627 None
633628 } ;
634629
635- let is_static = is_static_appimage ( & provide_path) . unwrap ( ) ;
636630 let offset = get_offset ( & provide_path) . unwrap ( ) ;
637- if !is_static {
631+
632+ if !is_static_elf ( & provide_path) {
638633 self . logger . info ( format ! (
639634 "{} -> Dynamic AppImage. Attempting to convert it to static." ,
640635 & provide_path. display( )
641636 ) ) ;
642637 let tmp_path = "SBUILD_TEMP/squashfs_tmp/" ;
643638 let file_path = & provide_path. to_string_lossy ( ) . to_string ( ) ;
644639 let env_vars = context. env_vars ( & self . soar_env . bin_path ) ;
645- let mut child = Command :: new ( "unsquashfs" )
640+
641+ let Ok ( usqfs) = which:: which ( "unsquashfs" ) else {
642+ self . logger . error ( "unsquashfs not found." ) ;
643+ std:: process:: exit ( 1 ) ;
644+ } ;
645+
646+ let mut child = Command :: new ( usqfs)
646647 . env_clear ( )
647648 . envs ( env_vars. clone ( ) )
648649 . args ( [
@@ -665,7 +666,6 @@ impl Builder {
665666 std:: process:: exit ( 1 ) ;
666667 }
667668 if !pack_appimage ( env_vars, tmp_path, & file_path, & self . logger ) {
668- self . logger . error ( "Failed to pack appimage" ) ;
669669 std:: process:: exit ( 1 ) ;
670670 } ;
671671 self . logger . info ( format ! (
@@ -745,14 +745,10 @@ impl Builder {
745745 } else if magic_bytes[ 4 ..8 ] == FLATIMAGE_MAGIC_BYTES {
746746 self . pkg_type = PackageType :: FlatImage
747747 } else if magic_bytes[ ..4 ] == ELF_MAGIC_BYTES {
748- let file = File :: open ( provide_path) . unwrap ( ) ;
749- let mmap = unsafe { Mmap :: map ( & file) . unwrap ( ) } ;
750- let elf = Elf :: parse ( & mmap) . unwrap ( ) ;
751-
752- self . pkg_type = if elf. interpreter . is_some ( ) {
753- PackageType :: Dynamic
754- } else {
748+ self . pkg_type = if is_static_elf ( & provide_path) {
755749 PackageType :: Static
750+ } else {
751+ PackageType :: Dynamic
756752 } ;
757753 } ;
758754
0 commit comments