[SCM] ci-tooling packaging branch, master, updated. 569b3ca0d1ab57271dae2d0f08fabbc2e43b700a
Harald Sitter
apachelogger-guest at moszumanska.debian.org
Tue Mar 24 14:20:56 UTC 2015
Gitweb-URL: http://git.debian.org/?p=pkg-kde/ci-tooling.git;a=commitdiff;h=3a9d8f8
The following commit has been merged in the master branch:
commit 3a9d8f8a6a8b28078b3f2edeba11f25fbde452dc
Author: Harald Sitter <sitter at kde.org>
Date: Tue Mar 24 15:17:26 2015 +0100
move qml static mapping into a standalone class
---
data/qml-static-map.yml | 6 ++++
lib/qml_dependency_verifier.rb | 9 ++---
lib/qml_static_map.rb | 61 ++++++++++++++++++++++++++++++++
test/data/test_qml_static_map/test_parse | 6 ++++
test/test_qml_static_map.rb | 24 +++++++++++++
5 files changed, 100 insertions(+), 6 deletions(-)
diff --git a/data/qml-static-map.yml b/data/qml-static-map.yml
new file mode 100644
index 0000000..7dd0310
--- /dev/null
+++ b/data/qml-static-map.yml
@@ -0,0 +1,6 @@
+plasma-framework:
+ - org.kde.plasma.plasmoid
+ - org.kde.plasma.configuration
+kwin:
+ - org.kde.kwin:
+ version: 2.0
diff --git a/lib/qml_dependency_verifier.rb b/lib/qml_dependency_verifier.rb
index e7c6608..6560456 100644
--- a/lib/qml_dependency_verifier.rb
+++ b/lib/qml_dependency_verifier.rb
@@ -7,13 +7,9 @@ require_relative 'dpkg'
require_relative 'lp'
require_relative 'lsb'
require_relative 'qml'
+require_relative 'qml_static_map'
class QMLDependencyVerifier
- PACKAGE_MAP = {
- 'org.kde.plasma.plasmoid' => 'plasma-framework',
- 'org.kde.plasma.configuration' => 'plasma-framework'
- }
-
def initialize
@log = Logger.new(STDOUT)
@log.level = Logger::INFO
@@ -72,6 +68,7 @@ class QMLDependencyVerifier
## - Purge the package and purge the now autoremovable sources. This should lead
## to an almost prestine environment again for the next package. Ideally we'd
## spin up a new container but that appears a bit of a waste of time.
+ static_map = QML::StaticMap.new
missing_modules = {}
binaries.each do |package, version|
@log.info "Checking #{package}: #{version}"
@@ -94,7 +91,7 @@ class QMLDependencyVerifier
modules.each do |mod|
found = false
- static_package = PACKAGE_MAP.fetch(mod.identifier, nil)
+ static_package = static_map.package(mod)
if static_package
# FIXME: move to dpkg module
# FIXME: instead of calling -s this probably should manually check /var/lib/dpkg/info as -s is rather slow
diff --git a/lib/qml_static_map.rb b/lib/qml_static_map.rb
new file mode 100644
index 0000000..3153a16
--- /dev/null
+++ b/lib/qml_static_map.rb
@@ -0,0 +1,61 @@
+require 'yaml'
+
+require_relative 'qml'
+
+module QML
+ # Statically maps specific QML modules to fixed packages.
+ class StaticMap
+ @base_dir = File.expand_path(File.dirname(File.dirname(__FILE__)))
+ @data_file = File.join(@base_dir, 'data', 'qml-static-map.yml')
+
+ class << self
+ # @return [String] path to the yaml data file with mapping information
+ attr_accessor :data_file
+ end
+
+ def initialize(data_file = nil)
+ data_file ||= self.class.data_file
+ data = YAML.load(File.read(data_file))
+ return if data.nil? || !data || data.empty?
+ parse(data)
+ end
+
+ # Get the mapped package for a QML module, or nil.
+ # @param qml_module [QML::Module] module to map to a package. Do note that
+ # version is ignored if the reference map has no version defined. Equally
+ # qualifier is entirely ignored as it has no impact on mapping
+ # @return [String, nil] package name if it maps to a package statically
+ def package(qml_module)
+ # FIXME: kinda slow, perhaps the interal structures should change to
+ # allow for faster lookup
+ @hash.each do |mod, package|
+ next unless mod.identifier == qml_module.identifier
+ next unless mod.version.nil? || mod.version == qml_module.version
+ return package
+ end
+ nil
+ end
+
+ private
+
+ def parse_module(mod)
+ return QML::Module.new(mod) if mod.is_a?(String)
+ mod.each do |name, properties|
+ # coerce version into a string as yaml will spit it out as a floaty
+ version = properties.fetch('version', nil)
+ version = String(version) unless version.nil?
+ return QML::Module.new(name, version)
+ end
+ end
+
+ def parse(data)
+ @hash = {}
+ data.each do |package, modules|
+ modules.each do |mod|
+ qml_mod = parse_module(mod)
+ @hash[qml_mod] = package
+ end
+ end
+ end
+ end
+end
diff --git a/test/data/test_qml_static_map/test_parse b/test/data/test_qml_static_map/test_parse
new file mode 100644
index 0000000..7dd0310
--- /dev/null
+++ b/test/data/test_qml_static_map/test_parse
@@ -0,0 +1,6 @@
+plasma-framework:
+ - org.kde.plasma.plasmoid
+ - org.kde.plasma.configuration
+kwin:
+ - org.kde.kwin:
+ version: 2.0
diff --git a/test/test_qml_static_map.rb b/test/test_qml_static_map.rb
new file mode 100644
index 0000000..ac2d041
--- /dev/null
+++ b/test/test_qml_static_map.rb
@@ -0,0 +1,24 @@
+require_relative '../lib/qml_static_map'
+require_relative 'lib/testcase'
+
+# test qml_static_map
+# This is mostly covered indirectly through dependency_verifier
+class QmlStaticMapTest < TestCase
+ def new_mod(id, version = nil)
+ QML::Module.new(id, version)
+ end
+
+ def test_parse
+ previous_file = QML::StaticMap.instance_variable_get(:@data_file)
+ QML::StaticMap.instance_variable_set(:@data_file, data)
+ assert_equal(data, QML::StaticMap.instance_variable_get(:@data_file))
+ map = QML::StaticMap.new
+ assert_nil(map.package(new_mod('groll')))
+ assert_equal('plasma-framework',
+ map.package(new_mod('org.kde.plasma.plasmoid')))
+ assert_nil(map.package(new_mod('org.kde.kwin')))
+ assert_equal('kwin', map.package(new_mod('org.kde.kwin', '2.0')))
+ ensure
+ QML::StaticMap.instance_variable_set(:@data_file, previous_file)
+ end
+end
--
ci-tooling packaging
More information about the pkg-kde-commits
mailing list