90 lines
2.9 KiB
Markdown
90 lines
2.9 KiB
Markdown
|
<p align="center">
|
|||
|
<img src="https://weforge.xyz/Spitfire/Branding/raw/branch/main/active/luncher/icon.svg" alt="Logo" width="64" height="64">
|
|||
|
</p>
|
|||
|
|
|||
|
<p align="center" style="font-size: 32px;">
|
|||
|
<strong>Spitfire Package Manager (SPM)</strong>
|
|||
|
</p>
|
|||
|
|
|||
|
<p align="center">
|
|||
|
A package management library designed to handle automatic updates for Spitfire browser and all of its components.
|
|||
|
</p>
|
|||
|
|
|||
|
### SPM is currently used in:
|
|||
|
- [Spitfire Luncher](https://weforge.xyz/Spitfire/Luncher)
|
|||
|
- [Spitfire Insaller](https://weforge.xyz/Spitfire/Installer)
|
|||
|
|
|||
|
### Example usage:
|
|||
|
|
|||
|
To use SPM for downloading, decompressing, and installing updates, implement the following example in your Go application:
|
|||
|
```go
|
|||
|
package main
|
|||
|
|
|||
|
import (
|
|||
|
"fmt"
|
|||
|
"runtime"
|
|||
|
|
|||
|
spm "weforge.xyz/Spitfire/SPM"
|
|||
|
)
|
|||
|
|
|||
|
func main() {
|
|||
|
// Define the packages to download
|
|||
|
specs := []spm.AppIndexEntry{
|
|||
|
{
|
|||
|
Name: "spitfire-launcher",
|
|||
|
Release: "nightly",
|
|||
|
OS: runtime.GOOS,
|
|||
|
Arch: runtime.GOARCH,
|
|||
|
Type: "launcher",
|
|||
|
},
|
|||
|
{
|
|||
|
Name: "spitfire-browser",
|
|||
|
Release: "nightly",
|
|||
|
OS: runtime.GOOS,
|
|||
|
Arch: runtime.GOARCH,
|
|||
|
Type: "browser",
|
|||
|
},
|
|||
|
}
|
|||
|
|
|||
|
// -- Download --
|
|||
|
// spm.AutoDownloadSpecified(specs) downloads specified packages to temp dir and decompresses them, making them ready for install by running "spm.AutoInstallUpdates()".
|
|||
|
fmt.Println("Starting download and decompression...")
|
|||
|
if err := spm.AutoDownloadSpecified(specs); err != nil {
|
|||
|
fmt.Println("Error downloading packages:", err)
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
fmt.Println("Download complete. Proceeding with installation...")
|
|||
|
|
|||
|
// -- Install --
|
|||
|
// Install and Download are separate as you cannot replace running binaries on Windows. So the final move to the correct folder is done by "spm.AutoInstallUpdates()".
|
|||
|
if err := spm.AutoInstallUpdates(); err != nil {
|
|||
|
fmt.Println("Error during installation:", err)
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
// -- Register --
|
|||
|
// spm.RegisterApp() is primarily used to modify the Windows registry so it recognizes Spitfire Browser as an installed program.
|
|||
|
// You shouldn’t need to run it more than once during installation. Also this function requires administrative privileges on Windows to work correctly.
|
|||
|
if err := spm.RegisterApp(); err != nil {
|
|||
|
fmt.Println("Error registering app:", err)
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
fmt.Println("Installation completed successfully!")
|
|||
|
|
|||
|
// -- Run --
|
|||
|
// This function detects the browser binary and runs it. Alternatively, you can also use spm.RunAndWait()
|
|||
|
spm.Run()
|
|||
|
}
|
|||
|
```
|
|||
|
*Functions, and specifically their names, are subject to change as I really don't like "AutoDownloadSpecified," but I don't want to make it "DownloadSpecified" yet, as there are still many functions in SPM used for manual downloads, installs, etc.*
|
|||
|
|
|||
|
<p align="center" style="font-size: 32px;">
|
|||
|
<strong>License</strong>
|
|||
|
</p>
|
|||
|
|
|||
|
<p align="center">
|
|||
|
<img src="https://www.gnu.org/graphics/agplv3-with-text-162x68.png" alt="AGPLv3 License" width="162" height="68">
|
|||
|
</p>
|