Skip to content

Commit c7abfeb

Browse files
all: initial support for freebsd
1 parent 26531fc commit c7abfeb

File tree

7 files changed

+71
-5
lines changed

7 files changed

+71
-5
lines changed

.github/workflows/build.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,42 @@ jobs:
6161
run: |
6262
cmake -GNinja -B build -DCRASH_REPORTER=OFF
6363
cmake --build build
64+
65+
freebsd:
66+
name: FreeBSD
67+
runs-on: ubuntu-latest
68+
steps:
69+
- uses: actions/checkout@v4
70+
71+
- name: Build in FreeBSD VM
72+
uses: vmactions/freebsd-vm@v1
73+
with:
74+
release: "15.0"
75+
usesh: true
76+
77+
prepare: |
78+
pkg update -f && pkg install -y \
79+
cmake \
80+
pkgconf \
81+
cli11 \
82+
spirv-tools \
83+
qt6-base \
84+
qt6-declarative \
85+
qt6-shadertools \
86+
qt6-wayland \
87+
wayland \
88+
wayland-protocols \
89+
libdrm \
90+
libxcb \
91+
pipewire \
92+
polkit \
93+
glib \
94+
mesa-libs \
95+
git \
96+
bash \
97+
ninja \
98+
gitup
99+
100+
run: |
101+
cmake -GNinja -B build -DCRASH_REPORTER=OFF -DUSE_JEMALLOC=OFF -DCMAKE_C_FLAGS="-I/usr/local/include -L/usr/local/lib" -DCMAKE_CXX_FLAGS="-I/usr/local/include -L/usr/local/lib"
102+
cmake --build build

src/core/logging.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@
2727
#include <qtmetamacros.h>
2828
#include <qtypes.h>
2929
#include <sys/mman.h>
30+
#ifdef __FreeBSD__
31+
#include <sys/types.h>
32+
#include <unistd.h>
33+
#else
3034
#include <sys/sendfile.h>
35+
#endif
3136

3237
#include "instanceinfo.hpp"
3338
#include "logcat.hpp"
@@ -392,7 +397,7 @@ void ThreadLogging::initFs() {
392397
delete detailedFile;
393398
detailedFile = nullptr;
394399
} else {
395-
auto lock = flock {
400+
struct flock lock = {
396401
.l_type = F_WRLCK,
397402
.l_whence = SEEK_SET,
398403
.l_start = 0,
@@ -414,7 +419,11 @@ void ThreadLogging::initFs() {
414419
auto* oldFile = this->file;
415420
if (oldFile) {
416421
oldFile->seek(0);
422+
#ifdef __FreeBSD__
423+
copy_file_range(oldFile->handle(), nullptr, file->handle(), nullptr, oldFile->size(), 0);
424+
#else
417425
sendfile(file->handle(), oldFile->handle(), nullptr, oldFile->size());
426+
#endif
418427
}
419428

420429
this->file = file;
@@ -426,7 +435,11 @@ void ThreadLogging::initFs() {
426435
auto* oldFile = this->detailedFile;
427436
if (oldFile) {
428437
oldFile->seek(0);
438+
#ifdef __FreeBSD__
439+
copy_file_range(oldFile->handle(), nullptr, detailedFile->handle(), nullptr, oldFile->size(), 0);
440+
#else
429441
sendfile(detailedFile->handle(), oldFile->handle(), nullptr, oldFile->size());
442+
#endif
430443
}
431444

432445
crash::CrashInfo::INSTANCE.logFd = detailedFile->handle();
@@ -889,7 +902,7 @@ bool LogReader::continueReading() {
889902
}
890903

891904
void LogFollower::FcntlWaitThread::run() {
892-
auto lock = flock {
905+
struct flock lock = {
893906
.l_type = F_RDLCK, // won't block other read locks when we take it
894907
.l_whence = SEEK_SET,
895908
.l_start = 0,

src/core/paths.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ void QsPaths::createLock() {
361361
return;
362362
}
363363

364-
auto lock = flock {
364+
struct flock lock = {
365365
.l_type = F_WRLCK,
366366
.l_whence = SEEK_SET,
367367
.l_start = 0,
@@ -389,7 +389,7 @@ bool QsPaths::checkLock(const QString& path, InstanceLockInfo* info, bool allowD
389389
auto file = QFile(QDir(path).filePath("instance.lock"));
390390
if (!file.open(QFile::ReadOnly)) return false;
391391

392-
auto lock = flock {
392+
struct flock lock = {
393393
.l_type = F_WRLCK,
394394
.l_whence = SEEK_SET,
395395
.l_start = 0,

src/core/toolsupport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ bool QmlToolingSupport::lockTooling() {
5454
return false;
5555
}
5656

57-
auto lock = flock {
57+
struct flock lock = {
5858
.l_type = F_WRLCK,
5959
.l_whence = SEEK_SET, // NOLINT (fcntl.h??)
6060
.l_start = 0,

src/services/pam/conversation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <qsocketnotifier.h>
77
#include <qstring.h>
88
#include <qtmetamacros.h>
9+
#include <csignal>
10+
#include <sys/signal.h>
911
#include <sys/wait.h>
1012

1113
#include "../../core/logcat.hpp"

src/services/pam/qml.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
#include <qtclasshelpermacros.h>
77
#include <qthread.h>
88
#include <qtmetamacros.h>
9+
#ifdef __FreeBSD__
10+
#include <security/pam_types.h>
11+
#else
912
#include <security/_pam_types.h>
13+
#endif
1014
#include <security/pam_appl.h>
1115

1216
#include "conversation.hpp"

src/services/pam/subprocess.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
#include <qloggingcategory.h>
88
#include <qstring.h>
99
#include <sched.h>
10+
#ifdef __FreeBSD__
11+
#include <security/pam_types.h>
12+
#else
1013
#include <security/_pam_types.h>
14+
#endif
1115
#include <security/pam_appl.h>
1216
#include <unistd.h>
1317

@@ -83,7 +87,11 @@ PamIpcExitCode PamSubprocess::exec(const char* configDir, const char* config, co
8387
logIf(this->log) << "Starting pam session for user \"" << user << "\" with config \"" << config
8488
<< "\" in dir \"" << configDir << "\"" << std::endl;
8589

90+
#ifdef __FreeBSD__
91+
auto result = pam_start(config, user, &conv, &handle);
92+
#else
8693
auto result = pam_start_confdir(config, user, &conv, configDir, &handle);
94+
#endif
8795

8896
if (result != PAM_SUCCESS) {
8997
logIf(true) << "Unable to start pam conversation with error \"" << pam_strerror(handle, result)

0 commit comments

Comments
 (0)