Establish beta and staging release channels, move indexes to helper

This commit is contained in:
Daniel
2021-06-03 23:28:41 +02:00
parent 8a46e78c0f
commit 642e2eb112
7 changed files with 161 additions and 120 deletions

View File

@@ -1,7 +1,6 @@
package helper
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
@@ -54,14 +53,6 @@ func EnsureChromeSandboxPermissions(reg *updater.ResourceRegistry) error {
return nil
}
// PlatformIdentifier converts identifier for the current platform.
func PlatformIdentifier(identifier string) string {
// From https://golang.org/pkg/runtime/#GOARCH
// GOOS is the running program's operating system target: one of darwin, freebsd, linux, and so on.
// GOARCH is the running program's architecture target: one of 386, amd64, arm, s390x, and so on.
return fmt.Sprintf("%s_%s/%s", runtime.GOOS, runtime.GOARCH, identifier)
}
func checkSysctl(setting string, value byte) bool {
c, err := sysctl(setting)
if err != nil {

50
updates/helper/indexes.go Normal file
View File

@@ -0,0 +1,50 @@
package helper
import (
"github.com/safing/portbase/updater"
)
const (
ReleaseChannelKey = "core/releaseChannel"
ReleaseChannelJSONKey = "core.releaseChannel"
ReleaseChannelStable = "stable"
ReleaseChannelBeta = "beta"
ReleaseChannelStaging = "staging"
)
func SetIndexes(registry *updater.ResourceRegistry, releaseChannel string) {
// Be reminded that the order is important, as indexes added later will
// override the current release from earlier indexes.
// Reset indexes before adding them (again).
registry.ResetIndexes()
// Always add the stable index as a base.
registry.AddIndex(updater.Index{
Path: "stable.json",
})
// Add beta index if in beta or staging channel.
if releaseChannel == ReleaseChannelBeta ||
releaseChannel == ReleaseChannelStaging {
registry.AddIndex(updater.Index{
Path: "beta.json",
PreRelease: true,
})
}
// Add staging index if in staging channel.
if releaseChannel == ReleaseChannelStaging {
registry.AddIndex(updater.Index{
Path: "staging.json",
PreRelease: true,
})
}
// Add the intel index last, as it updates the fastest and should not be
// crippled by other faulty indexes. It can only specify versions for its
// scope anyway.
registry.AddIndex(updater.Index{
Path: "all/intel/intel.json",
})
}

68
updates/helper/updates.go Normal file
View File

@@ -0,0 +1,68 @@
package helper
import (
"fmt"
"runtime"
)
const (
onWindows = runtime.GOOS == "windows"
)
// PlatformIdentifier converts identifier for the current platform.
func PlatformIdentifier(identifier string) string {
// From https://golang.org/pkg/runtime/#GOARCH
// GOOS is the running program's operating system target: one of darwin, freebsd, linux, and so on.
// GOARCH is the running program's architecture target: one of 386, amd64, arm, s390x, and so on.
return fmt.Sprintf("%s_%s/%s", runtime.GOOS, runtime.GOARCH, identifier)
}
// MandatoryUpdates returns mandatory updates that should be loaded on install
// or reset.
func MandatoryUpdates() (identifiers []string) {
// Binaries
if onWindows {
identifiers = []string{
PlatformIdentifier("core/portmaster-core.exe"),
PlatformIdentifier("kext/portmaster-kext.dll"),
PlatformIdentifier("kext/portmaster-kext.sys"),
PlatformIdentifier("start/portmaster-start.exe"),
PlatformIdentifier("notifier/portmaster-notifier.exe"),
PlatformIdentifier("notifier/portmaster-snoretoast.exe"),
}
} else {
identifiers = []string{
PlatformIdentifier("core/portmaster-core"),
PlatformIdentifier("start/portmaster-start"),
PlatformIdentifier("notifier/portmaster-notifier"),
}
}
// Components, Assets and Data
identifiers = append(
identifiers,
// User interface components
PlatformIdentifier("app/portmaster-app.zip"),
"all/ui/modules/portmaster.zip",
"all/ui/modules/assets.zip",
// Filter lists data
"all/intel/lists/base.dsdl",
"all/intel/lists/intermediate.dsdl",
"all/intel/lists/urgent.dsdl",
// Geo IP data
"all/intel/geoip/geoipv4.mmdb.gz",
"all/intel/geoip/geoipv6.mmdb.gz",
)
return identifiers
}
// AutoUnpackUpdates returns assets that need unpacking.
func AutoUnpackUpdates() []string {
return []string{
PlatformIdentifier("app/portmaster-app.zip"),
}
}