Removed
Link Here
|
1 |
#!/bin/sh |
2 |
|
3 |
# If a port installs Qt version-specific binaries (e.g. "designer" which |
4 |
# existed as a Qt4 application and exists as a Qt5 application and will |
5 |
# probably be a Qt6 application) which should have a qtchooser-based |
6 |
# wrapper, the port should set `QT_BINARIES=yes`. |
7 |
# |
8 |
# When QT_BINARIES is set to yes, compatibility symlinks (in bin/, |
9 |
# designer -> qtchooser, so that qtchooser can run designer-qt5 or |
10 |
# whatever is the selected Qt version) are installed by the port. |
11 |
# |
12 |
# Versioned binaries in ports are conventionally installed in <ver>/bin/, |
13 |
# so qt5/bin/designer is the versioned form of "designer". |
14 |
|
15 |
PREFIX=%%PREFIX%% |
16 |
BINDIR=${PREFIX}/bin |
17 |
QTCHOOSER=${BINDIR}/qtchooser |
18 |
VERSIONS=%%QT_SUPPORTED%% |
19 |
|
20 |
# Sanity-checking. Distinguish weird failure cases by exit code. |
21 |
if [ ! -d ${BINDIR} ] ; then |
22 |
echo "Binary directory '${BINDIR}' missing." >&2 |
23 |
exit 1 |
24 |
fi |
25 |
|
26 |
if [ ! -x ${QTCHOOSER} ] ; then |
27 |
echo "Qtchooser binary '${QTCHOOSER}' missing." >&2 |
28 |
exit 2 |
29 |
fi |
30 |
|
31 |
# Remove links-to-qtchooser that are no longer needed. |
32 |
# |
33 |
# We check in ${BINDIR} -- only **directly** in bindir, hence the |
34 |
# `-maxdepth 1` -- for symlinks to qtchooser. Those are unversioned |
35 |
# names (e.g. designer -> qtchooser) for the case where qtchooser |
36 |
# should pick the right one. |
37 |
# |
38 |
# If there aren't any versioned names for the same, remove the link |
39 |
# (e.g. when designer is removed from the versioned bin/ directory |
40 |
# under qt5/bin/, then designer -> qtchooser can go as well). |
41 |
# |
42 |
remove_links() { |
43 |
for file in $(find -L ${BINDIR} -maxdepth 1 -samefile ${QTCHOOSER}) ; do |
44 |
# Only symlinks count, since qtchooser lives here too |
45 |
if [ ! -L ${file} ] ; then |
46 |
continue |
47 |
fi |
48 |
# If at least one versioned executable is found for this name, |
49 |
# keep the qtchooser compatibility symlink for this name; |
50 |
# otherwise, remove it. |
51 |
local found=0 |
52 |
for version in ${VERSIONS} ; do |
53 |
version_bin_dir=${PREFIX}/lib/qt${version}/bin |
54 |
target=${version_bin_dir}/$(basename ${file}) |
55 |
# Only need to find **one** to keep the link. |
56 |
if [ -x ${target} ] ; then |
57 |
found=1 |
58 |
break |
59 |
fi |
60 |
done |
61 |
if [ ${found} -eq 0 ] ; then |
62 |
rm ${file} |
63 |
fi |
64 |
done |
65 |
} |
66 |
|
67 |
# Create links-to-qtchooser when a versioned application is installed. |
68 |
# |
69 |
# We check directly under the versioned bin/ directories, not in subdirectories |
70 |
# of bin/ -- so we need `-maxdepth 1` -- for names which can be hooked up to |
71 |
# qtchooser. Each of the names in the versioned bin/ dir is connected to |
72 |
# qtchooser if there isn't already a link of that name. |
73 |
# |
74 |
create_links() { |
75 |
for version in ${VERSIONS} ; do |
76 |
version_bin_dir=${PREFIX}/lib/qt${version}/bin |
77 |
if [ -d ${version_bin_dir} ] ; then |
78 |
for file in $(find ${version_bin_dir} -type f -maxdepth 1) ; do |
79 |
# target is the **unversioned** one (e.g. |
80 |
# designer, living in bin/) which needs to |
81 |
# be pointed at qtchooser because there is a |
82 |
# **versioned** designer in e.g. qt5/bin/. |
83 |
target=${BINDIR}/$(basename ${file}) |
84 |
if [ ! -L ${target} -a ! -f ${target} ] ; then |
85 |
ln -s ${QTCHOOSER} ${target} |
86 |
fi |
87 |
done |
88 |
fi |
89 |
done |
90 |
} |
91 |
|
92 |
remove_links |
93 |
create_links |