# File lib/fpm/package/pacman.rb, line 97
  def input(pacman_pkg_path)
    control = {}
    # Unpack the control tarball
    safesystem(tar_cmd, "-C", staging_path, "-xf", pacman_pkg_path)
    pkginfo = staging_path(".PKGINFO")
    mtree = staging_path(".MTREE")
    install = staging_path(".INSTALL")

    control_contents = File.read(pkginfo)
    FileUtils.rm(pkginfo)
    FileUtils.rm(mtree)


    control_lines = control_contents.split("\n")
    control_lines.each do |line|
      key, val = line.split(/ += +/, 2)
      if control.has_key? key
        control[key].push(val)
      else
        control[key] = [val]
      end
    end

    self.name = control["pkgname"][0]

    # Parse 'epoch:version-iteration' in the version string
    version_re = /^(?:([0-9]+):)?(.+?)(?:-(.*))?$/
    m = version_re.match(control["pkgver"][0])
    if !m
      raise "Unsupported version string '#{control["pkgver"][0]}'"
    end
    self.epoch, self.version, self.iteration = m.captures

    self.maintainer = control["packager"][0]

    # Arch has no notion of vendor, so...
    #self.vendor =

    self.url = control["url"][0]
    # Groups could include more than one.
    # Speaking of just taking the first entry of the field:
    # A crude thing to do, but I suppose it's better than nothing.
    # -- Daniel Haskin, 3/24/2015
    self.category = control["group"] && control["group"][0] || self.category

    # Licenses could include more than one.
    # Speaking of just taking the first entry of the field:
    # A crude thing to do, but I suppose it's better than nothing.
    # -- Daniel Haskin, 3/24/2015
    self.license = control["license"][0] || self.license

    self.architecture = control["arch"][0]

    self.dependencies = control["depend"] || self.dependencies

    self.provides = control["provides"] || self.provides

    self.conflicts = control["conflict"] || self.conflicts

    self.replaces = control["replaces"] || self.replaces

    self.description = control["pkgdesc"][0]

    if control.include? "backup"
      self.config_files = control["backup"].map{|file| "/" + file}
    else
      self.config_files = []
    end

    self.dependencies = control["depend"] || self.dependencies
    
    if attributes[:no_auto_depends?]
      self.dependencies = []
    end

    self.attributes[:pacman_optional_depends] = control["optdepend"] || []
    # There are other available attributes, but I didn't include them because:
    # - makedepend: deps needed to make the arch package. But it's already
    #   made. It just needs to be converted at this point
    # - checkdepend: See above
    # - makepkgopt: See above
    # - size: can be dynamically generated
    # - builddate: Should be changed to time of package conversion in the new
    #   package, so this value should be thrown away.

    if File.exist?(install)
      functions = parse_install_script(install)
      if functions.include?("pre_install")
        self.scripts[:before_install] = functions["pre_install"].join("\n")
      end
      if functions.include?("post_install")
        self.scripts[:after_install] = functions["post_install"].join("\n")
      end
      if functions.include?("pre_upgrade")
        self.scripts[:before_upgrade] = functions["pre_upgrade"].join("\n")
      end
      if functions.include?("post_upgrade")
        self.scripts[:after_upgrade] = functions["post_upgrade"].join("\n")
      end
      if functions.include?("pre_remove")
        self.scripts[:before_remove] = functions["pre_remove"].join("\n")
      end
      if functions.include?("post_remove")
        self.scripts[:after_remove] = functions["post_remove"].join("\n")
      end
      FileUtils.rm(install)
    end

    # Note: didn't use `self.directories`.
    # Pacman doesn't really record that information, to my knowledge.

  end