diff options
-rwxr-xr-x | abuild.in | 50 |
1 files changed, 32 insertions, 18 deletions
@@ -483,10 +483,38 @@ prepare_tracedeps() { done } +# check if dir has arch specific binaries +dir_has_arch_binaries() { + local dir="$1" + # if scanelf returns something, then we have binaries + [ -n "$(scanelf -R "$dir" | head -n 1)" ] && return 0 + + # look for static *.a + [ -n "$(find "$dir" -type f -name '*.a' | head -n 1)" ] && return 0 + + return 1 +} + +# check that noarch is set if needed +archcheck() { + options_has "!archcheck" && return 0 + if dir_has_arch_binaries "${subpkgdir:-$pkgdir}"; then + [ "$arch" != "noarch" ] && return 0 + error "Arch specific binaries found so arch must not be set to \"noarch\"" + return 1 + else + [ "$arch" = "noarch" ] && return 0 + error "No arch specific binaries found so arch should be set to \"noarch\"" + return 1 + fi + return 0 +} + prepare_package() { msg "Preparing ${subpkgname:+sub}package ${subpkgname:-$pkgname}..." stripbin - prepare_metafiles && prepare_tracedeps + prepare_metafiles && prepare_tracedeps || return 1 + archcheck } pkginfo_val() { @@ -576,21 +604,6 @@ trace_apk_deps() { done } -# check that noarch is set if needed -arch_check() { - local name=$1 - local dir="$2" - if [ -z "$(scanelf -R "$dir" | head -n 1)" ]; then - [ "$arch" = "noarch" ] && return 0 - warning "No elf files found for $name so arch should probably be set to \"noarch\"" - else - [ "$arch" != "noarch" ] && return 0 - error "Elf files found so arch must not be set to \"noarch\"" - return 1 - fi - return 0 -} - create_apks() { local file getpkgver || return 1 @@ -601,7 +614,6 @@ create_apks() { local apk=$name-$ver.apk local datadir="$pkgbasedir"/$name - arch_check "$name" "$datadir" || return 1 trace_apk_deps "$name" "$dir" || return 1 msg "Creating $apk..." ( @@ -1007,7 +1019,9 @@ checksum() { stripbin() { local bin - options_has "!strip" && return 0 + if options_has "!strip" || [ "$arch" = "noarch" ]; then + return 0 + fi cd "${subpkgdir:-$pkgdir}" || return 1 msg "Stripping binaries" scanelf --recursive --nobanner --etype "ET_DYN,ET_EXEC" . \ |