Fix a regression that broke kitten update-self

Fixes #6729
This commit is contained in:
Kovid Goyal
2023-10-18 19:19:35 +05:30
parent 0300a355d0
commit a9b412baba
5 changed files with 19 additions and 16 deletions

View File

@@ -64,6 +64,8 @@ Detailed list of changes
- Remote control launch: Fix the ``--copy-env`` option not copying current environment variables (:iss:`6724`) - Remote control launch: Fix the ``--copy-env`` option not copying current environment variables (:iss:`6724`)
- Fix a regression that broke ``kitten update-self`` (:iss:`6729`)
0.30.1 [2023-10-05] 0.30.1 [2023-10-05]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -592,11 +592,11 @@ const VersionString string = "{kc.str_version}"
const WebsiteBaseURL string = "{kc.website_base_url}" const WebsiteBaseURL string = "{kc.website_base_url}"
const FileTransferCode int = {FILE_TRANSFER_CODE} const FileTransferCode int = {FILE_TRANSFER_CODE}
const ImagePlaceholderChar rune = {placeholder_char} const ImagePlaceholderChar rune = {placeholder_char}
const VCSRevision string = ""
const SSHControlMasterTemplate = "{kc.ssh_control_master_template}" const SSHControlMasterTemplate = "{kc.ssh_control_master_template}"
const RC_ENCRYPTION_PROTOCOL_VERSION string = "{kc.RC_ENCRYPTION_PROTOCOL_VERSION}" const RC_ENCRYPTION_PROTOCOL_VERSION string = "{kc.RC_ENCRYPTION_PROTOCOL_VERSION}"
const IsFrozenBuild bool = false var VCSRevision string = ""
const IsStandaloneBuild bool = false var IsFrozenBuild string = ""
var IsStandaloneBuild string = ""
const HandleTermiosSignals = {Mode.HANDLE_TERMIOS_SIGNALS.value[0]} const HandleTermiosSignals = {Mode.HANDLE_TERMIOS_SIGNALS.value[0]}
const HintsDefaultRegex = `{DEFAULT_REGEX}` const HintsDefaultRegex = `{DEFAULT_REGEX}`
const DefaultTermName = `{Options.term}` const DefaultTermName = `{Options.term}`

View File

@@ -972,15 +972,16 @@ def build_static_kittens(
update_go_generated_files(args, os.path.join(launcher_dir, appname)) update_go_generated_files(args, os.path.join(launcher_dir, appname))
cmd = [go, 'build', '-v'] cmd = [go, 'build', '-v']
vcs_rev = args.vcs_rev or get_vcs_rev() vcs_rev = args.vcs_rev or get_vcs_rev()
ld_flags = [f"-X 'kitty.VCSRevision={vcs_rev}'"] ld_flags: List[str] = []
binary_data_flags = [f"-X kitty.VCSRevision={vcs_rev}"]
if for_freeze: if for_freeze:
ld_flags.append("-X 'kitty.IsFrozenBuild=true'") binary_data_flags.append("-X kitty.IsFrozenBuild=true")
if for_platform: if for_platform:
ld_flags.append("-X 'kitty.IsStandaloneBuild=true'") binary_data_flags.append("-X kitty.IsStandaloneBuild=true")
if not args.debug: if not args.debug:
ld_flags.append('-s') ld_flags.append('-s')
ld_flags.append('-w') ld_flags.append('-w')
cmd += ['-ldflags', ' '.join(ld_flags)] cmd += ['-ldflags', ' '.join(binary_data_flags + ld_flags)]
dest = os.path.join(destination_dir or launcher_dir, 'kitten') dest = os.path.join(destination_dir or launcher_dir, 'kitten')
if for_platform: if for_platform:
dest += f'-{for_platform[0]}-{for_platform[1]}' dest += f'-{for_platform[0]}-{for_platform[1]}'

View File

@@ -4,11 +4,11 @@ package update_self
import ( import (
"fmt" "fmt"
"kitty"
"os" "os"
"path/filepath" "path/filepath"
"runtime" "runtime"
"kitty"
"kitty/tools/cli" "kitty/tools/cli"
"kitty/tools/tty" "kitty/tools/tty"
"kitty/tools/tui" "kitty/tools/tui"
@@ -33,7 +33,7 @@ func update_self(version string) (err error) {
if err != nil { if err != nil {
return err return err
} }
if !kitty.IsStandaloneBuild { if kitty.IsStandaloneBuild == "" {
return fmt.Errorf("This is not a standalone kitten executable. You must update all of kitty instead.") return fmt.Errorf("This is not a standalone kitten executable. You must update all of kitty instead.")
} }
rv := "v" + version rv := "v" + version

View File

@@ -139,7 +139,14 @@ func DownloadFileWithProgress(destpath, url string, kill_if_signaled bool) (err
} }
} }
on_timer_tick := func(timer_id loop.IdType) error {
return lp.OnWakeup()
}
lp.OnInitialize = func() (string, error) { lp.OnInitialize = func() (string, error) {
if _, err = lp.AddTimer(rd.spinner.interval, true, on_timer_tick); err != nil {
return "", err
}
go do_download() go do_download()
lp.QueueWriteString("Downloading: " + url + "\r\n") lp.QueueWriteString("Downloading: " + url + "\r\n")
return "\r\n", nil return "\r\n", nil
@@ -179,13 +186,6 @@ func DownloadFileWithProgress(destpath, url string, kill_if_signaled bool) (err
return nil return nil
} }
on_timer_tick := func(timer_id loop.IdType) error {
return lp.OnWakeup()
}
if _, err = lp.AddTimer(rd.spinner.interval, true, on_timer_tick); err != nil {
return
}
err = lp.Run() err = lp.Run()
dl_data.mutex.Lock() dl_data.mutex.Lock()
if dl_data.temp_file_path != "" && !dl_data.download_finished { if dl_data.temp_file_path != "" && !dl_data.download_finished {