show drives. remove stupid commit of plugin binary. damnit
This commit is contained in:
parent
edb3e23311
commit
bd5b16d875
|
@ -2,4 +2,5 @@
|
|||
go.mod
|
||||
go.sum
|
||||
fixup
|
||||
*.so
|
||||
/files/*
|
||||
|
|
38
Makefile
38
Makefile
|
@ -3,15 +3,14 @@ GUIVERSION = $(shell git describe --tags)
|
|||
BUILDTIME = $(shell date +%Y.%m.%d)
|
||||
|
||||
all: verbose
|
||||
-fixup --gui-check-plugin ../../../toolkits/gocui/gocui.so
|
||||
fixup --gui gocui --gui-verbose --gui-file ../../toolkits/gocui/gocui.so drives
|
||||
# -fixup --gui-check-plugin ../../../toolkits/gocui/gocui.so
|
||||
fixup --gui gocui --gui-verbose --gui-file ../../toolkits/gocui/gocui.so
|
||||
|
||||
go-build: goimports
|
||||
GO111MODULE=off go build \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
||||
verbose: goimports
|
||||
-cp -a ../../../toolkits/gocui/gocui.so resources/
|
||||
GO111MODULE=off go install -v -x \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
||||
|
@ -22,9 +21,9 @@ install: goimports
|
|||
vet:
|
||||
GO111MODULE=off go vet
|
||||
|
||||
stderr: go-build
|
||||
echo "writing to /tmp/wit-test.log"
|
||||
./wit-test >/tmp/wit-test.log 2>&1
|
||||
stderr: verbose
|
||||
echo "writing to /tmp/fixup.log"
|
||||
fixup --gui gocui --gui-verbose --gui-file ../../toolkits/gocui/gocui.so drives >/tmp/fixup.log 2>&1
|
||||
|
||||
goimports:
|
||||
goimports -w *.go
|
||||
|
@ -39,30 +38,3 @@ gpl:
|
|||
|
||||
check-git-clean:
|
||||
@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
|
||||
|
|
40
doGui.go
40
doGui.go
|
@ -7,10 +7,12 @@ package main
|
|||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
|
@ -41,31 +43,35 @@ func doGui() {
|
|||
func drawWindow(win *gadgets.GenericWindow) {
|
||||
grid := win.Group.RawGrid()
|
||||
|
||||
grid.NewLabel("Drives:")
|
||||
|
||||
me.dd = grid.NewDropdown()
|
||||
me.dd.AddText("/dev/blah")
|
||||
// me.dd.AddText("/dev/blah")
|
||||
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()
|
||||
|
||||
// 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() {
|
||||
doDrives()
|
||||
})
|
||||
|
||||
grid.NewButton("doDrives2()", func() {
|
||||
doDrives2()
|
||||
})
|
||||
|
||||
grid.NewButton("partition drives", func() {
|
||||
log.Info("something")
|
||||
})
|
||||
|
||||
grid.NextRow()
|
||||
|
||||
grid.NewButton("ConfigSave()", func() {
|
||||
log.Info("todo: make code for this")
|
||||
})
|
||||
doDrives2()
|
||||
|
||||
}
|
||||
|
|
21
main.go
21
main.go
|
@ -6,7 +6,6 @@ package main
|
|||
import (
|
||||
"debug/buildinfo"
|
||||
"embed"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
@ -33,6 +32,14 @@ func main() {
|
|||
gui.InitArg()
|
||||
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 {
|
||||
argv.doBash()
|
||||
os.Exit(0)
|
||||
|
@ -42,9 +49,6 @@ func main() {
|
|||
os.Exit(0)
|
||||
}
|
||||
|
||||
// checkPlug("../../../toolkits/gocui/gocui.so")
|
||||
// checkPlug("/usr/lib/go-gui-toolkits/gocui.v0.22.46.so")
|
||||
|
||||
/*
|
||||
if argv.Drives != nil {
|
||||
doDrives()
|
||||
|
@ -52,9 +56,6 @@ func main() {
|
|||
}
|
||||
*/
|
||||
|
||||
// doDrives()
|
||||
// okExit("everything compiled")
|
||||
|
||||
go listenForBlockEvents()
|
||||
doGui()
|
||||
okExit("everything compiled")
|
||||
|
@ -117,7 +118,7 @@ func dumpDebug() {
|
|||
|
||||
func checkPlug(pluginPath string) *plugin.Plugin {
|
||||
if err := checkPluginViaSubprocess(pluginPath); err != nil {
|
||||
fmt.Printf("Plugin check failed: %v\n", err)
|
||||
log.Printf("Plugin check failed: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -133,11 +134,11 @@ func checkPlug(pluginPath string) *plugin.Plugin {
|
|||
func checkPluginViaSubprocess(path string) error {
|
||||
exe, err := os.Executable()
|
||||
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)
|
||||
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)
|
||||
|
|
|
@ -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.
|
@ -12,7 +12,9 @@ var me *autoType
|
|||
|
||||
// this app's variables
|
||||
type autoType struct {
|
||||
pp *arg.Parser // go-arg preprocessor
|
||||
myGui *gui.Node // the gui toolkit handle
|
||||
dd *gui.Node // the drives dropdown list
|
||||
pp *arg.Parser // go-arg preprocessor
|
||||
myGui *gui.Node // the gui toolkit handle
|
||||
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
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"syscall"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
/*
|
||||
|
@ -43,7 +44,9 @@ func listenForBlockEvents() {
|
|||
msg := parseUevent(buf[:n])
|
||||
if msg["SUBSYSTEM"] == "block" && msg["ACTION"] == "add" {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue