aboutsummaryrefslogtreecommitdiff
path: root/Mk/Uses/qt-dist.mk
diff options
context:
space:
mode:
authorAdriaan de Groot <adridg@FreeBSD.org>2021-02-23 20:11:56 +0000
committerAdriaan de Groot <adridg@FreeBSD.org>2021-02-23 20:11:56 +0000
commitebaa6d9f96ab9201bc6c5d760c1b17c9cbf6029f (patch)
tree6ca2db3756294aedbe2f0520e38a44ef75f4236d /Mk/Uses/qt-dist.mk
parentc43726d120e10ffcd3a55de99a42cd3b3bda8871 (diff)
downloadports-ebaa6d9f96ab9201bc6c5d760c1b17c9cbf6029f.tar.gz
ports-ebaa6d9f96ab9201bc6c5d760c1b17c9cbf6029f.zip
Re-work Qt5 install- and deinstall scripts.
Qt5 packages *together* manage a header file qconfig-modules.h which `#includes` other headers. A given Qt5 package may get a line in there, or it might not: that depends on package settings. On installing a package, add the line (if needed), on deinstall, remove the line (if it was there). There's a tricky case, too: upgrading a package that *had* a line, but no longer has one. That behaves like deinstall. Previously we used @postexec and @postunexec lines, but these were fragile in their own special way. See the linked PRs for examples -- or tcberner's comment that his qconfig-modules.h file *was* a screenful, and is now much shorter (and alphabetical, too!) An additional complication comes from needing to update qtchooser, *if* it is installed and *if* the package needs it. There was another set of @postexec lines for that. Migrate all the update logic to a shell script (there already was one for deinstall, now make it do triple-duty). From the template file, `pkg-change.in`, we generate a pkg-install and a pkg-deinstall script that does the right thing. PR: 253356 253360 Reported by: Nimaje on IRC Reviewed by: tcberner
Notes
Notes: svn path=/head/; revision=566427
Diffstat (limited to 'Mk/Uses/qt-dist.mk')
-rw-r--r--Mk/Uses/qt-dist.mk72
1 files changed, 47 insertions, 25 deletions
diff --git a/Mk/Uses/qt-dist.mk b/Mk/Uses/qt-dist.mk
index 5cfbd3356a73..6b91e0fc313e 100644
--- a/Mk/Uses/qt-dist.mk
+++ b/Mk/Uses/qt-dist.mk
@@ -196,11 +196,9 @@ QT_DEFINES?= # For qconfig.h flags (without "QT_" prefix).
QT_CONFIG?= # For *.pri files QT_CONFIG flags.
. if ${QT_DEFINES}
QMAKE_ARGS+= DEFINES+="${QT_DEFINES:O:u:C/^([^-])/QT_\1/:C/^-/QT_NO_/:O}"
-. if ${QT_DEFINES:N-*}
-# Use a script to cleanup qconfig-modules.h (see qt-post-install).
-PKGDEINSTALL= ${WRKDIR}/pkg-deinstall
-. endif
. endif # ${QT_DEFINES}
+PKGDEINSTALL= ${WRKDIR}/pkg-install
+PKGINSTALL= ${WRKDIR}/pkg-deinstall
. if ${QT_CONFIG:N-*}
QMAKE_ARGS+= QT_CONFIG+="${QT_CONFIG:N-*:O:u}"
. endif
@@ -346,17 +344,55 @@ qt5-pre-configure:
. endfor
. endif
+. if ${QT_DEFINES:N-*}
+# There **are** defines, so we need to **add** this port to the
+# qconfig-modules.h header; make @need_add empty and comment out
+# the @need_remove lines in the script (see below in qt-post-install).
+# If there are no defines, do it the other way around.
+_sub_need_add=
+_sub_need_remove= \#\#
+. else
+_sub_need_add= \#\#
+_sub_need_remove=
+. endif
+# Handle misc/qtchooser wrapper installation and deinstallation
+# If a port installs Qt version-specific binaries (e.g. "designer" which
+# existed as a Qt4 application and exists as a Qt5 application and will
+# probably be a Qt6 application) which should have a qtchooser-based wrapper,
+# the port should set `QT_BINARIES=yes`.
+. if defined(QT_BINARIES)
+_sub_need_bin=
+. else
+_sub_need_bin= \#\#
+. endif
+. if ${QT_MODNAME} == core
+# QtCore (e.g. devel/qt5-core) is the one that starts the header,
+# and is also the one that can clean it up when deinstalled.
+_sub_need_clean=
+. else
+_sub_need_clean= \#\#
+. endif
post-install: qt-post-install
qt-post-install:
-. if ${QT_DEFINES:N-*}
-# We can't use SUB_FILES with a shared pkg-deinstall.in.
-# We need it to be a script instead of a group of @unexecs, otherwise
-# qconfig-modules.h cleanup will be run in pre-deinstall stage, which is
-# useless. This will probably be replaced by a Keywords/ script in the future.
+# We can't use SUB_FILES with the shared pkg-change.in.
+# We need it to be a script instead of a group of @unexecs.
+# Do two steps of processing -- introducing the Qt variables,
+# and replacing the @tags with comment (or nothing) characters
+# according to the port's settings -- in one sed and write
+# to pkg-change.tmp. Then split it up and minify for the
+# install and deinstall step.
@${SED} -e 's,%%QT_MODNAME%%,${QT_MODNAME},g' \
-e 's,%%QT_INCDIR%%,${QT_INCDIR},g' \
- ${PORTSDIR}/devel/${_QT_RELNAME}/${FILESDIR:T}/${PKGDEINSTALL:T}.in > \
- ${PKGDEINSTALL}
+ -e 's,@need_add,${_sub_need_add},' \
+ -e 's,@need_remove,${_sub_need_remove},' \
+ -e 's,@need_clean,${_sub_need_clean},' \
+ -e 's,@need_bin,${_sub_need_bin},' \
+ ${PORTSDIR}/devel/${_QT_RELNAME}/${FILESDIR:T}/pkg-change.in > \
+ ${WRKDIR}/pkg-change.tmp
+ @${SED} -e 's,@install,,' -e 's,@deinstall,##,' ${WRKDIR}/pkg-change.tmp | ${SED} -e '/##/d' > ${PKGINSTALL}
+ @${SED} -e 's,@install,##,' -e 's,@deinstall,,' ${WRKDIR}/pkg-change.tmp | ${SED} -e '/##/d' > ${PKGDEINSTALL}
+ @${REINPLACE_CMD} 's/\t//g' ${PKGINSTALL} ${PKGDEINSTALL}
+. if ${QT_DEFINES:N-*}
@${MKDIR} ${STAGEDIR}${QT_INCDIR}/QtCore/modules
@${ECHO_CMD} -n \
> ${STAGEDIR}${QT_INCDIR}/QtCore/modules/qconfig-${QT_MODNAME}.h
@@ -372,8 +408,6 @@ qt-post-install:
. endfor
@${ECHO_CMD} "${PREFIX}/${QT_INCDIR_REL}/QtCore/modules/qconfig-${QT_MODNAME}.h" \
>> ${TMPPLIST}
- @${ECHO_CMD} "@exec echo '#include <QtCore/modules/qconfig-${QT_MODNAME}.h>' >> ${PREFIX}/${QT_INCDIR_REL}/QtCore/qconfig-modules.h" \
- >> ${TMPPLIST}
. endif # ${QT_DEFINES:N-*}
. if ${QT_CONFIG:N-*}
@${MKDIR} ${STAGEDIR}${QT_MKSPECDIR}/modules
@@ -383,16 +417,4 @@ qt-post-install:
>> ${TMPPLIST}
. endif # ${QT_CONFIG:N-*}
. endif # M5
-
-# Handle misc/qtchooser wrapper installation and deinstallation
-# If a port installs Qt version-specific binaries (e.g. "designer" which existed as a Qt4 application
-# and exists as a Qt5 application and will probably be a Qt6 application) which should have a
-# qtchooser-based wrapper, the port should set `QT_BINARIES=yes`.
-#
-# When QT_BINARIES is set to yes, compatibility symlinks (designer -> qtchooser, so that
-# qtchooser can run designer-qt5 or whatever is the selected Qt version) are installed by the port.
-. if defined(QT_BINARIES)
- ${ECHO_CMD} '@postexec if type update-qtchooser-wrapper >/dev/null 2>&1; then update-qtchooser-wrapper; fi' >> ${TMPPLIST}
- ${ECHO_CMD} '@postunexec if type update-qtchooser-wrapper >/dev/null 2>&1; then update-qtchooser-wrapper; fi' >> ${TMPPLIST}
-. endif
.endif # defined(_QT_DIST_MK_INCLUDED)