#!/usr/bin/env ruby # ___ _ _ _ # / _ \ _ _(_)__| |___ __ __ _ __| |____ _ __ _ ___ # | (_) | || | / _| / / '_ \/ _' / _| / / _' / _' / -_) # \__\_\\_,_|_\__|_\_\ .__/\__,_\__|_\_\__,_\__, \___| # |_| |___/ # # Copyright (c) 2003-2008 # Christoffer Sawicki # # Licensed under GNU GPL version 2 require "pathname" require "erb" def input(what, default, pattern = //) begin print "#{what} [#{default}]: " input = gets.chomp input = default if input.empty? end until input.match(pattern) return input end data = Hash.new ## Maintainer name = ENV["DEBFULLNAME"] email = ENV["DEBEMAIL"] unless name and email abort "Please set the environment variables DEBFULLNAME and DEBEMAIL." end data[:maintainer] = "#{name} <#{email}>" ## Debian Directory debian = Pathname.new "debian" if debian.exist? abort "`debian' directory does already exist. Aborting." end ## Configure unless File.file? "configure" abort "There's no `configure' script here. Quickpackage only supports software that uses Autotools." end ## Name, Version and Description wd = File.basename Dir.getwd name = wd.match(/^[A-z]*/).to_s.downcase version = wd.match(/\d[\d\.]*$/).to_s puts "Please verify that Quickpackage detected the correct name and version." data[:name] = input "* Name", name, /^(\w|-)+$/ data[:version] = input "* Version", version, /^[\w.]+$/ data[:description] = input "* Description", "..." ## Fire ze missiles! data[:date] = `822-date`.chomp # FIXME puts "Quickpackage will now create the `debian' directory." debian.mkdir for file in Dir.glob "/usr/share/quickpackage/*" template = File.read file target = debian + File.basename(file) result = ERB.new(template).result File.open(target, "w") { |f| f << result } end File.chmod 0755, (debian + "rules") puts "Done! Thank you for using Quickpackage." puts "You can now build the package using `dpkg-buildpackage'"