sysutils/bsdisks: 0.36 requires full C++20 header

From: Tatsuki Makino <tatsuki_makino_at_hotmail.com>
Date: Sun, 10 Nov 2024 23:23:24 UTC
Hello.

bsdisks-0.36 is now something that can't be built for people like me who are still using environments with incomplete c20 headers.
If you want to force it to build, apply a patch like the one attached below and build it :)

Regards.

diff --git a/sysutils/bsdisks/files/patch-block.cpp b/sysutils/bsdisks/files/patch-block.cpp
new file mode 100644
index 00000000000..03cb6bc613f
--- /dev/null
+++ b/sysutils/bsdisks/files/patch-block.cpp
@@ -0,0 +1,22 @@
+--- block.cpp.orig	2024-11-10 10:48:14 UTC
++++ block.cpp
+@@ -238,10 +238,19 @@ QDBusObjectPath Block::table() const
+
+ void Block::fillMountPoints()
+ {
++#if __FreeBSD__ >= 13
+     auto readyStorage = QStorageInfo::mountedVolumes()
+         | views::filter([](const QStorageInfo &storage) { return storage.isValid() && storage.isReady(); });
++#else
++    auto readyStorage = QStorageInfo::mountedVolumes();
++#endif
+     for (const QStorageInfo &storage : readyStorage)
+     {
++#if __FreeBSD__ >= 13
++#else
++        if(!(storage.isValid() && storage.isReady()))
++            continue;
++#endif
+         // first check if the mounted device matches this->device()
+         bool match = !storage.device().compare(device().chopped(1));
+         // then go over all labels
diff --git a/sysutils/bsdisks/files/patch-blockfilesystem.cpp b/sysutils/bsdisks/files/patch-blockfilesystem.cpp
new file mode 100644
index 00000000000..415e7adf20a
--- /dev/null
+++ b/sysutils/bsdisks/files/patch-blockfilesystem.cpp
@@ -0,0 +1,39 @@
+--- blockfilesystem.cpp.orig	2024-11-10 10:48:14 UTC
++++ blockfilesystem.cpp
+@@ -320,9 +320,17 @@ void BlockFilesystem::signalMountPointsChanged()
+ {
+     // TODO: this probably need a less hacky fix
+     // See https://foss.heptapod.net/bsdutils/bsdisks/-/issues/12
++#if __FreeBSD__ >= 13
+     auto mounts = mountPoints
+         | views::transform([](const auto& pair) { return pair.first + '\0'; });
+     auto mps = QByteArrayList(mounts.begin(), mounts.end());
++#else
++    QByteArrayList mps;
++    for (const auto& mountPair : mountPoints)
++    {
++        mps << (mountPair.first + '\0');
++    }
++#endif
+
+     QVariantMap props;
+     props.insert(QStringLiteral("MountPoints"), QVariant::fromValue(mps));
+@@ -351,9 +359,18 @@ void BlockFilesystem::tryAddMountPoint(QString mountDe
+     }
+
+     if(match) {
++#if __FreeBSD__ >= 13
+         auto exists = [mountPoint](const auto& mountPair) { return mountPoint == mountPair.first; };
+         if (ranges::any_of(mountPoints, exists))
+             return;
++#else
++        for (const auto& mountPair : mountPoints)
++        {
++            if (mountPoint == mountPair.first) {
++                return;
++            }
++        }
++#endif
+
+         mountPoints << qMakePair(mountPoint.toLocal8Bit(), 0);
+
diff --git a/sysutils/bsdisks/files/patch-objectmanager.cpp b/sysutils/bsdisks/files/patch-objectmanager.cpp
new file mode 100644
index 00000000000..2054fd17fc3
--- /dev/null
+++ b/sysutils/bsdisks/files/patch-objectmanager.cpp
@@ -0,0 +1,26 @@
+--- objectmanager.cpp.orig	2024-11-10 10:48:14 UTC
++++ objectmanager.cpp
+@@ -467,10 +467,23 @@ void ObjectManager::addZFSDataset(const ZFSInfo& zfsIn
+
+ void ObjectManager::mountFS(QString mountDevice, QString mountPoint)
+ {
++#if __FreeBSD__ >= 13
+     auto blocks = m_blockObjects.values()
+         | views::filter([](const auto *block) { return block->bFilesystem; });
++#else
++    auto blocks = m_blockObjects.values();
++#endif
+     for(const auto* block: blocks)
++#if __FreeBSD__ >= 13
+         block->bFilesystem->tryAddMountPoint(mountDevice, mountPoint);
++#else
++    {
++        auto* bfs = block->bFilesystem;
++        if(!bfs)
++            continue;
++        block->bFilesystem->tryAddMountPoint(mountDevice, mountPoint);
++    }
++#endif
+ }
+
+ void ObjectManager::unmountFS(QString mountPoint)