#!/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!"
抽取qt工程依赖库脚本
最新推荐文章于 2024-07-17 14:55:21 发布