fpm 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/fpm +11 -0
 - data/lib/fpm/builder.rb +15 -1
 - data/lib/fpm/source.rb +16 -4
 - data/lib/fpm/source/dir.rb +18 -9
 - data/lib/fpm/target/rpm.rb +6 -1
 - metadata +5 -5
 
    
        data/bin/fpm
    CHANGED
    
    | 
         @@ -11,6 +11,7 @@ require "fpm" 
     | 
|
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
            def main(args)
         
     | 
| 
       13 
13 
     | 
    
         
             
              settings = OpenStruct.new
         
     | 
| 
      
 14 
     | 
    
         
            +
              settings.exclude = []
         
     | 
| 
       14 
15 
     | 
    
         | 
| 
       15 
16 
     | 
    
         
             
              opts = OptionParser.new do |opts|
         
     | 
| 
       16 
17 
     | 
    
         
             
                opts.banner = "Usage: #{$0} [options]"
         
     | 
| 
         @@ -68,6 +69,16 @@ def main(args) 
     | 
|
| 
       68 
69 
     | 
    
         
             
                        "A path to prefix files with when building the target package. This may not be necessary for all source types. For example, the 'gem' type will prefix with your gem directory (gem env | grep -A1 PATHS:)") do |prefix|
         
     | 
| 
       69 
70 
     | 
    
         
             
                  settings.prefix = prefix
         
     | 
| 
       70 
71 
     | 
    
         
             
                end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                opts.on("-e", "--edit", "Edit the specfile before building") do
         
     | 
| 
      
 74 
     | 
    
         
            +
                  settings.edit = true
         
     | 
| 
      
 75 
     | 
    
         
            +
                end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                opts.on("-x PATTERN", "--exclude PATTERN",
         
     | 
| 
      
 78 
     | 
    
         
            +
                        "Exclude paths matching pattern (according to tar --exclude)") do |pattern|
         
     | 
| 
      
 79 
     | 
    
         
            +
                  settings.exclude << pattern
         
     | 
| 
      
 80 
     | 
    
         
            +
                end # -x / --exclude
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
       71 
82 
     | 
    
         
             
              end # OptionParser
         
     | 
| 
       72 
83 
     | 
    
         | 
| 
       73 
84 
     | 
    
         
             
              opts.parse!(args)
         
     | 
    
        data/lib/fpm/builder.rb
    CHANGED
    
    | 
         @@ -35,9 +35,12 @@ class FPM::Builder 
     | 
|
| 
       35 
35 
     | 
    
         
             
                  :version => settings.version,
         
     | 
| 
       36 
36 
     | 
    
         
             
                  :name => settings.package_name,
         
     | 
| 
       37 
37 
     | 
    
         
             
                  :prefix => settings.prefix,
         
     | 
| 
       38 
     | 
    
         
            -
                  :suffix => settings.suffix
         
     | 
| 
      
 38 
     | 
    
         
            +
                  :suffix => settings.suffix,
         
     | 
| 
      
 39 
     | 
    
         
            +
                  :exclude => settings.exclude
         
     | 
| 
       39 
40 
     | 
    
         
             
                )
         
     | 
| 
       40 
41 
     | 
    
         | 
| 
      
 42 
     | 
    
         
            +
                @edit = !!settings.edit
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
       41 
44 
     | 
    
         
             
                @paths = paths
         
     | 
| 
       42 
45 
     | 
    
         
             
                @package = package_class_for(settings.package_type).new(@source)
         
     | 
| 
       43 
46 
     | 
    
         
             
                # Append dependencies given from settings (-d flag for fpm)
         
     | 
| 
         @@ -67,6 +70,7 @@ class FPM::Builder 
     | 
|
| 
       67 
70 
     | 
    
         | 
| 
       68 
71 
     | 
    
         
             
                  generate_md5sums
         
     | 
| 
       69 
72 
     | 
    
         
             
                  generate_specfile
         
     | 
| 
      
 73 
     | 
    
         
            +
                  edit_specfile if @edit
         
     | 
| 
       70 
74 
     | 
    
         
             
                end
         
     | 
| 
       71 
75 
     | 
    
         | 
| 
       72 
76 
     | 
    
         
             
                ::Dir.chdir(builddir) do
         
     | 
| 
         @@ -129,6 +133,16 @@ class FPM::Builder 
     | 
|
| 
       129 
133 
     | 
    
         
             
                end
         
     | 
| 
       130 
134 
     | 
    
         
             
              end
         
     | 
| 
       131 
135 
     | 
    
         | 
| 
      
 136 
     | 
    
         
            +
              private
         
     | 
| 
      
 137 
     | 
    
         
            +
              def edit_specfile
         
     | 
| 
      
 138 
     | 
    
         
            +
                editor = ENV['FPM_EDITOR'] || ENV['EDITOR'] || 'vi'
         
     | 
| 
      
 139 
     | 
    
         
            +
                system("#{editor} '#{package.specfile(builddir)}'")
         
     | 
| 
      
 140 
     | 
    
         
            +
                unless File.size? package.specfile(builddir)
         
     | 
| 
      
 141 
     | 
    
         
            +
                  puts "Empty specfile.  Aborting."
         
     | 
| 
      
 142 
     | 
    
         
            +
                  exit 1
         
     | 
| 
      
 143 
     | 
    
         
            +
                end
         
     | 
| 
      
 144 
     | 
    
         
            +
              end
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
       132 
146 
     | 
    
         
             
              private
         
     | 
| 
       133 
147 
     | 
    
         
             
              def generate_md5sums
         
     | 
| 
       134 
148 
     | 
    
         
             
                md5sums = checksum(paths)
         
     | 
    
        data/lib/fpm/source.rb
    CHANGED
    
    | 
         @@ -83,9 +83,21 @@ class FPM::Source 
     | 
|
| 
       83 
83 
     | 
    
         
             
                    path = File.dirname(path)
         
     | 
| 
       84 
84 
     | 
    
         
             
                  end
         
     | 
| 
       85 
85 
     | 
    
         
             
                end # paths.each
         
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
                 
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                excludes = self[:exclude].map { |e| ["--exclude", e] }.flatten
         
     | 
| 
      
 88 
     | 
    
         
            +
                # TODO(sissel): To properly implement excludes as regexps, we
         
     | 
| 
      
 89 
     | 
    
         
            +
                # will need to find files ourselves. That may be more work
         
     | 
| 
      
 90 
     | 
    
         
            +
                # than it is worth. For now, rely on tar's --exclude.
         
     | 
| 
      
 91 
     | 
    
         
            +
                dir_tar = ["tar", "-C", chdir, "--owner=root", "--group=root" ] \
         
     | 
| 
      
 92 
     | 
    
         
            +
                          + excludes \
         
     | 
| 
      
 93 
     | 
    
         
            +
                          + ["-cf", output, "--no-recursion" ] \
         
     | 
| 
      
 94 
     | 
    
         
            +
                          + dirs
         
     | 
| 
      
 95 
     | 
    
         
            +
                system(*dir_tar) if dirs.any?
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                files_tar = [ "tar", "-C", chdir ] \
         
     | 
| 
      
 98 
     | 
    
         
            +
                            + excludes \
         
     | 
| 
      
 99 
     | 
    
         
            +
                            + [ "--owner=root", "--group=root", "-rf", output ] \
         
     | 
| 
      
 100 
     | 
    
         
            +
                            + paths
         
     | 
| 
      
 101 
     | 
    
         
            +
                system(*files_tar)
         
     | 
| 
       90 
102 
     | 
    
         
             
              end # def tar
         
     | 
| 
       91 
103 
     | 
    
         
             
            end
         
     | 
    
        data/lib/fpm/source/dir.rb
    CHANGED
    
    | 
         @@ -10,15 +10,21 @@ class FPM::Source::Dir < FPM::Source 
     | 
|
| 
       10 
10 
     | 
    
         
             
                if self[:prefix]
         
     | 
| 
       11 
11 
     | 
    
         
             
                  self[:prefix] = self[:prefix][1..-1] if self[:prefix] =~ /^\//
         
     | 
| 
       12 
12 
     | 
    
         
             
                  # Prefix all files with a path.
         
     | 
| 
       13 
     | 
    
         
            -
                  FileUtils.mkdir_p(self[:prefix])
         
     | 
| 
       14 
     | 
    
         
            -
                  paths.each do |path|
         
     | 
| 
      
 13 
     | 
    
         
            +
                  ::FileUtils.mkdir_p(self[:prefix])
         
     | 
| 
      
 14 
     | 
    
         
            +
                  @paths.each do |path|
         
     | 
| 
       15 
15 
     | 
    
         
             
                    # Trim @root (--chdir)
         
     | 
| 
       16 
16 
     | 
    
         
             
                    path = path[@root.size .. -1] if path.start_with?(@root)
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
                    # Copy to self[:prefix] (aka --prefix)
         
     | 
| 
       19 
     | 
    
         
            -
                     
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 19 
     | 
    
         
            +
                    if File.directory?(path)
         
     | 
| 
      
 20 
     | 
    
         
            +
                      dest = "#{builddir}/tarbuild/#{self[:prefix]}/#{path}"
         
     | 
| 
      
 21 
     | 
    
         
            +
                    else
         
     | 
| 
      
 22 
     | 
    
         
            +
                      dest = "#{builddir}/tarbuild/#{self[:prefix]}/#{File.dirname(path)}"
         
     | 
| 
      
 23 
     | 
    
         
            +
                    end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                    ::FileUtils.mkdir_p(dest)
         
     | 
| 
       21 
26 
     | 
    
         
             
                    rsync = ["rsync", "-a", path, dest]
         
     | 
| 
      
 27 
     | 
    
         
            +
                    p rsync
         
     | 
| 
       22 
28 
     | 
    
         
             
                    system(*rsync)
         
     | 
| 
       23 
29 
     | 
    
         | 
| 
       24 
30 
     | 
    
         
             
                    # FileUtils.cp_r is pretty silly about how it copies files in some
         
     | 
| 
         @@ -26,10 +32,13 @@ class FPM::Source::Dir < FPM::Source 
     | 
|
| 
       26 
32 
     | 
    
         
             
                    # Use rsync instead..
         
     | 
| 
       27 
33 
     | 
    
         
             
                    #FileUtils.cp_r(path, dest)
         
     | 
| 
       28 
34 
     | 
    
         
             
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                  # Prefix paths with 'prefix' if necessary.
         
     | 
| 
      
 37 
     | 
    
         
            +
                  if self[:prefix]
         
     | 
| 
      
 38 
     | 
    
         
            +
                    @paths = @paths.collect { |p| File.join("/", self[:prefix], p) }
         
     | 
| 
      
 39 
     | 
    
         
            +
                  end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
       29 
41 
     | 
    
         
             
                  ::Dir.chdir("#{builddir}/tarbuild") do
         
     | 
| 
       30 
     | 
    
         
            -
                    puts "TAR"
         
     | 
| 
       31 
     | 
    
         
            -
                    puts tar_path
         
     | 
| 
       32 
     | 
    
         
            -
                    puts "#{builddir}/tarbuild"
         
     | 
| 
       33 
42 
     | 
    
         
             
                    system("ls #{builddir}/tarbuild")
         
     | 
| 
       34 
43 
     | 
    
         
             
                    tar(tar_path, ".")
         
     | 
| 
       35 
44 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -39,5 +48,5 @@ class FPM::Source::Dir < FPM::Source 
     | 
|
| 
       39 
48 
     | 
    
         | 
| 
       40 
49 
     | 
    
         
             
                # TODO(sissel): Make a helper method.
         
     | 
| 
       41 
50 
     | 
    
         
             
                system(*["gzip", "-f", tar_path])
         
     | 
| 
       42 
     | 
    
         
            -
              end
         
     | 
| 
       43 
     | 
    
         
            -
            end
         
     | 
| 
      
 51 
     | 
    
         
            +
              end # def make_tarball!
         
     | 
| 
      
 52 
     | 
    
         
            +
            end # class FPM::Source::Dir
         
     | 
    
        data/lib/fpm/target/rpm.rb
    CHANGED
    
    | 
         @@ -12,12 +12,17 @@ class FPM::Target::Rpm < FPM::Package 
     | 
|
| 
       12 
12 
     | 
    
         
             
                       "--define", "buildroot #{Dir.pwd}/BUILD",
         
     | 
| 
       13 
13 
     | 
    
         
             
                       "--define", "_topdir #{Dir.pwd}",
         
     | 
| 
       14 
14 
     | 
    
         
             
                       "--define", "_sourcedir #{Dir.pwd}",
         
     | 
| 
       15 
     | 
    
         
            -
                       "--define", "_rpmdir #{ 
     | 
| 
      
 15 
     | 
    
         
            +
                       "--define", "_rpmdir #{Dir.pwd}/RPMS",
         
     | 
| 
       16 
16 
     | 
    
         
             
                       "#{name}.spec"]
         
     | 
| 
       17 
17 
     | 
    
         
             
                ret = system(*args)
         
     | 
| 
       18 
18 
     | 
    
         
             
                if !ret
         
     | 
| 
       19 
19 
     | 
    
         
             
                  raise "rpmbuild failed"
         
     | 
| 
       20 
20 
     | 
    
         
             
                end
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
      
 22 
     | 
    
         
            +
                Dir["#{Dir.pwd}/RPMS/**/*.rpm"].each do |path|
         
     | 
| 
      
 23 
     | 
    
         
            +
                  # This should only output one rpm, should we verify this?
         
     | 
| 
      
 24 
     | 
    
         
            +
                  system("mv", path, params[:output])
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
       22 
27 
     | 
    
         
             
              end
         
     | 
| 
       23 
28 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,13 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: fpm
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              hash:  
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 29
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 0
         
     | 
| 
       8 
8 
     | 
    
         
             
              - 2
         
     | 
| 
       9 
     | 
    
         
            -
              -  
     | 
| 
       10 
     | 
    
         
            -
              version: 0.2. 
     | 
| 
      
 9 
     | 
    
         
            +
              - 5
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 0.2.5
         
     | 
| 
       11 
11 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
12 
     | 
    
         
             
            authors: 
         
     | 
| 
       13 
13 
     | 
    
         
             
            - Jordan Sissel
         
     | 
| 
         @@ -15,7 +15,7 @@ autorequire: 
     | 
|
| 
       15 
15 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       16 
16 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
            date: 2011- 
     | 
| 
      
 18 
     | 
    
         
            +
            date: 2011-03-01 00:00:00 -08:00
         
     | 
| 
       19 
19 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       20 
20 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       21 
21 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       88 
88 
     | 
    
         
             
            requirements: []
         
     | 
| 
       89 
89 
     | 
    
         | 
| 
       90 
90 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       91 
     | 
    
         
            -
            rubygems_version: 1. 
     | 
| 
      
 91 
     | 
    
         
            +
            rubygems_version: 1.5.0
         
     | 
| 
       92 
92 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       93 
93 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       94 
94 
     | 
    
         
             
            summary: fpm - package building and mangling
         
     |