Skip to content

Commit 032ae04

Browse files
committed
Fix for old distros
1 parent edfb7ce commit 032ae04

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sharun"
3-
version = "0.2.4"
3+
version = "0.2.5"
44
readme = "README.md"
55
license = "MIT"
66
repository = "https://github.com/VHSgunzo/sharun"

lib4bin

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,12 @@ ldd_libs() {
131131

132132
get_libs() {
133133
unset libs libs4libs
134-
if [[ "$STRACE_MODE" == 1 && ! -n "$IS_SO" ]]
134+
if [ "$STRACE_MODE" == 1 ] && ! is_so
135135
then
136136
local libs_file="/tmp/libs.$$"
137-
strace -f -e trace=openat --always-show-pid -o "$libs_file" "$1" "${STRACE_CMD_ARGS[@]}" &>/dev/null &
137+
[[ "$(strace --help)" =~ always-show-pid ]] && \
138+
STRACE_ARGS='--always-show-pid'||unset STRACE_ARGS
139+
strace -f -e trace=openat $STRACE_ARGS -o "$libs_file" "$1" "${STRACE_CMD_ARGS[@]}" &>/dev/null &
138140
sleep $STRACE_TIME
139141
local pids="$(cut -d ' ' -f1<"$libs_file"|sort -u)"
140142
kill $pids 2>/dev/null
@@ -210,6 +212,8 @@ try_cd() {
210212
211213
find_so() { find "$@" -name '*.so' -o -name '*.so.*' 2>/dev/null ; }
212214
215+
is_so() { [ -n "$IS_SO" ] && [[ "${binary_name,,}" =~ .*(\.so$|\.so\..*) || "${binary_real_name,,}" =~ .*(\.so$|\.so\..*) ]] ; }
216+
213217
check_url_stat_code() {
214218
set -o pipefail
215219
if is_exe_exist curl
@@ -400,6 +404,7 @@ for binary in "${BINARY_LIST[@]}"
400404
IS_ELF32="$(grep -q 'ELF 32-bit'<<<"$FILE_INFO")"
401405
IS_SO="$(grep -o 'shared object'<<<"$FILE_INFO")"
402406
IS_EXECUTABLE="$(grep -o 'executable'<<<"$FILE_INFO")"
407+
IS_EXECUTABLE="${IS_EXECUTABLE:=$(([ -n "$IS_SO" ] && ! is_so) && echo executable)}"
403408
info_msg "$YELLOW[ $binary_number ]: $BLUE[$binary_name] ${GREEN}..."
404409
if [ "$HARD_LINKS" == 1 ] && [[ -n "$IS_SCRIPT" || -n "$IS_STATIC" ]]
405410
then
@@ -408,12 +413,11 @@ for binary in "${BINARY_LIST[@]}"
408413
fi
409414
hard_links=${HARD_LINKS:=0}
410415
with_sharun=${WITH_SHARUN:=0}
411-
if [[ -n "$IS_EXECUTABLE" || -n "$IS_SO" ]] && [[ "$ANY_EXECUTABLE" == 1 || -n "$IS_ELF" ]]
416+
if ([ -n "$IS_EXECUTABLE" ] || is_so) && [[ "$ANY_EXECUTABLE" == 1 || -n "$IS_ELF" ]]
412417
then
413418
needed_libs="$(print_needed "$binary_src_pth")"
414419
LIBS="$(get_libs "$binary_src_pth" "$needed_libs")"
415-
[ -n "$IS_SO" ] && \
416-
LIBS="$(echo -e "$LIBS\n$binary"|sort -u|sed '/^$/d')"
420+
is_so && LIBS="$(echo -e "$LIBS\n$binary"|sort -u|sed '/^$/d')"
417421
if [[ -n "$LIBS" && ! -n "$IS_SCRIPT" && ! -n "$IS_STATIC" ]]
418422
then
419423
INTERPRETER="$(basename "$(grep 'ld-linux'<<<"$LIBS"|cut -d'=' -f1|sed 's|\t||' )")"
@@ -424,7 +428,7 @@ for binary in "${BINARY_LIST[@]}"
424428
fi
425429
if [[ -n "$LIBS" || "$ANY_EXECUTABLE" == 1 ]]
426430
then
427-
if [[ "$LIBS_ONLY" != 1 && ! -n "$IS_SO" ]]
431+
if [ "$LIBS_ONLY" != 1 ] && ! is_so
428432
then
429433
if [[ "$with_sharun" == 1 && ! -x "${dst_dir}/sharun" ]]
430434
then
@@ -531,14 +535,15 @@ for binary in "${BINARY_LIST[@]}"
531535
fi
532536
if [[ "${LIBRARIES["$lib_dst_pth"]}" != 1 ]]
533537
then
534-
if [[ ! -n "$IS_SO" && "$hard_links" == 1 && ! -L "${dst_dir}/${lib_dir}" ]]
538+
if ! is_so && [[ "$hard_links" == 1 && ! -L "${dst_dir}/${lib_dir}" ]]
535539
then
536540
(try_cd "$dst_dir"
537541
try_ln shared/$lib_dir $lib_dir)||exit 1
538542
fi
539543
repath_needed_libs "$lib_dst_pth"
540544
try_strip "$lib_dst_pth"
541-
if [[ ! "$lib_dst_pth" =~ "$INTERPRETER" ]]
545+
if [[ ! "$lib_dst_pth" =~ "$INTERPRETER" && \
546+
! "$lib_dst_pth" =~ ld-[0-9]\.[0-9]+\.so ]]
542547
then try_set_rpath "$lib_dst_pth"
543548
fi
544549
if [ "$WITH_HOOKS" == 1 ]
@@ -652,7 +657,7 @@ for binary in "${BINARY_LIST[@]}"
652657
done
653658
if [[ -n "$INTERPRETER" && "$PATCH_INTERPRETER" == 1 && "${LIBRARIES["${INTERPRETER}_patched"]}" != 1 ]]
654659
then
655-
if [[ "$LIBS_ONLY" != 1 && ! -n "$IS_SO" ]]
660+
if [ "$LIBS_ONLY" != 1 ] && ! is_so
656661
then
657662
(try_cd "$bin_dir_pth"
658663
if [ -f "../$lib_dir/$INTERPRETER" ]

0 commit comments

Comments
 (0)