Author: Andy Green Date: Mon Dec 07 07:56:37 2020 +0000 netbsd: rpath diff --git a/.sai.json b/.sai.json index eaefd4d..1b388c7 100644 --- a/.sai.json +++ b/.sai.json @@ -11,10 +11,15 @@ "linux-fedora-32/x86_64-amd/gcc": { "build": "mkdir build destdir;cd build;export CCACHE_DISABLE=1;cmake .. ${cmake};make -j;cpack -G RPM" }, - "netbsd-OSX-catalina/x86_64-intel-i3/llvm": { + "netbsd-OSX-bigsur/x86_64-intel-i3/llvm": { "build": "mkdir build destdir; cd build; export SAI_CPACK=\"-G ZIP\";export MACOSX_DEPLOYMENT_TARGET=10.14 ; cmake .. -DCMAKE_MAKE_PROGRAM=/usr/bin/make -DLWS_OPENSSL_INCLUDE_DIRS=/usr/local/opt/openssl@1.1/include -DLWS_OPENSSL_LIBRARIES=\"/usr/local/opt/openssl/lib/libssl.dylib;/usr/local/opt/openssl/lib/libcrypto.dylib\" ${cmake} && make -j && make -j DESTDIR=../destdir install && ctest -j4 --output-on-failure ${cpack}", "default": false }, + "netbsd/aarch64BE-bcm2837-a53/gcc": { + "build": "mkdir build destdir;cd build;export CCACHE_DISABLE=1;cmake .. ${cmake};make -j4", + "default": false + }, + "windows-10/x86_64-amd/msvc": { "build": "mkdir build && cd build && set SAI_CPACK=\"-G ZIP\" && cmake .. -DSAI_LWS_INC_PATH=\"C:\\Program Files (x86)\\libwebsockets\\include\" -DSAI_LWS_LIB_PATH=\"C:\\Program Files (x86)\\libwebsockets\\lib\\websockets_static.lib\" -DSAI_EXT_PTHREAD_INCLUDE_DIR=\"C:\\Program Files (x86)\\pthreads\\include\" -DSAI_EXT_PTHREAD_LIBRARIES=\"C:\\Program Files (x86)\\pthreads\\lib\\x64\\libpthreadGC2.a\" -DLWS_OPENSSL_INCLUDE_DIRS=\"C:\\Program Files\\OpenSSL\\include\" -DSAI_GIT2_INC_PATH=\"C:\\Program Files (x86)\\libgit2\\include\" -DSAI_GIT2_LIB_PATH=\"C:\\Program Files (x86)\\libgit2\\lib\\git2.lib\" -DLWS_OPENSSL_LIBRARIES=\"C:\\Program Files\\OpenSSL\\lib\\libcrypto.lib;C:\\Program Files\\OpenSSL\\lib\\libssl.lib\" ${cmake} && cmake --build . --config DEBUG && set CTEST_OUTPUT_ON_FAILURE=1 && ctest . -C DEBUG -j4 --output-on-failure ${cpack}", "default": false @@ -29,7 +34,7 @@ }, "builder-only": { "cmake": "-DSAI_SERVER=0 ", - "platforms": "windows-10/x86_64-amd/msvc, netbsd-OSX-catalina/x86_64-intel-i3/llvm", + "platforms": "windows-10/x86_64-amd/msvc, netbsd-OSX-bigsur/x86_64-intel-i3/llvm,netbsd/aarch64BE-bcm2837-a53/gcc", "cpack": "&& cpack -C DEBUG $SAI_CPACK", "artifacts": "build/sai-*.deb, build/sai-*.rpm, build/sai-*.7z" } diff --git a/CMakeLists.txt b/CMakeLists.txt index 55aad93..d16a2c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,11 @@ list(APPEND CMAKE_MODULE_PATH ${LWS_CMAKE_DIR}) include(CheckCSourceCompiles) include(LwsCheckRequirements) -set(CMAKE_SKIP_RPATH 1) +if (CMAKE_HOST_SYSTEM_NAME MATCHES "NetBSD") + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +else() + set(CMAKE_SKIP_RPATH 1) +endif() find_package(Git) if(GIT_EXECUTABLE) diff --git a/READMEs/README-build-bsds.md b/READMEs/README-build-bsds.md new file mode 100644 index 0000000..8bfb465 --- /dev/null +++ b/READMEs/README-build-bsds.md @@ -0,0 +1,127 @@ +# Building Sai on BSDs + +This is what I found as an experieced linux user when setting +up lws + sai on NetBSD for arch64 Big Endian (`aarch64_be`) from +a minimal image. + +https://mail-index.netbsd.org/port-arm/2020/12/03/msg007117.html + +## Packaging + +NetBSD has a system 'pkgsrc' that is equivlent to package source +and binary builds. Normally, you can install binary packages from +a central repository for your arch, as you would expect. This +looks like `pkg_add mypackage`. + +https://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/ + +But arch64BE is too new to have the package repo populated yet... +the base install comes with basic build tools like cvs, gcc and make, +everything else has to be built from the source package, which +is a day of build time on an RPi3. However it's doable and there +and enough pieces there. + +Pkgsrc is not a simple build wrapper, it understands recursive package +deps and can sub-build those automatically. So building large projects +is not a matter of having to chase everything down and build by hand, +it knows how to do it for you for toplevel projects with many deps. + +## Bootstrapping pkgsrc + +### 1) Prepare pkgsrc + +As root, follow the advice here for quickstart/bootstrap + +https://www.pkgsrc.org/ + +``` +cvs -danoncvs@anoncvs.netbsd.org:/cvsroot checkout pkgsrc +cd pkgsrc/bootstrap +./bootstrap +``` + +### 2) Build pkgsrc packges from source + +Then, where x/y is the package category and name + +``` +# cd pkgsrc/x/y +# make install clean +``` + +for these packages + +``` +# devel/git +# devel/cmake +# devel/libgit2 +# shells/bash +# security/mozilla-rootcerts +# sysutils/daemond +``` + +The base install has a very simplified vi, you may also want +to build `editors/vim` + +### 3) symlink to executables + +Some packages are referred to by well-known paths +like `/bin/bash` + +``` +# ln -s /usr/pkg/bin/bash /bin/bash +# ln -s /usr/pkg/bin/cmke /bin/cmake +``` + +### 4) Set up CA bundle abd openssl cnf + +The base OS doesn't have a trusted C bundle for openssl, +additionlly install the rootcert bundle: + +``` +# mozilla-rootcerts install +``` + +The openssl it comes with expects a config file in order to +create certs, as needed by lws configuration. Create +`/etc/openssl/openssl.cnf` with this: + +``` +[req] +default_bits=2048 +encrypt_key=no +default_md=sha256 +distinguished_name=req_subj +[req_subj] +commonName="Fully Qualified Domain Name (FQDN)" +emailAddress="Administrative Email Address" +countryName="Country Name (2 letter code)" +countryName_default=US +stateOrProvinceName="State Name (full name)" +stateOrProvinceName_default=Ohio +localityName="Locality Name (e.g., city)" +localityName_default=Columbus +organizationName="Organization Name (e.g., company)" +organizationName_default=Widgets Inc +organizationalUnitName="Organizational Unit Name (e.g., section)" +organizationalUnitName_default=Some Unit +``` + +After that there are enough pieces to fetch from git and +build lws and sai-builder as you would expect. + +### 5) Build lws + sai + +lws requires the additional cmake flag `-DLWS_WITHOUT_DAEMONIZE=0` + +There is no sudo, I dealt with make install by having a root +and user console session open in parallel on the same build +dir. + +### 6) Set up init + +Copy `./scripts/etc-rc.d-sai_builder-NetBSD` to `/etc/rc.d/sai_builder` + +Edit `/etc/rc.conf` and add `sai_builder=YES` at the bottom to start +it at boot, then `/etc/rc.d/sai_builder start` + diff --git a/READMEs/README-systemd-nspawn.md b/READMEs/README-systemd-nspawn.md index e6b120a..d379926 100644 --- a/READMEs/README-systemd-nspawn.md +++ b/READMEs/README-systemd-nspawn.md @@ -109,6 +109,7 @@ root@myhost:~# useradd -u883 -gnogroup sai -d/home/sai -m -r ``` For redhat type systems, use `-gnobody` instead +For BSDs, `useradd -u883 -g32766 -d/home/sai -m sai` ### Specific to Debian Buster / Sid diff --git a/assets/arch-aarch64BE-bcm2837-a53.svg b/assets/arch-aarch64BE-bcm2837-a53.svg new file mode 100644 index 0000000..d7eadcc --- /dev/null +++ b/assets/arch-aarch64BE-bcm2837-a53.svg @@ -0,0 +1,26 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + BE + + diff --git a/assets/netbsd.svg b/assets/netbsd.svg new file mode 100644 index 0000000..9ce59a1 --- /dev/null +++ b/assets/netbsd.svg @@ -0,0 +1,16 @@ + + + + + + image/svg+xml + + + + + + + + + + diff --git a/src/builder/b-sai.c b/src/builder/b-sai.c index 67e8144..8143123 100644 --- a/src/builder/b-sai.c +++ b/src/builder/b-sai.c @@ -322,6 +322,14 @@ int main(int argc, const char **argv) if ((p = lws_cmdline_option(argc, argv, "-d"))) logs = atoi(p); +#if defined(__NetBSD__) + if (lws_cmdline_option(argc, argv, "-D")) { + if (lws_daemonize("/var/run/sai_builder.pid")) + return 1; + lws_set_log_level(logs, lwsl_emit_syslog); + } else +#endif + lws_set_log_level(logs, NULL); #if defined(WIN32)