Add no-simple-init flag

This commit is contained in:
timoxa0 2024-08-08 11:08:26 +05:00
parent a119d6ac19
commit 97a5127a59

View file

@ -23,7 +23,9 @@ var username string
var password string var password string
var serail string var serail string
var partsize string var partsize string
var nosimpleinit bool
var partpercent int var partpercent int
var deployCmd = &cobra.Command{ var deployCmd = &cobra.Command{
Use: "deploy <rootfs.lni>", Use: "deploy <rootfs.lni>",
Short: "Deploy system to device", Short: "Deploy system to device",
@ -353,6 +355,12 @@ var deployCmd = &cobra.Command{
logger.Info("System cofigured") logger.Info("System cofigured")
} }
var uefi_out string
if nosimpleinit {
logger.Info("-Q flag present. Skipping simpleinit install")
uefi_out = "0"
} else {
adbd.RunCommand("mkdir /tmp/uefi-install") adbd.RunCommand("mkdir /tmp/uefi-install")
bootshim, err := utils.Files.UEFIBootshim.Get(*pbar.WithTitle("Downloading uefi bootshim")) bootshim, err := utils.Files.UEFIBootshim.Get(*pbar.WithTitle("Downloading uefi bootshim"))
@ -395,28 +403,26 @@ var deployCmd = &cobra.Command{
conn.Close() conn.Close()
uefiSpinner, _ := spinner.Start("Patching UEFI") uefiSpinner, _ := spinner.Start("Patching UEFI")
out, err = adbd.RunCommand("uefi-patch > /dev/null 2>&1; echo $?") uefi_out, err = adbd.RunCommand("uefi-patch > /dev/null 2>&1; echo $?")
out = strings.TrimRight(out, "\n")
if err != nil { if err != nil {
logger.Error("Failed to install uefi. Reflash stock rom and try again", logger.Args("Error", err)) logger.Error("Failed to install uefi. Reflash stock rom and try again", logger.Args("Error", err))
os.Exit(176) os.Exit(176)
} }
uefi_out = strings.TrimRight(uefi_out, "\n")
logger.Debug("Uefi patch", logger.Args("Out", out)) logger.Debug("Uefi patch", logger.Args("Out", out))
switch out {
case "1":
uefiSpinner.Stop() uefiSpinner.Stop()
}
switch uefi_out {
case "1":
logger.Error("Failed to install uefi. Reflash stock rom and try again", logger.Args("Error", err)) logger.Error("Failed to install uefi. Reflash stock rom and try again", logger.Args("Error", err))
adbd.RunCommand("reboot bootloader") adbd.RunCommand("reboot bootloader")
os.Exit(176) os.Exit(176)
case "2": case "2":
adbd.RunCommand("reboot") adbd.RunCommand("reboot")
uefiSpinner.Stop()
logger.Info("Bootimage already patched") logger.Info("Bootimage already patched")
case "0": case "0":
adbd.RunCommand("reboot") adbd.RunCommand("reboot")
uefiSpinner.Stop()
logger.Info("Installation done!") logger.Info("Installation done!")
} }
}, },
@ -428,4 +434,5 @@ func init() {
deployCmd.Flags().StringVarP(&password, "password", "p", "", "User password") deployCmd.Flags().StringVarP(&password, "password", "p", "", "User password")
deployCmd.Flags().StringVarP(&serail, "serial", "s", "autodetect", "Device serial") deployCmd.Flags().StringVarP(&serail, "serial", "s", "autodetect", "Device serial")
deployCmd.Flags().StringVarP(&partsize, "part-size", "S", "", "Linux partition size in percents") deployCmd.Flags().StringVarP(&partsize, "part-size", "S", "", "Linux partition size in percents")
deployCmd.Flags().BoolVarP(&nosimpleinit, "no-simple-init", "Q", false, "Disable simple init install")
} }