Skip to content

Instantly share code, notes, and snippets.

@jperkin
jperkin / pkg_add_nfs.md
Last active April 17, 2024 16:28
pkg_add issue with macOS NFS

Problem

pkgsrc builds on macOS have historically been significantly more unreliable than all other operating systems.

In my most recent builds there were over 400 instances of the error:

pkg_add: no pkg found for '<pkgname>', sorry.
@jperkin
jperkin / edgerouter.md
Last active March 25, 2024 13:22
OpenBSD/octeon EdgeRouter Lite

This is a nifty little device for under £100 suitable for a home router.

I am using one running OpenBSD 6.8 for my AAISP PPPoE connection (avoiding the supplied VMG1312-B10A which has a number of issues).

Installation

I bought a SanDisk 16GB USB stick as there were reports the supplied USB stick isn't particularly reliable, plus it's nice to keep it separate in case of backup or selling the device in the future.

Download the OpenBSD miniroot68.img file system and dd(1) it, for example on macOS (assuming /dev/disk2):

@jperkin
jperkin / userland-dtrace-so.md
Created February 27, 2024 17:28
userland dtrace from shared library

Userland arguments work for functions from the main object, but not those in shared libraries.

An example from the main smbd program is ok:

$ dtrace -lvn 'pid$target:smbd:samba_cmdline_init:entry' -p 76224 
   ID   PROVIDER            MODULE                          FUNCTION NAME
96158   pid76224              smbd                samba_cmdline_init entry

        Probe Description Attributes
@jperkin
jperkin / rpi-cpuinfo-dt.md
Last active January 8, 2024 13:39
raspberry pi cpuinfo vs device-tree

Raspberry Pi cpuinfo vs device-tree

My attempt at gathering information on how to detect exactly which Raspberry Pi model we are running on for https://github.com/jperkin/node-rpio. The goal is to come up with an optimal way of detecting the host across a wide range of hardware and OS.

Data

Name (Rev) cpuinfo /proc/device-tree/model device-tree/soc/ranges OS
B (1.0) 0002 Raspberry Pi Model B 7e000000 20000000 01000000 7
B (1.0) 0002 Raspberry Pi Model B Rev 1 7e000000 20000000 02000000 10
--- pkg_io.o ---
pkg_io.c:81:20: error: incomplete definition of type 'struct url'
if (strcasecmp(url->scheme, SCHEME_HTTP) == 0 ||
~~~^
./lib.h:342:8: note: forward declaration of 'struct url'
struct url *find_best_package(const char *, const char *, int);
^
pkg_io.c:82:20: error: incomplete definition of type 'struct url'
strcasecmp(url->scheme, SCHEME_FTP) == 0)
~~~^
botan-1.10.17nb2/install.log:ERROR: /opt/pkg/lib/libiconv.so.2: libiconv-1.17 is not a runtime dependency
botan-1.10.17nb2/install.log:ERROR: /opt/pkg/lib/libintl.so.8: gettext-lib-0.22.3 is not a runtime dependency
botan-2.19.3nb3/install.log:ERROR: /opt/pkg/lib/libiconv.so.2: libiconv-1.17 is not a runtime dependency
botan-2.19.3nb3/install.log:ERROR: /opt/pkg/lib/libintl.so.8: gettext-lib-0.22.3 is not a runtime dependency
botan3-3.2.0nb1/install.log:ERROR: /opt/pkg/lib/libiconv.so.2: libiconv-1.17 is not a runtime dependency
botan3-3.2.0nb1/install.log:ERROR: /opt/pkg/lib/libintl.so.8: gettext-lib-0.22.3 is not a runtime dependency
cgoban-1.9.14/install.log:ERROR: /opt/pkg/lib/libICE.so.6: libICE-1.1.1 is not a runtime dependency
cgoban-1.9.14/install.log:ERROR: /opt/pkg/lib/libSM.so.6: libSM-1.2.4 is not a runtime dependency
cmark-0.30.3nb1/install.log:ERROR: /opt/pkg/lib/libiconv.so.2: libiconv-1.17 is not a runtime dependency
cmark-0.30.3nb1/install.log:ERROR: /opt/pkg/lib/libintl.so.8: gettext-lib-0.2
Index: mk/buildlink3/bsd.buildlink3.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/buildlink3/bsd.buildlink3.mk,v
retrieving revision 1.261
diff -u -r1.261 bsd.buildlink3.mk
--- mk/buildlink3/bsd.buildlink3.mk 27 Jun 2023 10:40:09 -0000 1.261
+++ mk/buildlink3/bsd.buildlink3.mk 20 Nov 2023 13:02:42 -0000
@@ -226,9 +226,41 @@
. endfor
.endfor

Before:

$ bmake _check-shlibs                                                                                                         
=> Checking for missing run-time search paths in nodejs-21.2.0                                                                 
$

This is wrong. node is linked against gettext-lib and iconv, neither of which are deps, but are pulled in implicitly by others.

#!/bin/sh
#
# Look for any known-to-hang processes that have been running for longer than
# 2 hours, these are not caught by the ulimit -t set by pbulk as they are not
# using any CPU time.
#
# Run from cron and redirect output to a log
#
if [ "$1" = "-n" ]; then
@jperkin
jperkin / rpio.md
Last active October 13, 2023 16:56
Raspberry Pi GPIO Comparison

Comparing node.js GPIO implementations

Here are two simple programs testing the performance of my rpio library against popular alternatives which use the /sys interface (with the number of npm stars indicated for a rough idea of popularity).

rpi-gpio (9 stars)

This test is based on an example on the rpi-gpio page.

As modules which uses /sys depend upon asynchronous behaviour they require callbacks to ensure that the next operation starts only when the previous one has completed.