Skip to content

Commit

Permalink
Merge d3db948 into 44b756c
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed Sep 24, 2018
2 parents 44b756c + d3db948 commit 63e95c6
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 4 deletions.
15 changes: 13 additions & 2 deletions doc/license_code_cleanup.md
Expand Up @@ -135,8 +135,8 @@ lib/y2packager/release_notes_reader.rb
Calling product.license_confirmation to write decision.
```

4.0 Adding a new product
==========================
4.0 Adding a new product via UI
=================================

Calling ProductLicense.AskAddOnLicenseAgreement(src_id) (file: modules/AddOnProduct.rb):
- ProductLicense.AskAddOnLicenseAgreement(src_id)
Expand All @@ -146,6 +146,17 @@ the licenses acceptance completely (reading, showing and accepting license)
It can handle all license types ( license is in /license.tar.gz, SCC license and libzypp license )
License types are stored under /tmp/YaST2-<number>/product-license .

4.0 Adding products via file add_on_products.xml
==================================================

While installation it is possible to add products automatically. The concerning product
has already to be on the medium. Adding products will be defined by the file
add_on_products.xml in the root directory of the installation source.
The flag -confirm_license- defines if the user has to accepted the license which has been
defined in the product.

AddPreselectedAddOnProducts in modules/AddOnProduct.rb

5.0 Firstboot module
======================
There are two available clients for checking licenses:
Expand Down
8 changes: 8 additions & 0 deletions package/yast2-packager.changes
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Fri Sep 21 12:58:42 CEST 2018 - schubi@suse.de

- add_on_products.xml : Added tag "confirm_license" to handle
Add-On-products licenses which will be added while installation.
(bsc#1105758)
- 4.0.70

-------------------------------------------------------------------
Mon Jul 16 11:19:03 UTC 2018 - 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: 4.0.69
Version: 4.0.70
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
6 changes: 5 additions & 1 deletion src/modules/AddOnProduct.rb
Expand Up @@ -1463,6 +1463,10 @@ def AddPreselectedAddOnProducts(filelist)
priority = one_product.fetch("priority", -1).to_i
prodname = one_product.fetch("name", "")
check_name = one_product.fetch("check_name", true)
# the default value in AutoYaST is false, otherwise it is true
confirm_license = one_product.fetch("confirm_license", !Mode.auto)
Builtins.y2milestone("confirm_license: %1", confirm_license)

# Check URL and setup network if required or prompt to insert CD/DVD
parsed = URL.Parse(url)
scheme = parsed.fetch("scheme", "").downcase
Expand All @@ -1484,7 +1488,7 @@ def AddPreselectedAddOnProducts(filelist)
end
next false unless repo_id

if !AcceptedLicenseAndInfoFile(repo_id)
if confirm_license && !AcceptedLicenseAndInfoFile(repo_id)
log.warn "License not accepted, delete the repository"
Pkg.SourceDelete(repo_id)
next false
Expand Down
65 changes: 65 additions & 0 deletions test/addon_product_test.rb
Expand Up @@ -290,6 +290,71 @@
end
end

context "when -confirm_license- is not set in add-on description" do
let(:repo_id) { 1 }
before do
allow(Yast::Pkg). to receive(:SourceProductData).with(repo_id)
allow(subject).to receive(:InstallProductsFromRepository)
allow(subject).to receive(:ReIntegrateFromScratch)
allow(subject).to receive(:AddRepo).and_return(repo_id)
allow(subject).to receive(:add_product_from_cd).and_return(repo_id)
allow(subject).to receive(:Integrate)
end

it "does not check license in AY mode" do
expect(Yast::Mode).to receive(:auto).and_return(true)
expect(subject).to_not receive(:AcceptedLicenseAndInfoFile)
subject.AddPreselectedAddOnProducts(filelist)
end
it "checks license in none AY mode" do
expect(Yast::Mode).to receive(:auto).and_return(false)
expect(subject).to receive(:AcceptedLicenseAndInfoFile).and_return(true)
subject.AddPreselectedAddOnProducts(filelist)
end
end

context "when -confirm_license- is defined in add-on description" do
let(:repo_id) { 1 }
before do
allow(Yast::Pkg). to receive(:SourceProductData).with(repo_id)
allow(subject).to receive(:InstallProductsFromRepository)
allow(subject).to receive(:ReIntegrateFromScratch)
allow(subject).to receive(:AddRepo).and_return(repo_id)
allow(subject).to receive(:add_product_from_cd).and_return(repo_id)
allow(subject).to receive(:Integrate)
end

context "when it is set to true" do
let(:repo) { ADDON_REPO.merge("confirm_license" => true) }

it "checks license in AY mode" do
expect(Yast::Mode).to receive(:auto).and_return(true)
expect(subject).to receive(:AcceptedLicenseAndInfoFile).and_return(true)
subject.AddPreselectedAddOnProducts(filelist)
end
it "checks license in none AY mode" do
expect(Yast::Mode).to receive(:auto).and_return(false)
expect(subject).to receive(:AcceptedLicenseAndInfoFile).and_return(true)
subject.AddPreselectedAddOnProducts(filelist)
end
end

context "when it is set to false" do
let(:repo) { ADDON_REPO.merge("confirm_license" => false) }

it "does not check license in AY mode" do
expect(Yast::Mode).to receive(:auto).and_return(true)
expect(subject).to_not receive(:AcceptedLicenseAndInfoFile)
subject.AddPreselectedAddOnProducts(filelist)
end
it "does not check license in none AY mode" do
expect(Yast::Mode).to receive(:auto).and_return(false)
expect(subject).to_not receive(:AcceptedLicenseAndInfoFile)
subject.AddPreselectedAddOnProducts(filelist)
end
end
end

context "when install_products is given in the add-on description" do
let(:repo_id) { 1 }
let(:repo) do
Expand Down

0 comments on commit 63e95c6

Please sign in to comment.