From cbdf91d8114cd46d55e84a87fed53ffe86c31885 Mon Sep 17 00:00:00 2001 From: Hiroki Tagato Date: Sat, 14 Jun 2025 14:25:20 +0900 Subject: [PATCH 1/9] Add support for FreeBSD --- binding.gyp | 6 +++--- src/kerberos_common.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/binding.gyp b/binding.gyp index 050ee707..749c9d1d 100644 --- a/binding.gyp +++ b/binding.gyp @@ -54,14 +54,14 @@ ] } }], - ['OS=="mac" or OS=="linux"', { + ['OS=="mac" or OS=="linux" or OS=="freebsd"', { 'sources': [ 'src/unix/base64.cc', 'src/unix/kerberos_gss.cc', 'src/unix/kerberos_unix.cc' ] }], - ['(OS=="mac") or (OS=="linux" and kerberos_use_rtld!="true")', { + ['(OS=="mac") or ((OS=="linux" or OS=="freebsd") and kerberos_use_rtld!="true")', { 'link_settings': { 'libraries': [ '-lkrb5', @@ -78,7 +78,7 @@ }] ] }], - ['(OS=="linux") and (kerberos_use_rtld=="true")', { + ['(OS=="linux" or OS=="freebsd") and (kerberos_use_rtld=="true")', { 'defines': ['KERBEROS_USE_RTLD=1'], 'link_settings': { 'libraries': [ diff --git a/src/kerberos_common.h b/src/kerberos_common.h index 6058f143..9d545949 100644 --- a/src/kerberos_common.h +++ b/src/kerberos_common.h @@ -1,7 +1,7 @@ #ifndef KERBEROS_COMMON_H #define KERBEROS_COMMON_H -#if defined(__linux__) || defined(__APPLE__) +#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) #include "unix/kerberos_gss.h" namespace node_kerberos { From 7a899b567b3672947c145b31c401a8295a907811 Mon Sep 17 00:00:00 2001 From: Hiroki Tagato Date: Wed, 18 Jun 2025 13:37:13 +0900 Subject: [PATCH 2/9] Add GitHub Actions for FreeBSD build --- .github/workflows/build.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 362d89d0..8e0c5beb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -63,3 +63,29 @@ jobs: if-no-files-found: 'error' retention-days: 1 compression-level: 0 + + freebsd_builds: + runs-on: ubuntu-latest + strategy: + matrix: + freebsd_arch: [aarch64, amd64] + steps: + - uses: actions/checkout@v4 + + - name: Build FreeBSD ${{ matrix.freebsd_arch }} Prebuild + uses: vmactions/freebsd-vm@v1 + with: + arch: ${{ matrix.freebsd_arch }} + usesh: true + run: | + node .github/scripts/build.mjs + + - id: upload + name: Upload prebuild + uses: actions/upload-artifact@v4 + with: + name: build-freebsd-${{ matrix.freebsd_arch }} + path: prebuilds/ + if-no-files-found: 'error' + retention-days: 1 + compression-level: 0 From ddf0ad708d4b389f1c3902c8651962ddbe58367a Mon Sep 17 00:00:00 2001 From: Hiroki Tagato Date: Wed, 18 Jun 2025 13:44:51 +0900 Subject: [PATCH 3/9] Install node package before run --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8e0c5beb..2e3df601 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -77,6 +77,8 @@ jobs: with: arch: ${{ matrix.freebsd_arch }} usesh: true + prepare: | + pkg install -y node run: | node .github/scripts/build.mjs From 280dc7e5ac27a95d650c7c2fea02b082363f98ce Mon Sep 17 00:00:00 2001 From: Hiroki Tagato Date: Wed, 18 Jun 2025 13:52:23 +0900 Subject: [PATCH 4/9] Install npm before run as well Node and npm are provided as separate packages in FreeBSD. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2e3df601..4fb70584 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,7 +78,7 @@ jobs: arch: ${{ matrix.freebsd_arch }} usesh: true prepare: | - pkg install -y node + pkg install -y node npm run: | node .github/scripts/build.mjs From 3472de5875511a3e9d6f5ae218e48a20693ee8c8 Mon Sep 17 00:00:00 2001 From: Hiroki Tagato Date: Wed, 18 Jun 2025 14:02:13 +0900 Subject: [PATCH 5/9] Of course we need to install krb5 package as well --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4fb70584..52bbfdec 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,7 +78,7 @@ jobs: arch: ${{ matrix.freebsd_arch }} usesh: true prepare: | - pkg install -y node npm + pkg install -y krb5 node npm run: | node .github/scripts/build.mjs From 42143aa9461299acd0195fd5e4f1c6d9140d2f22 Mon Sep 17 00:00:00 2001 From: Hiroki Tagato Date: Wed, 18 Jun 2025 14:23:14 +0900 Subject: [PATCH 6/9] Add FreeBSD-specific include and library dirs FreeBSD packages are installed into /usr/local/... by default. So we need to add those directories to header and library search paths. --- binding.gyp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/binding.gyp b/binding.gyp index 749c9d1d..67365cb8 100644 --- a/binding.gyp +++ b/binding.gyp @@ -86,6 +86,16 @@ ] }, }], + ['OS=="freebsd"', { + 'include_dirs': [ + '/usr/local/include', + ], + 'link_settings': { + 'library_dirs': [ + '/usr/local/lib', + ] + }, + }], ['OS=="win"', { 'sources': [ 'src/win32/kerberos_sspi.cc', From ba14495cc5db6903c905b67b50bfeae179eec5d5 Mon Sep 17 00:00:00 2001 From: Hiroki Tagato Date: Wed, 18 Jun 2025 15:07:34 +0900 Subject: [PATCH 7/9] libcom_err.so on FreeBSD has different major version than Linux This causes runtime error when the module is compiled with kerberos_use_rtld==true. --- src/unix/kerberos_gss.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/unix/kerberos_gss.cc b/src/unix/kerberos_gss.cc index ddcf39b5..c9230f7f 100644 --- a/src/unix/kerberos_gss.cc +++ b/src/unix/kerberos_gss.cc @@ -65,10 +65,17 @@ struct DLOpenHandle { DLOpenHandle& operator=(DLOpenHandle&) = delete; }; +#ifndef __FreeBSD__ #define DYLIBS(V) \ V(gssapi, "libgssapi_krb5.so.2") \ V(krb5, "libkrb5.so.3") \ V(comerr, "libcom_err.so.2") +#else +#define DYLIBS(V) \ + V(gssapi, "libgssapi_krb5.so.2") \ + V(krb5, "libkrb5.so.3") \ + V(comerr, "libcom_err.so.3") +#endif #define LIBRARY_HANDLE_GETTER(name, lib) \ static const DLOpenHandle& name ## _handle() { \ From c92dbccae4ef93a89ed670386159d9a12495df6e Mon Sep 17 00:00:00 2001 From: Hiroki Tagato Date: Wed, 18 Jun 2025 15:32:00 +0900 Subject: [PATCH 8/9] Align step name with host_builds step --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 52bbfdec..4629d5f9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -72,7 +72,7 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Build FreeBSD ${{ matrix.freebsd_arch }} Prebuild + - name: Build freebsd-${{ matrix.freebsd_arch }} Prebuild uses: vmactions/freebsd-vm@v1 with: arch: ${{ matrix.freebsd_arch }} From 3a3fc8f97daab9ec5887c8e6effd8d0d92162a5e Mon Sep 17 00:00:00 2001 From: Hiroki Tagato Date: Fri, 20 Jun 2025 22:07:29 +0900 Subject: [PATCH 9/9] Utilize pkg-config to get include/library paths for compiler --- .github/workflows/build.yml | 2 +- binding.gyp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4629d5f9..daaef6bd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,7 +78,7 @@ jobs: arch: ${{ matrix.freebsd_arch }} usesh: true prepare: | - pkg install -y krb5 node npm + pkg install -y krb5 node npm pkgconf run: | node .github/scripts/build.mjs diff --git a/binding.gyp b/binding.gyp index 67365cb8..646836cf 100644 --- a/binding.gyp +++ b/binding.gyp @@ -87,12 +87,12 @@ }, }], ['OS=="freebsd"', { - 'include_dirs': [ - '/usr/local/include', + 'include_dirs+': [ + '