Skip to content

Commit

Permalink
Merge pull request #271 from SUSE/zypper-migration-bug
Browse files Browse the repository at this point in the history
Honor auto-import-gpg-keys flag on migration
  • Loading branch information
mssola authored Oct 28, 2024
2 parents 4b63a24 + 90f7981 commit ac20840
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
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

0 comments on commit ac20840

Please sign in to comment.