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

⌈⌋ ⎇ branch:  cross package maker


Check-in [06727e35c2]

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

Overview
Comment:Make lintian happy: move DEB changelog generation before write_md5sums. (Workaround for [#833](https://github.com/jordansissel/fpm/issues/833).) Add stub copyright (actually prepared for DEP-5 / parseable debian/copyright). Augment deb/control.erb regex check for empty lines.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 06727e35c231c822662d6fc0f9112fb24bec0e7b
User & Date: mario 2015-02-08 01:48:57
Context
2015-02-08
06:12
Make fixperms ignore symlinks / or any other chmod errors. check-in: fec5fcaca3 user: mario tags: trunk
01:48
Make lintian happy: move DEB changelog generation before write_md5sums. (Workaround for [#833](https://github.com/jordansissel/fpm/issues/833).) Add stub copyright (actually prepared for DEP-5 / parseable debian/copyright). Augment deb/control.erb regex check for empty lines. check-in: 06727e35c2 user: mario tags: trunk
2015-02-06
20:52
Make some inherited relative target paths working. check-in: bc0c714540 user: mario tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
        datatar = build_path("data.tar.xz")
        compression = "-J"
      else
        raise FPM::InvalidPackageConfiguration,
          "Unknown compression type '#{self.attributes[:deb_compression]}'"
    end

    # Write the changelog file
    dest_changelog = File.join(staging_path, "usr/share/doc/#{name}/changelog.Debian.gz")
    FileUtils.mkdir_p(File.dirname(dest_changelog))
    File.new(dest_changelog, "wb", 0644).tap do |changelog|
      Zlib::GzipWriter.new(changelog, Zlib::BEST_COMPRESSION).tap do |changelog_gz|
        if attributes[:deb_changelog]
          logger.info("Writing user-specified changelog", :source => attributes[:deb_changelog])
          File.new(attributes[:deb_changelog]).tap do |fd|
            chunk = nil
            # Ruby 1.8.7 doesn't have IO#copy_stream
            changelog_gz.write(chunk) while chunk = fd.read(16384)
          end.close
        else
          logger.info("Creating boilerplate changelog file")
          changelog_gz.write(template("deb/changelog.erb").result(binding))
        end
      end.close
    end # No need to close, GzipWriter#close will close it.

    attributes.fetch(:deb_init_list, []).each do |init|
      name = File.basename(init, ".init")
      dest_init = File.join(staging_path, "etc/init.d/#{name}")
      FileUtils.mkdir_p(File.dirname(dest_init))
      FileUtils.cp init, dest_init
      File.chmod(0755, dest_init)







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







383
384
385
386
387
388
389


















390
391
392
393
394
395
396
        datatar = build_path("data.tar.xz")
        compression = "-J"
      else
        raise FPM::InvalidPackageConfiguration,
          "Unknown compression type '#{self.attributes[:deb_compression]}'"
    end




















    attributes.fetch(:deb_init_list, []).each do |init|
      name = File.basename(init, ".init")
      dest_init = File.join(staging_path, "etc/init.d/#{name}")
      FileUtils.mkdir_p(File.dirname(dest_init))
      FileUtils.cp init, dest_init
      File.chmod(0755, dest_init)
568
569
570
571
572
573
574


575
576
577
578
579
580
581
    end
  end # def control_path

  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_triggers # write trigger config to 'triggers' file
    write_md5sums # write the md5sums file








>
>







550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
    end
  end # def control_path

  def write_control_tarball
    # Use custom Debian control file when given ...
    write_control # write the control file
    write_shlibs # write optional shlibs file
    write_changelog # write changelog file
    write_copyright # write copyright 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_triggers # write trigger config to 'triggers' file
    write_md5sums # write the md5sums file

635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
  # Write out the maintainer scripts
  #
  # SCRIPT_MAP is a map from the package ':after_install' to debian
  # 'post_install' names
  def write_scripts
    SCRIPT_MAP.each do |scriptname, filename|
      next unless script?(scriptname)

      with(control_path(filename)) do |controlscript|
        logger.debug("Writing control script", :source => filename, :target => controlscript)
        File.write(controlscript, script(scriptname))
        # deb maintainer scripts are required to be executable
        File.chmod(0755, controlscript)
      end
    end 







<







619
620
621
622
623
624
625

626
627
628
629
630
631
632
  # Write out the maintainer scripts
  #
  # SCRIPT_MAP is a map from the package ':after_install' to debian
  # 'post_install' names
  def write_scripts
    SCRIPT_MAP.each do |scriptname, filename|
      next unless script?(scriptname)

      with(control_path(filename)) do |controlscript|
        logger.debug("Writing control script", :source => filename, :target => controlscript)
        File.write(controlscript, script(scriptname))
        # deb maintainer scripts are required to be executable
        File.chmod(0755, controlscript)
      end
    end 
678
679
680
681
682
683
684





















685
686
687
688
689
690
691
692










693
694
695
696
697
698
699
          out.puts("/" + cf)
        end
      end
      File.chmod(0644, conffiles)
    end
  end # def write_conffiles






















  def write_shlibs
    return unless attributes[:deb_shlibs]
    logger.info("Adding shlibs", :content => attributes[:deb_shlibs])
    File.open(control_path("shlibs"), "w") do |out|
      out.write(attributes[:deb_shlibs])
    end
  end # def write_shlibs











  def write_debconf
    if attributes[:deb_config]
      FileUtils.cp(attributes[:deb_config], control_path("config"))
      File.chmod(0755, control_path("config"))
    end

    if attributes[:deb_templates]







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








>
>
>
>
>
>
>
>
>
>







661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
          out.puts("/" + cf)
        end
      end
      File.chmod(0644, conffiles)
    end
  end # def write_conffiles

  def write_changelog
    # Write the changelog file
    dest_changelog = File.join(staging_path, "usr/share/doc/#{name}/changelog.Debian.gz")
    FileUtils.mkdir_p(File.dirname(dest_changelog))
    File.new(dest_changelog, "wb", 0644).tap do |changelog|
      Zlib::GzipWriter.new(changelog, Zlib::BEST_COMPRESSION).tap do |changelog_gz|
        if attributes[:deb_changelog]
          logger.info("Writing user-specified changelog", :source => attributes[:deb_changelog])
          File.new(attributes[:deb_changelog]).tap do |fd|
            chunk = nil
            # Ruby 1.8.7 doesn't have IO#copy_stream
            changelog_gz.write(chunk) while chunk = fd.read(16384)
          end.close
        else
          logger.info("Creating boilerplate changelog file")
          changelog_gz.write(template("deb/changelog.erb").result(binding))
        end
      end.close
    end # No need to close, GzipWriter#close will close it.
  end # def write_changelog

  def write_shlibs
    return unless attributes[:deb_shlibs]
    logger.info("Adding shlibs", :content => attributes[:deb_shlibs])
    File.open(control_path("shlibs"), "w") do |out|
      out.write(attributes[:deb_shlibs])
    end
  end # def write_shlibs

  def write_copyright
    logger.info("Adding copyright stub");
    unless File.exist?(dest = "#{staging_path}/usr/share/doc/#{name}/copyright")
      FileUtils.mkdir_p(File.dirname(dest))
      File.open(dest, "w", 0644) do |out|
        out.write(template("deb/copyright.erb").result(binding))
      end
    end
  end # def write_copyright

  def write_debconf
    if attributes[:deb_config]
      FileUtils.cp(attributes[:deb_config], control_path("config"))
      File.chmod(0755, control_path("config"))
    end

    if attributes[:deb_templates]

Changes to templates/deb.erb.

39
40
41
42
43
44
45
46
47
48
49
50
Section: <%= category %>
Priority: <%= attributes[:deb_priority] %>
Homepage: <%= url or "http://nourlgiven.example.com/" %>
<% lines = (description or "no description given").split("\n") -%>
<% firstline, *remainder = lines -%>
Description: <%= firstline %>
<% if remainder.any? -%>
<%= remainder.collect { |l| l =~ /^ *$/ ? " ." : " #{l}" }.join("\n") %>
<% end -%>
<% extra_fields.each do |field, value| -%>
<%= field %>: <%= value %>
<% end -%>







|




39
40
41
42
43
44
45
46
47
48
49
50
Section: <%= category %>
Priority: <%= attributes[:deb_priority] %>
Homepage: <%= url or "http://nourlgiven.example.com/" %>
<% lines = (description or "no description given").split("\n") -%>
<% firstline, *remainder = lines -%>
Description: <%= firstline %>
<% if remainder.any? -%>
<%= remainder.collect { |l| l =~ /^\s*$/ ? " ." : " #{l}" }.join("\n") %>
<% end -%>
<% extra_fields.each do |field, value| -%>
<%= field %>: <%= value %>
<% end -%>

Added templates/deb/copyright.erb.

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: <%= name %>
Upstream-Contact: <%= maintainer %>
Source: <%= url %>

Files: *
Copyright: <%= license %>
License: permissive