lwzm
8/27/2019 - 2:57 AM

find *.so the pyinstaller loaded

cmd="$1"

dir=$(dirname $(realpath $cmd))

$cmd &

pyinstaller_ppid="$!"

#echo $pyinstaller_ppid
#ps -o pid,ppid
#ps uf

sleep 0.3

ps -o pid,ppid | awk -v ppid=$pyinstaller_ppid '
$2 == ppid {
    print $1
}
' | xargs lsof -p | awk '{print $9}' | grep '\.so' | grep $dir

kill $pyinstaller_ppid
cmd=$(realpath "$1")

dir=$(dirname $cmd)

$cmd &

pyinstaller_ppid="$!"

#echo $pyinstaller_ppid
#ps -o pid,ppid
#ps uf

sleep 0.3

mkdir -p tmp
mkdir -p pre

ps -o pid,ppid | awk -v ppid=$pyinstaller_ppid '
$2 == ppid {
    print $1
}
' | xargs lsof -p | awk '{print $9}' | grep '\.so' | grep $dir | xargs -I X cp X tmp


kill $pyinstaller_ppid
#exit

mv $dir/*.so* pre
mv tmp/* $dir