Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honor auto-import-gpg-keys flag on migration #271

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cmd/zypper-migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,8 @@ func compareEditions(left, right string) int {
return 0
}

func cleanupProductRepos(p connect.Product, force bool) error {
productPackages, err := zypper.FindProductPackages(p.Name)
func cleanupProductRepos(p connect.Product, force, autoImportRepoKeys bool) error {
productPackages, err := zypper.FindProductPackages(p.Name, autoImportRepoKeys)
if err != nil {
return err
}
Expand Down Expand Up @@ -564,7 +564,7 @@ func isSUSEService(service zypper.ZypperService) bool {
// adds/removes services to match target state
// disables obsolete repos
// returns base product version string
func migrateSystem(migration connect.MigrationPath, forceDisableRepos bool) (string, error) {
func migrateSystem(migration connect.MigrationPath, forceDisableRepos, autoImportRepoKeys bool) (string, error) {
var baseProductVersion string

systemServices, _ := zypper.InstalledServices()
Expand All @@ -587,7 +587,7 @@ func migrateSystem(migration connect.MigrationPath, forceDisableRepos bool) (str
}
}

if err := cleanupProductRepos(p, forceDisableRepos); err != nil {
if err := cleanupProductRepos(p, forceDisableRepos, autoImportRepoKeys); err != nil {
return baseProductVersion, err
}

Expand Down Expand Up @@ -678,7 +678,7 @@ func applyMigration(migration connect.MigrationPath, systemProducts []connect.Pr
}
}

baseProductVersion, err := migrateSystem(migration, nonInteractive || forceDisableRepos)
baseProductVersion, err := migrateSystem(migration, nonInteractive || forceDisableRepos, autoImportRepoKeys)
if err != nil {
return fsInconsistent, err
}
Expand Down
6 changes: 5 additions & 1 deletion internal/zypper/zypper.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,13 @@ func parseSearchResultXML(xmlDoc []byte) ([]Package, error) {
}

// FindProductPackages returns list of product packages for given product
func FindProductPackages(identifier string) ([]Package, error) {
func FindProductPackages(identifier string, autoImportRepoKeys bool) ([]Package, error) {
args := []string{"--xmlout", "--no-refresh", "--non-interactive", "search", "-s",
"--match-exact", "-t", "product", identifier}
if autoImportRepoKeys {
args = append([]string{"--gpg-auto-import-keys"}, args...)
}

// Don't fail when zypper exits with 104 (no product found) or 6 (no repositories)
output, err := zypperRun(args, []int{zypperOK, zypperErrNoRepos, zypperInfoCapNotFound})
if err != nil {
Expand Down