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

⌈⌋ branch:  cross package maker


Check-in [e8ccf504fe]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added support for extra control files for debs (fixes #599)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e8ccf504feb4faec4eb3c0fe3c50c5b5fae241c3
User & Date: dan@madebymany.co.uk 2014-04-30 15:05:39
Context
2014-05-01
13:43
Added support for dpkg triggers (fixes #595) check-in: be4b7a492e user: dan@madebymany.co.uk tags: trunk
2014-04-30
15:05
Added support for extra control files for debs (fixes #599) check-in: e8ccf504fe user: dan@madebymany.co.uk tags: trunk
05:15
Support being given a directory for the output path (-p flag) This should fix #656 and maybe a few other things. check-in: 3a86742bb9 user: jls@semicomplete.com tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to lib/fpm/package/deb.rb.

94
95
96
97
98
99
100






101
102
103
104
105
106
107
...
502
503
504
505
506
507
508

509
510
511
512
513
514
515
...
619
620
621
622
623
624
625










626
627
628
629
630
631
632
  end

  option "--suggests", "PACKAGE", "Add PACKAGE to Suggests" do |pkg|
    @suggests ||= []
    @suggests << pkg
    next @suggests
  end







  option "--field", "'FIELD: VALUE'", "Add custom field to the control file" do |fv|
    @custom_fields ||= {}
    field, value = fv.split(/: */, 2)
    @custom_fields[field] = value
    next @custom_fields
  end
................................................................................
  def write_control_tarball
    # Use custom Debian control file when given ...
    write_control # write the control file
    write_shlibs # write optional shlibs file
    write_scripts # write the maintainer scripts
    write_conffiles # write the conffiles
    write_debconf # write the debconf files

    write_md5sums # write the md5sums file

    # Make the control.tar.gz
    with(build_path("control.tar.gz")) do |controltar|
      @logger.info("Creating", :path => controltar, :from => control_path)

      args = [ tar_cmd, "-C", control_path, "-zcf", controltar, 
................................................................................
    end

    if attributes[:deb_templates]
      FileUtils.cp(attributes[:deb_templates], control_path("templates"))
      File.chmod(0755, control_path("templates"))
    end
  end # def write_debconf











  def write_md5sums
    md5_sums = {}

    Find.find(staging_path) do |path|
      if File.file?(path) && !File.symlink?(path)
        md5 = Digest::MD5.file(path).hexdigest







>
>
>
>
>
>







 







>







 







>
>
>
>
>
>
>
>
>
>







94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
...
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
...
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
  end

  option "--suggests", "PACKAGE", "Add PACKAGE to Suggests" do |pkg|
    @suggests ||= []
    @suggests << pkg
    next @suggests
  end

  option "--meta-file", "FILEPATH", "Add FILEPATH to DEBIAN directory" do |file|
    @meta_files ||= []
    @meta_files << File.expand_path(file)
    next @meta_files
  end

  option "--field", "'FIELD: VALUE'", "Add custom field to the control file" do |fv|
    @custom_fields ||= {}
    field, value = fv.split(/: */, 2)
    @custom_fields[field] = value
    next @custom_fields
  end
................................................................................
  def write_control_tarball
    # Use custom Debian control file when given ...
    write_control # write the control file
    write_shlibs # write optional shlibs file
    write_scripts # write the maintainer scripts
    write_conffiles # write the conffiles
    write_debconf # write the debconf files
    write_meta_files # write additional meta files
    write_md5sums # write the md5sums file

    # Make the control.tar.gz
    with(build_path("control.tar.gz")) do |controltar|
      @logger.info("Creating", :path => controltar, :from => control_path)

      args = [ tar_cmd, "-C", control_path, "-zcf", controltar, 
................................................................................
    end

    if attributes[:deb_templates]
      FileUtils.cp(attributes[:deb_templates], control_path("templates"))
      File.chmod(0755, control_path("templates"))
    end
  end # def write_debconf

  def write_meta_files
    files = attributes[:deb_meta_files]
    return unless files
    files.each do |fn|
      dest = control_path(File.basename(fn))
      FileUtils.cp(fn, dest)
      File.chmod(0644, dest)
    end
  end

  def write_md5sums
    md5_sums = {}

    Find.find(staging_path) do |path|
      if File.file?(path) && !File.symlink?(path)
        md5 = Digest::MD5.file(path).hexdigest

Added spec/fixtures/deb/meta_test.



>
1
asdf

Changes to spec/fpm/package/deb_spec.rb.

146
147
148
149
150
151
152



153
154
155
156
157
158
159
160
161
162




















163
164
165
166
167
168
169
      @original.attributes[:deb_build_depends] << 'something-else > 0.0.0'
      @original.attributes[:deb_build_depends] << 'something-else < 1.0.0'

      @original.attributes[:deb_priority] = "fizzle"
      @original.attributes[:deb_field_given?] = true
      @original.attributes[:deb_field] = { "foo" => "bar" }




      @original.output(@target)

      @input = FPM::Package::Deb.new
      @input.input(@target)
    end

    after :all do
      @original.cleanup
      @input.cleanup
    end # after





















    context "package attributes" do
      it "should have the correct name" do
        insist { @input.name } == @original.name
      end

      it "should have the correct version" do







>
>
>










>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
      @original.attributes[:deb_build_depends] << 'something-else > 0.0.0'
      @original.attributes[:deb_build_depends] << 'something-else < 1.0.0'

      @original.attributes[:deb_priority] = "fizzle"
      @original.attributes[:deb_field_given?] = true
      @original.attributes[:deb_field] = { "foo" => "bar" }

      @original.attributes[:deb_meta_files] = [
        File.expand_path("../../../fixtures/deb/meta_test", __FILE__)]

      @original.output(@target)

      @input = FPM::Package::Deb.new
      @input.input(@target)
    end

    after :all do
      @original.cleanup
      @input.cleanup
    end # after

    context "when the deb's control section is extracted" do
      before :all do
        tmp_control = Tempfile.new("fpm-test-deb-control")
        @control_extracted = tmp_control.path
        tmp_control.unlink
        system("dpkg-deb -e '#{@target}' '#{@control_extracted}'") or \
          raise "couldn't extract test deb"
      end

      it "should have the requested meta file in the control archive" do
        File.open(File.join(@control_extracted, 'meta_test')) do |f|
          insist { f.read.chomp } == "asdf"
        end
      end

      after :all do
        FileUtils.rm_rf @control_extracted
      end
    end

    context "package attributes" do
      it "should have the correct name" do
        insist { @input.name } == @original.name
      end

      it "should have the correct version" do