[WIP] Improve bundle generation

This commit is contained in:
Daniel
2024-10-09 16:50:46 +02:00
parent 8b68243cc6
commit 5d9088f27e
5 changed files with 271 additions and 69 deletions

View File

@@ -9,44 +9,54 @@ import (
"github.com/safing/portmaster/service/updates"
)
var binaryMap = map[string]updates.Artifact{
"geoipv4.mmdb.gz": {
Filename: "geoipv4.mmdb",
Unpack: "gz",
},
"geoipv6.mmdb.gz": {
Filename: "geoipv6.mmdb",
Unpack: "gz",
},
}
var bundleSettings = updates.BundleFileSettings{
Name: "Portmaster Binaries",
PrimaryArtifact: "linux_amd64/portmaster-core",
BaseURL: "https://updates.safing.io/",
IgnoreFiles: []string{
// Indexes, checksums, latest symlinks.
"*.json",
"sha256*.txt",
"latest/**",
var ignoreFiles = map[string]struct{}{
"bin-index.json": {},
"intel-index.json": {},
// Signatures.
"*.sig",
"**/*.sig",
// Related, but not required artifacts.
"**/*.apk",
"**/*install*",
"**/spn-hub*",
"**/jess*",
"**/hubs*.json",
"**/*mini*.mmdb.gz",
// Deprecated artifacts.
"**/profilemgr*.zip",
"**/settings*.zip",
"**/monitor*.zip",
"**/base*.zip",
"**/console*.zip",
"**/portmaster-wintoast*.dll",
"**/portmaster-snoretoast*.exe",
"**/portmaster-kext*.dll",
},
UnpackFiles: map[string]string{
"gz": "**/*.gz",
"zip": "**/app2/**/portmaster-app*.zip",
},
}
func main() {
dir := flag.String("dir", "", "path to the directory that contains the artifacts")
name := flag.String("name", "", "name of the bundle")
version := flag.String("version", "", "version of the bundle")
flag.Parse()
if *dir == "" {
fmt.Fprintf(os.Stderr, "-dir parameter is required\n")
return
}
if *name == "" {
fmt.Fprintf(os.Stderr, "-name parameter is required\n")
return
}
settings := updates.BundleFileSettings{
Name: *name,
Version: *version,
Properties: binaryMap,
IgnoreFiles: ignoreFiles,
}
bundle, err := updates.GenerateBundleFromDir(*dir, settings)
bundle, err := updates.GenerateBundleFromDir(*dir, bundleSettings)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to generate bundle: %s\n", err)
return