44 lines
831 B
Bash
44 lines
831 B
Bash
#!/bin/bash
|
|
|
|
# Simple 'n Stupid ELF dynamic file copier for Android.
|
|
# By *DANiO* (C) 2022 y.
|
|
|
|
# Functions
|
|
copy_deps()
|
|
{
|
|
[ ! -e ${1} -o -e ${2}/${1} ]&&return 1
|
|
cp -fv ${1} ${2}||return 1
|
|
for i in `readelf -d ${1} |grep NEEDED|awk '{print $5}'|tr -d "[]"`;do
|
|
copy_deps ${i} ${2}
|
|
done
|
|
[ -n ${1} ]&©_deps ${@}
|
|
}
|
|
help()
|
|
{
|
|
cat <<eot
|
|
Help:
|
|
`basename ${0}` -h|--help -- to see this page
|
|
`basename ${0}` -i|--input <FILE_IN> -o|--output <DIR_OUT> -- to properly run this script
|
|
eot
|
|
}
|
|
|
|
# If no arguments bail-out.
|
|
[ ${#} -lt 1 ]&&help&&exit 0
|
|
|
|
# Parameters parser.
|
|
for i in ${@}; do
|
|
case ${i} in
|
|
-h|--help)help;exit 0;;
|
|
-i|--input)in=${2};shift 2;;
|
|
-o|--output)out=${2};shift 2;;
|
|
*)help&&exit 0;;
|
|
esac
|
|
done
|
|
|
|
# Create dir for final binaries.
|
|
mkdir -pv ${out}
|
|
|
|
# Run main function.
|
|
copy_deps ${in} ${out}||exit 1
|
|
exit 0
|