2022-11-20 01:51:55 +01:00
|
|
|
package ialpm
|
|
|
|
|
|
|
|
import (
|
2023-01-24 00:03:32 +01:00
|
|
|
alpm "github.com/Jguer/go-alpm/v2"
|
|
|
|
|
2022-11-20 01:51:55 +01:00
|
|
|
"github.com/Jguer/yay/v11/pkg/text"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GetPackageNamesBySource returns package names with and without correspondence in SyncDBS respectively.
|
|
|
|
func (ae *AlpmExecutor) getPackageNamesBySource() {
|
|
|
|
for _, localpkg := range ae.LocalPackages() {
|
|
|
|
pkgName := localpkg.Name()
|
|
|
|
if ae.SyncPackage(pkgName) != nil {
|
|
|
|
ae.installedSyncPkgNames = append(ae.installedSyncPkgNames, pkgName)
|
|
|
|
} else {
|
|
|
|
ae.installedRemotePkgNames = append(ae.installedRemotePkgNames, pkgName)
|
2023-01-24 00:03:32 +01:00
|
|
|
ae.installedRemotePkgMap[pkgName] = localpkg
|
2022-11-20 01:51:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
text.Debugln("populating db executor package caches.",
|
|
|
|
"sync_len", len(ae.installedSyncPkgNames), "remote_len", len(ae.installedRemotePkgNames))
|
|
|
|
}
|
|
|
|
|
2023-01-24 00:03:32 +01:00
|
|
|
func (ae *AlpmExecutor) InstalledRemotePackages() map[string]alpm.IPackage {
|
|
|
|
if ae.installedRemotePkgMap == nil {
|
2022-11-20 01:51:55 +01:00
|
|
|
ae.getPackageNamesBySource()
|
|
|
|
}
|
|
|
|
|
2023-01-24 00:03:32 +01:00
|
|
|
return ae.installedRemotePkgMap
|
2022-11-20 01:51:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (ae *AlpmExecutor) InstalledRemotePackageNames() []string {
|
|
|
|
if ae.installedRemotePkgNames == nil {
|
|
|
|
ae.getPackageNamesBySource()
|
|
|
|
}
|
|
|
|
|
|
|
|
return ae.installedRemotePkgNames
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ae *AlpmExecutor) InstalledSyncPackageNames() []string {
|
|
|
|
if ae.installedSyncPkgNames == nil {
|
|
|
|
ae.getPackageNamesBySource()
|
|
|
|
}
|
|
|
|
|
|
|
|
return ae.installedSyncPkgNames
|
|
|
|
}
|