File indexing completed on 2024-10-06 13:09:53
0001 require 'yaml' 0002 0003 class SnapcraftConfig 0004 module AttrRecorder 0005 def attr_accessor(*args) 0006 record_readable(*args) 0007 super 0008 end 0009 0010 def attr_reader(*args) 0011 record_readable(*args) 0012 super 0013 end 0014 0015 def record_readable(*args) 0016 @readable_attrs ||= [] 0017 @readable_attrs += args 0018 end 0019 0020 def readable_attrs 0021 @readable_attrs 0022 end 0023 end 0024 0025 module YamlAttributer 0026 def encode_with(c) 0027 c.tag = nil # Unset the tag to prevent clutter 0028 self.class.readable_attrs.each do |readable_attrs| 0029 c[readable_attrs.to_s.tr('_', '-')] = method(readable_attrs).call 0030 end 0031 super(c) if defined?(super) 0032 end 0033 end 0034 0035 class Part 0036 extend AttrRecorder 0037 prepend YamlAttributer 0038 0039 # Array<String> 0040 attr_accessor :after 0041 # String 0042 attr_accessor :plugin 0043 # String 0044 attr_accessor :source 0045 # Array<String> 0046 attr_accessor :configflags 0047 # Array<String> 0048 attr_accessor :build_packages 0049 # Array<String> 0050 attr_accessor :stage_packages 0051 # Hash 0052 attr_accessor :filesets 0053 # Array<String> 0054 attr_accessor :snap 0055 0056 def initialize 0057 @after = [] 0058 @plugin = 'cmake' 0059 @source = nil 0060 @configflags = %w( 0061 -DKDE_INSTALL_USE_QT_SYS_PATHS=ON 0062 -DCMAKE_INSTALL_PREFIX=/usr 0063 -DCMAKE_BUILD_TYPE=Debug 0064 -DENABLE_TESTING=OFF 0065 -DBUILD_TESTING=OFF 0066 -DKDE_SKIP_TEST_SETTINGS=ON 0067 ) 0068 @build_packages = [] 0069 @stage_packages = [] 0070 @filesets = { 0071 'exclusion' => %w( 0072 -usr/lib/*/cmake/* 0073 -usr/include/* 0074 -usr/share/ECM/* 0075 -usr/share/doc/* 0076 -usr/share/man/* 0077 ) 0078 } 0079 @snap = %w($exclusion) 0080 end 0081 0082 def encode_with(c) 0083 return unless @plugin == 'nil' || @plugin.nil? 0084 p c 0085 # c['configflags'] 0086 end 0087 end 0088 0089 class Slot 0090 extend AttrRecorder 0091 prepend YamlAttributer 0092 0093 attr_accessor :content 0094 attr_accessor :interface 0095 attr_accessor :read 0096 end 0097 0098 extend AttrRecorder 0099 prepend YamlAttributer 0100 0101 attr_accessor :name 0102 attr_accessor :version 0103 attr_accessor :summary 0104 attr_accessor :description 0105 attr_accessor :confinement 0106 attr_accessor :grade 0107 attr_accessor :slots 0108 attr_accessor :parts 0109 0110 def initialize 0111 @parts = {} 0112 @slots = {} 0113 end 0114 end 0115 0116 config = SnapcraftConfig.new 0117 config.name = 'kde-frameworks-5' 0118 config.version = '5.30' 0119 config.summary = 'KDE Frameworks 5' 0120 config.description = 'KDE Frameworks are addons and useful extensions to Qt' 0121 config.confinement = 'devmode' 0122 config.grade = 'stable' 0123 0124 slot = SnapcraftConfig::Slot.new 0125 slot.content = 'kde-frameworks-5-all' 0126 slot.interface = 'content' 0127 slot.read = %w(usr) 0128 config.slots['kde-frameworks-5-slot'] = slot 0129 0130 # This list is generated by resolving and sorting the dep tree from 0131 # kde-build-metadata. Commented out bits we don't presently want to build. 0132 parts = %w(qt5 extra-cmake-modules kcoreaddons) + # kdesupport/polkit-qt-1 0133 %w(kauth kconfig kwidgetsaddons kcompletion 0134 kwindowsystem kcrash karchive ki18n kdoctools kfilemetadata 0135 kjobwidgets kpty kunitconversion kcodecs) + # kdesupport/phonon/phonon 0136 %w(knotifications kpackage kguiaddons kconfigwidgets kitemviews 0137 kiconthemes attica kdbusaddons kservice kglobalaccel sonnet 0138 ktextwidgets breeze-icons kxmlgui kbookmarks solid kwallet kio 0139 kdeclarative kcmutils kplotting kparts kdewebkit kdesignerplugin 0140 kemoticons kjs knewstuff kinit kjsembed knotifyconfig kded 0141 kross kmediaplayer kdesu ktexteditor kactivities kactivities-stats 0142 kdnssd kidletime kitemmodels threadweaver oxygen-icons5 0143 plasma-framework kxmlrpcclient kpeople frameworkintegration 0144 kdelibs4support krunner khtml kwayland kf5umbrella baloo) 0145 # padding 0146 parts = [nil] + parts 0147 # parts += [nil] 0148 parts.each_cons(2) do |first_name, second_name| 0149 # puts "#{second_name} AFTER #{first_name}" 0150 next unless second_name # first item is nil 0151 part = SnapcraftConfig::Part.new 0152 part.after = [first_name] if first_name # last item is also nil 0153 part.source = "http://download.kde.org/stable/frameworks/5.26/#{second_name}-5.26.0.tar.xz" 0154 config.parts[second_name] = part 0155 end 0156 0157 puts File.write('new', YAML.dump(config, indentation: 4))