Skip to content
Browse files

- work-in-progress making it so you can conver rpms to puppet modules.

  • Loading branch information...
1 parent 4bcb64f commit d6ceead964fffa95ccebf18a61a591929973bbe0 @jordansissel committed
Showing with 35 additions and 17 deletions.
  1. +16 −0 lib/fpm/builder.rb
  2. +3 −1 lib/fpm/package.rb
  3. +2 −1 lib/fpm/source.rb
  4. +10 −9 lib/fpm/source/rpm.rb
  5. +4 −6 lib/fpm/target/puppet.rb
View
16 lib/fpm/builder.rb
@@ -86,6 +86,22 @@ def assemble!
::Dir.chdir root do
@source.make_tarball!(tar_path, builddir)
+ # Hack to unpack before generating the spec, etc.
+ # Need to formalize this feature.
+ # Perhaps something like @package.prepare
+ if @package.respond_to?(:unpack_data_to)
+ data_tarball = File.join(builddir, "data.tar.gz")
+ FileUtils.mkdir_p(output)
+ Dir.chdir(output) do
+ FileUtils.mkdir_p(@package.unpack_data_to)
+ system("gzip -d #{data_tarball}")
+ Dir.chdir(@package.unpack_data_to) do
+ @source.root = Dir.pwd
+ system("tar -xf #{data_tarball.gsub(/\.gz$/, "")}")
+ end
+ end
+ end
+
generate_md5sums if @package.needs_md5sums
generate_specfile
edit_specfile if @edit
View
4 lib/fpm/package.rb
@@ -144,6 +144,7 @@ def render_spec
@source.paths.each do |path|
Find.find(path) { |p| paths << p }
end
+ #@logger.info(:paths => paths.sort)
template.result(binding)
end # def render_spec
@@ -156,6 +157,7 @@ def default_output
end # def default_output
def fixpath(path)
+ p :fixpath => path
if path.first != "/"
path = File.join(@source.root, path)
end
@@ -163,7 +165,7 @@ def fixpath(path)
realpath = Pathname.new(path).realpath.to_s
re = Regexp.new("^#{Regexp.escape(@source.root)}")
realpath.gsub!(re, "")
- #p :realpath => [path, realpath]
+ p :fixpath => {:path => realpath, :caller => caller[0] }
return realpath
end # def fixpath
end # class FPM::Package
View
3 lib/fpm/source.rb
@@ -23,7 +23,8 @@ def dependencies
end
attr_reader :paths
- attr_reader :root
+ attr_accessor :root
+
def initialize(paths, root, params={})
@paths = paths
@root = root
View
19 lib/fpm/source/rpm.rb
@@ -2,18 +2,17 @@
class FPM::Source::RPM < FPM::Source
def get_metadata
- self[:name] = %x{rpm -q --qf '%{name}' -p #{@paths.first}}
+ @rpm = @paths.first
+ self[:name] = %x{rpm -q --qf '%{name}' -p #{@rpm}}
- self[:version] = %x{rpm -q --qf '%{version}' -p #{@paths.first}}
- self[:iteration] = %x{rpm -q --qf '%{release}' -p #{@paths.first}}
- self[:summary] = %x{rpm -q --qf '%{summary}' -p #{@paths.first}}
- #self[:description] = %x{rpm -q --qf '%{description}' -p #{@paths.first}}
- self[:dependencies] = %x{rpm -qRp #{@paths.first}}.split("\n")\
+ self[:version] = %x{rpm -q --qf '%{version}' -p #{@rpm}}
+ self[:iteration] = %x{rpm -q --qf '%{release}' -p #{@rpm}}
+ self[:summary] = %x{rpm -q --qf '%{summary}' -p #{@rpm}}
+ #self[:description] = %x{rpm -q --qf '%{description}' -p #{@rpm}}
+ self[:dependencies] = %x{rpm -qRp #{@rpm}}.split("\n")\
.collect { |line| line.strip }
- @rpm = @paths.first
- @paths = %x{rpm -qlp #{@paths.first}}.split("\n")
-
+ @paths = %x{rpm -qlp #{@rpm}}.split("\n")
end
def make_tarball!(tar_path, builddir)
@@ -21,6 +20,8 @@ def make_tarball!(tar_path, builddir)
::Dir.mkdir(tmpdir)
system("rpm2cpio #{@rpm} | (cd #{tmpdir}; cpio -i --make-directories)")
tar(tar_path, ".", tmpdir)
+ @paths = "."
+ @root = tmpdir
# TODO(sissel): Make a helper method.
system(*["gzip", "-f", tar_path])
View
10 lib/fpm/target/puppet.rb
@@ -21,6 +21,10 @@ def specfile(builddir)
"#{builddir}/package.pp"
end # def specfile
+ def unpack_data_to
+ "files"
+ end
+
def build!(params)
# TODO(sissel): Support these somehow, perhaps with execs and files.
self.scripts.each do |name, path|
@@ -34,14 +38,8 @@ def build!(params)
Dir.mkdir(params[:output])
builddir = Dir.pwd
- data_tarball = File.join(builddir, "data.tar.gz")
Dir.chdir(params[:output]) do
- # Unpack data.tar.gz
- Dir.mkdir("files")
- system("gzip -d #{data_tarball}");
- Dir.chdir("files") { system("tar -xf #{data_tarball.gsub(/.gz$/, "")}") }
-
Dir.mkdir("manifests")
FileUtils.cp(specfile(builddir), "manifests")
end

0 comments on commit d6ceead

Please sign in to comment.
Something went wrong with that request. Please try again.