]> ruderich.org/simon Gitweb - safcm/safcm.git/commitdiff
Add basic support for OpenBSD
authorSimon Ruderich <simon@ruderich.org>
Sat, 17 Apr 2021 12:48:42 +0000 (14:48 +0200)
committerSimon Ruderich <simon@ruderich.org>
Sat, 17 Apr 2021 12:53:38 +0000 (14:53 +0200)
Installing packages and starting/enabling services is not yet supported.
There are minor limitations when handling symlinks (see README.adoc).

/var/tmp is a symlink on OpenBSD so just remove this test.

.builds/openbsd.yml [new file with mode: 0644]
README.adoc
ci/run
cmd/safcm-remote/build.sh
cmd/safcm-remote/sync/files_test.go
cmd/safcm/config/files_test.go
rpc/dial.go

diff --git a/.builds/openbsd.yml b/.builds/openbsd.yml
new file mode 100644 (file)
index 0000000..6ba273e
--- /dev/null
@@ -0,0 +1,17 @@
+image: openbsd/latest
+packages:
+  - go
+  - gmake
+  - xz
+tasks:
+  - all: |
+      # OpenBSD 6.8 only ships with Go 1.15
+      curl -O https://ruderich.eu/go-1.16.3-openbsd-amd64.tar.xz
+      xz -d go-1.16.3-openbsd-amd64.tar.xz
+      tar xf go-1.16.3-openbsd-amd64.tar
+      mv go-1.16.3 go
+      #
+      doas ln -sf /usr/local/bin/gmake /usr/bin/make
+      cd safcm
+      # Go does not yet support -race on OpenBSD
+      ./ci/run GOFLAGS=
index f120694f97abdfe5adbc728996efccee8d7be8b0..d65e2b0f181fcd3493c03fcc988fc5ef247afae2 100644 (file)
@@ -135,6 +135,7 @@ future, others are due to the design of safcm.
     ** GNU/Linux with common commands (`uname`, `id`, `stat`, `sha512sum`,
        `cat`, `mktemp`, `rm`, `ln`, `chmod`)
     ** FreeBSD (same commands, but uses `sha512`)
+    ** OpenBSD (same commands, but uses `sha512`)
   * SSH server
   * to install packages:
     ** `apt-get` (Debian or derivative)
diff --git a/ci/run b/ci/run
index 30b22a1b8b11f58bd6784bc4f3fb08d02ee24bb3..92e81a6e3105150ac87340ab738e50da89117046 100755 (executable)
--- a/ci/run
+++ b/ci/run
@@ -7,15 +7,20 @@ set -x
 PATH=$HOME/go/bin:$PATH
 export PATH
 
-make
-make test
+flags=
+if test $# -ne 0; then
+    flags="$*"
+fi
+
+make $flags
+make test $flags
 
 # Strict umask
 umask 077
 rm -rf *
 git checkout .
-make
-make test
+make $flags
+make test $flags
 
 # Additional static checks only run in CI
 go get honnef.co/go/tools/cmd/staticcheck
index 7edd09078b0331e20c2793fa6b848d087ed4278c..3ee7ccd99607161c2890ebc0f82ecf8ae1334196 100755 (executable)
@@ -36,5 +36,6 @@ mkdir -p "$dest"
 
 build freebsd amd64
 build linux amd64
+build openbsd amd64
 build_arm linux arm 7
 # TODO: support more operating systems and architectures
index 91a85befb83c24d9ea494e991e6699318c0289f8..879fefda156b8789d6b0818459a05b15eb3aa9ae 100644 (file)
@@ -288,13 +288,6 @@ func TestSyncFiles(t *testing.T) {
                                                Gid:       0,
                                                OrigGroup: "group",
                                        },
-                                       "/var/tmp": {
-                                               Path:      "/var/tmp",
-                                               Mode:      fs.ModeDir | 0777 | fs.ModeSticky,
-                                               Uid:       0,
-                                               Gid:       0,
-                                               OrigGroup: "group",
-                                       },
                                },
                        },
                        nil,
@@ -307,7 +300,6 @@ func TestSyncFiles(t *testing.T) {
                                `4: sync remote: files: "/" (group): unchanged`,
                                `4: sync remote: files: "/etc" (group): unchanged`,
                                `4: sync remote: files: "/tmp" (group): unchanged`,
-                               `4: sync remote: files: "/var/tmp" (group): unchanged`,
                        },
                        nil,
                },
index 46da59055ee602646257b77ebea609ab84e07081..6124e8ad93b8a2b48eb59ad658b3689251096eeb 100644 (file)
@@ -47,7 +47,8 @@ func TestLoadFiles(t *testing.T) {
        }
 
        // Regular users cannot create sticky files
-       skipInvalidSticky := runtime.GOOS == "freebsd"
+       skipInvalidSticky := runtime.GOOS == "freebsd" ||
+               runtime.GOOS == "openbsd"
 
        chmod("files-invalid-perm-dir/files", 0500)
        defer chmod("files-invalid-perm-dir/files", 0700)
index f300370aba3f75eb7ff55b7fc9eb0be2c15d9871..ef280191ef57b23ca8f03461a97af206e23ecc67 100644 (file)
@@ -113,7 +113,7 @@ compat_sha512sum() {
        sha512sum "$1"
 }
 `
-       case "freebsd":
+       case "freebsd", "openbsd":
                compat = `
 dir_stat='41777 0 0'
 file_stat="100700 $(id -u) $(id -g)"
@@ -274,7 +274,7 @@ f
 }
 
 func connGetGoos(stdin io.Writer, stdout *bufio.Reader) (string, error) {
-       _, err := fmt.Fprintln(stdin, "uname -o")
+       _, err := fmt.Fprintln(stdin, "uname")
        if err != nil {
                return "", err
        }
@@ -287,12 +287,14 @@ func connGetGoos(stdin io.Writer, stdout *bufio.Reader) (string, error) {
        // NOTE: Adapt helper uploading in dialSSH() when adding new systems
        var goos string
        switch x {
-       case "GNU/Linux":
+       case "Linux":
                goos = "linux"
        case "FreeBSD":
                goos = "freebsd"
+       case "OpenBSD":
+               goos = "openbsd"
        default:
-               return "", fmt.Errorf("unsupported OS %q (`uname -o`)", x)
+               return "", fmt.Errorf("unsupported OS %q (`uname`)", x)
        }
        return goos, nil
 }