Compare commits
No commits in common. "dfd5cee2fc613e12dc8e3f1e15858d2881315b30" and "aa9e30ee6a785ebccda945e03c0e26bca4e9c907" have entirely different histories.
dfd5cee2fc
...
aa9e30ee6a
7
Makefile
7
Makefile
|
@ -1,16 +1,15 @@
|
||||||
# Define variables
|
# Define variables
|
||||||
NAME = lon-tool
|
|
||||||
GOFLAGS ?= -ldflags="-s -w"
|
GOFLAGS ?= -ldflags="-s -w"
|
||||||
SRC ?= main.go
|
SRC ?= main.go
|
||||||
BIN_DIR ?= ./bin
|
BIN_DIR ?= ./bin
|
||||||
|
|
||||||
# macOS settings
|
# macOS settings
|
||||||
MACOS_BIN = $(BIN_DIR)/$(NAME)_mac_amd64
|
MACOS_BIN = $(BIN_DIR)/lnd_mac_amd64
|
||||||
MACOS_CC = x86_64-apple-darwin23-gcc-14
|
MACOS_CC = x86_64-apple-darwin23-gcc-14
|
||||||
MACOS_CXX = x86_64-apple-darwin23-g++-14
|
MACOS_CXX = x86_64-apple-darwin23-g++-14
|
||||||
|
|
||||||
# Windows settings
|
# Windows settings
|
||||||
WINDOWS_BIN = $(BIN_DIR)/$(NAME)_win_amd64.exe
|
WINDOWS_BIN = $(BIN_DIR)/lnd_win_amd64.exe
|
||||||
WINDOWS_CC = x86_64-w64-mingw32-gcc
|
WINDOWS_CC = x86_64-w64-mingw32-gcc
|
||||||
WINDOWS_CXX = x86_64-w64-mingw32-g++
|
WINDOWS_CXX = x86_64-w64-mingw32-g++
|
||||||
WINDOWS_PKG_CONFIG_PATH = /usr/local/x86_64-w64-mingw32/lib/pkgconfig
|
WINDOWS_PKG_CONFIG_PATH = /usr/local/x86_64-w64-mingw32/lib/pkgconfig
|
||||||
|
@ -18,7 +17,7 @@ WINDOWS_CGO_CFLAGS = -I/usr/local/x86_64-w64-mingw32/include
|
||||||
WINDOWS_CGO_LDFLAGS = -L/usr/local/x86_64-w64-mingw32/lib
|
WINDOWS_CGO_LDFLAGS = -L/usr/local/x86_64-w64-mingw32/lib
|
||||||
|
|
||||||
# Linux settings
|
# Linux settings
|
||||||
LINUX_BIN = $(BIN_DIR)/$(NAME)_lin_amd64
|
LINUX_BIN = $(BIN_DIR)/lnd_lin_amd64
|
||||||
LINUX_CC = x86_64-linux-gnu-gcc
|
LINUX_CC = x86_64-linux-gnu-gcc
|
||||||
LINUX_CXX = x86_64-linux-gnu-g++
|
LINUX_CXX = x86_64-linux-gnu-g++
|
||||||
LINUX_PKG_CONFIG_PATH = /usr/local/x86_64-linux-gnu/lib/pkgconfig
|
LINUX_PKG_CONFIG_PATH = /usr/local/x86_64-linux-gnu/lib/pkgconfig
|
||||||
|
|
|
@ -3,8 +3,8 @@ package cmd
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"lon-tool/image"
|
|
||||||
"lon-tool/utils"
|
"lon-tool/utils"
|
||||||
|
"lon-tool/image"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -30,7 +30,6 @@ var deployCmd = &cobra.Command{
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var msg string
|
var msg string
|
||||||
|
|
||||||
req_repartition := partsize != ""
|
req_repartition := partsize != ""
|
||||||
|
|
||||||
image, close, err := image.ReadImage(args[0])
|
image, close, err := image.ReadImage(args[0])
|
||||||
|
@ -45,7 +44,6 @@ var deployCmd = &cobra.Command{
|
||||||
logger.Fatal("Failed to get adb client", logger.Args(err))
|
logger.Fatal("Failed to get adb client", logger.Args(err))
|
||||||
}
|
}
|
||||||
fb_devs, err := fastboot.FindDevices()
|
fb_devs, err := fastboot.FindDevices()
|
||||||
logger.Debug("Devices", logger.Args("Devices", fb_devs, "err", err))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Fatal("Failed to get fastboot device", logger.Args(err))
|
logger.Fatal("Failed to get fastboot device", logger.Args(err))
|
||||||
}
|
}
|
||||||
|
@ -58,16 +56,14 @@ var deployCmd = &cobra.Command{
|
||||||
if serail == "autodetect" {
|
if serail == "autodetect" {
|
||||||
for _, dev := range fb_devs {
|
for _, dev := range fb_devs {
|
||||||
product, err := dev.GetVar("product")
|
product, err := dev.GetVar("product")
|
||||||
devSerial, _ := dev.Device.SerialNumber()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warn("Unable to communicate with device", logger.Args("Serial", devSerial))
|
logger.Warn("Unable to communicate with device", logger.Args("Serial", dev.Serial))
|
||||||
logger.Debug("Unable to communicate with device", logger.Args("err", err))
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
logger.Debug("Found device", logger.Args("Product", product, "Sraial", devSerial, "object", dev))
|
logger.Debug("Found device", logger.Args("Product", product, "Sraial", dev.Serial))
|
||||||
if product == "nabu" {
|
if product == "nabu" {
|
||||||
logger.Debug("Nabu found", logger.Args("Serial", devSerial))
|
logger.Debug("Nabu found", logger.Args("Serial", dev.Serial))
|
||||||
serail = devSerial
|
serail = dev.Serial
|
||||||
if !req_repartition {
|
if !req_repartition {
|
||||||
_, err1 := dev.GetVar("partition-type:linux")
|
_, err1 := dev.GetVar("partition-type:linux")
|
||||||
_, err2 := dev.GetVar("partition-type:esp")
|
_, err2 := dev.GetVar("partition-type:esp")
|
||||||
|
@ -76,9 +72,6 @@ var deployCmd = &cobra.Command{
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, dev := range fb_devs {
|
|
||||||
dev.Close()
|
|
||||||
}
|
|
||||||
if serail == "autodetect" {
|
if serail == "autodetect" {
|
||||||
logger.Fatal("Nabu in fastboot mode not found")
|
logger.Fatal("Nabu in fastboot mode not found")
|
||||||
os.Exit(170)
|
os.Exit(170)
|
||||||
|
@ -113,10 +106,6 @@ var deployCmd = &cobra.Command{
|
||||||
} else {
|
} else {
|
||||||
run_repartition, _ = pterm.DefaultInteractiveConfirm.Show("Found compatible partition table. Do you want to change it?")
|
run_repartition, _ = pterm.DefaultInteractiveConfirm.Show("Found compatible partition table. Do you want to change it?")
|
||||||
}
|
}
|
||||||
if req_repartition && !run_repartition {
|
|
||||||
pterm.Println("Bye")
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if partsize != "" || !run_repartition {
|
if partsize != "" || !run_repartition {
|
||||||
|
@ -166,14 +155,7 @@ var deployCmd = &cobra.Command{
|
||||||
pterm.Println("Bye")
|
pterm.Println("Bye")
|
||||||
os.Exit(253)
|
os.Exit(253)
|
||||||
}
|
}
|
||||||
fb_dev, err := fastboot.FindDevice(serail)
|
fb_dev, _ := fastboot.FindDevice(serail)
|
||||||
if err != nil {
|
|
||||||
logger.Error("Unable to find device", logger.Args("object", fb_dev, "err", err))
|
|
||||||
fb_devs, err := fastboot.FindDevices()
|
|
||||||
logger.Debug("Devices", logger.Args("Devices", fb_devs, "err", err))
|
|
||||||
os.Exit(255)
|
|
||||||
}
|
|
||||||
|
|
||||||
adbd := adbc.Device(adb.DeviceWithSerial(serail))
|
adbd := adbc.Device(adb.DeviceWithSerial(serail))
|
||||||
bootdata, err := utils.Files.OrangeFox.Get(*pbar.WithTitle("Downloading orangefox"))
|
bootdata, err := utils.Files.OrangeFox.Get(*pbar.WithTitle("Downloading orangefox"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -184,6 +166,7 @@ var deployCmd = &cobra.Command{
|
||||||
os.Exit(179)
|
os.Exit(179)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logger.Debug("Bootdata")
|
||||||
|
|
||||||
if run_repartition {
|
if run_repartition {
|
||||||
gpt, err := utils.Files.GPT.Get(*pbar.WithTitle("Downloading default partition table"))
|
gpt, err := utils.Files.GPT.Get(*pbar.WithTitle("Downloading default partition table"))
|
||||||
|
|
|
@ -28,21 +28,17 @@ var uninstallCmd = &cobra.Command{
|
||||||
if serail == "autodetect" {
|
if serail == "autodetect" {
|
||||||
for _, dev := range fb_devs {
|
for _, dev := range fb_devs {
|
||||||
product, err := dev.GetVar("product")
|
product, err := dev.GetVar("product")
|
||||||
devSerial, _ := dev.Device.SerialNumber()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warn("Unable to communicate with device", logger.Args("Serial", devSerial))
|
logger.Warn("Unable to communicate with device", logger.Args("Serial", dev.Serial))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
logger.Debug("Found device", logger.Args("Product", product, "Sraial", devSerial))
|
logger.Debug("Found device", logger.Args("Product", product, "Sraial", dev.Serial))
|
||||||
if product == "nabu" {
|
if product == "nabu" {
|
||||||
logger.Debug("Nabu found", logger.Args("Serial", devSerial))
|
logger.Debug("Nabu found", logger.Args("Serial", dev.Serial))
|
||||||
serail = devSerial
|
serail = dev.Serial
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, dev := range fb_devs {
|
|
||||||
dev.Close()
|
|
||||||
}
|
|
||||||
if serail == "autodetect" {
|
if serail == "autodetect" {
|
||||||
logger.Fatal("Nabu in fastboot mode not found")
|
logger.Fatal("Nabu in fastboot mode not found")
|
||||||
os.Exit(170)
|
os.Exit(170)
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -7,7 +7,7 @@ require (
|
||||||
github.com/pterm/pterm v0.12.79
|
github.com/pterm/pterm v0.12.79
|
||||||
github.com/spf13/cobra v1.8.0
|
github.com/spf13/cobra v1.8.0
|
||||||
github.com/timoxa0/goadb v0.0.0-20240617073314-c303241c8c53
|
github.com/timoxa0/goadb v0.0.0-20240617073314-c303241c8c53
|
||||||
github.com/timoxa0/gofastboot v0.0.0-20240621122731-6a022539b068
|
github.com/timoxa0/gofastboot v0.0.0-20240617184805-918afbb71e47
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|
Reference in a new issue