-
Notifications
You must be signed in to change notification settings - Fork 0
/
atomize.rb
157 lines (139 loc) · 4.16 KB
/
atomize.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
require 'yaml'
class SnapcraftConfig
module AttrRecorder
def attr_accessor(*args)
record_readable(*args)
super
end
def attr_reader(*args)
record_readable(*args)
super
end
def record_readable(*args)
@readable_attrs ||= []
@readable_attrs += args
end
def readable_attrs
@readable_attrs
end
end
module YamlAttributer
def encode_with(c)
c.tag = nil # Unset the tag to prevent clutter
self.class.readable_attrs.each do |readable_attrs|
c[readable_attrs.to_s.tr('_', '-')] = method(readable_attrs).call
end
super(c) if defined?(super)
end
end
class Part
extend AttrRecorder
prepend YamlAttributer
# Array<String>
attr_accessor :after
# String
attr_accessor :plugin
# String
attr_accessor :source
# Array<String>
attr_accessor :configflags
# Array<String>
attr_accessor :build_packages
# Array<String>
attr_accessor :stage_packages
# Hash
attr_accessor :filesets
# Array<String>
attr_accessor :snap
def initialize
@after = []
@plugin = 'cmake'
@source = nil
@configflags = %w(
-DKDE_INSTALL_USE_QT_SYS_PATHS=ON
-DCMAKE_INSTALL_PREFIX=/usr
-DCMAKE_BUILD_TYPE=Debug
-DENABLE_TESTING=OFF
-DBUILD_TESTING=OFF
-DKDE_SKIP_TEST_SETTINGS=ON
)
@build_packages = []
@stage_packages = []
@filesets = {
'exclusion' => %w(
-usr/lib/*/cmake/*
-usr/include/*
-usr/share/ECM/*
-usr/share/doc/*
-usr/share/man/*
)
}
@snap = %w($exclusion)
end
def encode_with(c)
return unless @plugin == 'nil' || @plugin.nil?
p c
# c['configflags']
end
end
class Slot
extend AttrRecorder
prepend YamlAttributer
attr_accessor :content
attr_accessor :interface
attr_accessor :read
end
extend AttrRecorder
prepend YamlAttributer
attr_accessor :name
attr_accessor :version
attr_accessor :summary
attr_accessor :description
attr_accessor :confinement
attr_accessor :grade
attr_accessor :slots
attr_accessor :parts
def initialize
@parts = {}
@slots = {}
end
end
config = SnapcraftConfig.new
config.name = 'kde-frameworks-5'
config.version = '5.30'
config.summary = 'KDE Frameworks 5'
config.description = 'KDE Frameworks are addons and useful extensions to Qt'
config.confinement = 'devmode'
config.grade = 'stable'
slot = SnapcraftConfig::Slot.new
slot.content = 'kde-frameworks-5-all'
slot.interface = 'content'
slot.read = %w(usr)
config.slots['kde-frameworks-5-slot'] = slot
# This list is generated by resolving and sorting the dep tree from
# kde-build-metadata. Commented out bits we don't presently want to build.
parts = %w(qt5 extra-cmake-modules kcoreaddons) + # kdesupport/polkit-qt-1
%w(kauth kconfig kwidgetsaddons kcompletion
kwindowsystem kcrash karchive ki18n kdoctools kfilemetadata
kjobwidgets kpty kunitconversion kcodecs) + # kdesupport/phonon/phonon
%w(knotifications kpackage kguiaddons kconfigwidgets kitemviews
kiconthemes attica kdbusaddons kservice kglobalaccel sonnet
ktextwidgets breeze-icons kxmlgui kbookmarks solid kwallet kio
kdeclarative kcmutils kplotting kparts kdewebkit kdesignerplugin
kemoticons kjs knewstuff kinit kjsembed knotifyconfig kded
kross kmediaplayer kdesu ktexteditor kactivities kactivities-stats
kdnssd kidletime kitemmodels threadweaver oxygen-icons5
plasma-framework kxmlrpcclient kpeople frameworkintegration
kdelibs4support krunner khtml kwayland kf5umbrella baloo)
# padding
parts = [nil] + parts
# parts += [nil]
parts.each_cons(2) do |first_name, second_name|
# puts "#{second_name} AFTER #{first_name}"
next unless second_name # first item is nil
part = SnapcraftConfig::Part.new
part.after = [first_name] if first_name # last item is also nil
part.source = "http://download.kde.org/stable/frameworks/5.26/#{second_name}-5.26.0.tar.xz"
config.parts[second_name] = part
end
puts File.write('new', YAML.dump(config, indentation: 4))