Cross package maker. DEB/RPM generation or conversion. Derived from jordansissel/fpm.

⌈⌋ ⎇ branch:  cross package maker


Artifact [dbf7741064]

Artifact dbf7741064fae11f5aba9f0dffc3bd8a79db89b0:

  • File lib/fpm/package/filter_unprefix.rb — part of check-in [0b26058d1e] at 2014-12-24 14:43:41 on branch trunk — Coarse filter to strip leading directory structures (reimporting systme packages to local paths, etc.) (user: mario size: 1088)

# Strips anything but the given prefix dir from staging_path.
#  -u unprefix=/usr/share/pkg/
# Will move the contents of that folder into the top level path.
#
# (It's kind of like the --chdir option for input,
# except that it works after input package extraction.)

require "fpm/package"
require "fpm/util"
require "fileutils"

# find manpages, compress them
class FPM::Package::Filter_unprefix < FPM::Package
  def update(opts=nil)

    if opts and opts.count == 1
      staging_from = "#{staging_path}/#{opts.first}"

      if File.exist?(staging_from)
        staging_keep = ::Dir.mktmpdir("package-#{type}-staging")

        if File.directory?(staging_keep)
          FileUtils.mv(::Dir.glob("#{staging_from}/*"), staging_keep)
          logger.debug("Exchanging staging path", :path => staging_path, :new => staging_keep)
          FileUtils.rm_r(staging_path)
          FileUtils.mv(staging_keep, staging_path)
        end

      else
        logger.error("Prefix directory doesn't exist in staging path", :path => opts.first)
      end

    end # opts
  end # update
end # class