-
Notifications
You must be signed in to change notification settings - Fork 10
/
qml_dependency_verifier.rb
81 lines (70 loc) · 2.4 KB
/
qml_dependency_verifier.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# frozen_string_literal: true
#
# Copyright (C) 2016 Harald Sitter <sitter@kde.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) version 3, or any
# later version accepted by the membership of KDE e.V. (or its
# successor approved by the membership of KDE e.V.), which shall
# act as a proxy defined in Section 6 of version 3 of the license.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library. If not, see <http://www.gnu.org/licenses/>.
require 'logger'
require 'logger/colors'
require 'yaml'
require_relative 'qml_dep_verify/package'
# A QML dependency verifier. It verifies by installing each built package
# and verifying the deps of the installed qml files are met.
# This depends on Launchpad at the time of writing.
class QMLDependencyVerifier
attr_reader :repo
def initialize(repo)
@log = Logger.new(STDOUT)
@log.level = Logger::INFO
@log.progname = self.class.to_s
@repo = repo
end
def missing_modules
repo.add || raise
# Call actual code for missing detection.
missing_modules_internal
ensure
repo.remove
end
private
def log_missing(missings)
# String the imports to make them easier to read.
stringy_missings = missings.map do |pkg, mods|
[pkg, mods.map(&:to_s)]
end.to_h
@log.info "Done looking for missing modules.\n" +
if stringy_missings.empty?
''
else
<<-LOG_OUTPUT
The following modules are missing:
#{YAML.dump(stringy_missings)}
LOG_OUTPUT
end
end
def missing_modules_internal
missing_modules = {}
repo.binaries.each do |package, version|
next if package.end_with?('-dbg', '-dbgsym', '-dev')
pkg = QMLDepVerify::Package.new(package, version)
@log.info "Checking #{package}: #{version}"
next if pkg.missing.empty?
missing_modules[package] = pkg.missing
end
log_missing(missing_modules)
missing_modules
end
end