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

⌈⌋ ⎇ branch:  cross package maker


Check-in [041a36ff2c]

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

Overview
Comment:- try using rspec+insist
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 041a36ff2c040bf01a2c9ed50846d5a08e1a2f78
User & Date: jls@semicomplete.com 2012-03-08 08:03:04
Context
2012-03-08
15:49
- more work aligning the deb package class with the new API check-in: 0c28fb4f70 user: jls@semicomplete.com tags: trunk
08:03
- try using rspec+insist check-in: 041a36ff2c user: jls@semicomplete.com tags: trunk
08:02
move class methods to bottom check-in: eb6bfd58d7 user: jls@semicomplete.com tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Gemfile.

1
2
3
4
5
6
7
8
9
source :rubygems

gemspec

group :development do
  gem "guard"
  gem "guard-minitest"
  gem "guard-shell"
end



<
<
<
<
<
<
1
2
3






source :rubygems

gemspec






Changes to Gemfile.lock.

1
2
3
4

5
6
7
8
9
10
11


12
13
14

15
16
17
18
19
20
21
22
23
24








25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
PATH
  remote: .
  specs:
    fpm (0.4.0)

      backports (= 2.3.0)
      cabin (~> 0.4.2)
      json

GEM
  remote: http://rubygems.org/
  specs:


    backports (2.3.0)
    cabin (0.4.2)
      json

    fattr (2.2.1)
    ffi (1.0.11)
    guard (1.0.0)
      ffi (>= 0.5.0)
      thor (~> 0.14.6)
    guard-minitest (0.3.0)
      guard (>= 0.2.2)
    guard-shell (0.3.0)
      guard (>= 0.2.0)
    json (1.6.5)








    rush (0.6.7)
      session
    session (3.1.0)
      fattr
    thor (0.14.6)

PLATFORMS
  ruby

DEPENDENCIES
  fpm!
  guard
  guard-minitest
  guard-shell
  rush




>







>
>



>

|
<
|
<
<
<
<
<

>
>
>
>
>
>
>
>




<






<
|
|

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

21





22
23
24
25
26
27
28
29
30
31
32
33
34

35
36
37
38
39
40

41
42
43
PATH
  remote: .
  specs:
    fpm (0.4.0)
      arr-pm
      backports (= 2.3.0)
      cabin (~> 0.4.2)
      json

GEM
  remote: http://rubygems.org/
  specs:
    arr-pm (0.0.2)
      cabin (> 0)
    backports (2.3.0)
    cabin (0.4.2)
      json
    diff-lcs (1.1.3)
    fattr (2.2.1)
    insist (0.0.1)

      cabin (> 0)





    json (1.6.5)
    rspec (2.8.0)
      rspec-core (~> 2.8.0)
      rspec-expectations (~> 2.8.0)
      rspec-mocks (~> 2.8.0)
    rspec-core (2.8.0)
    rspec-expectations (2.8.0)
      diff-lcs (~> 1.1.2)
    rspec-mocks (2.8.0)
    rush (0.6.7)
      session
    session (3.1.0)
      fattr


PLATFORMS
  ruby

DEPENDENCIES
  fpm!

  insist
  rspec
  rush

Changes to fpm.gemspec.

31
32
33
34
35
36
37



38
39
40
41
42
43
44
45
46
47
48
  # For reading and writing rpms
  spec.add_dependency("arr-pm") # license: Apache 2

  # For simple shell/file hackery in the tests.
  # http://rush.heroku.com/rdoc/
  spec.add_development_dependency("rush") # license: MIT




  spec.files = files
  spec.require_paths << "lib"
  spec.bindir = "bin"
  spec.executables << "fpm"
  spec.executables << "fpm-npm"

  spec.author = "Jordan Sissel"
  spec.email = "jls@semicomplete.com"
  spec.homepage = "https://github.com/jordansissel/fpm"
end








>
>
>











31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  # For reading and writing rpms
  spec.add_dependency("arr-pm") # license: Apache 2

  # For simple shell/file hackery in the tests.
  # http://rush.heroku.com/rdoc/
  spec.add_development_dependency("rush") # license: MIT

  spec.add_development_dependency("rspec") # license: ???
  spec.add_development_dependency("insist") # license: ???

  spec.files = files
  spec.require_paths << "lib"
  spec.bindir = "bin"
  spec.executables << "fpm"
  spec.executables << "fpm-npm"

  spec.author = "Jordan Sissel"
  spec.email = "jls@semicomplete.com"
  spec.homepage = "https://github.com/jordansissel/fpm"
end

Added spec/fpm/package/rpm_spec.rb.













































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require "spec_setup"
require "fpm" # local
require "fpm/package/rpm" # local
require "fpm/package/dir" # local
require "rpm" # gem arr-pm

describe FPM::Package::RPM do
  subject { FPM::Package::RPM.new }

  before :each do
    @target = Tempfile.new
  end # before

  after :each do
    subject.cleanup
    @target.close
  end # after

  describe "#output" do
    context "basics" do
      before :each do

      end

      it "should output a package with the correct name" do
        subject.output(@target.path)
        rpm = RPM::File.new(@target.path)
        # TODO(sissel): verify rpm name vs subject.name

      end

      it "should output a package with the correct version"
      it "should output a package with the correct iteration"
      it "should output a package with the correct epoch"
      it "should output a package with the correct dependencies"
  end

end # describe FPM::Package::Dir

Changes to spec/fpm/package_spec.rb.

17
18
19
20
21
22
23





























24

    it "should allow setting the package name" do
      name = "my-package"
      subject.name = name
      insist { subject.name } == name
    end
  end





























end # describe FPM::Package







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

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

    it "should allow setting the package name" do
      name = "my-package"
      subject.name = name
      insist { subject.name } == name
    end
  end

  describe "#version" do
    it "should default to '1.0'" do
      insist { subject.version } == "1.0"
    end

    it "should allow setting the package name" do
      version = "hello"
      subject.version = version
      insist { subject.version } == version
    end
  end

  describe "#architecture"
  describe "#attributes"
  describe "#category"
  describe "#config_files"
  describe "#conflicts"
  describe "#dependencies"
  describe "#description"
  describe "#epoch"
  describe "#iteration"
  describe "#license"
  describe "#maintainer"
  describe "#provides"
  describe "#replaces"
  describe "#scripts"
  describe "#url"
  describe "#vendor"
end # describe FPM::Package

Deleted test/fpm/package/dir.rb.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
require "rubygems"
require File.join(File.dirname(File.expand_path(__FILE__)), "..", "..", "testing")
$: << File.join(File.dirname(File.expand_path(__FILE__)), "..", "..", "..", "lib")
require "minitest/autorun"
require "tmpdir"
require "fileutils"
require "fpm/package/dir"
require "rush" # for simple file stuff

if $DEBUG or ENV["DEBUG"]
  Cabin::Channel.get.level = :debug
  Cabin::Channel.get.subscribe(STDOUT)
end

describe FPM::Package::Dir do
  before do
    @source = FPM::Package::Dir.new
    @rush = Rush::Box.new("localhost")
    @tmpdir = @rush[::Dir.mktmpdir("package-test-tmpdir")]
    @output = @rush[::Dir.mktmpdir("package-test-output")]
  end # before

  after do
    @source.cleanup
    FileUtils.rm_r(@tmpdir.full_path)
    FileUtils.rm_r(@output.full_path)
  end # after

  test "adding a single file" do
    file = @tmpdir["hello"]
    file.write "Hello world"
    @source.input(@tmpdir.full_path)
    @source.output(@output.full_path)

    assert_equal(@output[File.join(".", file.full_path)].contents,
                 file.contents, "The file #{@tmpdir["hello"].full_path} should appear in the output")
  end

  test "single file in a directory" do
    dir = @tmpdir.create_dir("a/b/c")
    file = dir.create_file("hello")
    file.write "Hello world"
    @source.input(@tmpdir.full_path)

    @source.output(@output.full_path)
    assert_equal(@output[File.join(".", file.full_path)].contents,
                 file.contents, "The file #{@tmpdir["a/b/c/hello"].full_path} should appear in the output")
  end

  test "multiple files" do
    dir = @tmpdir.create_dir("a/b/c")
    files = rand(50).times.collect do |i|
      dir.create_file("hello-#{i}")
    end
    files.each { |f| f.write(rand(1000)) }

    @source.input(@tmpdir.full_path)
    @source.output(@output.full_path)

    files.each do |file|
      assert_equal(@output[File.join(".", file.full_path)].contents,
                   file.contents, "The file #{file.full_path} should appear in the output")
    end
  end

  test "single file with prefix" do
    prefix = @source.attributes[:prefix] = "/usr/local"
    file = @tmpdir["hello"]
    file.write "Hello world"
    @source.input(@tmpdir.full_path)
    @source.output(@output.full_path)

    expected_path = File.join(".", file.full_path)

    assert_equal(@output[File.join(prefix, expected_path)].contents,
                 file.contents, "The file #{@tmpdir["hello"].full_path} should appear in the output")
  end

  test "single file with prefix and chdir" do
    prefix = @source.attributes[:prefix] = "/usr/local"
    chdir = @source.attributes[:chdir] = @tmpdir.full_path
    file = @tmpdir["hello"]
    file.write "Hello world"
    @source.input(".") # since we chdir, copy the entire root
    @source.output(@output.full_path)

    # path relative to the @output directory.
    expected_path = File.join(".", prefix, file.name)
    assert_equal(@output[expected_path].contents,
                 file.contents, "The file #{@tmpdir["hello"].full_path} should appear in the output")
  end

end # describe FPM::Package::Dir
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<