mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-05-03 02:52:07 -04:00
system update: general fixes to flatpak parsing
This commit is contained in:
@@ -70,13 +70,32 @@ type flatpakInstalledEntry struct {
|
||||
}
|
||||
|
||||
func (flatpakBackend) Upgrade(ctx context.Context, opts UpgradeOptions, onLine func(string)) error {
|
||||
argv := []string{"flatpak", "update", "-y", "--noninteractive"}
|
||||
if opts.DryRun {
|
||||
argv = []string{"flatpak", "update", "--no-deploy", "-y"}
|
||||
return Run(ctx, []string{"flatpak", "update", "--no-deploy", "-y"}, RunOptions{OnLine: onLine})
|
||||
}
|
||||
refs := flatpakTargetRefs(opts.Targets)
|
||||
if len(refs) == 0 {
|
||||
return nil
|
||||
}
|
||||
argv := append([]string{"flatpak", "update", "-y", "--noninteractive"}, refs...)
|
||||
return Run(ctx, argv, RunOptions{OnLine: onLine})
|
||||
}
|
||||
|
||||
func flatpakTargetRefs(targets []Package) []string {
|
||||
out := make([]string, 0, len(targets))
|
||||
for _, p := range targets {
|
||||
if p.Backend != "flatpak" {
|
||||
continue
|
||||
}
|
||||
ref := p.Ref
|
||||
if ref == "" {
|
||||
ref = p.Name
|
||||
}
|
||||
out = append(out, ref)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func parseFlatpakUpdates(text string, installed map[string]flatpakInstalledEntry) []Package {
|
||||
if text == "" {
|
||||
return nil
|
||||
@@ -111,14 +130,25 @@ func parseFlatpakUpdates(text string, installed map[string]flatpakInstalledEntry
|
||||
key = appID + "//" + branch
|
||||
}
|
||||
inst := installed[key]
|
||||
|
||||
if inst.commit != "" && commit != "" && strings.HasPrefix(commit, inst.commit) {
|
||||
continue
|
||||
}
|
||||
|
||||
from, to := flatpakVersionPair(inst.version, inst.commit, version, commit)
|
||||
|
||||
ref := appID
|
||||
if branch != "" {
|
||||
ref = appID + "//" + branch
|
||||
}
|
||||
|
||||
pkgs = append(pkgs, Package{
|
||||
Name: display,
|
||||
Repo: RepoFlatpak,
|
||||
Backend: "flatpak",
|
||||
FromVersion: from,
|
||||
ToVersion: to,
|
||||
Ref: ref,
|
||||
})
|
||||
}
|
||||
return pkgs
|
||||
|
||||
Reference in New Issue
Block a user