From 4c4b6735e09a5a5fe2d553a25493cdeae0ec35c8 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 28 Mar 2026 13:35:47 +0200 Subject: Remove packaging targets from Magefile, moved to conf/packages Build/upload logic for FreeBSD and OpenBSD packages now lives in ~/git/conf/packages/ as a Makefile + shell scripts. Magefile retains only build, test, vet, and lint targets. Co-Authored-By: Claude Opus 4.6 --- Magefile.go | 267 ------------------------------------------------------------ 1 file changed, 267 deletions(-) diff --git a/Magefile.go b/Magefile.go index daabc74..9a58046 100644 --- a/Magefile.go +++ b/Magefile.go @@ -7,40 +7,10 @@ import ( "fmt" "os" "os/exec" - "strings" "github.com/magefile/mage/mg" ) -const ( - // SSH targets for native packaging - freebsdHost = "f0.lan.buetow.org" - freebsdSSH = "-p 22" - openbsdHost = "rex@fishfinger.buetow.org" - - // NFS path on freebsdHost where the PV is mounted - pvBase = "/data/nfs/k3svolumes/pkgrepo" - - // Repo URL paths - freebsdRepoPath = "freebsd/FreeBSD:15:amd64/latest" - openbsdRepoPath = "openbsd/7.8/packages/amd64" -) - -// version reads the version from internal/version.go, stripping the "v" prefix. -func version() (string, error) { - data, err := os.ReadFile("internal/version.go") - if err != nil { - return "", fmt.Errorf("reading version.go: %w", err) - } - for _, line := range strings.Split(string(data), "\n") { - if strings.Contains(line, "Version") && strings.Contains(line, "=") { - v := strings.Trim(strings.Split(line, "\"")[1], "v") - return v, nil - } - } - return "", fmt.Errorf("version not found in internal/version.go") -} - // Build builds the gogios binary for the current platform. func Build() error { fmt.Println("Building...") @@ -103,240 +73,3 @@ func Test() error { testCmd.Stderr = os.Stderr return testCmd.Run() } - -// crossBuild compiles gogios for the given GOOS and outputs to the given path. -func crossBuild(goos, output string) error { - fmt.Printf("Cross-compiling for %s/amd64...\n", goos) - env := os.Environ() - env = append(env, "GOOS="+goos, "GOARCH=amd64") - cmd := exec.Command("go", "build", "-o", output, "cmd/gogios/main.go") - cmd.Env = env - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - return cmd.Run() -} - -// sshRun executes a command on a remote host via SSH. -func sshRun(host, command string) error { - args := []string{} - if host == freebsdHost { - args = append(args, "-p", "22") - } - args = append(args, host, command) - cmd := exec.Command("ssh", args...) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - return cmd.Run() -} - -// scpTo copies a local file to a remote host via SCP. -func scpTo(localPath, host, remotePath string) error { - args := []string{} - if host == freebsdHost { - args = append(args, "-P", "22") - } - args = append(args, localPath, host+":"+remotePath) - cmd := exec.Command("scp", args...) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - return cmd.Run() -} - -// scpFrom copies a remote file to a local path via SCP. -func scpFrom(host, remotePath, localPath string) error { - args := []string{} - if host == freebsdHost { - args = append(args, "-P", "22") - } - args = append(args, host+":"+remotePath, localPath) - cmd := exec.Command("scp", args...) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - return cmd.Run() -} - -// BuildFreebsd cross-compiles gogios for FreeBSD amd64. -func BuildFreebsd() error { - return crossBuild("freebsd", "gogios-freebsd") -} - -// BuildOpenbsd cross-compiles gogios for OpenBSD amd64. -func BuildOpenbsd() error { - return crossBuild("openbsd", "gogios-openbsd") -} - -// PkgFreebsd builds the FreeBSD package on f0 and uploads it to the repo. -// Cross-compiles locally, ships the binary to f0, packages with pkg create, -// regenerates repo metadata, and copies to the PV. -func PkgFreebsd() error { - if err := BuildFreebsd(); err != nil { - return err - } - - ver, err := version() - if err != nil { - return err - } - - fmt.Printf("Packaging gogios %s for FreeBSD...\n", ver) - - // Write a local temp script, scp it, then execute via /bin/sh on f0 - script := fmt.Sprintf(`#!/bin/sh -set -e -cd /tmp && rm -rf gogios-pkg -mkdir -p gogios-pkg/stage/usr/local/bin gogios-pkg/out/All -cp /tmp/gogios gogios-pkg/stage/usr/local/bin/gogios -chmod 755 gogios-pkg/stage/usr/local/bin/gogios - -printf 'bin/gogios\n' > gogios-pkg/plist - -cat > gogios-pkg/+MANIFEST < gogios-pkg/plist - -cat > gogios-pkg/desc <