Porting Qt app from GitLab

Edit: After submitting I corrected some errors in the thread and added my learning here at the top.

Learnings added after port was submitted:

- Porters handbook is a great starting point but when stuck open bsd.port.mk
- Look for and use test options from bsd.port.mk. It's better to do make fetch-list than to do make fetch
- Remember to update distfiles and pkg-plist when needed
- Don't let the freebsd installer add /usr/ports - you will need to do this with git
- The people on this forum are great. Thanks to everyone for letting me have fun trying to create a port

Original thread starts here:

Source from GitLab that is free with GPL - https://gitlab.com/tp3/Entropy-Piano-Tuner.

About the original GitLab source code.
  • The source contains code for multiple target platforms
  • There's code to build two libraries that are already in base system
  • To compile some changes are necessary to some config files
  • It's uses Qt6, xorg, qmake, mate, gl
  • Compiles with QtCreator on latest GhostBSD (FreeBSD 14.3) or from shell with qmake and make
  • Because of the "inside" libraries some LD_LIBRARY_PATHS needs to be added to run, ie startscript required
Having never done a port for FreeBSD before I am thinking this could be as easy as creating patches with diff between GitHub source and the changes required to make it run.​
What is best practice?​
Is it possible to make fetch the original GitHub repo as a tarball into distfiles (Without a GitLab account?)​
How will the patches get to the ports - are there PATCH_SITES (bsd.port.mk) available?​
Could a beginning Makefile look something like this? (using /usr/ports/audio/fmit as example)​
Makefile:
PORTNAME=    entropypianotuner[/INDENT][/INDENT][/INDENT]
[INDENT=4][INDENT=4]PORTVERSION=    ??[/INDENT][/INDENT]
[INDENT=4][INDENT=4]DISTVERSIONPREFIX=    v[/INDENT][/INDENT]
[INDENT=4][INDENT=4]PORTREVISION=    ??[/INDENT][/INDENT]
[INDENT=4][INDENT=4]CATEGORIES=    audio[/INDENT][/INDENT]
[INDENT=4][INDENT=4][/INDENT][/INDENT]
[INDENT=4][INDENT=4]MAINTAINER=    thinking.about@creating.port[/INDENT][/INDENT]
[INDENT=4][INDENT=4]COMMENT=    Free Piano Tuning software[/INDENT][/INDENT]
[INDENT=4][INDENT=4]WWW=        https://gitlab.com/tp3/Entropy-Piano-Tuner[/INDENT][/INDENT]
[INDENT=4][INDENT=4][/INDENT][/INDENT]
[INDENT=4][INDENT=4]LICENSE=    GPLv3[/INDENT][/INDENT]
[INDENT=4][INDENT=4]LICENSE_COMB=    ???[/INDENT][/INDENT]
[INDENT=4][INDENT=4]LICENSE_FILE_GPLv3=    ${WRKSRC}/gpl_v3.md[/INDENT][/INDENT]
[INDENT=4][INDENT=4][/INDENT][/INDENT]
[INDENT=4][INDENT=4]LIB_DEPENDS=    libfftw3.so:math/fftw3 libuv.so:devel/libuv[/INDENT][/INDENT]
[INDENT=4][INDENT=4][/INDENT][/INDENT]
[INDENT=4][INDENT=4]USES=        compiler:c++14 gl gnome pkgconfig qmake qt:6 tar:bzip2 xorg[/INDENT][/INDENT]
[INDENT=4][INDENT=4][/INDENT][/INDENT]
[INDENT=4][INDENT=4]USE_QT=        buildtools:build core gui opengl qmake:build multimedia network svg widgets[/INDENT][/INDENT]
[INDENT=4][INDENT=4]USE_GL=        gl glut[/INDENT][/INDENT]
[INDENT=4][INDENT=4][/INDENT][/INDENT]
[INDENT=4][INDENT=4]USE_GITHUB=    yes[/INDENT][/INDENT]
[INDENT=4][INDENT=4]GH_ACCOUNT=    ??????[/INDENT][/INDENT]
[INDENT=4][INDENT=4][/INDENT][/INDENT]
[INDENT=4][INDENT=4]QMAKE_ARGS+=    PREFIXSHORTCUT=${PREFIX}[/INDENT][/INDENT]
[INDENT=4][INDENT=4][/INDENT][/INDENT]
[INDENT=4][INDENT=4]OPTIONS_DEFINE=        ALSA JACK OSS PORTAUDIO[/INDENT][/INDENT]
[INDENT=4][INDENT=4]OPTIONS_DEFAULT=    JACK OSS[/INDENT][/INDENT]
[INDENT=4][INDENT=4][/INDENT][/INDENT]
[INDENT=4][INDENT=4]ALSA_LIB_DEPENDS=    libasound.so:audio/alsa-lib[/INDENT][/INDENT]
[INDENT=4][INDENT=4]ALSA_QMAKE_ON=        CONFIG+=acs_alsa[/INDENT][/INDENT]
[INDENT=4][INDENT=4][/INDENT][/INDENT]
[INDENT=4][INDENT=4]OSS_QMAKE_ON=        CONFIG+=acs_oss[/INDENT][/INDENT]
[INDENT=4][INDENT=4][/INDENT][/INDENT]
[INDENT=4][INDENT=4]JACK_LIB_DEPENDS=    libjack.so:audio/jack[/INDENT][/INDENT]
[INDENT=4][INDENT=4]JACK_QMAKE_ON=        CONFIG+=acs_jack[/INDENT][/INDENT]
[INDENT=4][INDENT=4][/INDENT][/INDENT]
[INDENT=4][INDENT=4]PORTAUDIO_LIB_DEPENDS=    libportaudio.so:audio/portaudio[/INDENT][/INDENT]
[INDENT=4][INDENT=4]PORTAUDIO_QMAKE_ON=    CONFIG+=acs_portaudio[/INDENT][/INDENT]
[INDENT=4][INDENT=4][/INDENT][/INDENT]
[INDENT=4][INDENT=4].include <bsd.port.mk>
/grandpa​
 
Last edited:
There's code to build two libraries that are already in base system
To compile some changes are necessary to some config files
It's uses Qt6, xorg, qmake, mate, gl
Compiles with QtCreator on latest GhostBSD (FreeBSD 14.3) or from shell with qmake and make
 
Some progress but stuck at USE_GITLAB.
I need the GITLAB fetch to be recursive - like this

git clone --recursive https://gitlab.com/tp3/Entropy-Piano-Tuner.git

I have this but make fetch only grabs the surface:

Makefile:
USE_GITLAB=     yes

GL_SITE=        https://gitlab.com

GL_ACCOUNT=     tp3

GL_PROJECT=     Entropy-Piano-Tuner

GL_TAGNAME=     f9181865345be460ab5a08a009b49caae1f0d37c

CONFIGURE_ARGS= --recursive

Is there a way?
/grandpa
 
Dear SirDice,
Porters-handbook really need a project based approach. To learn basic stuff about the FreeBSD ports build system. Now all in one document, too much in one for my little brain... It would be nice if someone could make not "a reference document" but "a guide", i know in an ideal world :)
 
I've tried to handwrite the git{hub/lab} submodules.
sh:
$ grep -m1 GL_TUPLE /usr/ports/Mk/bsd.sites.mk
# GL_TUPLE      - above shortened to [site[:port][/webroot]:]account:project:tagname:group[/subdir]
Makefile:
USE_GITHUB=     nodefault
GH_TUPLE=       libuv:libuv:ca107b7:libuv/thirdparty/libuv/libuv
USE_GITLAB=     yes
GL_ACCOUNT=     tp3
GL_TAGNAME=     f9181865345be460ab5a08a009b49caae1f0d37c
GL_TUPLE=       chwick:fftw3-qmake:9fc2a56:fftw3_qmake/thirdparty/fftw3 \
                tp3:qtmidi:1c3bf17:qtmidi/thirdparty/qtmidi \
                chwick:qwt-lib:c778d34:qwt_lib/thirdparty/qwt-lib \
                tp3:tp3log:3861a44:tp3log/thirdparty/tp3log
sh:
yusuf@freebsd:/tmp/Entropy-Piano-Tuner $ git submodule
 9fc2a56e20f80a22a4b55e795a94647f536ee498 thirdparty/fftw3 (remotes/origin/Qt6)
 ca107b7f17fdbede154f00b63952eb523b003a4b thirdparty/libuv/libuv (v1.9.1-92-gca107b7f)
 1c3bf17cef82b9b6ac92b8c50e5b3f0c0ecbb550 thirdparty/qtmidi (qt5-3-g1c3bf17)
 c778d34abbfe7e2d28f4b493f61ef9b8ec17cb84 thirdparty/qwt-lib (heads/master)
 3861a44979d42ed3ded3367d9216d36df9893f13 thirdparty/tp3log (remotes/origin/no-qml-4-g3861a44)

Code:
[submodule "thirdparty/fftw3"]
    path = thirdparty/fftw3
    url = https://gitlab.com/chwick/fftw3-qmake.git
[submodule "thirdparty/libuv/libuv"]
    path = thirdparty/libuv/libuv
    url = https://github.com/libuv/libuv.git
[submodule "thirdparty/qwt-lib"]
    path = thirdparty/qwt-lib
    url = https://gitlab.com/chwick/qwt-lib.git
[submodule "thirdparty/tp3log"]
    path = thirdparty/tp3log
    url = https://gitlab.com/tp3/tp3log.git
[submodule "thirdparty/qtmidi"]
    path = thirdparty/qtmidi
    url = https://gitlab.com/tp3/qtmidi
 
I've tried to handwrite the git{hub/lab} submodules.
Thank you, I had just added qtmidi when I saw your reply :)

Your help proved invaluable - now it's compiling, albeit manually in the workdir. Have to change some arguments for qmake and do some testing and cleanup after build but this looks promising. Thank you once again!

Confirmed working 👍
 
Not sure if it was mentioned or inferred above, but best practice also includes submitting the platform patches back to the main github FOSS project repo. Granted, some FOSS project organizers can be jerks about accepting patches that don't fit their particular vision or FOSS license religion, but at least give it a shot. Just make sure the freeBSD port build is non-destructive to other platforms if it is merged back upstream.
 
Not sure if it was mentioned or inferred above, but best practice also includes submitting the platform patches back to the main github FOSS project repo. Granted, some FOSS project organizers can be jerks about accepting patches that don't fit their particular vision or FOSS license religion, but at least give it a shot. Just make sure the freeBSD port build is non-destructive to other platforms if it is merged back upstream.
I will contact the original authors and ask if they would like that.
 
Ok, so far I have it doing the following:

make fetch - ok
make stage - ok
make stage-qa - Warning: you might not need LIB_DEPENDS on libGL.so
make package - working on sorting this out

As for the stage-qa warning - there is no LIB_DEPENDS for libGL.so in the Makefile but there is USES+=gl. Can this warning be ignored?

/grandpa
 
So, with below Makefile it now does:

make fetch - ok
make stage - ok
make package - ok
make install - ok
runs as user - ok
make deinstall - ok
make clean - ok

There's 2 warnings for make-qa
make stage-qa
- Warning: you might not need LIB_DEPENDS on libGL.so
- Warning: you might not need LIB_DEPENDS on libQt6Qml.so

How do I go about managing these 2 warnings?

Moving on to testing on a fresh FreeBSD14.

/grandpa

Makefile:
PORTNAME=entropypianotuner
PORTVERSION=master
PORTREVISION=0
CATEGORIES=audio

MAINTAINER=maintainer@maintainers.net
COMMENT=Experimental software for tuning a piano

LICENSE=GPLv3
LICENSE_FILE_GPLv3=${WRKSRC}/gpl_v3.md

LIB_DEPENDS+=libfftw3.so:math/fftw3
LIB_DEPENDS+=libuv.so:devel/libuv
USE_LDCONFIG=   ${PREFIX}/lib/entropypianotuner ${PREFIX}/lib/entropypianotuner/algorithms

USES=compiler:c++14-lang qmake
USES+=qt:6
USES+=gl
USE_QT+=base
USE_QT+=declarative
USE_QT+=multimedia
USE_QT+=svg
USE_QT6+=buildtools:build core gui widgets
USE_GL+=gl
USE_GL+=opengl
USE_GITLAB=yes
GL_ACCOUNT=tp3
GL_PROJECT=Entropy-Piano-Tuner
GL_TUPLE=tp3:qtmidi:1c3bf17:qtmidi/thirdparty/qtmidi \
chwick:qwt-lib:c778d34:qwt_lib/thirdparty/qwt-lib \
tp3:tp3log:3861a44:tp3log/thirdparty/tp3log

post-fetch:
        DISTVERSION=1.3.0

do-install:
        ${INSTALL_PROGRAM} ${WRKSRC}/bin/entropypianotuner ${STAGEDIR}${PREFIX}/bin/
        ${MKDIR} ${STAGEDIR}${PREFIX}/lib/entropypianotuner
        ${INSTALL_LIB} ${WRKSRC}/bin/libcore.so.1.0.0 ${STAGEDIR}${PREFIX}/lib/entropypianotuner/

        ${RLN} ${STAGEDIR}${PREFIX}/lib/entropypianotuner/libcore.so.1.0.0  ${STAGEDIR}${PREFIX}/lib/entropypianotuner/libcore.so
        ${RLN} ${STAGEDIR}${PREFIX}/lib/entropypianotuner/libcore.so.1.0.0  ${STAGEDIR}${PREFIX}/lib/entropypianotuner/libcore.so.1
        ${RLN} ${STAGEDIR}${PREFIX}/lib/entropypianotuner/libcore.so.1.0.0  ${STAGEDIR}${PREFIX}/lib/entropypianotuner/libcore.so.1.0

        ${MKDIR} ${STAGEDIR}${PREFIX}/lib/entropypianotuner/algorithms
        ${INSTALL_LIB} ${WRKSRC}/bin/algorithms/libentropyminimizer.so ${STAGEDIR}${PREFIX}/lib/entropypianotuner/algorithms/
        ${INSTALL_LIB} ${WRKSRC}/bin/algorithms/libpitchraise.so ${STAGEDIR}${PREFIX}/lib/entropypianotuner/algorithms/
        ${INSTALL_LIB} ${WRKSRC}/bin/algorithms/libresettorecording.so ${STAGEDIR}${PREFIX}/lib/entropypianotuner/algorithms/

.include <bsd.port.mk>
 
I know nothing , this automatic build system tells maybe not needed.
- What happens when you remove these dependencies ?
- Otherwise i think everything will just be ok, its a warning , not an error.
 
There's 2 warnings for make-qa
make stage-qa
- Warning: you might not need LIB_DEPENDS on libGL.so
- Warning: you might not need LIB_DEPENDS on libQt6Qml.so
No need to explicitly request GL if using Qt6. Here's a recent port switch from Qt5 to Qt6: https://cgit.freebsd.org/ports/commit/?id=017ebc5f1c79dd3abc3535c5e368adbe59c7feac
As you can see, USES=gl and USE_GL are no longer needed.

As for QML: Don't put it in USE_QT if it's not actually needed/used by upstream.
 
No need to explicitly request GL if using Qt6. Here's a recent port switch from Qt5 to Qt6: https://cgit.freebsd.org/ports/commit/?id=017ebc5f1c79dd3abc3535c5e368adbe59c7feac
As you can see, USES=gl and USE_GL are no longer needed.

As for QML: Don't put it in USE_QT if it's not actually needed/used by upstream.

:) As with everything - if I remove it stage-qa tells me I need it and if I keep it in stage-qa tells me I might not need it. I'll settle for the warning for now.

Thanks for the input!

/grandpa
 
Is port lint ok ?

Well, that is a relative question.

Portlint says:

portlint -A
WARN: /usr/ports/audio/entropypianotuner/pkg-descr: includes lines that exceed 80 characters.
fatal: not a git repository (or any parent up to mount point /usr)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /usr)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /usr)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /usr)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /usr)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /usr)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /usr)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /usr)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
FATAL: work: be sure to cleanup the working directory before committing the port

I know the reason for the fatal.​
It is caused by an ENV variable not being set. if GIT_DISCOVERY_ACROSS_FILESYSTEM is set to 1 this goes away. Edit: This is also needed to be able to commit the port using git.

Improved:​
Makefile:
ORTNAME=       entropypianotuner
DISTVERSION=    1.3.0
CATEGORIES=     audio

MAINTAINER=     <email>
COMMENT=        Experimental software for tuning a piano

LICENSE=                GPLv3
LICENSE_FILE_GPLv3=     ${WRKSRC}/gpl_v3.md

LIB_DEPENDS+=   libfftw3.so:math/fftw3 libuv.so:devel/libuv

USES=           tar:bzip2 compiler:c++14-lang qmake qt:6 gl
USE_LDCONFIG=   ${PREFIX}/lib/entropypianotuner ${PREFIX}/lib/entropypianotuner/algorithms
USE_QT+=        multimedia base svg
USE_GL+=        gl opengl
USE_GITLAB=     yes
GL_ACCOUNT=     tp3
GL_PROJECT=     Entropy-Piano-Tuner
GL_TAGNAME=     f9181865345be460ab5a08a009b49caae1f0d37c
GL_TUPLE=       tp3:qtmidi:1c3bf17:qtmidi/thirdparty/qtmidi chwick:qwt-lib:c778d34:qwt_lib/thirdparty/qwt-lib \
                tp3:tp3log:3861a44:tp3log/thirdparty/tp3log

do-install:
        ${INSTALL_PROGRAM} ${WRKSRC}/bin/entropypianotuner ${STAGEDIR}${PREFIX}/bin/
        ${MKDIR} ${STAGEDIR}${PREFIX}/lib/entropypianotuner
        ${INSTALL_LIB} ${WRKSRC}/bin/libcore.so.1.0.0 ${STAGEDIR}${PREFIX}/lib/entropypianotuner/

        ${RLN} ${STAGEDIR}${PREFIX}/lib/entropypianotuner/libcore.so.1.0.0  ${STAGEDIR}${PREFIX}/lib/entropypianotuner/libcore.so
        ${RLN} ${STAGEDIR}${PREFIX}/lib/entropypianotuner/libcore.so.1.0.0  ${STAGEDIR}${PREFIX}/lib/entropypianotuner/libcore.so.1
        ${RLN} ${STAGEDIR}${PREFIX}/lib/entropypianotuner/libcore.so.1.0.0  ${STAGEDIR}${PREFIX}/lib/entropypianotuner/libcore.so.1.0

        ${MKDIR} ${STAGEDIR}${PREFIX}/lib/entropypianotuner/algorithms
        ${INSTALL_LIB} ${WRKSRC}/bin/algorithms/libentropyminimizer.so ${STAGEDIR}${PREFIX}/lib/entropypianotuner/algorithms/
        ${INSTALL_LIB} ${WRKSRC}/bin/algorithms/libpitchraise.so ${STAGEDIR}${PREFIX}/lib/entropypianotuner/algorithms/
        ${INSTALL_LIB} ${WRKSRC}/bin/algorithms/libresettorecording.so ${STAGEDIR}${PREFIX}/lib/entropypianotuner/algorithms/

.include <bsd.port.mk>
/grandpa​
 
Last edited:
Tested with Makefile from #18 on FreeBSD14.4 installed from memstick on a laptop with even worse hardware than on the one used for creating the port ...

After install including ports and src tree the following was done to the FreeBSD14. Edit: Don't include src and ports tree, add them using git once the install is finished.

pkg update && pkg upgrade
pkg install xorg drm-kmod mate mate-terminal lightdm lightdm-gtk-greeter
cat <<EOF> /etc/rc.conf
dbus_enable="YES"
sysrc lightdm_enable="YES"
EOF
cat <<EOF > /usr/local/etc/X11/xorg.conf.d/20.conf
Section "Device"
Identifier "ident"
Driver "scfb"
EndSection
EOF
reboot


After copying the port structure manually to /usr/ports/audio/entropypianotuner and doing make install clean - as root and then exiting to user - it runs just fine.

Two questions: Edit: Decided to move on from the below questions

1 . What is best practice for the GUI stuff? Leave it to the user to install xfce/xlibre/xorg/mate whatever? What I mean is that in the Makefile there should be no USES+= xorg or similar?
I decided to remove USES+= xorg and let the users install whatever GUI they prefer. Ideally the port after install would state "You will need a GUI to run this" but it's not a perfect world.​
2. Why does the porters handbook say that "make package" should be able to be run as user when user can't access /var/db/pkg?
I was confused about the porters handbook stating that make package should be doable as user. Since /var/db/pkg isn't accessible by user I decided to ignore the handbook in this case.​


/grandpa
 
Back
Top