# File lib/fpm/target/deb.rb, line 79
  def build!(params)
    control_files = [ "control" ]
    if File.exists? "./md5sums"
      control_files << "md5sums"
    end

    # Use custom Debian control file when given ...
    if self.settings[:control]
      %x{cp #{self.settings[:control]} ./control 2> /dev/null 2>&1}
      @logger.warn("Unable to process custom Debian control file (exit " \
                   "code: #{$?.exitstatus}). Falling back to default " \
                   "template.") unless $?.exitstatus == 0
    end

    # place the postinst prerm files
    self.scripts.each do |name, path|
      case name
        when "pre-install"
          safesystem("cp #{path} ./preinst")
          control_files << "preinst"
        when "post-install"
          safesystem("cp #{path} ./postinst")
          control_files << "postinst"
        when "pre-uninstall"
          safesystem("cp #{path} ./prerm")
          control_files << "prerm"
        when "post-uninstall"
          safesystem("cp #{path} ./postrm")
          control_files << "postrm"
        else raise "Unsupported script name '#{name}' (path: #{path})"
      end # case name
    end # self.scripts.each

    if self.config_files.any?
      File.open('conffiles', 'w'){ |f| f.puts(config_files.join("\n")) }
      control_files << 'conffiles'
    end

    # Make the control
    safesystem("tar -zcf control.tar.gz #{control_files.map{ |f| "./#{f}" }.join(" ")}")

    # create debian-binary
    File.open("debian-binary", "w") { |f| f.puts "2.0" }

    # pack up the .deb
    safesystem("ar -qc #{params[:output]} debian-binary control.tar.gz data.tar.gz")
  end