Compare commits
5 commits
dfd5cee2fc
...
29e8665223
Author | SHA1 | Date | |
---|---|---|---|
|
29e8665223 | ||
|
6bbd36c9ea | ||
|
5a57ab02e8 | ||
|
5636e187aa | ||
|
4a28684c48 |
35
Makefile
35
Makefile
|
@ -1,52 +1,43 @@
|
|||
# Define variables
|
||||
NAME = lon-tool
|
||||
GOFLAGS ?= -ldflags="-s -w"
|
||||
SRC ?= main.go
|
||||
BIN_DIR ?= ./bin
|
||||
|
||||
# macOS settings
|
||||
MACOS_BIN = $(BIN_DIR)/$(NAME)_mac_amd64
|
||||
MACOS_CC = x86_64-apple-darwin23-gcc-14
|
||||
MACOS_CXX = x86_64-apple-darwin23-g++-14
|
||||
GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
|
||||
GOFLAGS ?= -ldflags="-s -w -X lon-tool/cmd.version=$(GIT_VERSION)"
|
||||
WINDOWS_GOFLAGS ?= -ldflags="-extldflags=-static -s -w -X lon-tool/cmd.version=$(GIT_VERSION)"
|
||||
|
||||
# Windows settings
|
||||
WINDOWS_BIN = $(BIN_DIR)/$(NAME)_win_amd64.exe
|
||||
WINDOWS_CC = x86_64-w64-mingw32-gcc
|
||||
WINDOWS_CXX = x86_64-w64-mingw32-g++
|
||||
WINDOWS_PKG_CONFIG_PATH = /usr/local/x86_64-w64-mingw32/lib/pkgconfig
|
||||
WINDOWS_CGO_CFLAGS = -I/usr/local/x86_64-w64-mingw32/include
|
||||
WINDOWS_CGO_LDFLAGS = -L/usr/local/x86_64-w64-mingw32/lib
|
||||
WINDOWS_PKG_CONFIG_PATH = /usr/x86_64-w64-mingw32/lib/pkgconfig
|
||||
WINDOWS_CGO_CFLAGS = -I/usr/x86_64-w64-mingw32/include
|
||||
WINDOWS_CGO_LDFLAGS = -L/usr/x86_64-w64-mingw32/lib
|
||||
|
||||
# Linux settings
|
||||
LINUX_BIN = $(BIN_DIR)/$(NAME)_lin_amd64
|
||||
LINUX_CC = x86_64-linux-gnu-gcc
|
||||
LINUX_CXX = x86_64-linux-gnu-g++
|
||||
LINUX_PKG_CONFIG_PATH = /usr/local/x86_64-linux-gnu/lib/pkgconfig
|
||||
LINUX_CGO_CFLAGS = -I/usr/local/x86_64-linux-gnu/include
|
||||
LINUX_CGO_LDFLAGS = -L/usr/local/x86_64-linux-gnu/lib
|
||||
LINUX_PKG_CONFIG_PATH = /usr/lib/pkgconfig
|
||||
LINUX_CGO_CFLAGS = -I/usr/include
|
||||
LINUX_CGO_LDFLAGS = -L/usr/lib
|
||||
|
||||
# Targets
|
||||
all: macos windows linux
|
||||
|
||||
macos:
|
||||
@export CGO_ENABLED=1 GOARCH=amd64 GOOS=darwin CC=$(MACOS_CC) CXX=$(MACOS_CXX) && \
|
||||
echo "Building macos bin" && \
|
||||
go build $(GOFLAGS) -o $(MACOS_BIN) $(SRC) && \
|
||||
echo "- saved to $(MACOS_BIN)"
|
||||
all: windows linux
|
||||
|
||||
windows:
|
||||
@echo "Building windows bin"
|
||||
@export CGO_ENABLED=1 GOARCH=amd64 GOOS=windows CC=$(WINDOWS_CC) CXX=$(WINDOWS_CXX) \
|
||||
PKG_CONFIG_PATH=$(WINDOWS_PKG_CONFIG_PATH) CGO_CFLAGS=$(WINDOWS_CGO_CFLAGS) \
|
||||
CGO_LDFLAGS=$(WINDOWS_CGO_LDFLAGS) && \
|
||||
echo "Building windows bin" && \
|
||||
go build $(GOFLAGS) -o $(WINDOWS_BIN) -ldflags="-extldflags=-static" $(SRC) && \
|
||||
go build $(WINDOWS_GOFLAGS) -o $(WINDOWS_BIN) $(SRC) && \
|
||||
echo "- saved to $(WINDOWS_BIN)"
|
||||
|
||||
linux:
|
||||
@echo "Building linux bin"
|
||||
@export CGO_ENABLED=1 GOARCH=amd64 GOOS=linux CC=$(LINUX_CC) CXX=$(LINUX_CXX) \
|
||||
PKG_CONFIG_PATH=$(LINUX_PKG_CONFIG_PATH) CGO_CFLAGS=$(LINUX_CGO_CFLAGS) \
|
||||
CGO_LDFLAGS=$(LINUX_CGO_LDFLAGS) && \
|
||||
echo "Building linux bin" && \
|
||||
go build $(GOFLAGS) -o $(LINUX_BIN) $(SRC) && \
|
||||
echo "- saved to $(LINUX_BIN)"
|
||||
|
||||
|
|
|
@ -353,7 +353,6 @@ var deployCmd = &cobra.Command{
|
|||
}
|
||||
|
||||
adbd.RunCommand("mkdir /tmp/uefi-install")
|
||||
uploadBar, _ := pbar.WithTotal(2).WithTitle("Uploading uefi files").Start()
|
||||
|
||||
bootshim, err := utils.Files.UEFIBootshim.Get(*pbar.WithTitle("Downloading uefi bootshim"))
|
||||
if err != nil {
|
||||
|
@ -367,16 +366,13 @@ var deployCmd = &cobra.Command{
|
|||
|
||||
conn, err := adbd.OpenWrite(pterm.Sprintf("/tmp/uefi-install/%s", utils.Files.UEFIBootshim.Name), fs.FileMode(0777), adb.MtimeOfClose)
|
||||
if err != nil {
|
||||
uploadBar.Stop()
|
||||
logger.Error("Failed to send uefi bootshim", logger.Args("Error", err))
|
||||
}
|
||||
_, err = conn.Write(bootshim)
|
||||
if err != nil {
|
||||
uploadBar.Stop()
|
||||
logger.Error("Failed to send uefi bootshim", logger.Args("Error", err))
|
||||
}
|
||||
conn.Close()
|
||||
uploadBar.Add(1)
|
||||
|
||||
payload, err := utils.Files.UEFIPayload.Get(*pbar.WithTitle("Downloading uefi payload"))
|
||||
if err != nil {
|
||||
|
@ -389,16 +385,13 @@ var deployCmd = &cobra.Command{
|
|||
}
|
||||
conn, err = adbd.OpenWrite(pterm.Sprintf("/tmp/uefi-install/%s", utils.Files.UEFIPayload.Name), fs.FileMode(0777), adb.MtimeOfClose)
|
||||
if err != nil {
|
||||
uploadBar.Stop()
|
||||
logger.Error("Failed to send uefi payload", logger.Args("Error", err))
|
||||
}
|
||||
_, err = conn.Write(payload)
|
||||
if err != nil {
|
||||
uploadBar.Stop()
|
||||
logger.Error("Failed to send uefi payload", logger.Args("Error", err))
|
||||
}
|
||||
conn.Close()
|
||||
uploadBar.Add(1)
|
||||
|
||||
uefiSpinner, _ := spinner.Start("Patching UEFI")
|
||||
out, err = adbd.RunCommand("uefi-patch > /dev/null 2>&1; echo $?")
|
||||
|
|
10
cmd/root.go
10
cmd/root.go
|
@ -24,6 +24,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var version string
|
||||
var logger pterm.Logger
|
||||
var pbar pterm.ProgressbarPrinter
|
||||
var spinner pterm.SpinnerPrinter
|
||||
|
@ -34,6 +35,7 @@ var rootCmd = &cobra.Command{
|
|||
Use: "lon-tool",
|
||||
Short: "A tool for installing linux on nabu and managing linux images",
|
||||
Long: "A tool for installing linux on nabu and managing linux images",
|
||||
Version: version,
|
||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||
if verbose {
|
||||
logger = *pterm.DefaultLogger.WithLevel(pterm.LogLevelDebug).WithTime(false)
|
||||
|
@ -47,14 +49,14 @@ var rootCmd = &cobra.Command{
|
|||
WithShowElapsedTime(false).
|
||||
WithRemoveWhenDone(false).
|
||||
WithShowCount(false).
|
||||
WithBarFiller(pbarFillStyle.Sprint("—")).
|
||||
WithLastCharacter("—").
|
||||
WithBarCharacter("—").
|
||||
WithBarFiller(pbarFillStyle.Sprint("─")).
|
||||
WithLastCharacter("─").
|
||||
WithBarCharacter("─").
|
||||
WithTitleStyle(pbarTitleStyle).
|
||||
WithBarStyle(pbarStyle)
|
||||
spinner = *pterm.DefaultSpinner.
|
||||
WithRemoveWhenDone(true).
|
||||
WithSequence("-", "\\", "|", "/").
|
||||
WithSequence("─", "\\", "|", "/").
|
||||
WithStyle(pbarTitleStyle).
|
||||
WithDelay(time.Millisecond * 100)
|
||||
},
|
||||
|
|
Reference in a new issue