| #!/usr/bin/env ruby | |
| require 'ostruct' | |
| require 'optparse' | |
| options = OpenStruct.new | |
| OptionParser.new do |opts| | |
| opts.banner = "Usage: #{opts.program_name} [options]" | |
| opts.on('-v VERSION', '--version VERSION', | |
| 'Library upstream version') do |v| | |
| options.version = v | |
| end | |
| opts.on('-e INPUTFILE', '-i INPUTFILE', '--input INPUTFILE', | |
| 'Library file to symbolize') do |v| | |
| options.input = v | |
| end | |
| opts.on('-p PACKAGE', '--package PACKAGE', | |
| 'Package name of the package containing the library (defaults to autodetermined)') do |v| | |
| options.package = v | |
| end | |
| opts.on('-O OUTPUTFILE', '-o OUTPUTFILE', '--output OUTPUTFILE', | |
| 'File to dump symbol table to (defaults to symbols.amd64)') do |v| | |
| options.output = v | |
| end | |
| opts.on('-s SYMBOLSFILE', '--symbols SYMBOLSFILE', | |
| 'Final symbols file to write to (defaults to autodetermined)') do |v| | |
| options.symbolsfile = v | |
| end | |
| end.parse! | |
| fail 'Need argument: version' unless options.version | |
| fail 'Need argument: input' unless options.input | |
| options.output = 'symbols.amd64' unless options.output | |
| unless options.package | |
| base = File.basename(options.input) | |
| parts = base.split('.so.') | |
| name = parts.first | |
| version = parts.last | |
| version = version.split('.').first # Get major version | |
| options.package = "#{name}#{version}" | |
| end | |
| unless options.symbolsfile | |
| # Find debian dir and construct a symbols file path | |
| dir = nil | |
| if File.basename(Dir.pwd) == 'debian' | |
| dir = Dir.pwd | |
| else # Otherwise get the first suitable debian/ dir we can find. | |
| dir = Dir.glob('**/debian').first | |
| dir = "#{Dir.pwd}/#{dir}" | |
| end | |
| options.symbolsfile = "#{dir}/#{options.package}.symbols" | |
| end | |
| puts `pkgkde-gensymbols -p#{options.package} -v#{options.version} -O#{options.output} -e#{options.input}` | |
| puts `pkgkde-symbolshelper create -o #{options.symbolsfile} -v #{options.version} #{options.output}` | |
| File.delete(options.output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment