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

⌈⌋ ⎇ branch:  cross package maker


Check-in [3ac992dcbc]

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

Overview
Comment:- Use my new 'insist' library for assertions
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3ac992dcbca8fd228ca07f65bc1abce982623d4e
User & Date: jls@semicomplete.com 2012-03-08 07:34:29
Context
2012-03-08
08:02
move class methods to bottom check-in: eb6bfd58d7 user: jls@semicomplete.com tags: trunk
07:34
- Use my new 'insist' library for assertions check-in: 3ac992dcbc user: jls@semicomplete.com tags: trunk
03:44
Add license and general info for dependencies check-in: 6670a84bde user: jls@semicomplete.com tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added spec/fpm/package/dir_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
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
require "spec_setup"
require "fpm" # local
require "fpm/package/dir" # local

describe FPM::Package::Dir do
  before :each 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 :each do
    @source.cleanup
    FileUtils.rm_r(@tmpdir.full_path)
    FileUtils.rm_r(@output.full_path)
  end # after

  it "single file: should copy single files to the root of the output" do
    file = @tmpdir["hello"]
    file.write "Hello world"
    @source.input(@tmpdir.full_path)
    @source.output(@output.full_path)

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

  it "should copy the full path given (single file)" 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)

    path = File.join(".", file.full_path)
    insist { @output[path].contents } == file.contents
    #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

  it "should copy entire directories given as input" 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|
      path = File.join(".", file.full_path)
      insist { @output[path].contents } == file.contents
                   #file.contents, "The file #{file.full_path} should appear in the output")
    end
  end

  it "should obey the :prefix attribute" 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)
    path = File.join(prefix, expected_path)
    insist { @output[path].contents } == file.contents
                 #file.contents, "The file #{@tmpdir["hello"].full_path} should appear in the output")
  end

  it "should obey :chdir and :prefix attributes together" 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)
    insist { @output[expected_path].contents } == file.contents
                 #file.contents, "The file #{@tmpdir["hello"].full_path} should appear in the output")
  end
end # describe FPM::Package::Dir

Added spec/fpm/package_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
require "spec_setup"
require "fpm" # local

describe FPM::Package do
  before :each do
    subject { FPM::Package.new }
  end # before

  after :each do
    subject.cleanup
  end # after

  describe "#name" do
    it "should have no default name" do
      insist { subject.name }.nil?
    end

    it "should allow setting the package name" do
      name = "my-package"
      subject.name = name
      insist { subject.name } == name
    end
  end
end # describe FPM::Package

Added spec/spec_setup.rb.































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
require "rubygems" # for ruby 1.8
require "insist" # gem 'insist'
require "rush" # gem 'rush'
require "tmpdir" # stdlib
require "fileutils" # stdlib

# put 'lib' in RUBYLIB
$: << File.join(File.dirname(File.dirname(__FILE__)), "lib")

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