_package

package
v0.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2026 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SystemFilterApplier = &filter.GormApplier{
	CustomAppliers: func() map[string]filter.FieldApplier {
		appliers := swcat.PrefixedAppliers(swcat.AppStreamPrefix, appStreamApplier)
		appliers["isApp"] = isAppApplier
		appliers["installed"] = installedApplier
		return appliers
	}(),
}

SystemFilterApplier применяет фильтры к GORM-запросу для системных пакетов.

View Source
var SystemFilterConfig = &filter.Config{
	Fields: func() map[string]filter.FieldConfig {
		fields := map[string]filter.FieldConfig{
			"name":             {DefaultOp: filter.OpEq, Sortable: true, AllowedOps: []filter.Op{filter.OpEq, filter.OpNe, filter.OpLike}, Extra: map[string]any{"type": "STRING", "description": "Package name"}},
			"isApp":            {DefaultOp: filter.OpEq, AllowedOps: []filter.Op{filter.OpEq, filter.OpNe}, Extra: map[string]any{"type": "BOOL", "description": "Has AppStream data (is application)"}},
			"section":          {DefaultOp: filter.OpLike, Sortable: true, AllowedOps: []filter.Op{filter.OpEq, filter.OpNe, filter.OpLike}, Extra: map[string]any{"type": "STRING", "description": "Package section (e.g. Shells, Editors)"}},
			"installedSize":    {DefaultOp: filter.OpEq, Sortable: true, AllowedOps: []filter.Op{filter.OpEq, filter.OpNe, filter.OpGt, filter.OpGte, filter.OpLt, filter.OpLte}, Extra: map[string]any{"type": "INTEGER", "description": "Installed size in bytes"}},
			"maintainer":       {DefaultOp: filter.OpLike, Sortable: true, AllowedOps: []filter.Op{filter.OpEq, filter.OpNe, filter.OpLike}, Extra: map[string]any{"type": "STRING", "description": "Package maintainer"}},
			"version":          {DefaultOp: filter.OpLike, Sortable: true, AllowedOps: []filter.Op{filter.OpEq, filter.OpNe, filter.OpLike}, Extra: map[string]any{"type": "STRING", "description": "Available version"}},
			"versionRaw":       {DefaultOp: filter.OpLike, Sortable: true, AllowedOps: []filter.Op{filter.OpEq, filter.OpNe, filter.OpLike}, Extra: map[string]any{"type": "STRING", "description": "Raw version string"}},
			"versionInstalled": {DefaultOp: filter.OpLike, Sortable: true, AllowedOps: []filter.Op{filter.OpEq, filter.OpNe, filter.OpLike}, Extra: map[string]any{"type": "STRING", "description": "Installed version"}},
			"depends":          {DefaultOp: filter.OpContains, Sortable: true, AllowedOps: []filter.Op{filter.OpEq, filter.OpNe, filter.OpLike, filter.OpContains}, Extra: map[string]any{"type": "STRING", "description": "Package dependencies"}},
			"provides":         {DefaultOp: filter.OpContains, Sortable: true, AllowedOps: []filter.Op{filter.OpEq, filter.OpNe, filter.OpLike, filter.OpContains}, Extra: map[string]any{"type": "STRING", "description": "Provided virtual packages"}},
			"size":             {DefaultOp: filter.OpEq, Sortable: true, AllowedOps: []filter.Op{filter.OpEq, filter.OpNe, filter.OpGt, filter.OpGte, filter.OpLt, filter.OpLte}, Extra: map[string]any{"type": "INTEGER", "description": "Download size in bytes"}},
			"filename":         {DefaultOp: filter.OpLike, Sortable: true, AllowedOps: []filter.Op{filter.OpEq, filter.OpNe, filter.OpLike}, Extra: map[string]any{"type": "STRING", "description": "Package filename"}},
			"description":      {DefaultOp: filter.OpLike, Sortable: true, AllowedOps: []filter.Op{filter.OpEq, filter.OpNe, filter.OpLike}, Extra: map[string]any{"type": "STRING", "description": "Package description"}},
			"summary":          {DefaultOp: filter.OpLike, Sortable: true, AllowedOps: []filter.Op{filter.OpEq, filter.OpNe, filter.OpLike}, Extra: map[string]any{"type": "STRING", "description": "Short package summary"}},
			"changelog":        {DefaultOp: filter.OpLike, Sortable: true, AllowedOps: []filter.Op{filter.OpEq, filter.OpNe, filter.OpLike}, Extra: map[string]any{"type": "STRING", "description": "Last changelog entry"}},
			"installed":        {DefaultOp: filter.OpEq, Sortable: true, AllowedOps: []filter.Op{filter.OpEq, filter.OpNe}, Extra: map[string]any{"type": "BOOL", "description": "Installation status"}},
			"typePackage": {DefaultOp: filter.OpEq, Sortable: true, AllowedOps: []filter.Op{filter.OpEq, filter.OpNe}, Extra: map[string]any{
				"type":        "ENUM",
				"description": app.T_("Package type"),
				"info": map[PackageType]string{
					PackageTypeSystem: "System package",
				},
			}},
			"files": {DefaultOp: filter.OpContains, AllowedOps: []filter.Op{filter.OpEq, filter.OpNe, filter.OpLike, filter.OpContains}, Extra: map[string]any{"type": "STRING", "description": "Package file list"}},
		}
		for k, v := range swcat.PrefixedFields(swcat.AppStreamPrefix) {
			fields[k] = v
		}
		return fields
	}(),
}

SystemFilterConfig конфигурация фильтрации для системных пакетов.

Functions

This section is empty.

Types

type Actions

type Actions struct {
	// contains filtered or unexported fields
}

func NewActions

func NewActions(serviceAptDatabase *PackageDBService, appConfig *app.Config, reporter *reply.Reporter) *Actions

func (*Actions) AptUpdate

func (a *Actions) AptUpdate(ctx context.Context, noLock ...bool) error

func (*Actions) AptUpdateIfStale added in v0.6.0

func (a *Actions) AptUpdateIfStale(ctx context.Context, ttl time.Duration, noLock ...bool) error

AptUpdateIfStale обновляет списки пакетов, только если последний успешный update был раньше, чем ttl назад

func (*Actions) CheckAutoRemove

func (a *Actions) CheckAutoRemove(ctx context.Context) (packageChanges *aptLib.PackageChanges, err error)

func (*Actions) CheckInstall

func (a *Actions) CheckInstall(ctx context.Context, packageName []string) (packageChanges *aptLib.PackageChanges, err error)

func (*Actions) CheckReinstall

func (a *Actions) CheckReinstall(ctx context.Context, packageName []string) (packageChanges *aptLib.PackageChanges, err error)

func (*Actions) CheckRemove

func (a *Actions) CheckRemove(ctx context.Context, packageName []string, purge bool, depends bool) (packageChanges *aptLib.PackageChanges, err error)

func (*Actions) CheckUpgrade

func (a *Actions) CheckUpgrade(ctx context.Context) (packageChanges *aptLib.PackageChanges, err error)

func (*Actions) CombineInstallRemovePackages

func (a *Actions) CombineInstallRemovePackages(ctx context.Context, packagesInstall []string,
	packagesRemove []string, purge bool, depends bool, downloadOnly bool) error

func (*Actions) DownloadSource added in v0.5.2

func (a *Actions) DownloadSource(ctx context.Context, packages []string, destDir string) ([]aptLib.SourcePackage, error)

DownloadSource скачивает .src.rpm пакеты в директорию destDir

func (*Actions) FindPackage

func (a *Actions) FindPackage(ctx context.Context, installed []string, removed []string, purge bool, depends bool, reinstall bool) ([]string, []string, []Package, *aptLib.PackageChanges, error)

func (*Actions) GetAptConfigOverrides

func (a *Actions) GetAptConfigOverrides() map[string]string

GetAptConfigOverrides возвращает текущие переопределения конфигурации APT

func (*Actions) GetInfo

func (a *Actions) GetInfo(ctx context.Context, packageName string) (packageChanges *aptLib.PackageInfo, err error)

func (*Actions) GetInstalledPackages

func (a *Actions) GetInstalledPackages(ctx context.Context, noLock ...bool) (map[string]string, error)

GetInstalledPackages возвращает карту, где ключ – имя пакета, а значение – его установленная версия.

func (*Actions) Install

func (a *Actions) Install(ctx context.Context, packages []string, downloadOnly bool) error

func (*Actions) InstallSourcePackages added in v0.5.2

func (a *Actions) InstallSourcePackages(ctx context.Context, files []string) error

InstallSourcePackages устанавливает .src.rpm файлы в сборочное дерево rpm

func (*Actions) PrepareInstallPackages

func (a *Actions) PrepareInstallPackages(ctx context.Context, packages []string) (install []string, remove []string, err error)

PrepareInstallPackages разбирает список пакетов с суффиксами +/- и возвращает два списка

func (*Actions) ReinstallPackages

func (a *Actions) ReinstallPackages(ctx context.Context, packages []string) error

func (*Actions) Remove

func (a *Actions) Remove(ctx context.Context, packages []string, purge bool, depends bool) error

func (*Actions) SetAptConfigOverrides

func (a *Actions) SetAptConfigOverrides(overrides map[string]string)

SetAptConfigOverrides устанавливает переопределения конфигурации APT

func (*Actions) Update

func (a *Actions) Update(ctx context.Context, noLock ...bool) ([]Package, error)

func (*Actions) UpdateDBOnly

func (a *Actions) UpdateDBOnly(ctx context.Context, noLock ...bool) ([]Package, error)

UpdateDBOnly обновляет статус установленных пакетов в БД без обновления репозиториев.

func (*Actions) Upgrade

func (a *Actions) Upgrade(ctx context.Context, downloadOnly bool) error

type DBPackage

type DBPackage struct {
	Name             string      `gorm:"column:name;primaryKey"`
	Architecture     string      `gorm:"column:architecture"`
	Section          string      `gorm:"column:section"`
	InstalledSize    int         `gorm:"column:installedSize"`
	Maintainer       string      `gorm:"column:maintainer"`
	Version          string      `gorm:"column:version;primaryKey"`
	VersionRaw       string      `gorm:"column:versionRaw"`
	VersionInstalled string      `gorm:"column:versionInstalled"`
	Depends          string      `gorm:"column:depends"`
	Aliases          string      `gorm:"column:aliases"`
	Provides         string      `gorm:"column:provides"`
	Size             int         `gorm:"column:size"`
	Filename         string      `gorm:"column:filename"`
	Summary          string      `gorm:"column:summary"`
	Description      string      `gorm:"column:description"`
	IDAppStream      *uint       `gorm:"column:idAppStream"`
	Changelog        string      `gorm:"column:changelog"`
	Installed        bool        `gorm:"column:installed"`
	TypePackage      PackageType `gorm:"column:typePackage"`
	Files            string      `gorm:"column:files"`
}

DBPackage описывает модель пакета для GORM.

func (DBPackage) TableName

func (DBPackage) TableName() string

TableName задаёт имя таблицы.

type Package

type Package struct {
	Name             string            `json:"name"`
	Architecture     string            `json:"architecture"`
	Section          string            `json:"section"`
	InstalledSize    int               `json:"installedSize"`
	Maintainer       string            `json:"maintainer"`
	Version          string            `json:"version"`
	VersionRaw       string            `json:"versionRaw"`
	VersionInstalled string            `json:"versionInstalled"`
	Depends          []string          `json:"depends"`
	Aliases          []string          `json:"aliases"`
	Provides         []string          `json:"provides"`
	Size             int               `json:"size"`
	Filename         string            `json:"filename"`
	Summary          string            `json:"summary"`
	Description      string            `json:"description"`
	AppStream        []swcat.Component `json:"appStream,omitempty"`
	HasAppStream     bool              `json:"-"`
	Changelog        string            `json:"lastChangelog"`
	Installed        bool              `json:"installed"`
	TypePackage      int               `json:"typePackage"`
	Files            []string          `json:"files"`
}

Package описывает структуру для хранения информации о пакете.

type PackageDBService

type PackageDBService struct {
	// contains filtered or unexported fields
}

PackageDBService предоставляет сервис для операций с базой данных пакетов.

func NewPackageDBService

func NewPackageDBService(dbManager app.DatabaseManager, reporter *reply.Reporter) *PackageDBService

NewPackageDBService создаёт новый сервис для работы с базой данных пакетов.

func (*PackageDBService) CountHostImagePackages

func (s *PackageDBService) CountHostImagePackages(ctx context.Context, filters []filter.FilterGroup) (int64, error)

CountHostImagePackages возвращает количество записей с учётом фильтров

func (*PackageDBService) GetPackageByName

func (s *PackageDBService) GetPackageByName(ctx context.Context, packageName string) (Package, error)

GetPackageByName возвращает запись пакета по имени.

func (*PackageDBService) GetPackagesByNames

func (s *PackageDBService) GetPackagesByNames(ctx context.Context, names []string) ([]Package, error)

GetPackagesByNames возвращает пакеты по списку имён одним batch-запросом

func (*PackageDBService) GetSections

func (s *PackageDBService) GetSections(ctx context.Context) ([]string, error)

GetSections возвращает список уникальных секций пакетов.

func (*PackageDBService) PackageDatabaseExist

func (s *PackageDBService) PackageDatabaseExist(ctx context.Context) error

PackageDatabaseExist проверяет, существует ли таблица и содержит ли она хотя бы одну запись.

func (*PackageDBService) QueryHostImagePackages

func (s *PackageDBService) QueryHostImagePackages(
	ctx context.Context,
	filters []filter.FilterGroup,
	sortField, sortOrder string,
	limit, offset int,
) ([]Package, error)

QueryHostImagePackages возвращает пакеты с возможностью фильтрации и сортировки

func (*PackageDBService) SavePackagesToDB

func (s *PackageDBService) SavePackagesToDB(ctx context.Context, packages []Package) error

SavePackagesToDB сохраняет список пакетов (перезапись всей таблицы).

func (*PackageDBService) SaveSinglePackage

func (s *PackageDBService) SaveSinglePackage(ctx context.Context, pkg Package) error

SaveSinglePackage сохраняет один пакет в базу данных без очистки таблицы

func (*PackageDBService) SearchPackagesByNameLike

func (s *PackageDBService) SearchPackagesByNameLike(ctx context.Context, likePattern string, installed bool) ([]Package, error)

SearchPackagesByNameLike ищет пакеты по произвольному шаблону LIKE

func (*PackageDBService) SearchPackagesMultiLimit

func (s *PackageDBService) SearchPackagesMultiLimit(ctx context.Context, likePattern string, limit int, installed bool) ([]Package, error)

SearchPackagesMultiLimit ищет пакеты по произвольному шаблону LIKE для автодополнения

func (*PackageDBService) SyncPackageInstallationInfo

func (s *PackageDBService) SyncPackageInstallationInfo(ctx context.Context, installedPackages map[string]string) error

SyncPackageInstallationInfo синхронизирует базу пакетов

func (s *PackageDBService) UpdateAppStreamLinks(ctx context.Context) error

UpdateAppStreamLinks обновляет idAppStream

type PackageType

type PackageType uint8
const (
	PackageTypeSystem PackageType = iota
	PackageTypeStplr
)

func (PackageType) String

func (t PackageType) String() string

func (PackageType) Value

func (t PackageType) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL