show drives. remove stupid commit of plugin binary. damnit

This commit is contained in:
Jeff Carr 2025-08-17 15:28:11 -05:00
parent edb3e23311
commit bd5b16d875
8 changed files with 49 additions and 111 deletions

1
.gitignore vendored
View File

@ -2,4 +2,5 @@
go.mod go.mod
go.sum go.sum
fixup fixup
*.so
/files/* /files/*

View File

@ -3,15 +3,14 @@ GUIVERSION = $(shell git describe --tags)
BUILDTIME = $(shell date +%Y.%m.%d) BUILDTIME = $(shell date +%Y.%m.%d)
all: verbose all: verbose
-fixup --gui-check-plugin ../../../toolkits/gocui/gocui.so # -fixup --gui-check-plugin ../../../toolkits/gocui/gocui.so
fixup --gui gocui --gui-verbose --gui-file ../../toolkits/gocui/gocui.so drives fixup --gui gocui --gui-verbose --gui-file ../../toolkits/gocui/gocui.so
go-build: goimports go-build: goimports
GO111MODULE=off go build \ GO111MODULE=off go build \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
verbose: goimports verbose: goimports
-cp -a ../../../toolkits/gocui/gocui.so resources/
GO111MODULE=off go install -v -x \ GO111MODULE=off go install -v -x \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
@ -22,9 +21,9 @@ install: goimports
vet: vet:
GO111MODULE=off go vet GO111MODULE=off go vet
stderr: go-build stderr: verbose
echo "writing to /tmp/wit-test.log" echo "writing to /tmp/fixup.log"
./wit-test >/tmp/wit-test.log 2>&1 fixup --gui gocui --gui-verbose --gui-file ../../toolkits/gocui/gocui.so drives >/tmp/fixup.log 2>&1
goimports: goimports:
goimports -w *.go goimports -w *.go
@ -39,30 +38,3 @@ gpl:
check-git-clean: check-git-clean:
@git diff-index --quiet HEAD -- || (echo "Git repository is dirty, please commit your changes first"; exit 1) @git diff-index --quiet HEAD -- || (echo "Git repository is dirty, please commit your changes first"; exit 1)
old-debian-release: install
wit-test debian --dry-run --verbose --release
debian-release: install
forge dirty
rm -f ~/incoming/*.deb
rm -f ~/go/lib/go-gui/*
forge --install go.wit.com/apps/go-deb
go-deb -h # check to make sure go-deb builds
wit-test debian --verbose
ls -hl ~/incoming/
do-aptly
debian-release-force: install
forge dirty
rm -f ~/incoming/*.deb
rm -f ~/go/lib/go-gui/*
forge --install go.wit.com/apps/go-deb
go-deb -h # check to make sure go-deb builds
wit-test debian --force --verbose
ls -hl ~/incoming/
-dpkg-deb -c ~/incoming/go-gui-toolkits*.deb
do-aptly
debian-release-build-only: install
wit-test debian --verbose --release

View File

@ -7,10 +7,12 @@ package main
import ( import (
"os" "os"
"strings"
"time" "time"
"go.wit.com/gui" "go.wit.com/gui"
"go.wit.com/lib/gadgets" "go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/shell"
"go.wit.com/log" "go.wit.com/log"
) )
@ -41,31 +43,35 @@ func doGui() {
func drawWindow(win *gadgets.GenericWindow) { func drawWindow(win *gadgets.GenericWindow) {
grid := win.Group.RawGrid() grid := win.Group.RawGrid()
grid.NewLabel("Drives:")
me.dd = grid.NewDropdown() me.dd = grid.NewDropdown()
me.dd.AddText("/dev/blah") // me.dd.AddText("/dev/blah")
me.dd.Custom = func() { me.dd.Custom = func() {
log.Info("todo: changed drive") fields := strings.Fields(me.dd.String())
log.Info("changed to", fields)
if len(fields) < 1 {
return
}
me.currentDev = fields[0]
me.parted.SetText("Partition " + me.currentDev)
} }
grid.NextRow() grid.NextRow()
// a button to format or blank a drive
me.parted = grid.NewButton("select drive", func() {
if me.currentDev == "" {
log.Info("You must select a drive first")
return
}
log.Info("check if", me.currentDev, "is in use")
shell.RunVerbose([]string{"parted", me.currentDev, "print"})
})
grid.NextRow()
grid.NewButton("doDrives()", func() { grid.NewButton("doDrives()", func() {
doDrives() doDrives()
}) })
grid.NewButton("doDrives2()", func() { doDrives2()
doDrives2()
})
grid.NewButton("partition drives", func() {
log.Info("something")
})
grid.NextRow()
grid.NewButton("ConfigSave()", func() {
log.Info("todo: make code for this")
})
} }

21
main.go
View File

@ -6,7 +6,6 @@ package main
import ( import (
"debug/buildinfo" "debug/buildinfo"
"embed" "embed"
"fmt"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
@ -33,6 +32,14 @@ func main() {
gui.InitArg() gui.InitArg()
me.pp = arg.MustParse(&argv) me.pp = arg.MustParse(&argv)
// check if the binary is being called to test
// if the plugin can actually loaded. This is a hack
// around needing a Test() plugin load function in GO
if gui.IsGoPluginTestHack() {
gui.CheckPlugin()
os.Exit(0)
}
if argv.Bash { if argv.Bash {
argv.doBash() argv.doBash()
os.Exit(0) os.Exit(0)
@ -42,9 +49,6 @@ func main() {
os.Exit(0) os.Exit(0)
} }
// checkPlug("../../../toolkits/gocui/gocui.so")
// checkPlug("/usr/lib/go-gui-toolkits/gocui.v0.22.46.so")
/* /*
if argv.Drives != nil { if argv.Drives != nil {
doDrives() doDrives()
@ -52,9 +56,6 @@ func main() {
} }
*/ */
// doDrives()
// okExit("everything compiled")
go listenForBlockEvents() go listenForBlockEvents()
doGui() doGui()
okExit("everything compiled") okExit("everything compiled")
@ -117,7 +118,7 @@ func dumpDebug() {
func checkPlug(pluginPath string) *plugin.Plugin { func checkPlug(pluginPath string) *plugin.Plugin {
if err := checkPluginViaSubprocess(pluginPath); err != nil { if err := checkPluginViaSubprocess(pluginPath); err != nil {
fmt.Printf("Plugin check failed: %v\n", err) log.Printf("Plugin check failed: %v\n", err)
return nil return nil
} }
@ -133,11 +134,11 @@ func checkPlug(pluginPath string) *plugin.Plugin {
func checkPluginViaSubprocess(path string) error { func checkPluginViaSubprocess(path string) error {
exe, err := os.Executable() exe, err := os.Executable()
if err != nil { if err != nil {
return fmt.Errorf("failed to get executable path: %w", err) return log.Errorf("failed to get executable path: %w", err)
} }
resolved, err := filepath.EvalSymlinks(exe) resolved, err := filepath.EvalSymlinks(exe)
if err != nil { if err != nil {
return fmt.Errorf("failed to resolve executable symlink: %w", err) return log.Errorf("failed to resolve executable symlink: %w", err)
} }
cmd := exec.Command(resolved, "--gui-check-plugin", path) cmd := exec.Command(resolved, "--gui-check-plugin", path)

View File

@ -1,47 +0,0 @@
package plugincheck
import (
"debug/buildinfo"
"errors"
"fmt"
"runtime/debug"
)
// CheckPluginCompatibility verifies that the plugin .so file was built
// with the same Go version and dependency versions as the host binary.
func CheckPluginCompatibility(pluginPath string) error {
pluginInfo, err := buildinfo.ReadFile(pluginPath)
if err != nil {
return fmt.Errorf("failed to read plugin build info: %w", err)
}
mainInfo, ok := debug.ReadBuildInfo()
if !ok {
return errors.New("failed to read main binary build info")
}
if pluginInfo.GoVersion != mainInfo.GoVersion {
return fmt.Errorf("Go version mismatch: plugin=%s, host=%s",
pluginInfo.GoVersion, mainInfo.GoVersion)
}
// Create a map of main binary dependencies for quick lookup
hostDeps := make(map[string]string)
for _, dep := range mainInfo.Deps {
hostDeps[dep.Path] = dep.Version
}
// Compare plugin dependencies
for _, dep := range pluginInfo.Deps {
hostVer, ok := hostDeps[dep.Path]
if !ok {
return fmt.Errorf("dependency %s not found in host binary", dep.Path)
}
if dep.Version != hostVer {
return fmt.Errorf("dependency version mismatch for %s: plugin=%s, host=%s",
dep.Path, dep.Version, hostVer)
}
}
return nil
}

Binary file not shown.

View File

@ -12,7 +12,9 @@ var me *autoType
// this app's variables // this app's variables
type autoType struct { type autoType struct {
pp *arg.Parser // go-arg preprocessor pp *arg.Parser // go-arg preprocessor
myGui *gui.Node // the gui toolkit handle myGui *gui.Node // the gui toolkit handle
dd *gui.Node // the drives dropdown list dd *gui.Node // the drives dropdown list
parted *gui.Node // the current drive to run parted on
currentDev string // the current dev entry to work on
} }

View File

@ -1,8 +1,9 @@
package main package main
import ( import (
"log"
"syscall" "syscall"
"go.wit.com/log"
) )
/* /*
@ -43,7 +44,9 @@ func listenForBlockEvents() {
msg := parseUevent(buf[:n]) msg := parseUevent(buf[:n])
if msg["SUBSYSTEM"] == "block" && msg["ACTION"] == "add" { if msg["SUBSYSTEM"] == "block" && msg["ACTION"] == "add" {
log.Printf("New block device added: %s\n", msg["DEVNAME"]) log.Printf("New block device added: %s\n", msg["DEVNAME"])
me.dd.AddText("/dev/" + msg["DEVNAME"] + " new")
} }
log.Printf("New syscall.NETLINK_KOBJECT_UEVENT: %v\n", msg)
} }
} }