Line 0
Link Here
|
|
|
1 |
#!/bin/sh |
2 |
|
3 |
# $FreeBSD$ |
4 |
|
5 |
# If a port installs Qt version-specific binaries (e.g. "designer" which existed as a Qt4 application |
6 |
# and exists as a Qt5 application and will probably be a Qt6 application) which should have a |
7 |
# qtchooser-based wrapper, the port should set `QT_BINARIES=yes`. |
8 |
# |
9 |
# When QT_BINARIES is set to yes, compatibility symlinks (designer -> qtchooser, so that |
10 |
# qtchooser can run designer-qt5 or whatever is the selected Qt version) are installed by the port. |
11 |
|
12 |
PREFIX=%%PREFIX%% |
13 |
BINDIR=${PREFIX}/bin |
14 |
QTCHOOSER=${BINDIR}/qtchooser |
15 |
VERSIONS=%%QT_SUPPORTED%% |
16 |
|
17 |
if [ ! -d ${BINDIR} ] ; then |
18 |
echo "Binary directory '${BINDIR}' missing." >&2 |
19 |
exit 1 |
20 |
fi |
21 |
|
22 |
if [ ! -x ${QTCHOOSER} ] ; then |
23 |
echo "Qtchooser binary '${QTCHOOSER}' missing." >&2 |
24 |
exit 2 |
25 |
fi |
26 |
|
27 |
remove_links() { |
28 |
echo "Removing qtchooser links" |
29 |
for file in $(find -L ${BINDIR} -maxdepth 1 -samefile ${QTCHOOSER}) ; do |
30 |
if [ ! -L ${file} ] ; then |
31 |
continue |
32 |
fi |
33 |
# If at least one versioned executable is found for this name, keep the |
34 |
# qtchooser compatibility symlink for this name; otherwise, remove it. |
35 |
local found=0 |
36 |
for version in ${VERSIONS} ; do |
37 |
version_bin_dir=${PREFIX}/lib/qt${version}/bin |
38 |
target=${version_bin_dir}/$(basename ${file}) |
39 |
if [ -x ${target} ] ; then |
40 |
found=1 |
41 |
break |
42 |
fi |
43 |
done |
44 |
if [ ${found} -eq 0 ] ; then |
45 |
echo " ${file}" |
46 |
rm ${file} |
47 |
fi |
48 |
done |
49 |
echo "done" |
50 |
} |
51 |
|
52 |
create_links() { |
53 |
echo "Creating qtchooser links" |
54 |
for version in ${VERSIONS} ; do |
55 |
version_bin_dir=${PREFIX}/lib/qt${version}/bin |
56 |
if [ -d ${version_bin_dir} ] ; then |
57 |
for file in $(find ${version_bin_dir} -type f -maxdepth 1) ; do |
58 |
target=${BINDIR}/$(basename ${file}) |
59 |
if [ ! -L ${target} -a ! -f ${target} ] ; then |
60 |
echo " ${target}" |
61 |
ln -s ${QTCHOOSER} ${target} |
62 |
fi |
63 |
done |
64 |
fi |
65 |
done |
66 |
echo "done" |
67 |
} |
68 |
|
69 |
remove_links |
70 |
create_links |