Index: Uses/qt-dist.mk =================================================================== --- Uses/qt-dist.mk +++ Uses/qt-dist.mk @@ -1,4 +1,4 @@ -# $FreeBSD$ +# $FreeBSD: head/Mk/Uses/qt-dist.mk 545533 2020-08-20 12:37:33Z lbartoletti $ # # There are three Qt related USES files with different access to Qt. # - qmake: The port requires Qt's qmake to build -- creates the configure target @@ -196,11 +196,9 @@ 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,50 @@ . endfor . endif +. if ${QT_DEFINES:N-*} +# Use a script to cleanup qconfig-modules.h (see qt-post-install), +# _CONFIG_EMPTY is substituted into the script. +_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`. +# +# 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) +_sub_need_bin= +. else +_sub_need_bin= \#\# +. endif +. if ${QT_MODNAME} == core +_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. @${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 +403,6 @@ . endfor @${ECHO_CMD} "${PREFIX}/${QT_INCDIR_REL}/QtCore/modules/qconfig-${QT_MODNAME}.h" \ >> ${TMPPLIST} - @${ECHO_CMD} "@exec echo '#include ' >> ${PREFIX}/${QT_INCDIR_REL}/QtCore/qconfig-modules.h" \ - >> ${TMPPLIST} . endif # ${QT_DEFINES:N-*} . if ${QT_CONFIG:N-*} @${MKDIR} ${STAGEDIR}${QT_MKSPECDIR}/modules @@ -383,16 +412,4 @@ >> ${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) Index: qt5/files/pkg-change.in =================================================================== --- /dev/null +++ qt5/files/pkg-change.in @@ -0,0 +1,105 @@ +#!/bin/sh +# +## ### PROCESSING +## +## This file is processed three times: +## - to replace %%variables%% with the intended values +## - to replace @tag with ## or blank as appropriate +## - to filter out lines containing ## +## +## The resulting "minified" script is used as pkg-install or pkg-deinstall +## script in the package. +## +## Lines with @tag at the beginning should be read as conditional; +## multiple @tags are read as "and", so the **rest** of the line +## only ends up in the resulting script when all the @tags are true. +## +## The file is formatted for 8-wide tab stops with hard tabs, +## so that the shell-script itself can be read in column 24, +## e.g. v--- here +## take care not to insert tabs in the actual shell commands. +## +## +## +## ### ABOUT +## +## A Qt module should be listed in QtCore/qconfig-modules.h only once, +## and only if that is needed (e.g. if it has a qconfig-*.h of its own). +## In case 1 (listed), update the target file by appending and sorting: +## - echo the new line +## - .. to sort which reads the existing qconfig-modules.h and stdin +## - .. then move the sorted-uniqued output to the config-modules.h +## In case 2 (unlisted), update the target file by deleting a line +## +## Removing QtCore *may* leave behind an empty file, and in that case +## clean up the config file and directories entirely. +## +## A module with versionable binaries (like "designer" which might have +## a Qt4, Qt5 and Qt6 version) can update the unversioned binary names +## via qt-chooser. +## + +## On deinstall, we need QT_INCDIR separately, so define variables $qi and $qc +## differently from install (which needs only $qc). +@deinstall qi="%%QT_INCDIR%%" +@deinstall qc="$qi/QtCore/qconfig-modules.h" +@install qc="%%QT_INCDIR%%/QtCore/qconfig-modules.h" + qm="%%QT_MODNAME%%" +## +## Distinguish the pkg step and call the relevant shell functions defined above. +## + case $2 in +@install POST-INSTALL) +## +## Add the line #include qconfig-.h to the global +## qconfig-modules.h; afterwards that global file exists. +## +## We might be adding to a non-existent file, which is why there +## is the slightly-weird construction with a subshell piping to sort. +## +@install@need_add { echo "#include " +@install@need_add [ -f "$qc" ] && /bin/cat "$qc" +@install@need_add } | /usr/bin/sort -u -o "$qc.new" +@install@need_add /bin/mv "$qc.new" "$qc" +## +## This removes the line that #includes qconfig-.h +## from the global qconfig-modules.h; afterwards, that global file exists +## although it may be empty. +## (This code is identical in install- and deinstall-scripts, unconditional in deinstall) +## +@install@need_remove [ \! -e "$qc" ] && touch "$qc" +@install@need_remove sed -i "" "/qconfig-$qm\.h/ d" "$qc" +## +## If there are binaries, and qtchooser is installed, update it. +## (This code is identical in install- and deinstall-scripts) +## +@install@need_bin { type update-qtchooser-wrapper && update-qtchooser-wrapper ; } >/dev/null 2>&1 +@install ;; +@deinstall POST-DEINSTALL) +## +## This removes the line that #includes qconfig-.h +## from the global qconfig-modules.h; afterwards, that global file exists +## although it may be empty. +## (This code is identical in install- and deinstall-scripts, unconditional in deinstall) +## +@deinstall [ \! -e "$qc" ] && touch "$qc" +@deinstall sed -i "" "/qconfig-$qm\.h/ d" "$qc" +## +## When qtcore is removed, the whole config dir can go away as well. +## +@deinstall [ \! -e "$qi/QtCore/qconfig.h" ] && \ +@deinstall [ \! -s "$qc" ] && ( +@deinstall rm -f "$qc" +@deinstall rmdir "$qi/QtCore" +@deinstall rmdir "$qi" +@deinstall ) > /dev/null 2>&1 +## +## If there are binaries, and qtchooser is installed, update it. +## (This code is identical in install- and deinstall-scripts) +## +@deinstall@need_bin { type update-qtchooser-wrapper && update-qtchooser-wrapper ; } >/dev/null 2>&1 +@deinstall ;; + esac +## Avoid exit code from any of the commands-above (e.g. checking for +## qtchooser updates) from leaking out of this script: be true. + : Index: devel/qt5/files/pkg-deinstall.in =================================================================== --- devel/qt5/files/pkg-deinstall.in +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# -# $FreeBSD$ - -case $2 in -POST-DEINSTALL) - sed -i "" '/qconfig-%%QT_MODNAME%%\.h/ d' \ - %%QT_INCDIR%%/QtCore/qconfig-modules.h 2>/dev/null || true - [ \! -e %%QT_INCDIR%%/QtCore/qconfig.h ] && - [ \! -s %%QT_INCDIR%%/QtCore/qconfig-modules.h ] && - ( rm -f %%QT_INCDIR%%/QtCore/qconfig-modules.h 2>/dev/null - rmdir %%QT_INCDIR%%/QtCore 2>/dev/null - rmdir %%QT_INCDIR%% 2>/dev/null ) || true - ;; -esac