mirror of
https://github.com/safing/portmaster
synced 2025-09-01 18:19:12 +00:00
[WIP] Remove updater index filename setting
This commit is contained in:
parent
68f5bf73e1
commit
d6812bb4ef
6 changed files with 17 additions and 23 deletions
12
Earthfile
12
Earthfile
|
@ -538,12 +538,12 @@ release-prep:
|
|||
RUN touch "./output/intel/urgent.dsdl"
|
||||
|
||||
COPY (+go-build/output/updatemgr --GOARCH=amd64 --GOOS=linux --CMDS=updatemgr) ./updatemgr
|
||||
RUN ./updatemgr scan --dir "./output/binary" > ./output/binary/bin-index.json
|
||||
RUN ./updatemgr scan --dir "./output/intel" > ./output/intel/intel-index.json
|
||||
RUN ./updatemgr scan --dir "./output/binary" > ./output/binary/index.json
|
||||
RUN ./updatemgr scan --dir "./output/intel" > ./output/intel/index.json
|
||||
|
||||
# Intel Extracted (needed for the installers)
|
||||
RUN mkdir -p ./output/intel_decompressed
|
||||
RUN cp ./output/intel/intel-index.json ./output/intel_decompressed/intel-index.json
|
||||
RUN cp ./output/intel/index.json ./output/intel_decompressed/index.json
|
||||
RUN gzip -dc ./output/intel/geoipv4.mmdb.gz > ./output/intel_decompressed/geoipv4.mmdb
|
||||
RUN gzip -dc ./output/intel/geoipv6.mmdb.gz > ./output/intel_decompressed/geoipv6.mmdb
|
||||
RUN touch "./output/intel_decompressed/index.dsd"
|
||||
|
@ -552,7 +552,7 @@ release-prep:
|
|||
RUN touch "./output/intel_decompressed/urgent.dsdl"
|
||||
|
||||
# Save all artifacts to output folder
|
||||
SAVE ARTIFACT --if-exists --keep-ts "output/binary/bin-index.json" AS LOCAL "${outputDir}/binary/bin-index.json"
|
||||
SAVE ARTIFACT --if-exists --keep-ts "output/binary/index.json" AS LOCAL "${outputDir}/binary/index.json"
|
||||
SAVE ARTIFACT --if-exists --keep-ts "output/binary/all/*" AS LOCAL "${outputDir}/binary/all/"
|
||||
SAVE ARTIFACT --if-exists --keep-ts "output/binary/linux_amd64/*" AS LOCAL "${outputDir}/binary/linux_amd64/"
|
||||
SAVE ARTIFACT --if-exists --keep-ts "output/binary/windows_amd64/*" AS LOCAL "${outputDir}/binary/windows_amd64/"
|
||||
|
@ -560,7 +560,7 @@ release-prep:
|
|||
SAVE ARTIFACT --if-exists --keep-ts "output/intel_decompressed/*" AS LOCAL "${outputDir}/intel_decompressed/"
|
||||
|
||||
# Save all artifacts to the container output folder so other containers can access it.
|
||||
SAVE ARTIFACT --if-exists --keep-ts "output/binary/bin-index.json" "output/binary/bin-index.json"
|
||||
SAVE ARTIFACT --if-exists --keep-ts "output/binary/index.json" "output/binary/index.json"
|
||||
SAVE ARTIFACT --if-exists --keep-ts "output/binary/all/*" "output/binary/all/"
|
||||
SAVE ARTIFACT --if-exists --keep-ts "output/binary/linux_amd64/*" "output/binary/linux_amd64/"
|
||||
SAVE ARTIFACT --if-exists --keep-ts "output/binary/windows_amd64/*" "output/binary/windows_amd64/"
|
||||
|
@ -588,7 +588,7 @@ installer-linux:
|
|||
COPY (+release-prep/output/binary/linux_amd64/portmaster) ./target/${target}/release/portmaster
|
||||
|
||||
RUN mkdir -p binary
|
||||
COPY (+release-prep/output/binary/bin-index.json) ./binary/bin-index.json
|
||||
COPY (+release-prep/output/binary/index.json) ./binary/index.json
|
||||
COPY (+release-prep/output/binary/linux_amd64/portmaster-core) ./binary/portmaster-core
|
||||
COPY (+release-prep/output/binary/all/portmaster.zip) ./binary/portmaster.zip
|
||||
COPY (+release-prep/output/binary/all/assets.zip) ./binary/assets.zip
|
||||
|
|
|
@ -21,7 +21,7 @@ if (-not (Test-Path -Path $binaryDir)) {
|
|||
|
||||
|
||||
Write-Output "Copying binary files"
|
||||
Copy-Item -Force -Path "dist/binary/bin-index.json" -Destination "$binaryDir/bin-index.json"
|
||||
Copy-Item -Force -Path "dist/binary/index.json" -Destination "$binaryDir/index.json"
|
||||
Copy-Item -Force -Path "dist/binary/windows_amd64/portmaster-core.exe" -Destination "$binaryDir/portmaster-core.exe"
|
||||
Copy-Item -Force -Path "dist/binary/windows_amd64/portmaster-kext.sys" -Destination "$binaryDir/portmaster-kext.sys"
|
||||
Copy-Item -Force -Path "dist/binary/all/portmaster.zip" -Destination "$binaryDir/portmaster.zip"
|
||||
|
|
|
@ -138,8 +138,7 @@ func New(svcCfg *ServiceConfig) (*Instance, error) { //nolint:maintidx
|
|||
DownloadDirectory: os.ExpandEnv("$ProgramData/Portmaster/new_binary"),
|
||||
PurgeDirectory: filepath.Join(binaryFolder, "old_binary"), // Default: C:/Program Files/Portmaster/old_binary
|
||||
Ignore: []string{"databases", "intel", "config.json"},
|
||||
IndexURLs: []string{"http://192.168.88.11:8000/test-binary.json"},
|
||||
IndexFile: "bin-index.json",
|
||||
IndexURLs: []string{"https://updates.safing.io/stable.v3.json"},
|
||||
AutoApply: false,
|
||||
NeedsRestart: true,
|
||||
}
|
||||
|
@ -148,8 +147,7 @@ func New(svcCfg *ServiceConfig) (*Instance, error) { //nolint:maintidx
|
|||
Directory: os.ExpandEnv("$ProgramData/Portmaster/intel"),
|
||||
DownloadDirectory: os.ExpandEnv("$ProgramData/Portmaster/new_intel"),
|
||||
PurgeDirectory: os.ExpandEnv("$ProgramData/Portmaster/old_intel"),
|
||||
IndexURLs: []string{"http://192.168.88.11:8000/test-intel.json"},
|
||||
IndexFile: "intel-index.json",
|
||||
IndexURLs: []string{"https://updates.safing.io/intel.v3.json"},
|
||||
AutoApply: true,
|
||||
NeedsRestart: false,
|
||||
}
|
||||
|
@ -159,8 +157,7 @@ func New(svcCfg *ServiceConfig) (*Instance, error) { //nolint:maintidx
|
|||
DownloadDirectory: "/var/lib/portmaster/new_bin",
|
||||
PurgeDirectory: "/var/lib/portmaster/old_bin",
|
||||
Ignore: []string{"databases", "intel", "config.json"},
|
||||
IndexURLs: []string{"http://localhost:8000/test-binary.json"},
|
||||
IndexFile: "bin-index.json",
|
||||
IndexURLs: []string{"https://updates.safing.io/stable.v3.json"},
|
||||
AutoApply: false,
|
||||
NeedsRestart: true,
|
||||
}
|
||||
|
@ -169,8 +166,7 @@ func New(svcCfg *ServiceConfig) (*Instance, error) { //nolint:maintidx
|
|||
Directory: "/var/lib/portmaster/intel",
|
||||
DownloadDirectory: "/var/lib/portmaster/new_intel",
|
||||
PurgeDirectory: "/var/lib/portmaster/intel_bin",
|
||||
IndexURLs: []string{"http://localhost:8000/test-intel.json"},
|
||||
IndexFile: "intel-index.json",
|
||||
IndexURLs: []string{"https://updates.safing.io/intel.v3.json"},
|
||||
AutoApply: true,
|
||||
NeedsRestart: false,
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import (
|
|||
|
||||
type Downloader struct {
|
||||
dir string
|
||||
indexFile string
|
||||
indexURLs []string
|
||||
bundle *Bundle
|
||||
version *semver.Version
|
||||
|
@ -33,7 +32,6 @@ type Downloader struct {
|
|||
func CreateDownloader(index UpdateIndex) Downloader {
|
||||
return Downloader{
|
||||
dir: index.DownloadDirectory,
|
||||
indexFile: index.IndexFile,
|
||||
indexURLs: index.IndexURLs,
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +76,7 @@ func (d *Downloader) downloadIndexFile(ctx context.Context) error {
|
|||
}
|
||||
|
||||
// Write the content into a file.
|
||||
indexFilepath := filepath.Join(d.dir, d.indexFile)
|
||||
indexFilepath := filepath.Join(d.dir, indexFilename)
|
||||
err = os.WriteFile(indexFilepath, []byte(content), defaultFileMode)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to write index file: %w", err)
|
||||
|
@ -98,7 +96,7 @@ func (d *Downloader) Verify() error {
|
|||
}
|
||||
|
||||
func (d *Downloader) parseBundle() error {
|
||||
indexFilepath := filepath.Join(d.dir, d.indexFile)
|
||||
indexFilepath := filepath.Join(d.dir, indexFilename)
|
||||
var err error
|
||||
d.bundle, err = LoadBundle(indexFilepath)
|
||||
if err != nil {
|
||||
|
|
|
@ -18,6 +18,8 @@ const (
|
|||
updateFailedNotificationID = "updates:update-failed"
|
||||
corruptInstallationNotificationID = "updates:corrupt-installation"
|
||||
|
||||
indexFilename = "index.json"
|
||||
|
||||
// ResourceUpdateEvent is emitted every time the
|
||||
// updater successfully performed a resource update.
|
||||
ResourceUpdateEvent = "resource update"
|
||||
|
@ -39,7 +41,6 @@ type UpdateIndex struct {
|
|||
PurgeDirectory string
|
||||
Ignore []string
|
||||
IndexURLs []string
|
||||
IndexFile string
|
||||
AutoApply bool
|
||||
NeedsRestart bool
|
||||
}
|
||||
|
@ -176,7 +177,6 @@ func (u *Updates) UpdateFromURL(url string) error {
|
|||
index := UpdateIndex{
|
||||
DownloadDirectory: u.downloader.dir,
|
||||
IndexURLs: []string{url},
|
||||
IndexFile: u.downloader.indexFile,
|
||||
}
|
||||
|
||||
// Initialize with proper values and download the index file.
|
||||
|
@ -214,7 +214,7 @@ func (u *Updates) applyUpdates(downloader Downloader, force bool) error {
|
|||
log.Infof("update: starting update: %s %s -> %s", currentBundle.Name, currentBundle.Version, downloadBundle.Version)
|
||||
}
|
||||
|
||||
err := u.registry.performRecoverableUpgrade(downloader.dir, downloader.indexFile)
|
||||
err := u.registry.performRecoverableUpgrade(downloader.dir, indexFilename)
|
||||
if err != nil {
|
||||
// Notify the user that update failed.
|
||||
notifications.NotifyPrompt(updateFailedNotificationID, "Failed to apply update.", err.Error())
|
||||
|
|
|
@ -36,7 +36,7 @@ func CreateRegistry(index UpdateIndex) (Registry, error) {
|
|||
}
|
||||
// Parse bundle
|
||||
var err error
|
||||
registry.bundle, err = LoadBundle(filepath.Join(index.Directory, index.IndexFile))
|
||||
registry.bundle, err = LoadBundle(filepath.Join(index.Directory, indexFilename))
|
||||
if err != nil {
|
||||
return Registry{}, err
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue