-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlib4bin
executable file
·1170 lines (1114 loc) · 68.2 KB
/
lib4bin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
shopt -s extglob
# deps: apt update && apt install bash file binutils patchelf findutils grep sed coreutils strace -y
# deps: apk add bash file binutils patchelf findutils grep sed coreutils strace
# deps: dnf install bash file binutils patchelf findutils grep sed coreutils strace -y
# deps: pacman -Sy bash file binutils patchelf findutils grep sed coreutils strace --noconfirm
# deps: xbps-install -Sy bash file binutils patchelf findutils grep sed coreutils strace
RED='\033[1;91m'
BLUE='\033[1;94m'
GREEN='\033[1;92m'
YELLOW='\033[1;33m'
RESETCOLOR='\033[1;00m'
ONE_DIR=${ONE_DIR:=1}
DST_DIR="${DST_DIR:=.}"
TMPDIR="${TMPDIR:=/tmp}"
CREATE_LINKS=${CREATE_LINKS:=1}
PYINSTALL_DIR="${PYINSTALL_DIR:=$TMPDIR/pyinstall}"
STRIP=${STRIP:=0}
VERBOSE=${VERBOSE:=0}
LIBS_ONLY=${LIBS_ONLY:=0}
QUIET_MODE=${QUIET_MODE:=0}
HARD_LINKS=${HARD_LINKS:=0}
WITH_HOOKS=${WITH_HOOKS:=0}
WITH_SHARUN=${WITH_SHARUN:=0}
WITH_WRAPPE=${WITH_WRAPPE:=0}
WRAPPE_CLVL=${WRAPPE_CLVL:=8}
PATCH_RPATH=${PATCH_RPATH:=0}
STRACE_MODE=${STRACE_MODE:=0}
STRACE_TIME=${STRACE_TIME:=5}
GEN_LIB_PATH=${GEN_LIB_PATH:=0}
ANY_EXECUTABLE=${ANY_EXECUTABLE:=0}
WRAPPE_CLEANUP=${WRAPPE_CLEANUP:=1}
MAX_INTERP_LEN=${MAX_INTERP_LEN:=256}
PATCH_INTERPRETER=${PATCH_INTERPRETER:=0}
GIT_SHARUN_RELEASES='https://github.com/VHSgunzo/sharun/releases'
GIT_WRAPPE_RELEASES='https://github.com/VHSgunzo/wrappe/releases'
GIT_UV_RELEASES='https://github.com/astral-sh/uv/releases'
usage() {
echo -e "[ Usage ]: lib4bin [OPTIONS] /path/executable -- [STRACE MODE EXEC ARGS]
[ Options ]:
-d, --dst-dir '/path' Destination directory (env: DST_DIR='/path')
-e, --strace-mode Use strace for get libs (env: STRACE_MODE=1)
-t, --strace-time 5 Specify the time in seconds for strace mode (env: STRACE_TIME=5)
-g, --gen-lib-path Generate a lib.path file (env: GEN_LIB_PATH=1)
-h, --help Show this message
-i, --patch-interpreter Patch INTERPRETER to a relative path (env: PATCH_INTERPRETER=1)
-k, --with-hooks Pack additional files required for libraries (env: WITH_HOOKS=1)
-l, --libs-only Pack only libraries without executables (env: LIBS_ONLY=1)
-n, --not-one-dir Separate directories for each executable (env: ONE_DIR=0)
-p, --hard-links Pack sharun and create hard links (env: HARD_LINKS=1)
-q, --quiet-mode Show only errors (env: QUIET_MODE=1)
-r, --patch-rpath Patch RPATH to a relative path (env: PATCH_RPATH=1)
-s, --strip Strip binaries and libraries (env: STRIP=1)
-v, --verbose Verbose mode (env: VERBOSE=1)
-w, --with-sharun Pack sharun from PATH or env or download
(env: WITH_SHARUN=1, SHARUN=/path|URL, SHARUN_URL=URL, UPX_SHARUN=1)
-o, --with-wrappe Pack with wrappe from PATH or env or download
(env: WITH_WRAPPE=1, WRAPPE=/path|URL, WRAPPE_URL=URL)
-c, --wrappe-clvl 0-22 Specify the compression level for wrappe (env: WRAPPE_CLVL=0-22) (default: 8)
-x, --wrappe-exec name Specify the name of the wrappe packaged executable (env: WRAPPE_EXEC=name)
-m, --wrappe-args 'args' Specify the args for the wrappe packaged executable (env: WRAPPE_ARGS='args')
-z, --wrappe-dir '/path' Specify path to the sharun dir for packing with wrappe (env: WRAPPE_DIR='/path')
-u, --wrappe-no-cleanup Disable cleanup the wrappe unpack directory after exit (env: WRAPPE_CLEANUP=0)
It can also be set at runtime (env: STARTPE_CLEANUP=0)
-y, --with-python Pack python using uv from PATH or env or download
(env: WITH_PYTHON=1, UV=/path|URL, UV_URL=URL)
-pp, --python-pkg 'pkg' Specify the python package for packing (env: PYTHON_PKG='pkg')
-pv, --python-ver 3.12 Specify the python version for packing (env: PYTHON_VER=3.12)
-pi, --python-pip Leave pip after install python package (env: PYTHON_LEAVE_PIP=1)
-pw, --python-wheel Leave wheel after install python package (env: PYTHON_LEAVE_WHEEL=1)
-ps, --python-setuptools Leave setuptools after install python package (env: PYTHON_LEAVE_SETUPTOOLS=1)"
exit 1
}
error_msg() {
echo -e "${RED}[ ERROR ][$(date +"%Y.%m.%d %T")]: $@ $RESETCOLOR" 1>&2
return 1
}
info_msg() {
if [ "$QUIET_MODE" != 1 ]
then echo -e "${GREEN}[ INFO ][$(date +"%Y.%m.%d %T")]: $@ $RESETCOLOR" 1>&2
fi
}
hook_msg() { info_msg "$YELLOW[ HOOK ]:$GREEN $@" ; }
skip_msg() {
if [ "$QUIET_MODE" != 1 ]
then echo -e "${YELLOW}[ SKIPPED ][$(date +"%Y.%m.%d %T")]: $@ $RESETCOLOR" 1>&2
fi
}
which_exe() { command -v "$@" ; }
is_exe_exist() { which_exe "$@" &>/dev/null ; }
check_deps() {
local ret=0
local binaries=(file patchelf find grep sed)
[ "$STRIP" != 1 ]||binaries+=(strip)
[ "$STRACE_MODE" != 1 ]||binaries+=(strace)
for bin in "${binaries[@]}"
do
if ! is_exe_exist $bin
then
error_msg "$BLUE[$bin]$YELLOW not found!"
ret=1
fi
done
if [ "$ret" != 0 ]
then
info_msg "You need to install ${BLUE}lib4bin${GREEN} dependencies: ${BLUE}file binutils patchelf findutils grep sed coreutils strace"
exit 1
fi
}
try_strip() {
if [[ "$STRIP" == 1 && ! "$FILE_INFO" =~ 'no section header' ]]
then
info_msg "$YELLOW[ STRIP ]: $BLUE[$1]"
strip -s -R .comment --strip-unneeded "$1"
fi
}
try_remove_fullrpath() {
if [ "$PATCH_RPATH" != 1 ]
then
local rpath="$(print_rpath "$1")"
if grep -qE '^/|:/'<<<"$rpath"
then
info_msg "$YELLOW[ REMOVE RPATH ]: $BLUE[$1 -> $rpath]"
patchelf $pvarg --remove-rpath "$1"||exit 1
fi
fi
}
try_set_rpath() {
info_msg "$YELLOW[ SET RPATH ]: $BLUE[$1 -> $rpath]"
if [ -n "$2" ]
then local rpath="$2"
else local rpath='$ORIGIN/../lib:$ORIGIN/../lib32'
fi
patchelf $pvarg --remove-rpath "$1"||exit 1
patchelf $pvarg --set-rpath "$rpath" --force-rpath "$1"||exit 1
patchelf $pvarg --no-default-lib "$1"||exit 1
}
get_md5sum() { md5sum<<<"$1"|awk '{print$1}'; }
print_needed() { patchelf --print-needed "$1" 2>/dev/null ; }
print_rpath() { patchelf --print-rpath "$1" 2>/dev/null ; }
ldd_libs() {
ldd "$1" 2>/dev/null|grep -v 'error while loading shared libraries'|\
grep '/lib'|cut -d'>' -f2|sed 's| (.*)||g'|sed 's|^[[:space:]]*||g'
}
get_libs() {
unset libs libs4libs
if [ "$STRACE_MODE" == 1 ] && ! is_so && \
([[ ! -n "$STRACE_EXE" || "$STRACE_EXE" == "$1" ]]||\
[[ "$STRACE_EXE" == 'sharun' && "$1" == "$dst_dir/sharun" && "$binary_name" == 'sharun' ]])
then
local libs_file="${TMPDIR}/libs.$$"
[[ "$(strace --help)" =~ always-show-pid ]] && \
STRACE_ARGS='--always-show-pid'||unset STRACE_ARGS
info_msg "$YELLOW[ STRACE ]: $BLUE[$1 ${STRACE_CMD_ARGS[@]}] ${GREEN}..."
strace -f -e trace=openat,open $STRACE_ARGS -o "$libs_file" "$(readlink -f "$1")" "${STRACE_CMD_ARGS[@]}" 1>&2 &
sleep $STRACE_TIME
local pids="$(cut -d ' ' -f1<"$libs_file"|sort -u)"
kill $pids 2>/dev/null
local libs="$(\
sed '/nvidia/d;/libcuda/d;/ENOENT/d;/unfinished/d;/lib-dynload/d;/.wrappe/d;/_internal/d'<"$libs_file"|\
grep -Eo '".*lib.*\.so(\.[0-9].*)?"'|sed -u 's|"||g')\n"
rm -f "$libs_file"
fi
[ -n "$2" ] && local needed_libs="$2"||\
local needed_libs="$(print_needed "$1")"
local libs+="$(([ -z "$needed_libs" ]||\
grep -E "$(tr '\n' '|'<<<"$needed_libs"|sed 's|\||$\||g')libpthread.so.0$"<<<"$ALL_LIBS" ; \
ldd_libs "$1")|sort -u)"
local libs="$(echo -e "$libs")"
[ -n "$IS_ELF32" ] && \
local libs="$(grep -vE '/lib/|/lib64/|/.*64-linux-gnu/'<<<"$libs")"||\
local libs="$(grep -vE '/lib32/|/i386-linux-gnu/|/arm-linux-gnu/'<<<"$libs")"
for lib in $libs
do local libs4libs="$(echo -e "$(ldd_libs "$lib")\n$libs4libs")"
done
echo -e "$libs\n$libs4libs"|sort -u|sed '/^$/d'
}
repath_needed_libs() {
[ -n "$2" ] && local needed_libs="$2"||\
local needed_libs="$(print_needed "$1")"
local patch_needed_libs="$(grep '^/'<<<"$needed_libs")"
if [ -n "$patch_needed_libs" ]
then
for lib in $patch_needed_libs
do
local relib="$(basename "$lib")"
info_msg "$YELLOW[ REPATH ]: $BLUE[$lib -> $relib]"
patchelf $pvarg --replace-needed "$lib" "$relib" "$1"||exit 1
done
fi
}
try_mkdir() {
if [ ! -d "$1" ]
then mkdir $varg -p "$1"||exit 1
fi
}
try_ln() {
if [ ! -L "$2" ]
then
[ "$VERBOSE" == 1 ] && \
echo -n "ln: "
ln $varg -sf "$1" "$2"||exit 1
fi
}
try_cp_exe() {
if [ ! -f "$2" ]
then
[ "$VERBOSE" == 1 ] && \
echo -n "cp: "
cp $varg -f "$1" "$2"||exit 1
chmod $varg 755 "$2"||exit 1
fi
}
try_cp() {
[ "$VERBOSE" == 1 ] && \
echo -n "cp: "
cp $varg -rf "$@"||exit 1
}
try_mv() {
[ "$VERBOSE" == 1 ] && \
echo -n "mv: "
mv $varg -f "$@"||exit 1
}
try_cd() {
[ "$VERBOSE" == 1 ] && \
echo "cd: '$1'"
cd "$1"||exit 1
}
get_relative_path() {
local start_dir="$1"
local target_dir="$2"
start_dir=$(readlink -f "$start_dir")
target_dir=$(readlink -f "$target_dir")
local common_path=''
local i=0
while [ $i -lt ${#start_dir} ] && \
[ $i -lt ${#target_dir} ] && \
[ "${start_dir:$i:1}" = "${target_dir:$i:1}" ]
do
common_path+="${start_dir:$i:1}"
i=$((i+1))
done
if [ -n "$common_path" ] && \
[ "${common_path: -1}" != "/" ]
then common_path=$(dirname "$common_path")
fi
local up_path=''
local remaining_start="${start_dir#"$common_path"}"
if [ -n "$remaining_start" ]
then
for dir in $(echo "$remaining_start" | tr "/" "\n" | grep -v "^$")
do up_path+="../"
done
fi
local down_path="${target_dir#"$common_path"}"
local relative_path="$up_path${down_path#/}"
echo "$relative_path"
}
find_exe() {
[ -n "$1" ] && local path="$1" && shift
find "$path" -maxdepth 1 -not -type d -executable "$@" 2>/dev/null|sort
}
find_so() { find "$@" -name '*.so' -o -name '*.so.*' 2>/dev/null ; }
is_so() { [ -n "$IS_SO" ] && [[ "${binary_name,,}" =~ .*(\.so$|\.so\..*) || "${binary_real_name,,}" =~ .*(\.so$|\.so\..*) ]] ; }
check_url_stat_code() {
set -o pipefail
if is_exe_exist curl
then curl -sL -o /dev/null -I -w "%{http_code}" "$1" 2>/dev/null
elif is_exe_exist wget
then wget --no-check-certificate --server-response \
--spider "$1"|& awk '/^ HTTP/{print$2}'|tail -1
else
error_msg "Failed to check URL $BLUE[$1]: ${RED}curl and wget not found!"
return 1
fi
}
get_git_url() {
echo "$1/download/$(NO_ARIA2C=1 try_dl "$1/latest" \
/dev/stdout 2>/dev/null|grep -Em1 "Release (v)?.*"|awk '{print$2}')"
}
is_url() {
[ ! -n "$1" ] && \
return 1
if [ -n "$2" ]
then [ "$(check_url_stat_code "$1")" == "$2" ]
else [ "$(check_url_stat_code "$1")" == "200" ]
fi
}
find_py_unneeded() {
OLD_IFS="$IFS"
IFS=$'\n'
PY_UNNEEDED_LIST=($(find "$1" -type f -iname '*.rst' -o -iname '*.cmd' \
-o -iname '*.md' -o -name 'LICENSE*' -o -iname '*.ps1' \
-o -iname '*.bat' -o -iname '*.exe' -o -iname '*.whl'))
IFS="$OLD_IFS"
}
is_net_conn() {
if is_exe_exist nc
then nc -zw1 github.com 443 &>/dev/null
elif is_exe_exist curl
then curl -Ifs github.com &>/dev/null
elif is_exe_exist wget
then wget -q --spider github.com &>/dev/null
elif is_exe_exist ping
then ping -c 2 github.com &>/dev/null
else
error_msg "Failed to check internet connection: nc, curl, wget and ping not found!"
return 1
fi
}
try_dl() {
if is_net_conn
then
if [ -n "$1" ]
then
URL="$1"
if [ -n "$2" ]
then
if [ -d "$2" ]
then
FILEDIR="$2"
FILENAME="$(basename "$1")"
else
FILEDIR="$(dirname "$2")"
FILENAME="$(basename "$2")"
fi
else
FILEDIR="."
FILENAME="$(basename "$1")"
fi
if is_url "$URL"
then
WGET_ARGS=(-q --no-check-certificate -t 3 -T 5 -w 0.5 "$URL" -O "$FILEDIR/$FILENAME")
try_mkdir "$FILEDIR"
if [ "$NO_ARIA2C" != 1 ] && is_exe_exist aria2c
then
aria2c --no-conf -R -x 13 -s 13 --allow-overwrite -d "$FILEDIR" -o "$FILENAME" "$URL"
elif is_exe_exist curl
then
curl -R --progress-bar --insecure --fail -L "$URL" -o "$FILEDIR/$FILENAME"
elif is_exe_exist wget2
then
wget2 --force-progress "${WGET_ARGS[@]}"
elif is_exe_exist wget
then
wget --show-progress "${WGET_ARGS[@]}"
else
error_msg "Downloader not found!"
fi
else
error_msg "$FILENAME not found in $(echo "$URL"|awk -F/ '{print$3"/"$4}')"
fi
else
error_msg "Specify download URL!"
fi
else
error_msg "There is no internet connection?"
fi
return $?
}
parse_arg_options() {
[ "$1" == 'dash' ] && shift && \
local _ALLOW_DASH=1||unset _ALLOW_DASH
if [ -n "$3" ] && [[ "$_ALLOW_DASH" == 1 || "$3" != -* ]]
then eval "${1}='$3'"
else
error_msg "${YELLOW}Option ${BLUE}$2 ${YELLOW}requires a non-empty argument!\n"
usage
fi
}
while [[ "$#" -gt 0 ]]; do
case $1 in
-h|--help) usage ;;
-s|--strip) STRIP=1; shift ;;
-v|--verbose) VERBOSE=1; shift ;;
-n|--not-one-dir) ONE_DIR=0; shift ;;
-l|--libs-only) LIBS_ONLY=1; shift ;;
-k|--with-hooks) WITH_HOOKS=1; shift ;;
-q|--quiet-mode) QUIET_MODE=1; shift ;;
-p|--hard-links) HARD_LINKS=1; shift ;;
-e|--strace-mode) STRACE_MODE=1; shift ;;
-w|--with-sharun) WITH_SHARUN=1; shift ;;
-o|--with-wrappe) WITH_WRAPPE=1; shift ;;
-y|--with-python) WITH_PYTHON=1; shift ;;
-r|--patch-rpath) PATCH_RPATH=1; shift ;;
-pi|--python-pip) PYTHON_LEAVE_PIP=1; shift ;;
-pw|--python-wheel) PYTHON_LEAVE_WHEEL=1; shift ;;
-ps|--python-setuptools) PYTHON_LEAVE_SETUPTOOLS=1; shift ;;
-g|--gen-lib-path) GEN_LIB_PATH=1; shift ;;
-u|--wrappe-no-cleanup) WRAPPE_CLEANUP=0; shift ;;
-i|--patch-interpreter) PATCH_INTERPRETER=1; shift ;;
-d|--dst-dir) parse_arg_options DST_DIR "$1" "$2"; shift 2 ;;
-pv|--python-ver) parse_arg_options PYTHON_VER "$1" "$2"; shift 2 ;;
-pp|--python-pkg) parse_arg_options PYTHON_PKG "$1" "$2"; shift 2 ;;
-t|--strace-time) parse_arg_options STRACE_TIME "$1" "$2"; shift 2 ;;
-x|--wrappe-exec) parse_arg_options WRAPPE_EXEC "$1" "$2"; shift 2 ;;
-c|--wrappe-clvl) parse_arg_options WRAPPE_CLVL "$1" "$2"; shift 2 ;;
-z|--wrappe-dir) parse_arg_options WRAPPE_DIR "$1" "$2"; shift 2 ;;
-m|--wrappe-args) parse_arg_options dash WRAPPE_ARGS "$1" "$2"; shift 2 ;;
-*) error_msg "Unknown parameter: ${BLUE}$1\n"; usage ;;
*) break ;;
esac
done
if [ "$VERBOSE" == 1 ]
then
varg='-v'
pvarg='--debug'
else
unset varg pvarg
fi
if [[ -n "$WRAPPE_DIR" && ! -x "$WRAPPE_DIR/sharun" ]]
then error_msg 'sharun was not found in specified wrappe directory!'; exit 1
fi
[[ "$STRACE_TIME" =~ ^[0-9]+$ ]]||\
STRACE_TIME=5
[[ -n "$WRAPPE_EXEC" || -n "$WRAPPE_ARGS" || -d "$WRAPPE_DIR" ]] && \
WITH_WRAPPE=1
(( WRAPPE_CLVL >= 0 && WRAPPE_CLVL <= 22 ))||\
WRAPPE_CLVL=8
[ -d "$WRAPPE_DIR" ] && \
WRAPPE_DIR="$(readlink -f "$WRAPPE_DIR")"
[ "$WITH_WRAPPE" == 1 ] && \
WITH_SHARUN=1 GEN_LIB_PATH=1
[[ -n "$PYTHON_PKG" ]] && WITH_PYTHON=1
[[ "$PYTHON_VER" =~ ^[0-9]+\.[0-9]+$ ]] && \
WITH_PYTHON=1||unset PYTHON_VER
if [ "$WITH_PYTHON" == 1 ]
then
ONE_DIR=1
WITH_SHARUN=1
TMP_UV="${TMPDIR}/uv-$(uname -m)-unknown-linux-musl/uv"
UV="${UV:="$(readlink -f "$(which_exe uv)")"}"
UV="${UV:="$TMP_UV"}"
if [ ! -x "$UV" ]
then
if [[ "${UV,,}" =~ ^http ]]
then
UV_URL="$UV"
UV="$TMP_UV"
fi
UV_URL="${UV_URL:=$(get_git_url "$GIT_UV_RELEASES")/uv-$(uname -m)-unknown-linux-musl.tar.gz}"
info_msg "Downloading uv -> '$UV'..."
info_msg "$UV_URL"
if NO_ARIA2C=1 try_dl "$UV_URL" '/dev/stdout'|tar -zxvf- -C "$TMPDIR"
then chmod $varg +x "$UV"
else
error_msg "Failed to download uv!"
exit 1
fi
fi
if [ ! -x "$UV" ]
then
error_msg "uv not found!"
exit 1
fi
fi
BINARY_LIST=()
unset STRACE_EXE
declare -A DST_DIRS
[ -n "$DST_DIR" ] && \
DST_DIR="$(readlink -f "$DST_DIR")"
if [[ ! -d "$WRAPPE_DIR" || "$WITH_PYTHON" == 1 ]]
then
if [ "$2" == '--' ]
then
STRACE_MODE=1
STRACE_EXE="$1"; shift 2
STRACE_CMD_ARGS=("$@"); shift "${#@}"
fi
check_deps
if [ "$WITH_PYTHON" == 1 ]
then
PYTMP_DIR="$DST_DIR/pytmp-$$"
info_msg "$YELLOW[ PYTHON INSTALL ]: $BLUE[$PYINSTALL_DIR] ${GREEN}..."
"$UV" python install --install-dir "$PYINSTALL_DIR" $PYTHON_VER||exit 1
CPYTHON_VER="$(ls -r1 "$PYINSTALL_DIR"|grep -m1 "cpython-${PYTHON_VER}.*-linux-$(uname -m).*")"
CPYTHON_DIR="$PYINSTALL_DIR/$CPYTHON_VER"
if [[ -n "$CPYTHON_VER" && -d "$CPYTHON_DIR" ]]
then
info_msg "$YELLOW[ PYTHON VERSION ]: $BLUE[$CPYTHON_VER]"
try_mkdir "$PYTMP_DIR"
try_cp -T "$PYINSTALL_DIR/$CPYTHON_VER" "$PYTMP_DIR"
find_py_unneeded "$PYTMP_DIR/"
rm -rf "$PYTMP_DIR"/{.lock,share} "$PYTMP_DIR/lib"/!(pkgconfig|*python*) "${PY_UNNEEDED_LIST[@]}"
if [ -n "$PYTHON_PKG" ]
then
info_msg "$YELLOW[ PIP INSTALL ]: $BLUE[$PYTHON_PKG -> $PYTMP_DIR] ${GREEN}..."
"$UV" pip install --prefix "$PYTMP_DIR" --compile-bytecode --refresh --upgrade \
--python "$PYTMP_DIR/bin/python" --link-mode=copy --prerelease=allow \
pip setuptools wheel "$PYTHON_PKG"||exit 1
find_py_unneeded "$PYTMP_DIR/"
PY_UNINSTALL_LIST=()
if [ "$PYTHON_LEAVE_PIP" != 1 ]
then
PY_UNINSTALL_LIST+=(pip)
PY_UNNEEDED_LIST+=(
"$PYTMP_DIR/lib/pkgconfig"
"$PYTMP_DIR"/{.lock,include}
"$PYTMP_DIR"/lib/python*/ensurepip
"$PYTMP_DIR/bin"/{pip,python*-config}*
"$PYTMP_DIR/lib"/python*/config-*-linux*
"$PYTMP_DIR"/lib/python*/site-packages/{pip,pip-*}
)
fi
[ "$PYTHON_LEAVE_WHEEL" == 1 ]||PY_UNINSTALL_LIST+=(wheel)
[ "$PYTHON_LEAVE_SETUPTOOLS" == 1 ]||PY_UNINSTALL_LIST+=(setuptools)
if [ -n "$PY_UNINSTALL_LIST" ]
then
"$UV" pip uninstall --prefix "$PYTMP_DIR" --python "$PYTMP_DIR/bin/python" \
"${PY_UNINSTALL_LIST[@]}"||exit 1
fi
rm -rf "$PYTMP_DIR/share/man" "${PY_UNNEEDED_LIST[@]}"
fi
else
error_msg "python $CPYTHON_VER not found!"
exit 1
fi
unset PY_UNNEEDED_LIST
[ "$WITH_WRAPPE" == 1 ] && \
dst_dir="$DST_DIR/wrappe-$$"||\
dst_dir="$DST_DIR"
try_mkdir "$dst_dir"
try_cp -T "$PYTMP_DIR" "$dst_dir"
rm -rf "$PYTMP_DIR"
OLD_IFS="$IFS"
IFS=$'\n'
for script in $(grep -m1 "^'''exec.*python" -lr "$dst_dir/bin")
do sed -i '1s|.*|#!/usr/bin/env python|;2,3d' "$script"
done
BINARY_LIST+=(
$(find_exe "$dst_dir/bin/")
#$(find_so "$dst_dir")
)
IFS="$OLD_IFS"
fi
if [ -n "$STRACE_EXE" ]
then BINARY_LIST+=("$STRACE_EXE")
elif [ -n "$1" ]
then BINARY_LIST+=("$@")
else
if [ ! -n "$BINARY_LIST" ]
then
error_msg "Specify the executable or shared object!\n"
usage
fi
fi
ALL_LIBS="$(find_so \
/usr/lib /usr/libexec /usr/lib64 \
/usr/lib32 /lib /lib64 /lib32 \
|sort -u \
)"
binary_number=1
declare -A BINARIES
declare -A LIBRARIES
for binary in "${BINARY_LIST[@]}"
do
unset binary_real_name IS_PYINSTELF
if [ -L "$binary" ]
then
binary_src_pth="$(readlink -f "$binary")"
binary_real_name="$(basename "$binary_src_pth")"
else
binary_src_pth="$binary"
fi
if [[ "${BINARIES["$binary"]}" != 1 ]]
then
binary_name="$(basename "$binary")"
binary_readlink_name="$(basename "$(readlink "$binary")")"
if [ "$WITH_PYTHON" != 1 ]
then
if [ "$ONE_DIR" == 1 ]
then
[ "$WITH_WRAPPE" == 1 ] && \
dst_dir="$DST_DIR/wrappe-$$"||\
dst_dir="$DST_DIR"
else
[ "$WITH_WRAPPE" == 1 ] && \
dst_dir="$DST_DIR/${binary_name}/wrappe-$$"||\
dst_dir="$DST_DIR/${binary_name}"
fi
fi
if [ "$binary" == 'sharun' ]
then binary_src_pth="$dst_dir/sharun"
fi
dst_dir_pth="${dst_dir}/shared"
sharun_bin_dir_pth="${dst_dir}/bin"
[[ -f "$dst_dir_pth" || -L "$dst_dir_pth" ]] && \
dst_dir_pth="${dst_dir_pth}.dir"
DST_DIRS["$dst_dir_pth"]=
bin_dir_pth="${dst_dir_pth}/bin"
FILE_INFO="$(file "$binary_src_pth" 2>/dev/null)"
IS_ELF="$(grep -o 'ELF'<<<"$FILE_INFO")"
IS_STATIC="$(grep -o 'static'<<<"$FILE_INFO")"
IS_SCRIPT="$(grep -o 'script'<<<"$FILE_INFO")"
IS_ELF32="$(grep -q 'ELF 32-bit'<<<"$FILE_INFO")"
IS_SO="$(grep -o 'shared object'<<<"$FILE_INFO")"
IS_EXECUTABLE="$(grep -o 'executable'<<<"$FILE_INFO")"
IS_EXECUTABLE="${IS_EXECUTABLE:=$(([ -n "$IS_SO" ] && ! is_so) && echo executable)}"
info_msg "$YELLOW[ $binary_number ]: $BLUE[$binary_name] ${GREEN}..."
if [ "$HARD_LINKS" == 1 ] && [[ -n "$IS_SCRIPT" || -n "$IS_STATIC" ]]
then
hard_links=0
with_sharun=1
fi
hard_links=${HARD_LINKS:=0}
with_sharun=${WITH_SHARUN:=0}
create_links=${CREATE_LINKS:=1}
patch_interpreter=${PATCH_INTERPRETER:=0}
if ([ -n "$IS_EXECUTABLE" ] || is_so)
then
needed_libs="$(print_needed "$binary_src_pth")"
LIBS="$(get_libs "$binary_src_pth" "$needed_libs")"
is_so && LIBS="$(echo -e "$LIBS\n$binary"|sort -u|sed '/^$/d')"
if [[ -n "$LIBS" && ! -n "$IS_SCRIPT" && ! -n "$IS_STATIC" ]]
then
INTERPRETER="$(basename "$(grep -Em1 'ld-(linux|musl).*\.so'<<<"$LIBS"|cut -d'=' -f1|sed 's|\t||')")"
[[ "$create_links" == 1 && "$hard_links" == 1 && ! -x "${dst_dir}/sharun" ]] && \
with_sharun=1
else
create_links=0
bin_dir_pth="$sharun_bin_dir_pth"
fi
if [ "$LIBS_ONLY" != 1 ] && ! is_so && [[ "$binary_name" != 'sharun' && \
"$binary_readlink_name" != 'sharun' ]]
then
if [ "$binary_real_name" != 'sharun' ]
then
if [[ "$with_sharun" == 1 && ! -x "${dst_dir}/sharun" ]]
then
TMP_SHARUN="${TMPDIR}/sharun-$(uname -m)$([ "$UPX_SHARUN" != 1 ]||echo -upx)"
SHARUN="${SHARUN:="$(readlink -f "$(which_exe sharun)")"}"
SHARUN="${SHARUN:="$TMP_SHARUN"}"
if [ ! -x "$SHARUN" ]
then
if [[ "${SHARUN,,}" =~ ^http ]]
then
SHARUN_URL="$SHARUN"
SHARUN="$TMP_SHARUN"
fi
SHARUN_URL="${SHARUN_URL:=$(get_git_url "$GIT_SHARUN_RELEASES")/sharun-$(uname -m)$([ "$UPX_SHARUN" != 1 ]||echo -upx)}"
info_msg "Downloading sharun -> '$SHARUN'..."
info_msg "$SHARUN_URL"
if try_dl "$SHARUN_URL" "$SHARUN"
then chmod $varg +x "$SHARUN"
else
error_msg "Failed to download sharun!"
exit 1
fi
fi
if [ -x "$SHARUN" ]
then
try_mkdir "$dst_dir"
try_cp_exe "$SHARUN" "${dst_dir}/sharun"
else
error_msg "sharun not found!"
exit 1
fi
fi
try_mkdir "$bin_dir_pth"
[ -n "$binary_real_name" ] && \
binary_dst_pth="$bin_dir_pth/$binary_real_name"||\
binary_dst_pth="$bin_dir_pth/$binary_name"
try_cp_exe "$binary_src_pth" "$binary_dst_pth"
if [ -n "$IS_SCRIPT" ]
then
for intep in python bash sh ash zsh fish dash perl ruby go node
do
if grep -qo "^#!.*bin/$intep" "$binary_dst_pth"
then
sed -i "1s|^#!.*bin/$intep|#!/usr/bin/env $intep|" "$binary_dst_pth"
break
fi
done
fi
if [[ "${BINARIES["$binary_dst_pth"]}" != 1 ]]
then
if [ -n "$IS_ELF" ]
then try_strip "$binary_dst_pth"
fi
if [[ -n "$LIBS" && ! -n "$IS_SCRIPT" && ! -n "$IS_STATIC" ]]
then
repath_needed_libs "$binary_dst_pth" "$needed_libs"
try_remove_fullrpath "$binary_dst_pth"
IS_PYINSTELF="$(grep -aom1 'PyInstaller' "$binary_src_pth")"
if [ -n "$IS_PYINSTELF" ]
then
pyinternal_dir="$(readlink -f "$(dirname "$binary_src_pth")/_internal")"
if [ -d "$pyinternal_dir" ]
then
rm -rf "$bin_dir_pth/_internal"
try_cp -T "$pyinternal_dir" "$bin_dir_pth/_internal"
if [ "$dst_dir" == "$(dirname "$pyinternal_dir")" ]
then rm -rf "$pyinternal_dir" "$binary_src_pth"
fi
else patch_interpreter=1
fi
export PATCH_RPATH_$(get_md5sum "${dst_dir_pth}")=1
fi
fi
BINARIES["$binary_dst_pth"]=1
fi
else
bin_dir_pth="${dst_dir_pth}/bin"
binary_real_name="$binary_readlink_name"
fi
if [[ -n "$binary_real_name" && "$binary_name" != "$binary_real_name" ]]
then
(try_cd "$bin_dir_pth"
try_ln "$binary_real_name" "$binary_name")||exit 1
fi
if [ "$create_links" == 1 ]
then
try_mkdir "$sharun_bin_dir_pth"
[ "$hard_links" == 1 ] && \
ln_args='-f'||ln_args='-sf'
(try_cd "$sharun_bin_dir_pth"
[ "$VERBOSE" != 1 ]||echo -n "ln: "
ln $varg $ln_args ../sharun "$binary_name"||exit 1
if [ -n "$binary_real_name" ]
then
[ "$VERBOSE" != 1 ]||echo -n "ln: "
ln $varg $ln_args ../sharun "$binary_real_name"||exit 1
fi)||exit 1
fi
fi
for lib_src_pth in $LIBS
do
if [[ "${LIBRARIES["$lib_src_pth"]}" != 1 ]]
then
unset lib_src_real_pth lib_src_real_name
if [ -L "$lib_src_pth" ]
then
lib_src_real_pth="$(readlink -f "$lib_src_pth")"
lib_src_real_name="$(basename "$lib_src_real_pth")"
lib_src_dirname_pth="$(readlink -f "$(dirname "$lib_src_real_pth")")"
FILE_INFO="$(file "$lib_src_real_pth" 2>/dev/null)"
else
lib_src_dirname_pth="$(readlink -f "$(dirname "$lib_src_pth")")"
FILE_INFO="$(file "$lib_src_pth" 2>/dev/null)"
fi
if [[ "$FILE_INFO" =~ 'shared object' ]]
then
lib_src_name="$(basename "$lib_src_pth")"
grep -qE '/lib32|/i386-linux-gnu|/arm-linux-gnu'<<<"$lib_src_dirname_pth" && \
lib_dir="lib32"||lib_dir="lib"
lib_dst_dir_pth="${dst_dir_pth}/${lib_dir}$(sed \
"s|$dst_dir||;s|/shared||;s|^/usr||;s|^/opt||;s|^/lib64||;s|^/lib32||;s|^/lib||;s|^/.*-linux-gnu||"<<<"$lib_src_dirname_pth")"
[ -n "$lib_src_real_name" ] && \
lib_dst_pth="$lib_dst_dir_pth/$lib_src_real_name"||\
lib_dst_pth="$lib_dst_dir_pth/$lib_src_name"
if [[ ! -d "${dst_dir_pth}/${lib_dir}" && -d "${dst_dir}/${lib_dir}" \
&& ! -L "${dst_dir_pth}/${lib_dir}" ]]
then
(try_mkdir "$dst_dir_pth"
try_cd "$dst_dir_pth"
try_ln ../$lib_dir $lib_dir)||exit 1
fi
try_mkdir "$lib_dst_dir_pth"
if [[ -d "$bin_dir_pth/_internal" && ! -L "$bin_dir_pth/_internal" ]]
then
try_cp -nT "$bin_dir_pth/_internal" "$(readlink -f "${dst_dir_pth}/${lib_dir}")"
rm -rf "$bin_dir_pth/_internal"
(try_cd "$bin_dir_pth"
try_ln ../${lib_dir} _internal)||exit 1
fi
try_cp_exe "$lib_src_pth" "$lib_dst_pth"
if [[ -n "$lib_src_real_name" && "$lib_src_name" != "$lib_src_real_name" ]]
then
(try_cd "$lib_dst_dir_pth"
try_ln "$lib_src_real_name" "$lib_src_name")||exit 1
fi
if [[ "${LIBRARIES["$lib_dst_pth"]}" != 1 ]]
then
if ! is_so && [[ ! -d "${dst_dir}/${lib_dir}" && \
! -L "${dst_dir}/${lib_dir}" ]]
then
(try_cd "$dst_dir"
try_ln shared/$lib_dir $lib_dir)||exit 1
fi
repath_needed_libs "$lib_dst_pth"
try_strip "$lib_dst_pth"
try_remove_fullrpath "$lib_dst_pth"
if [ "$WITH_HOOKS" == 1 ]
then
case "$lib_dst_pth" in
*/gio/modules/*.so)
sys_giom_cache="${lib_src_pth/modules\/*\.so/modules\/giomodule.cache}"
dst_giom_dir="$(dirname "$lib_dst_pth")"
dst_giom_cache="$dst_giom_dir/giomodule.cache"
if [[ -f "$sys_giom_cache" && ! -f "$dst_giom_cache" ]]
then
hook_msg "copy giomodule.cache..."
try_mkdir "$dst_giom_dir"
try_cp "$sys_giom_cache" "$dst_giom_cache"
fi ;;
*/libglib-*.so*)
glib="$(grep -o 'glib-.*\.so'<<<"$lib_src_name"|sed "s|\.so$||")"
sys_glib_schemas="/usr/share/$glib/schemas"
dst_glib_schemas="$dst_dir/share/$glib/schemas"
if [[ -d "$sys_glib_schemas" && ! -d "$dst_glib_schemas" ]]
then
hook_msg "copy glib schemas..."
try_mkdir "$dst_glib_schemas"
try_cp -T "$sys_glib_schemas" "$dst_glib_schemas"
fi ;;
*/gdk-pixbuf-*/*/loaders/*.so)
sys_pixbufl_cache="${lib_src_pth/loaders\/*\.so/loaders.cache}"
dst_pixbufl_dir="$(dirname "$lib_dst_pth")"
dst_pixbufl_cache="${dst_pixbufl_dir}.cache"
if [[ -f "$sys_pixbufl_cache" && ! -f "$dst_pixbufl_cache" ]]
then
hook_msg "copy gdk pixbuf loaders.cache..."
try_mkdir "$dst_pixbufl_dir"
try_cp "$sys_pixbufl_cache" "$dst_pixbufl_cache"
sed -i 's|/usr/lib/.*/loaders/||g' "$dst_pixbufl_cache"
fi ;;
*/gtk-*/*/immodules/*.so)
sys_gtkimm_cache="${lib_src_pth/immodules\/*\.so/immodules.cache}"
dst_gtkimm_dir="$(dirname "$lib_dst_pth")"
dst_gtkimm_cache="${dst_gtkimm_dir}.cache"
if [[ -f "$sys_gtkimm_cache" && ! -f "$dst_gtkimm_cache" ]]
then
hook_msg "copy gtk immodules.cache..."
try_mkdir "$dst_gtkimm_dir"
try_cp "$sys_gtkimm_cache" "$dst_gtkimm_cache"
sed -i 's|/usr/lib/.*/immodules/||g' "$dst_gtkimm_cache"
fi ;;
*/libfontconfig.so*)
sys_fcfg='/etc/fonts/fonts.conf'
dst_fcfg="$dst_dir/etc/fonts/fonts.conf"
if [[ -f "$sys_fcfg" && ! -f "$dst_fcfg" ]]
then
hook_msg "copy fonts.conf..."
try_mkdir "$dst_dir/etc/fonts"
try_cp "$sys_fcfg" "$dst_fcfg"
fi ;;
*/libxkbcommon*.so*)
sys_xcb_dir='/usr/share/X11/xkb'
dst_xcb_dir="$dst_dir/share/X11/xkb"
if [[ -d "$sys_xcb_dir" && ! -d "$dst_xcb_dir" ]]
then
hook_msg "copy X11 xkb..."
try_mkdir "$dst_xcb_dir"
try_cp -T "$sys_xcb_dir" "$dst_xcb_dir"
fi ;;
*/libEGL_mesa.so*)
sys_glvnd_dir='/usr/share/glvnd/egl_vendor.d'
dst_glvnd_dir="$dst_dir/share/glvnd/egl_vendor.d"
if [[ -d "$sys_glvnd_dir" && ! -d "$dst_glvnd_dir" ]]
then
hook_msg "copy EGL vendors..."
try_mkdir "$dst_glvnd_dir"
try_cp -T "$sys_glvnd_dir" "$dst_glvnd_dir"
fi ;;
*/libvulkan.so*)
sys_vk_icd_dir='/usr/share/vulkan/icd.d'
dst_vk_icd_dir="$dst_dir/share/vulkan/icd.d"
if [[ -d "$sys_vk_icd_dir" && ! -d "$dst_vk_icd_dir" ]]
then
hook_msg "copy Vulkan ICD..."
try_mkdir "$dst_vk_icd_dir"
try_cp -T "$sys_vk_icd_dir" "$dst_vk_icd_dir"
sed -i 's|/usr/lib||g;s|/.*-linux-gnu||g;s|"/|"|g' "$dst_vk_icd_dir"/*
fi ;;
*/libwebkit*gtk-*.so*)
webkit="$(grep -Eo 'webkit(2)?gtk-[0-9]*\.[0-9]*'<<<"$lib_src_name")"
dst_webkit_lib_dir="$(dirname "$lib_dst_pth")/$webkit"
hook_msg "hack webkitgtk to be portable..."
sed -i 's|/usr|././|g' "$lib_dst_pth"
for sys_webkit_lib_dir in "$(dirname "$lib_src_pth")/$webkit" \
"$(dirname "$lib_src_pth")exec/$webkit"
do
if [ -d "$sys_webkit_lib_dir" ] && \
[[ ! -d "$dst_webkit_lib_dir/injected-bundle" || \
! -f "$dst_webkit_lib_dir/WebKitWebProcess" ]]
then try_cp -T "$sys_webkit_lib_dir" "$dst_webkit_lib_dir"
fi
done
for bin_to_wrap in "$dst_webkit_lib_dir"/*
do
if [[ -f "$bin_to_wrap" && ! -L "$bin_to_wrap" ]] && \
! grep -q '.*\.so.*'<<<"$bin_to_wrap"
then
try_mkdir "$bin_dir_pth"
try_mv "$bin_to_wrap" "$bin_dir_pth"
ln $varg -sr "$dst_dir/sharun" "$dst_webkit_lib_dir/$(basename "$bin_to_wrap")"
fi
done
if [ "$(basename "$(dirname "$lib_src_pth")")" != "$lib_dir" ]
then try_ln . "$dst_dir_pth/$lib_dir/$(basename "$(dirname "$lib_src_pth")")"
fi
if ! grep -q 'SHARUN_WORKING_DIR=${SHARUN_DIR}' "$dst_dir/.env" 2>/dev/null
then echo 'SHARUN_WORKING_DIR=${SHARUN_DIR}' >> "$dst_dir/.env"
fi ;;
*/libwebkit*gtkinjectedbundle.so)
sed -i 's|/usr|././|g' "$lib_dst_pth" ;;
*/libncursesw.so*|*/libcursesw.so*|*/libcurses.so*)
dst_terminfo_dir="$dst_dir/share/terminfo"
for terminfo_dir in '/etc' '/usr/share'
do
sys_terminfo_dir="$terminfo_dir/terminfo"
if [[ -d "$sys_terminfo_dir" && ! -d "$dst_terminfo_dir" ]]
then
hook_msg "copy terminfo..."
try_mkdir "$dst_terminfo_dir"
try_cp -T "$sys_terminfo_dir" "$dst_terminfo_dir"
break
fi
done
sys_tabset_dir='/usr/share/tabset'
dst_tabset_dir="$dst_dir/share/tabset"
if [[ -d "$sys_tabset_dir" && ! -d "$dst_tabset_dir" ]]
then
hook_msg "copy tabset..."
try_mkdir "$dst_tabset_dir"
try_cp -T "$sys_tabset_dir" "$dst_tabset_dir"
fi ;;
*/qt*/plugins/*.so)
qt_conf="$sharun_bin_dir_pth/qt.conf"
if [ ! -f "$qt_conf" ]
then
hook_msg "create qt.conf..."
qt="$(grep -Eo 'qt([0-9])?'<<<"$lib_src_pth")"
echo -e \
"[Paths]\nPrefix = ../shared/${lib_dir}/${qt}\nPlugins = plugins\nImports = qml\nQml2Imports = qml" \
> "$qt_conf"
fi ;;
*/libmagic.so*)
dst_magic_file="$dst_dir/share/file/misc/magic.mgc"
for magic_file_dir in 'file' 'file/misc' 'misc'
do
sys_magic_file="$(readlink -f "/usr/share/$magic_file_dir/magic.mgc")"
if [[ -f "$sys_magic_file" && ! -f "$dst_magic_file" ]]
then
hook_msg "copy magic file..."
try_mkdir "$(dirname "$dst_magic_file")"
try_cp "$sys_magic_file" "$dst_magic_file"
break
fi
done ;;
esac
fi
LIBRARIES["$lib_dst_pth"]=1
fi
else
skip_msg "$BLUE[$lib_src_pth]$YELLOW not shared object!"