git: 0453380c15a5 - main - sysutils/qflipper: New port

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Mon, 28 Nov 2022 21:08:41 UTC
The branch main has been updated by kbowling:

URL: https://cgit.FreeBSD.org/ports/commit/?id=0453380c15a58b9384f199e492133ba7f79e071a

commit 0453380c15a58b9384f199e492133ba7f79e071a
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2022-11-28 21:08:08 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2022-11-28 21:08:08 +0000

    sysutils/qflipper: New port
    
    PC support for Flipper Zero
---
 sysutils/Makefile                                  |  1 +
 sysutils/qflipper/Makefile                         | 28 ++++++++++++++++
 sysutils/qflipper/distinfo                         |  3 ++
 .../files/patch-application_application.pro        | 13 ++++++++
 .../files/patch-application_applicationupdater.cpp | 38 ++++++++++++++++++++++
 ...backend_flipperzero_helper_deviceinfohelper.cpp | 12 +++++++
 .../patch-backend_flipperzero_protobufsession.cpp  | 11 +++++++
 sysutils/qflipper/files/patch-cli_cli.pro          | 18 ++++++++++
 .../files/patch-dfu_device_stm32wb55_infotable.h   | 10 ++++++
 .../patch-plugins_flipperproto0_flipperproto0.pro  | 26 +++++++++++++++
 sysutils/qflipper/files/patch-qFlipper.pro         | 15 +++++++++
 sysutils/qflipper/files/patch-qflipper__common.pri | 35 ++++++++++++++++++++
 sysutils/qflipper/pkg-descr                        |  3 ++
 sysutils/qflipper/pkg-message                      |  8 +++++
 14 files changed, 221 insertions(+)

diff --git a/sysutils/Makefile b/sysutils/Makefile
index 21824f164767..e0ee3a33413b 100644
--- a/sysutils/Makefile
+++ b/sysutils/Makefile
@@ -1137,6 +1137,7 @@
     SUBDIR += pydf
     SUBDIR += qchroot
     SUBDIR += qdirstat
+    SUBDIR += qflipper
     SUBDIR += qjail
     SUBDIR += qjail54
     SUBDIR += qlogtools
diff --git a/sysutils/qflipper/Makefile b/sysutils/qflipper/Makefile
new file mode 100644
index 000000000000..93b2a4242abc
--- /dev/null
+++ b/sysutils/qflipper/Makefile
@@ -0,0 +1,28 @@
+PORTNAME=	qFlipper
+PORTVERSION=	1.2.1
+CATEGORIES=	sysutils
+
+MAINTAINER=	kbowling@FreeBSD.org
+COMMENT=	Application for updating Flipper Zero firmware
+WWW=		https://github.com/flipperdevices/qFlipper
+
+LICENSE=	GPLv3
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+LIB_DEPENDS=	libprotobuf-nanopb.so:devel/nanopb
+
+USES=		compiler:c++11-lang desktop-file-utils gl qmake qt:5
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	flipperdevices
+USE_GL=		gl
+USE_QT=		concurrent core declarative gui linguisttools network \
+		quickcontrols2 serialport svg widgets buildtools:build
+
+PLIST_FILES=	bin/qFlipper \
+		bin/qFlipper-cli \
+		lib/qt5/plugins/libflipperproto0.so \
+		share/applications/qFlipper.desktop \
+		share/icons/hicolor/512x512/apps/qFlipper.png
+
+.include <bsd.port.mk>
diff --git a/sysutils/qflipper/distinfo b/sysutils/qflipper/distinfo
new file mode 100644
index 000000000000..d4d1e2f3e2a7
--- /dev/null
+++ b/sysutils/qflipper/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1669525166
+SHA256 (flipperdevices-qFlipper-1.2.1_GH0.tar.gz) = 3780c77c09e3837e01af8bdc12ea55e052b2f540812736421224112e66a06f00
+SIZE (flipperdevices-qFlipper-1.2.1_GH0.tar.gz) = 1282416
diff --git a/sysutils/qflipper/files/patch-application_application.pro b/sysutils/qflipper/files/patch-application_application.pro
new file mode 100644
index 000000000000..eeea07ecc370
--- /dev/null
+++ b/sysutils/qflipper/files/patch-application_application.pro
@@ -0,0 +1,13 @@
+--- application/application.pro.orig	2022-11-27 22:12:16 UTC
++++ application/application.pro
+@@ -100,8 +100,8 @@ unix:!macx {
+     iconfiles.files = $$PWD/assets/icons/$${TARGET}.png
+     iconfiles.path = $$PREFIX/share/icons/hicolor/512x512/apps
+ 
+-    udevfiles.files = $$PWD/../installer-assets/udev/42-flipperzero.rules
+-    udevfiles.path = $$PREFIX/lib/udev/rules.d
++    #udevfiles.files = $$PWD/../installer-assets/udev/42-flipperzero.rules
++    #udevfiles.path = $$PREFIX/lib/udev/rules.d
+ 
+     INSTALLS += target desktopfiles iconfiles udevfiles
+ 
diff --git a/sysutils/qflipper/files/patch-application_applicationupdater.cpp b/sysutils/qflipper/files/patch-application_applicationupdater.cpp
new file mode 100644
index 000000000000..2dbc1d0f5d33
--- /dev/null
+++ b/sysutils/qflipper/files/patch-application_applicationupdater.cpp
@@ -0,0 +1,38 @@
+--- application/applicationupdater.cpp.orig	2022-11-27 21:54:15 UTC
++++ application/applicationupdater.cpp
+@@ -57,6 +57,9 @@ void ApplicationUpdater::installUpdate(const Flipper::
+ 
+ void ApplicationUpdater::installUpdate(const Flipper::Updates::VersionInfo &versionInfo)
+ {
++#ifdef Q_OS_UNIX
++    return;
++#else
+ #ifdef Q_OS_WINDOWS
+     const auto fileInfo = versionInfo.fileInfo(QStringLiteral("installer"), QStringLiteral("windows/amd64"));
+ #elif defined(Q_OS_MAC)
+@@ -64,7 +67,7 @@ void ApplicationUpdater::installUpdate(const Flipper::
+ #elif defined(Q_OS_LINUX)
+     const auto fileInfo = versionInfo.fileInfo(QStringLiteral("AppImage"), QStringLiteral("linux/amd64"));
+ #else
+-#error "Unsupported OS"
++    #error "Unsupported OS"
+ #endif
+ 
+     const auto fileName = QFileInfo(fileInfo.url()).fileName();
+@@ -145,6 +148,7 @@ void ApplicationUpdater::installUpdate(const Flipper::
+         qCWarning(CATEGORY_SELFUPDATES) << "Downloading the application update package...";
+         setState(State::Downloading);
+     }
++#endif
+ }
+ 
+ void ApplicationUpdater::setState(State state)
+@@ -207,6 +211,7 @@ bool ApplicationUpdater::performUpdate(const QString &
+     return success;
+ 
+ #else
+-#error "Unsupported OS"
++#warning "Unsupported OS"
++    return 1;
+ #endif
+ }
diff --git a/sysutils/qflipper/files/patch-backend_flipperzero_helper_deviceinfohelper.cpp b/sysutils/qflipper/files/patch-backend_flipperzero_helper_deviceinfohelper.cpp
new file mode 100644
index 000000000000..345b565e6b74
--- /dev/null
+++ b/sysutils/qflipper/files/patch-backend_flipperzero_helper_deviceinfohelper.cpp
@@ -0,0 +1,12 @@
+--- backend/flipperzero/helper/deviceinfohelper.cpp.orig	2022-11-28 05:07:31 UTC
++++ backend/flipperzero/helper/deviceinfohelper.cpp
+@@ -97,7 +97,8 @@ void VCPDeviceInfoHelper::findSerialPort()
+ 
+ void VCPDeviceInfoHelper::findSerialPort()
+ {
+-    auto *finder = new SerialFinder(m_deviceInfo.usbInfo.serialNumber(), this);
++    QString serialBsd = QString(m_deviceInfo.usbInfo.serialNumber()).remove(QString("_"));
++    auto *finder = new SerialFinder(serialBsd, this);
+ 
+     connect(finder, &SerialFinder::finished, this, [=](const QSerialPortInfo &portInfo) {
+         if(portInfo.isNull()) {
diff --git a/sysutils/qflipper/files/patch-backend_flipperzero_protobufsession.cpp b/sysutils/qflipper/files/patch-backend_flipperzero_protobufsession.cpp
new file mode 100644
index 000000000000..ebf09f12f3d9
--- /dev/null
+++ b/sysutils/qflipper/files/patch-backend_flipperzero_protobufsession.cpp
@@ -0,0 +1,11 @@
+--- backend/flipperzero/protobufsession.cpp.orig	2022-11-27 21:43:32 UTC
++++ backend/flipperzero/protobufsession.cpp
+@@ -426,7 +426,7 @@ const QString ProtobufSession::protobufPluginFileName(
+     return QStringLiteral("flipperproto%1.dll").arg(versionMajor);
+ #elif defined(Q_OS_MAC)
+     return QStringLiteral("libflipperproto%1.dylib").arg(versionMajor);
+-#elif defined(Q_OS_LINUX)
++#elif defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
+     return QStringLiteral("libflipperproto%1.so").arg(versionMajor);
+ #else
+ #error "Unsupported OS"
diff --git a/sysutils/qflipper/files/patch-cli_cli.pro b/sysutils/qflipper/files/patch-cli_cli.pro
new file mode 100644
index 000000000000..3ecb5467b0bf
--- /dev/null
+++ b/sysutils/qflipper/files/patch-cli_cli.pro
@@ -0,0 +1,18 @@
+--- cli/cli.pro.orig	2022-11-27 06:21:50 UTC
++++ cli/cli.pro
+@@ -11,13 +11,13 @@ unix|win32 {
+ 
+ unix|win32 {
+     LIBS += \
+-        -L$$OUT_PWD/../3rdparty/ -l3rdparty \
++        -lprotobuf-nanopb \
+         -L$$OUT_PWD/../plugins/ -lflipperproto0 \
+         -L$$OUT_PWD/../backend/ -lbackend \
+         -L$$OUT_PWD/../dfu/ -ldfu
+ 
+     contains(CONFIG, static): LIBS += \
+-        -L$$OUT_PWD/../3rdparty/ -l3rdparty \
++        -lprotobuf-nanopb \
+         -L$$OUT_PWD/../plugins/ -lflipperproto0
+ }
+ 
diff --git a/sysutils/qflipper/files/patch-dfu_device_stm32wb55_infotable.h b/sysutils/qflipper/files/patch-dfu_device_stm32wb55_infotable.h
new file mode 100644
index 000000000000..9e22d3f21fe9
--- /dev/null
+++ b/sysutils/qflipper/files/patch-dfu_device_stm32wb55_infotable.h
@@ -0,0 +1,10 @@
+--- dfu/device/stm32wb55/infotable.h.orig	2022-11-27 21:57:44 UTC
++++ dfu/device/stm32wb55/infotable.h
+@@ -52,6 +52,7 @@ struct FUSDeviceInfoTable
+     uint32_t  reserved2;
+     uint64_t  UID64;
+     uint16_t  deviceID;
++    uint32_t  padding_ /* padding for 32 bit build */;
+ };
+ 
+ struct DeviceInfoTable {
diff --git a/sysutils/qflipper/files/patch-plugins_flipperproto0_flipperproto0.pro b/sysutils/qflipper/files/patch-plugins_flipperproto0_flipperproto0.pro
new file mode 100644
index 000000000000..f37f9ff2978e
--- /dev/null
+++ b/sysutils/qflipper/files/patch-plugins_flipperproto0_flipperproto0.pro
@@ -0,0 +1,26 @@
+--- plugins/flipperproto0/flipperproto0.pro.orig	2022-10-03 15:15:41 UTC
++++ plugins/flipperproto0/flipperproto0.pro
+@@ -13,7 +13,6 @@ INCLUDEPATH += $$PWD/../protobufinterface \
+ VERSION = 0.0.0
+ 
+ INCLUDEPATH += $$PWD/../protobufinterface \
+-    $$PWD/../../3rdparty/nanopb
+ 
+ HEADERS += \
+     guirequest.h \
+@@ -59,13 +58,13 @@ unix|win32 {
+     systemresponse.cpp
+ 
+ unix|win32 {
+-    LIBS += -L$$OUT_PWD/../../3rdparty/ -l3rdparty
++    LIBS += -lprotobuf-nanopb
+ }
+ 
+ DEFINES += PB_ENABLE_MALLOC
+ 
+ unix:!macx {
+-    target.path = $$PREFIX/lib/$$NAME/plugins
++    target.path = $$PREFIX/lib/qt5/plugins
+ } else:macx {
+     target.path = $$DESTDIR/../$${NAME}.app/Contents/PlugIns
+ } else:win32 {
diff --git a/sysutils/qflipper/files/patch-qFlipper.pro b/sysutils/qflipper/files/patch-qFlipper.pro
new file mode 100644
index 000000000000..0c6310092aa8
--- /dev/null
+++ b/sysutils/qflipper/files/patch-qFlipper.pro
@@ -0,0 +1,15 @@
+--- qFlipper.pro.orig	2022-11-27 06:24:58 UTC
++++ qFlipper.pro
+@@ -1,7 +1,6 @@ SUBDIRS += \
+ TEMPLATE = subdirs
+ 
+ SUBDIRS += \
+-    3rdparty \
+     application \
+     backend \
+     dfu \
+@@ -11,4 +10,3 @@ cli.depends = backend
+ backend.depends = dfu plugins
+ application.depends = backend
+ cli.depends = backend
+-plugins.depends = 3rdparty
diff --git a/sysutils/qflipper/files/patch-qflipper__common.pri b/sysutils/qflipper/files/patch-qflipper__common.pri
new file mode 100644
index 000000000000..c7b70517a74b
--- /dev/null
+++ b/sysutils/qflipper/files/patch-qflipper__common.pri
@@ -0,0 +1,35 @@
+--- qflipper_common.pri.orig	2022-11-27 18:49:46 UTC
++++ qflipper_common.pri
+@@ -5,7 +5,7 @@ unix:!macx {
+ unix:!macx {
+     DEFINES += USB_BACKEND_LIBUSB
+     CONFIG += link_pkgconfig
+-    PKGCONFIG += libusb-1.0 zlib
++    LIBS += -lusb -lz
+ 
+     isEmpty(PREFIX): PREFIX = /usr
+ 
+@@ -27,20 +27,11 @@ unix:!macx {
+     error("Unsupported OS or compiler")
+ }
+ 
+-GIT_VERSION = $$system("git describe --tags --abbrev=0","lines", HAS_VERSION)
+-!equals(HAS_VERSION, 0) {
+-    GIT_VERSION = unknown
+-}
++GIT_VERSION = 1.2.1
+ 
+-GIT_COMMIT = $$system("git rev-parse --short=8 HEAD","lines", HAS_COMMIT)
+-!equals(HAS_COMMIT, 0) {
+-    GIT_COMMIT = unknown
+-}
++GIT_COMMIT = 3ec0fd9d
+ 
+-GIT_TIMESTAMP = $$system("git log -1 --pretty=format:%ct","lines", HAS_TIMESTAMP)
+-!equals(HAS_TIMESTAMP, 0) {
+-    GIT_TIMESTAMP = 0
+-}
++GIT_TIMESTAMP = 1664810141
+ 
+ DEFINES += APP_NAME=\\\"$$NAME\\\" \
+            APP_VERSION=\\\"$$GIT_VERSION\\\" \
diff --git a/sysutils/qflipper/pkg-descr b/sysutils/qflipper/pkg-descr
new file mode 100644
index 000000000000..268de2596b34
--- /dev/null
+++ b/sysutils/qflipper/pkg-descr
@@ -0,0 +1,3 @@
+Graphical desktop application for updating Flipper Zero firmware via PC
+
+This utility allows updating firmware, repair, remote control, and backup.
diff --git a/sysutils/qflipper/pkg-message b/sysutils/qflipper/pkg-message
new file mode 100644
index 000000000000..14c300202d57
--- /dev/null
+++ b/sysutils/qflipper/pkg-message
@@ -0,0 +1,8 @@
+[
+{ type: install
+  message: <<EOM
+qFlipper must have access to /dev/cuaU* serial ports.
+Either add a user to the "dialer" group, or run it with sudo.
+EOM
+}
+]