#!/usr/bin/env ruby ############################################################################### ## Script : easyfpm-translatecl ## Author : Erwan SEITE ## Aim : Translate an easyfpm changelog file to a deb or rpm changelog ## Licence : GPL v2 ## Source : https://github.com/wanix/easyfpm.git ############################################################################### #Libraries needed require 'optparse' $: << File.join(File.dirname(__FILE__), "..", "lib") require 'easyfpm' ############################################################################### ## Main ############################################################################### #Prise en charge des options options = {} optparse = OptionParser.new do |opts| opts.banner = "Usage easyfpm-translatecl [options]" opts.on("-f", "--file [PATH]", String, "easyfpm changelog format file") do |opt| options[:file] = opt end opts.on("-t", "--translation [deb|rpm]", String, "deb or rpm translation (default rpm)") do |opt| options[:translate] = opt.downcase end opts.on("-d", "--date [DATE]", String, "defaut date if don't exists, format '%Y-%m-%d %H:%M:%S'") do |opt| options[:date] = Time.parse(opt) end opts.on("-p", "--package [PACKAGE NAME]", String, "Package name needed for Debian (default dirname of filepath given)") do |opt| options[:package] = opt end opts.on("-u", "--urgency [PACKAGE URGENCY]", String, "urgency needed for Debian (default low)") do |opt| options[:urgency] = opt end opts.on("-D", "--distribution [Debian Distribution]", String, "Debian Distribution (default stable)") do |opt| options[:distribution] = opt end opts.on("--version", "Display version") do |opt| puts "easyfpm version #{EASYFPM::VERSION}" exit end opts.on("-h", "--help", "Display help") do |opt| puts opts exit end end #Looking for options valuability optparse.parse! options[:translate] = "rpm" if options[:translate].nil? if options[:file].nil? warn "Error: --file [PATH] needed" exit 1 end unless File.readable?(options[:file]) warn "Error: #{options[:file]} is not readable" exit 1 end easyfpmcl = EASYFPM::PkgChangelog.new(options[:file]) easyfpmcl.defaultDate = options[:date] if options.key? :date easyfpmcl.pkgname = options[:package] if options.key? :package easyfpmcl.distribution = options[:distribution] if options.key? :distribution easyfpmcl.urgency = options[:urgency] if options.key? :urgency exit 0 if easyfpmcl.print(options[:translate]) exit 1