Skip to content

Commit

Permalink
make product renames updatable from SCC
Browse files Browse the repository at this point in the history
(related to bnc#883206)

- 3.1.27
  • Loading branch information
lslezak committed Jul 4, 2014
1 parent 22088e9 commit cb7af2c
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,6 +3,7 @@ Makefile
Makefile.in
aclocal.m4
autom4te.cache
/coverage
config.cache
config.guess
config.h
Expand Down
6 changes: 6 additions & 0 deletions package/yast2-packager.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri Jul 4 12:09:55 UTC 2014 - lslezak@suse.cz

- make product renames updatable from SCC (related to bnc#883206)
- 3.1.27

-------------------------------------------------------------------
Fri Jun 27 12:00:38 UTC 2014 - lslezak@suse.cz

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-packager.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-packager
Version: 3.1.25
Version: 3.1.26
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
31 changes: 30 additions & 1 deletion src/modules/AddOnProduct.rb
Expand Up @@ -16,6 +16,8 @@

module Yast
class AddOnProductClass < Module
include Yast::Logger

def main
Yast.import "UI"
Yast.import "Pkg"
Expand Down Expand Up @@ -125,6 +127,18 @@ def main
# ]
# ]
@patterns_preselected_by_addon = {}

# product renames needed for detecting the product update
# this mapping can be updated by SCC registration server,
# this is the static default for offline updates
# mapping: <old_name> => [ <new_name> ]
@product_renames = {
"SUSE_SLES" => [ "SLES" ],
# SLED or Workstation extension
"SUSE_SLED" => [ "SLED", "sle-we" ],
"sle-haegeo" => [ "sle-ha-geo" ]
}

end

# Downloads a requested file, caches it and returns path to that cached file.
Expand Down Expand Up @@ -872,7 +886,9 @@ def RegisterAddOnProduct(src_id)
# or check the content file
if WorkflowManager.WorkflowRequiresRegistration(src_id) || Builtins.contains(@addons_requesting_registration, src_id)
Builtins.y2milestone("Repository ID %1 requests registration", src_id)
WFM.CallFunction("inst_suse_register", [])
# TODO FIXME: user needs to manually select the addon to register,
# pass the addon so it could be pre-selected
WFM.CallFunction("inst_scc", [])
else
Builtins.y2milestone(
"Repository ID %1 doesn't need registration",
Expand Down Expand Up @@ -2161,6 +2177,19 @@ def SetSignatureCallbacks(product)
nil
end

def renamed?(old_name, new_name)
@product_renames[old_name] && @product_renames[old_name].include?(new_name)
end

def add_rename(old_name, new_name)
# already known
return if renamed?(old_name, new_name)

log.info "Adding product rename: '#{old_name}' => '#{new_name}'"
@product_renames[old_name] = [] unless @product_renames[old_name]
@product_renames[old_name] << new_name
end

publish :variable => :add_on_products, :type => "list <map <string, any>>"
publish :variable => :src_id, :type => "integer"
publish :variable => :last_ret, :type => "symbol"
Expand Down
14 changes: 2 additions & 12 deletions src/modules/Packages.rb
Expand Up @@ -17,15 +17,6 @@ class PackagesClass < Module
# All known types of resolvables
RESOLVABLE_TYPES = [:product, :patch, :package, :pattern, :language]

# product renames needed for detecting the product update
# <old_name> => [ <new_name> ]
PRODUCT_RENAMES = {
"SUSE_SLES" => [ "SLES" ],
# SLED or Workstation extension
"SUSE_SLED" => [ "SLED", "sle-we" ],
"sle-haegeo" => [ "sle-ha-geo" ]
}

def main
Yast.import "UI"
Yast.import "Pkg"
Expand Down Expand Up @@ -2660,9 +2651,8 @@ def products_to_update(installed_products, removed_products)
removed_name = removed_product["name"]

# check the current product names or product renames
removed_name == installed_name ||
(PRODUCT_RENAMES[removed_name] &&
PRODUCT_RENAMES[removed_name].include?(installed_name))
removed_name == installed_name
AddOnProduct.renamed?(removed_name, installed_name)
end

updated_products[removed] = installed_product if removed
Expand Down
1 change: 1 addition & 0 deletions test/Makefile.am
@@ -1,4 +1,5 @@
TESTS = \
addon_product_test.rb \
packages_test.rb

TEST_EXTENSIONS = .rb
Expand Down
35 changes: 35 additions & 0 deletions test/addon_product_test.rb
@@ -0,0 +1,35 @@
#! /usr/bin/env rspec

require_relative "./test_helper"

Yast.import "AddOnProduct"

describe Yast::AddOnProduct do
describe "#renamed?" do
it "returns true if product has been renamed" do
expect(Yast::AddOnProduct.renamed?("SUSE_SLES", "SLES")).to be_true
end

it "returns false if the product rename is not known" do
expect(Yast::AddOnProduct.renamed?("foo", "bar")).to be_false
end
end

describe "#add_rename" do
it "adds a new product rename" do
expect(Yast::AddOnProduct.renamed?("FOO", "BAR")).to be_false
Yast::AddOnProduct.add_rename("FOO", "BAR")
expect(Yast::AddOnProduct.renamed?("FOO", "BAR")).to be_true
end

it "keeps the existing renames" do
# add new rename
Yast::AddOnProduct.add_rename("SUSE_SLES", "SLES_NEW")
# check the new rename
expect(Yast::AddOnProduct.renamed?("SUSE_SLES", "SLES_NEW")).to be_true
# check the already known rename
expect(Yast::AddOnProduct.renamed?("SUSE_SLES", "SLES")).to be_true
end
end

end
3 changes: 1 addition & 2 deletions test/packages_test.rb
@@ -1,8 +1,7 @@
#! /usr/bin/env rspec

ENV["Y2DIR"] = File.expand_path("../../src", __FILE__)
require_relative "./test_helper"

require "yast"
require "yaml"

include Yast::Logger
Expand Down
8 changes: 8 additions & 0 deletions test/test_helper.rb
@@ -0,0 +1,8 @@
ENV["Y2DIR"] = File.expand_path("../../src", __FILE__)

if ENV["COVERAGE"]
require "simplecov"
SimpleCov.start
end

require "yast"

0 comments on commit cb7af2c

Please sign in to comment.