Skip to content

Commit

Permalink
Honor auto-import-gpg-keys flag on migration
Browse files Browse the repository at this point in the history
The parsing of CLI arguments and how these are passed through the
internal SCC client, zypper and other tools is not ideal and needs to be
re-worked quite urgently. This is why other silly bugs have appeared in
which we are not passing the correct arguments to our backend code.

Until this rework is not done, let's simply apply this quick fix which
simply passes the `--gpg-auto-import-keys` flag to the zypper backend
when finding product packages.

Fixes bsc#1231328

Signed-off-by: Miquel Sabaté Solà <[email protected]>
  • Loading branch information
mssola committed Oct 28, 2024
1 parent 4b63a24 commit 90f7981
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 90f7981

Please sign in to comment.