Release LanUps 0.1.2 with native installers and monitoring updates

This commit is contained in:
tongtong committed 2026-11-28 21:18:14 +08:00
1 parent 90c57f020f
commit 5bdc79d8e4
30 files changed
+751 -270

No files matched your search

+5 -5
View File
@@ -11,10 +11,10 @@ import (
)
func main() {
if len(os.Args) != 6 {
log.Fatal("usage: macpack payload preinstall postinstall architecture output.pkg")
if len(os.Args) != 7 {
log.Fatal("usage: macpack payload preinstall postinstall architecture output.pkg version")
}
root, prePath, postPath, architecture, output := os.Args[1], os.Args[2], os.Args[3], os.Args[4], os.Args[5]
root, prePath, postPath, architecture, output, version := os.Args[1], os.Args[2], os.Args[3], os.Args[4], os.Args[5], os.Args[6]
if architecture != pkg.ArchARM64 && architecture != pkg.ArchX8664 {
log.Fatal("invalid macOS architecture")
}
@@ -22,7 +22,7 @@ func main() {
check(err)
post, err := os.ReadFile(postPath)
check(err)
component := pkg.NewPackage().WithIdentifier("local.lanups").WithName("LanUps").WithVersion("0.1.0").
component := pkg.NewPackage().WithIdentifier("local.lanups").WithName("LanUps").WithVersion(version).
WithPreInstallScript(pre).WithPostInstallScript(post)
check(filepath.WalkDir(root, func(path string, entry fs.DirEntry, err error) error {
if err != nil || entry.IsDir() {
@@ -40,7 +40,7 @@ func main() {
component.WithFileFromPath("/"+name, path).WithMode(mode).Add()
return nil
}))
product, err := pkg.NewProduct().WithTitle("LanUps").WithIdentifier("local.lanups.product").WithVersion("0.1.0").
product, err := pkg.NewProduct().WithTitle("LanUps").WithIdentifier("local.lanups.product").WithVersion(version).
WithHostArchitectures(architecture).WithMinOSVersion("15.0").WithComponent(component).Build()
check(err)
file, err := os.Create(output)
@@ -1,77 +0,0 @@
//go:build windows
package main
import (
"archive/zip"
"fmt"
"io"
"io/fs"
"os"
"os/exec"
"path/filepath"
)
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, "LanUps installation failed:", err)
os.Exit(1)
}
}
func run() error {
self, err := os.Executable()
if err != nil {
return err
}
archive, err := zip.OpenReader(self)
if err != nil {
return err
}
defer archive.Close()
stage, err := os.MkdirTemp("", "LanUps-Setup-")
if err != nil {
return err
}
defer os.RemoveAll(stage)
for _, entry := range archive.File {
path := filepath.FromSlash(entry.Name)
if !fs.ValidPath(entry.Name) || !filepath.IsLocal(path) || !entry.Mode().IsRegular() {
return fmt.Errorf("invalid installer entry: %q", entry.Name)
}
if err := extract(filepath.Join(stage, path), entry); err != nil {
return err
}
}
if len(os.Args) == 2 && os.Args[1] == "--verify" {
fmt.Printf("Verified %d installer files\n", len(archive.File))
return nil
}
setup := filepath.Join(stage, "Setup.ps1")
args := append([]string{"-NoProfile", "-ExecutionPolicy", "Bypass", "-File", setup}, os.Args[1:]...)
powershell := filepath.Join(os.Getenv("SystemRoot"), "System32", "WindowsPowerShell", "v1.0", "powershell.exe")
command := exec.Command(powershell, args...)
command.Stdout, command.Stderr = os.Stdout, os.Stderr
return command.Run()
}
func extract(path string, entry *zip.File) error {
if err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil {
return err
}
input, err := entry.Open()
if err != nil {
return err
}
defer input.Close()
output, err := os.OpenFile(path, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o600)
if err != nil {
return err
}
_, err = io.Copy(output, input)
closeErr := output.Close()
if err != nil {
return err
}
return closeErr
}