Warning, /packaging/snap-kf5/contentparser is written in an unsupported language. File is not indexed.
0001 #!/usr/bin/env ruby 0002 # frozen_string_literal: true 0003 # 0004 # Copyright (C) 2018 Harald Sitter <sitter@kde.org> 0005 # 0006 # This program is free software; you can redistribute it and/or 0007 # modify it under the terms of the GNU General Public License as 0008 # published by the Free Software Foundation; either version 3 of 0009 # the License or any later version accepted by the membership of 0010 # KDE e.V. (or its successor approved by the membership of KDE 0011 # e.V.), which shall act as a proxy defined in Section 14 of 0012 # version 3 of the license. 0013 # 0014 # This program is distributed in the hope that it will be useful, 0015 # but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 # GNU General Public License for more details. 0018 # 0019 # You should have received a copy of the GNU General Public License 0020 # along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 0022 # Parses output of 7z inspecting a squashfs and sorts by compressed size. 0023 0024 # bionic 7z needed. 0025 # 7z l -slt kde-frameworks-5_19.squashfs &> content 0026 0027 class Entry 0028 attr_reader :path 0029 attr_reader :folder 0030 attr_reader :size 0031 attr_reader :packed_size 0032 attr_reader :modified 0033 attr_reader :mode 0034 0035 def initialize(blob) 0036 hash = blob.split("\n") 0037 hash = hash.collect do |line| 0038 line.split(' = ', 2) 0039 end.to_h 0040 @path = hash.delete('Path') 0041 @folder = hash.delete('Folder') 0042 @size = hash.delete('Size').to_i 0043 @packed_size = hash.delete('Packed Size').to_i 0044 @modified = hash.delete('Modified') 0045 @mode = hash.delete('Mode') 0046 raise hash unless hash.empty? 0047 end 0048 end 0049 0050 data = File.read('content') 0051 data = data.split("----------\n", 2)[-1] 0052 blobs = data.split("\n\n") 0053 entries = blobs.collect { |x| Entry.new(x) } 0054 entries = entries.sort_by!(&:packed_size) 0055 require 'pp' 0056 entries.each do |x| 0057 puts format("%-100s %s\n", x.path, x.packed_size) 0058 # puts "#{x.path}" 0059 end