mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-10-22 07:21:21 +00:00
9979f76803
For Ubuntu 22.04 and later the GUI will be built with Qt 6 instead of Qt 5 due to severe issues with 22.04, Qt 5 and high DPI displays. See issue #3358 for more information. Unfortunately Debian's package tooling isn't powerful enough to express complex dependencies, and it cannot express things based on the distribution & version the package is built for. The packaging for Qt 6 requires different libraries than the packaging for Qt 5, obviously. The only thing one could do in a single `control` file is using ORed dependencies such as `libqt6svg6 | libqt5svg5`, but that can lead to situations where the user has `libqt5svg5` installed, doesn't have `libqt6svg6` installed, and then MKVToolNix built with Qt 6 will install just fine but all the icons will be missing as it cannot load the SVG plugin dynamically. Therefore the `control` & `rules` files are now built from templates, and a Ruby script called `packaging/debian/create_files.rb` is used to create the files from their templates. The user can specify the distribution & version to create for with command line arguments. If not specified, the script will attempt to guess the distribution & version it's running on. Only Debian ≥ 10 & Ubuntu ≥ 20.04 are supported, same as before.
186 lines
4.7 KiB
Ruby
Executable File
186 lines
4.7 KiB
Ruby
Executable File
#!/usr/bin/env ruby
|
|
|
|
require "erb"
|
|
|
|
$distribution = nil
|
|
$distribution_version = nil
|
|
|
|
def show_help error
|
|
puts "Error: #{error}"
|
|
puts
|
|
|
|
puts "Syntax: #{__FILE__} [-d|--distribution <distribution> -v|--version <version>]"
|
|
puts " Example 1: #{__FILE__} -d Ubuntu -v 22.04"
|
|
puts " Example 2: #{__FILE__} --distribution Debian --version 11"
|
|
puts
|
|
puts "If at least one of them isn't specified, guessing the distribution &"
|
|
puts "version the scripts runs under is attempted."
|
|
|
|
exit 1
|
|
end
|
|
|
|
def create_file erb_file_name, erb_binding
|
|
puts "handling #{erb_file_name}"
|
|
|
|
dest_file_name = erb_file_name.gsub(%r{\.erb$}, '')
|
|
content = IO.read(erb_file_name, encoding: "utf-8")
|
|
|
|
File.open(dest_file_name, 'w') { |file| file.puts(ERB.new(content, nil, '<>').result(erb_binding)) }
|
|
end
|
|
|
|
def handle_all_erb_files
|
|
distro = $distribution.downcase
|
|
version = Gem::Version.new($distribution_version)
|
|
|
|
puts "Creating files for #{distro} #{version}"
|
|
|
|
Dir.glob(File.absolute_path(File.dirname(__FILE__)) + "/*.erb").each do |file_name|
|
|
create_file(file_name, binding)
|
|
end
|
|
end
|
|
|
|
def parse_cli_args
|
|
while !ARGV.empty?
|
|
arg = ARGV.shift
|
|
|
|
if %r{^-(?:d|-distribution)$}.match(arg)
|
|
show_help("Missing argument to '#{arg}'") if ARGV.empty?
|
|
$distribution = ARGV.shift
|
|
|
|
elsif %r{^-(?:v|-version)$}.match(arg)
|
|
show_help("Missing argument to '#{arg}'") if ARGV.empty?
|
|
$distribution_version = ARGV.shift
|
|
|
|
else
|
|
show_help("Unrecognized option '#{arg}'")
|
|
end
|
|
end
|
|
end
|
|
|
|
def parse_lsb_release
|
|
lsb_file = "/etc/lsb-release"
|
|
|
|
return false if !FileTest.file?(lsb_file)
|
|
|
|
values = Hash[*
|
|
IO.readlines(lsb_file).
|
|
map(&:chomp).
|
|
select { |line| %r{.+=.+}.match(line) }.
|
|
map { |line| a = line.split('=', 2); [ a[0], a[1].gsub(%r{^"|"$}, '') ] }.
|
|
flatten
|
|
]
|
|
|
|
$distribution = values["DISTRIB_ID"]
|
|
version = (values["DISTRIB_RELEASE"] || '').gsub(%r{[^\d.].*}, '')
|
|
$distribution_version = version != '' ? version : nil
|
|
|
|
return false # $distribution && $distribution_version
|
|
end
|
|
|
|
def parse_sources_list
|
|
content = ([ "/etc/apt/sources.list" ] + Dir.glob("/etc/apt/sources.list.d/*")).
|
|
select { |file_name| FileTest.file?(file_name) }.
|
|
map { |file_name| IO.readlines(file_name, encoding: "utf-8") }.
|
|
inject([]) { |accu, lines| accu + lines }
|
|
|
|
### Ubuntu
|
|
|
|
if content.any? { |line| %r{ubuntu.*jammy}.match(line) }
|
|
$distribution = 'ubuntu'
|
|
$distribution_version = '22.04'
|
|
return true
|
|
end
|
|
|
|
if content.any? { |line| %r{ubuntu.*impish}.match(line) }
|
|
$distribution = 'ubuntu'
|
|
$distribution_version = '21.10'
|
|
return true
|
|
end
|
|
|
|
if content.any? { |line| %r{ubuntu.*hirsute}.match(line) }
|
|
$distribution = 'ubuntu'
|
|
$distribution_version = '21.04'
|
|
return true
|
|
end
|
|
|
|
if content.any? { |line| %r{ubuntu.*groovy}.match(line) }
|
|
$distribution = 'ubuntu'
|
|
$distribution_version = '20.10'
|
|
return true
|
|
end
|
|
|
|
if content.any? { |line| %r{ubuntu.*focal}.match(line) }
|
|
$distribution = 'ubuntu'
|
|
$distribution_version = '20.04'
|
|
return true
|
|
end
|
|
|
|
if content.any? { |line| %r{ubuntu.*eoan}.match(line) }
|
|
$distribution = 'ubuntu'
|
|
$distribution_version = '19.10'
|
|
return true
|
|
end
|
|
|
|
if content.any? { |line| %r{ubuntu.*disco}.match(line) }
|
|
$distribution = 'ubuntu'
|
|
$distribution_version = '19.04'
|
|
return true
|
|
end
|
|
|
|
if content.any? { |line| %r{ubuntu.*cosmic}.match(line) }
|
|
$distribution = 'ubuntu'
|
|
$distribution_version = '18.10'
|
|
return true
|
|
end
|
|
|
|
if content.any? { |line| %r{ubuntu.*bionic}.match(line) }
|
|
$distribution = 'ubuntu'
|
|
$distribution_version = '18.04'
|
|
return true
|
|
end
|
|
|
|
### Debian
|
|
|
|
if content.any? { |line| %r{debian.*bookworm}.match(line) }
|
|
$distribution = 'debian'
|
|
$distribution_version = '12'
|
|
return true
|
|
end
|
|
|
|
if content.any? { |line| %r{debian.*bullseye}.match(line) }
|
|
$distribution = 'debian'
|
|
$distribution_version = '11'
|
|
return true
|
|
end
|
|
|
|
if content.any? { |line| %r{debian.*buster}.match(line) }
|
|
$distribution = 'debian'
|
|
$distribution_version = '10'
|
|
return true
|
|
end
|
|
|
|
if content.any? { |line| %r{debian.*stretch}.match(line) }
|
|
$distribution = 'debian'
|
|
$distribution_version = '9'
|
|
return true
|
|
end
|
|
|
|
return false
|
|
end
|
|
|
|
def guess_distribution
|
|
return if parse_lsb_release
|
|
return if parse_sources_list
|
|
end
|
|
|
|
def main
|
|
parse_cli_args
|
|
|
|
guess_distribution if !$distribution || !$distribution_version
|
|
show_help("Could not guess distribution & version") if !$distribution || !$distribution_version
|
|
|
|
handle_all_erb_files
|
|
end
|
|
|
|
main
|