Hello community,

here is the log from the commit of package yast2-packager for openSUSE:Factory 
checked in at 2020-06-10 00:37:49
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-packager (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-packager.new.3606 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-packager"

Wed Jun 10 00:37:49 2020 rev:396 rq:811479 version:4.3.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-packager/yast2-packager.changes    
2020-05-15 23:49:24.953208756 +0200
+++ /work/SRC/openSUSE:Factory/.yast2-packager.new.3606/yast2-packager.changes  
2020-06-10 00:38:10.193358586 +0200
@@ -1,0 +2,8 @@
+Thu Jun  4 11:45:45 UTC 2020 - Josef Reidinger <[email protected]>
+
+- Replace anyxml agent with rubygem-nokogiri as yast2 already
+  depends on nokogiri, to reduce amount of used xml parsers.
+  (related to bsc#1170886)
+- 4.3.2
+
+-------------------------------------------------------------------

Old:
----
  yast2-packager-4.3.1.tar.bz2

New:
----
  yast2-packager-4.3.2.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ yast2-packager.spec ++++++
--- /var/tmp/diff_new_pack.uYLDke/_old  2020-06-10 00:38:11.529362169 +0200
+++ /var/tmp/diff_new_pack.uYLDke/_new  2020-06-10 00:38:11.529362169 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-packager
-Version:        4.3.1
+Version:        4.3.2
 Release:        0
 Summary:        YaST2 - Package Library
 License:        GPL-2.0-or-later
@@ -29,6 +29,7 @@
 BuildRequires:  update-desktop-files
 BuildRequires:  yast2-devtools >= 4.2.2
 BuildRequires:  rubygem(%{rb_default_ruby_abi}:cfa) >= 0.5.0
+BuildRequires:  rubygem(%{rb_default_ruby_abi}:nokogiri)
 BuildRequires:  rubygem(%{rb_default_ruby_abi}:rspec)
 BuildRequires:  rubygem(%{rb_default_ruby_abi}:yast-rake)
 # Y2Storage::Device#exists_in_raw_probed
@@ -53,8 +54,6 @@
 Requires:       unzip
 # HTTP, FTP, HTTPS modules (inst_productsources.ycp)
 Requires:       yast2-transfer
-# XML module (inst_productsources.ycp)
-Requires:       yast2-xml
 # Bugzilla #305503 - storing/checking MD5 of licenses
 Requires:       /usr/bin/md5sum
 # .process agent
@@ -65,6 +64,8 @@
 Requires:       augeas-lenses
 # zypp.conf model and minimal modifications (bsc#1023204)
 Requires:       rubygem(%{rb_default_ruby_abi}:cfa) >= 0.5.0
+# parsing xml with repositories
+Requires:       rubygem(%{rb_default_ruby_abi}:nokogiri)
 # One of libyui-qt-pkg, libyui-ncurses-pkg, libyui-gtk-pkg
 Requires:       libyui_pkg
 Requires:       ruby-solv

++++++ yast2-packager-4.3.1.tar.bz2 -> yast2-packager-4.3.2.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-packager-4.3.1/package/yast2-packager.changes 
new/yast2-packager-4.3.2/package/yast2-packager.changes
--- old/yast2-packager-4.3.1/package/yast2-packager.changes     2020-05-11 
11:30:15.000000000 +0200
+++ new/yast2-packager-4.3.2/package/yast2-packager.changes     2020-06-04 
15:15:18.000000000 +0200
@@ -1,4 +1,12 @@
 -------------------------------------------------------------------
+Thu Jun  4 11:45:45 UTC 2020 - Josef Reidinger <[email protected]>
+
+- Replace anyxml agent with rubygem-nokogiri as yast2 already
+  depends on nokogiri, to reduce amount of used xml parsers.
+  (related to bsc#1170886)
+- 4.3.2
+
+-------------------------------------------------------------------
 Mon May 11 09:13:21 UTC 2020 - Stefan Hundhammer <[email protected]>
 
 - Removed widget option :immediate which is undefined for the
@@ -10,7 +18,7 @@
 
 - bnc#1166661
   - do not crash on empty system_packages_repos.yaml
-- 4.3.0 
+- 4.3.0
 
 -------------------------------------------------------------------
 Mon Apr 20 11:46:59 UTC 2020 - Josef Reidinger <[email protected]>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-packager-4.3.1/package/yast2-packager.spec 
new/yast2-packager-4.3.2/package/yast2-packager.spec
--- old/yast2-packager-4.3.1/package/yast2-packager.spec        2020-05-11 
11:30:15.000000000 +0200
+++ new/yast2-packager-4.3.2/package/yast2-packager.spec        2020-06-04 
15:15:18.000000000 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-packager
-Version:        4.3.1
+Version:        4.3.2
 Release:        0
 Summary:        YaST2 - Package Library
 License:        GPL-2.0-or-later
@@ -31,6 +31,7 @@
 BuildRequires:  rubygem(%{rb_default_ruby_abi}:cfa) >= 0.5.0
 BuildRequires:  rubygem(%{rb_default_ruby_abi}:rspec)
 BuildRequires:  rubygem(%{rb_default_ruby_abi}:yast-rake)
+BuildRequires:  rubygem(%{rb_default_ruby_abi}:nokogiri)
 # Y2Storage::Device#exists_in_raw_probed
 BuildRequires:  yast2-storage-ng >= 4.0.141
 # break the yast2-packager -> yast2-storage-ng -> yast2-packager build cycle
@@ -53,8 +54,6 @@
 Requires:       unzip
 # HTTP, FTP, HTTPS modules (inst_productsources.ycp)
 Requires:       yast2-transfer
-# XML module (inst_productsources.ycp)
-Requires:       yast2-xml
 # Bugzilla #305503 - storing/checking MD5 of licenses
 Requires:       /usr/bin/md5sum
 # .process agent
@@ -65,6 +64,8 @@
 Requires:       augeas-lenses
 # zypp.conf model and minimal modifications (bsc#1023204)
 Requires:       rubygem(%{rb_default_ruby_abi}:cfa) >= 0.5.0
+# parsing xml with repositories
+Requires:       rubygem(%{rb_default_ruby_abi}:nokogiri)
 # One of libyui-qt-pkg, libyui-ncurses-pkg, libyui-gtk-pkg
 Requires:       libyui_pkg
 Requires:       yast2-ruby-bindings >= 1.0.0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-packager-4.3.1/src/modules/OneClickInstallStandard.rb 
new/yast2-packager-4.3.2/src/modules/OneClickInstallStandard.rb
--- old/yast2-packager-4.3.1/src/modules/OneClickInstallStandard.rb     
2020-05-11 11:30:15.000000000 +0200
+++ new/yast2-packager-4.3.2/src/modules/OneClickInstallStandard.rb     
2020-06-04 15:15:18.000000000 +0200
@@ -1,14 +1,16 @@
 require "yast"
 
+require "nokogiri"
+
 # Yast namespace
 module Yast
   # Module for parsing One Click Install Standard
   # http://en.opensuse.org/Standards/One_Click_Install
   class OneClickInstallStandardClass < Module
+    include Yast::Logger
+
     def main
       textdomain "packager"
-
-      Yast.import "FileUtils"
     end
 
     # Converts XML file to a list of maps with all repositories described in 
the XML content.
@@ -42,85 +44,54 @@
     #              ],
     #      ]
     def GetRepositoriesFromXML(filename)
-      ret = []
-
-      if !FileUtils.Exists(filename)
-        Builtins.y2error("File doesn't exist: %1", filename)
-        return deep_copy(ret)
-      end
-
-      read_result = Convert.to_map(SCR.Read(path(".anyxml"), filename))
-
-      if read_result.nil?
-        Builtins.y2error("Cannot read file: %1", filename)
-        return deep_copy(ret)
-      elsif read_result == {}
-        Builtins.y2warning("File %1 is empty", filename)
-        return deep_copy(ret)
+      if !::File.exist?(filename)
+        log.error "File doesn't exist: #{filename}"
+        return []
       end
 
-      distversion = ""
+      doc = Nokogiri::XML(File.read(filename), &:strict)
+      doc.remove_namespaces! # avoid fancy namespaces as it is not needed for 
this xml
 
-      one_repo_out = {}
+      ret = []
+      groups = doc.root.xpath("/metapackage/group")
 
       # starting with <metapackage>-><group>
-      Builtins.foreach(
-        Ops.get_list(read_result, ["metapackage", 0, "group"], [])
-      ) do |one_group|
-        distversion = Ops.get_string(one_group, "distversion", "")
-        Builtins.foreach(
-          Ops.get_list(one_group, ["repositories", 0, "repository"], [])
-        ) do |repository|
-          # One repository (requierd keys)
-          one_repo_out = {
+      groups.each do |group|
+        distversion = group["distversion"] || ""
+        repositories = group.xpath("./repositories/repository")
+        repositories.each do |repository|
+          url = repository.xpath("./url")
+          url = url ? url.text : ""
+          # One repository (required keys)
+          repo_out = {
             "distversion" => distversion,
-            "url"         => Ops.get_string(
-              repository,
-              ["url", 0, "content"],
-              ""
-            ),
-            "format"      => Ops.get_string(repository, "format", ""),
+            "url"         => url,
+            "format"      => repository["format"] || "",
             "alias"       => repository["alias"],
-            "recommended" => Ops.get_string(repository, "recommended", 
"false") == "true"
+            "recommended" => repository["recommended"] == "true"
           }
           # Required + dynamic (localized) keys
-          Builtins.foreach(["name", "description", "summary"]) do |one_key|
-            loc_key = Ops.add("localized_", one_key)
-            Ops.set(one_repo_out, loc_key, {})
-            Builtins.foreach(Ops.get_list(repository, one_key, [])) do 
|one_item|
-              if Ops.get_string(one_item, "content", "") != ""
-                if Builtins.haskey(one_item, "xml:lang")
-                  Ops.set(
-                    one_repo_out,
-                    [loc_key, Ops.get_string(one_item, "xml:lang", "")],
-                    Ops.get_string(one_item, "content", "")
-                  )
-                else
-                  Ops.set(
-                    one_repo_out,
-                    one_key,
-                    Ops.get_string(one_item, "content", "")
-                  )
-                end
+          ["name", "description", "summary"].each do |key|
+            loc_key = "localized_" + key
+            repo_out[loc_key] = {}
+            elements = repository.xpath("./#{key}")
+            elements.each do |item|
+              if item["lang"]
+                repo_out[loc_key][item["lang"]] = item.text
+              else
+                repo_out[key] = item.text
               end
             end
           end
-          # Fallback
-          Builtins.foreach(["name", "description", "summary"]) do |one_key|
-            if Ops.is_map?(Ops.get(repository, one_key)) &&
-                Ops.get_string(repository, [one_key, "content"], "") != ""
-              Ops.set(
-                one_repo_out,
-                one_key,
-                Ops.get_string(repository, [one_key, "content"], "")
-              )
-            end
-          end
-          ret = Builtins.add(ret, one_repo_out)
+
+          ret << repo_out
         end
       end
 
-      deep_copy(ret)
+      ret
+    rescue Nokogiri::XML::SyntaxError => e
+      log.error "syntax error in file #{filename}: #{e.message}"
+      []
     end
 
     publish function: :GetRepositoriesFromXML, type: "list <map <string, any>> 
(string)"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-packager-4.3.1/test/lib/clients/inst_productsources_test.rb 
new/yast2-packager-4.3.2/test/lib/clients/inst_productsources_test.rb
--- old/yast2-packager-4.3.1/test/lib/clients/inst_productsources_test.rb       
2020-05-11 11:30:15.000000000 +0200
+++ new/yast2-packager-4.3.2/test/lib/clients/inst_productsources_test.rb       
2020-06-04 15:15:18.000000000 +0200
@@ -2,6 +2,7 @@
 
 require_relative "../../test_helper"
 require "y2packager/clients/inst_productsources"
+require "tempfile"
 Yast.import "SourceManager"
 
 describe Yast::InstProductsourcesClient do
@@ -84,7 +85,10 @@
     end
 
     it "returns false if file is empty" do
-      expect(client.ParseListOfSources("/dev/zero", url)).to eq false
+      Tempfile.create do |f|
+        f.close
+        expect(client.ParseListOfSources(f.path, url)).to eq false
+      end
     end
 
     it "adds repos to list of repos" do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-packager-4.3.1/test/one_click_install_standard_test.rb 
new/yast2-packager-4.3.2/test/one_click_install_standard_test.rb
--- old/yast2-packager-4.3.1/test/one_click_install_standard_test.rb    
1970-01-01 01:00:00.000000000 +0100
+++ new/yast2-packager-4.3.2/test/one_click_install_standard_test.rb    
2020-06-04 15:15:18.000000000 +0200
@@ -0,0 +1,103 @@
+#!/usr/bin/env rspec
+
+require_relative "test_helper"
+
+require "tempfile"
+
+Yast.import "OneClickInstallStandard"
+
+# note partially covered also by test/lib/clients/inst_productsources_test.rb
+describe "Yast::OneClickInstallStandard" do
+  subject { Yast::OneClickInstallStandard }
+
+  let(:file) do
+    File.expand_path("data/_openSUSE_Leap_15.0_Default.xml", __dir__)
+  end
+
+  describe "#GetRepositoriesFromXML" do
+    it "returns empty array if file does not exist" do
+      expect(subject.GetRepositoriesFromXML("/dev/null/non-existing")).to eq []
+    end
+
+    it "returns empty array if file is empty" do
+      Tempfile.create do |f|
+        f.write("\n")
+        f.close
+        expect(subject.GetRepositoriesFromXML(f.path)).to eq []
+      end
+    end
+
+    it "returns array of repository hashes" do
+      expect(subject.GetRepositoriesFromXML(file)).to have_attributes(size: 8, 
class: ::Array)
+      expect(subject.GetRepositoriesFromXML(file)).to be_all(::Hash)
+    end
+
+    it "fills distversion from group to repository hash" do
+      expect(subject.GetRepositoriesFromXML(file).first).to(
+        include("distversion" => "openSUSE Main Repository")
+      )
+    end
+
+    it "fills url to repository hash" do
+      expect(subject.GetRepositoriesFromXML(file).first).to(
+        include("url" => 
"http://download.opensuse.org/distribution/leap/15.0/repo/oss/";)
+      )
+    end
+
+    it "fills format to repository hash" do
+      expect(subject.GetRepositoriesFromXML(file).first).to(
+        include("format" => "yast")
+      )
+    end
+
+    it "fills alias to repository hash" do
+      expect(subject.GetRepositoriesFromXML(file).first).to(
+        include("alias" => "main")
+      )
+    end
+
+    it "fills recommended to repository hash" do
+      expect(subject.GetRepositoriesFromXML(file).first).to(
+        include("recommended" => true)
+      )
+    end
+
+    it "fills localized name to repository hash" do
+      expect(subject.GetRepositoriesFromXML(file).first["localized_name"]).to(
+        include("cs" => "Hlavní repozitář (OSS)")
+      )
+    end
+
+    it "fills localized summary to repository hash" do
+      
expect(subject.GetRepositoriesFromXML(file).first["localized_summary"]).to(
+        include("cs" => "Hlavní repozitář openSUSE Leap obsahující pouze Open 
source software")
+      )
+    end
+
+    it "fills localized description to repository hash" do
+      
expect(subject.GetRepositoriesFromXML(file).first["localized_description"]).to(
+        include("cs" => "Velký repozitář s Open source softwarem pro openSUSE 
Leap, který " \
+          "vám zpřístupní tisíce balíčků spravovaných komunitou openSUSE.")
+      )
+    end
+
+    it "fills name to repository hash" do
+      expect(subject.GetRepositoriesFromXML(file).first).to(
+        include("name" => "Main Repository (OSS)")
+      )
+    end
+
+    it "fills summary to repository hash" do
+      expect(subject.GetRepositoriesFromXML(file).first).to(
+        include("summary" => "Main repository of openSUSE Leap including only 
Open Source Software")
+      )
+    end
+
+    it "fills description to repository hash" do
+      expect(subject.GetRepositoriesFromXML(file).first).to(
+        include("description" => "The big Open Source Software (OSS) 
repository for openSUSE " \
+          "Leap, giving you access to thousands of packages maintained by the 
openSUSE community.")
+      )
+    end
+  end
+end


Reply via email to