|
8 | 8 | "io"
|
9 | 9 | "net/http"
|
10 | 10 | "os"
|
| 11 | + "os/exec" |
11 | 12 | "path/filepath"
|
12 | 13 | "runtime"
|
13 | 14 | "strings"
|
@@ -159,7 +160,7 @@ func (u *CoreUpdater) Update(currentExePath string, channel string, force bool)
|
159 | 160 | return fmt.Errorf("backuping: %w", err)
|
160 | 161 | }
|
161 | 162 |
|
162 |
| - err = u.replace(updateExePath, currentExePath) |
| 163 | + err = u.copyFile(updateExePath, currentExePath) |
163 | 164 | if err != nil {
|
164 | 165 | return fmt.Errorf("replacing: %w", err)
|
165 | 166 | }
|
@@ -284,21 +285,6 @@ func (u *CoreUpdater) backup(currentExePath, backupExePath, backupDir string) (e
|
284 | 285 | return nil
|
285 | 286 | }
|
286 | 287 |
|
287 |
| -// replace moves the current executable with the updated one |
288 |
| -func (u *CoreUpdater) replace(updateExePath, currentExePath string) error { |
289 |
| - log.Infoln("replacing: %s to %s", updateExePath, currentExePath) |
290 |
| - |
291 |
| - // Use copyFile to retain the original file attributes |
292 |
| - err := u.copyFile(updateExePath, currentExePath) |
293 |
| - if err != nil { |
294 |
| - return err |
295 |
| - } |
296 |
| - |
297 |
| - log.Infoln("updater: copy: %s to %s", updateExePath, currentExePath) |
298 |
| - |
299 |
| - return nil |
300 |
| -} |
301 |
| - |
302 | 288 | // clean removes the temporary directory itself and all it's contents.
|
303 | 289 | func (u *CoreUpdater) clean(updateDir string) {
|
304 | 290 | _ = os.RemoveAll(updateDir)
|
@@ -474,5 +460,13 @@ func (u *CoreUpdater) copyFile(src, dst string) (err error) {
|
474 | 460 | return fmt.Errorf("io.Copy(): %w", err)
|
475 | 461 | }
|
476 | 462 |
|
| 463 | + if runtime.GOOS == "darwin" { |
| 464 | + err = exec.Command("/usr/bin/codesign", "--sign", "-", dst).Run() |
| 465 | + if err != nil { |
| 466 | + log.Warnln("codesign failed: %v", err) |
| 467 | + } |
| 468 | + } |
| 469 | + |
| 470 | + log.Infoln("updater: copy: %s to %s", src, dst) |
477 | 471 | return nil
|
478 | 472 | }
|
0 commit comments