抽取qt工程依赖库脚本

#!/bin/bash
if [ $# -ne 1 ]
then
	echo "Usage: $0 <executable name>"
	exit 1
fi

deployscript=${0##*/}	# delete path and leave file name remained
executable=$1

# Obtain the Linux flavour and version
# distro=`lsb_release -d | awk '{print $2$3$4}' | sed 's/\./_/g'`

# Create the directory that will be tarred up for distribution.
# tardir=`echo $executable"_"$distro | awk '{print tolower($0)}'`
tardir=`echo $executable"_deply" | awk '{print tolower($0)}'`
mkdir $tardir
echo "Created tar ball directory: "$tardir

# Copy executable across
chmod u+x $executable
cp $executable $tardir
echo "Copied executable "$executable" to "$tardir

# Copy other files and dirs
nfiles=0
ndirs=0
for files_dirs in `ls ./`
do
	if [ "$files_dirs" != "$deployscript" ] && [ "$files_dirs" != "$executable" ] && [ "$files_dirs" != "$tardir" ]; then
		if [ -d "$files_dirs" ]; then
			ndirs=$(($ndirs+1))
		else
			nfiles=$(($nfiles+1))
		fi
	
		cp -r $files_dirs $tardir
	fi
done
echo "Copied other $nfiles file(s) and $ndirs dir(s) to "$tardir

# Create the libs directory
libsdir=$PWD/$tardir/libs
mkdir $libsdir
echo "Created libs directory: "$libsdir

# Copy all dependencies across to the tar directory
echo "Copying dependencies..."

for dep in `ldd ./$executable | awk '{print $3}' | grep -v "("`
do
	cp $dep $libsdir
	echo "Copied dependency "$dep" to "$libsdir
done

# You will need to change this to point wherever libqxcb.so lives on your PC
qtplatformplugin=/usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libqxcb.so
qtplatformplugindir=$tardir/platforms
mkdir $qtplatformplugindir
echo "Created platforms directory: "$qtplatformplugindir
cp $qtplatformplugin $qtplatformplugindir
echo "Copied platform "$qtplatformplugin" to "$qtplatformplugindir

echo "Copying qtplatformplugin dependencies..."
for dep in `ldd $qtplatformplugin | awk '{print $3}' | grep -v "("`
do
	cp -u $dep $libsdir
	echo "Copied qtplatformplugin dependency "$dep" to "$libsdir
done
echo "Copied qtplatformplugin dependencies"

# Create the run script
execscript=$tardir/"run$executable.sh"
echo "Created run script: "$execscript

echo "#!/bin/sh" > $execscript
echo "export LD_LIBRARY_PATH=\`pwd\`/libs" >> $execscript
# echo "export QT_QPA_FONTDIR=\`pwd\`/fonts" >> $execscript
echo "pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY \`pwd\`/$executable" >> $execscript

# Make executable
chmod u+x $execscript

echo "Creating tarball..."
tar -czvf $tardir".tar.gz" $tardir

echo "Cleaning up..."
rm -rf $tardir
echo "Done!"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值