suppository 0.0.2
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.
- checksums.yaml +15 -0
- data/.gitignore +76 -0
- data/.rubocop.yml +5 -0
- data/.ruby-version +1 -0
- data/.travis.yml +19 -0
- data/Gemfile +4 -0
- data/Guardfile +30 -0
- data/LICENSE.txt +674 -0
- data/README.md +103 -0
- data/Rakefile +34 -0
- data/bin/suppository +36 -0
- data/fixtures/curl_7.22.0-3ubuntu4.11_amd64.deb +0 -0
- data/fixtures/vim_7.3.547-7_amd64.deb +0 -0
- data/lib/suppository/add_command.rb +116 -0
- data/lib/suppository/checksummed.rb +24 -0
- data/lib/suppository/cli.rb +26 -0
- data/lib/suppository/command_runner.rb +30 -0
- data/lib/suppository/create_command.rb +75 -0
- data/lib/suppository/dpkg_deb.rb +29 -0
- data/lib/suppository/dpkg_deb_line.rb +28 -0
- data/lib/suppository/exceptions.rb +20 -0
- data/lib/suppository/gzip.rb +14 -0
- data/lib/suppository/help.rb +22 -0
- data/lib/suppository/help_command.rb +13 -0
- data/lib/suppository/logger.rb +24 -0
- data/lib/suppository/master_deb.rb +62 -0
- data/lib/suppository/package.rb +23 -0
- data/lib/suppository/release.rb +57 -0
- data/lib/suppository/repository.rb +16 -0
- data/lib/suppository/tty.rb +43 -0
- data/lib/suppository/version.rb +3 -0
- data/lib/suppository/version_command.rb +12 -0
- data/lib/suppository.rb +5 -0
- data/spec/spec_helper.rb +55 -0
- data/spec/suppository/add_command_spec.rb +141 -0
- data/spec/suppository/cli_spec.rb +50 -0
- data/spec/suppository/command_runner_spec.rb +26 -0
- data/spec/suppository/create_command_spec.rb +80 -0
- data/spec/suppository/dpkg_deb_line_spec.rb +36 -0
- data/spec/suppository/dpkg_deb_spec.rb +65 -0
- data/spec/suppository/gzip_spec.rb.rb +22 -0
- data/spec/suppository/help_command_spec.rb +13 -0
- data/spec/suppository/help_spec.rb +12 -0
- data/spec/suppository/logger_spec.rb +64 -0
- data/spec/suppository/master_deb_spec.rb +84 -0
- data/spec/suppository/package_spec.rb +63 -0
- data/spec/suppository/release_spec.rb +70 -0
- data/spec/suppository/repository_spec.rb +53 -0
- data/spec/suppository/tty_spec.rb +92 -0
- data/spec/suppository/version_command_spec.rb +13 -0
- data/spec/suppository/version_spec.rb +13 -0
- data/spec/suppository_spec.rb +83 -0
- data/suppository.gemspec +34 -0
- metadata +286 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'English'
|
2
|
+
|
3
|
+
require 'suppository/exceptions'
|
4
|
+
require 'suppository/command_runner'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
module Suppository
|
8
|
+
class Release
|
9
|
+
def initialize(repo_path, dist, unsigned = false)
|
10
|
+
@dist = dist
|
11
|
+
@unsigned = unsigned
|
12
|
+
@dist_path = "#{repo_path}/dists/#{dist}"
|
13
|
+
@release_file = "#{@dist_path}/Release"
|
14
|
+
end
|
15
|
+
|
16
|
+
def create
|
17
|
+
open(@release_file, 'w') { |f| f.puts content }
|
18
|
+
sign unless @unsigned
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def sign
|
24
|
+
gpg_file = "#{@release_file}.gpg"
|
25
|
+
FileUtils.rm_rf(gpg_file)
|
26
|
+
CommandRunner.new('gpg', "-abs -o #{gpg_file} #{@release_file}").run
|
27
|
+
end
|
28
|
+
|
29
|
+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
30
|
+
def content
|
31
|
+
result = "Codename: #{@dist}\n"
|
32
|
+
component_dirs = Dir.glob("#{@dist_path}/*").select { |f| File.directory? f }
|
33
|
+
components = component_dirs.collect { |d| File.basename(d) }.join(' ')
|
34
|
+
arch_dirs = Dir.glob("#{@dist_path}/*/*").select { |f| File.directory? f }
|
35
|
+
architectures = arch_dirs.collect { |d| File.basename(d).split('-')[1] }
|
36
|
+
.uniq.join(' ')
|
37
|
+
result << "Architectures: #{architectures}\n"
|
38
|
+
result << "Components: #{components}\n"
|
39
|
+
result << "Date: #{Time.new.strftime('%a, %d %b %Y %H:%M:%S %Z')}\n"
|
40
|
+
packages = Dir.glob("#{@dist_path}/*/*/Packages*")
|
41
|
+
result << "MD5Sum:\n"
|
42
|
+
packages.each { |f| result << puts_hash(f, Digest::MD5.file(f)) }
|
43
|
+
result << "SHA1:\n"
|
44
|
+
packages.each { |f| result << puts_hash(f, Digest::SHA1.file(f)) }
|
45
|
+
result << "SHA256:\n"
|
46
|
+
packages.each { |f| result << puts_hash(f, Digest::SHA256.file(f)) }
|
47
|
+
result << "SHA512:\n"
|
48
|
+
packages.each { |f| result << puts_hash(f, Digest::SHA512.file(f)) }
|
49
|
+
result
|
50
|
+
end
|
51
|
+
|
52
|
+
def puts_hash(f, hash)
|
53
|
+
relative = f.split(@dist_path).pop[1..-1]
|
54
|
+
sprintf(" %s %17d %s\n", hash, File.size(f), relative)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Suppository
|
2
|
+
class Repository
|
3
|
+
attr_reader :path, :dists, :archs, :suppository
|
4
|
+
|
5
|
+
def initialize(path)
|
6
|
+
@path = File.expand_path(path)
|
7
|
+
@dists = %w(natty lucid precise saucy trusty)
|
8
|
+
@archs = %w(amd64 i386)
|
9
|
+
@suppository = "#{@path}/.suppository"
|
10
|
+
end
|
11
|
+
|
12
|
+
def exist?
|
13
|
+
File.exist? @suppository
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Suppository
|
2
|
+
class Tty
|
3
|
+
class << self
|
4
|
+
def gray
|
5
|
+
bold 30
|
6
|
+
end
|
7
|
+
|
8
|
+
def white
|
9
|
+
bold 39
|
10
|
+
end
|
11
|
+
|
12
|
+
def red
|
13
|
+
underline 31
|
14
|
+
end
|
15
|
+
|
16
|
+
def reset
|
17
|
+
escape 0
|
18
|
+
end
|
19
|
+
|
20
|
+
def green
|
21
|
+
bold 32
|
22
|
+
end
|
23
|
+
|
24
|
+
def em
|
25
|
+
underline 39
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def bold(n)
|
31
|
+
escape "1;#{n}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def underline(n)
|
35
|
+
escape "4;#{n}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def escape(n)
|
39
|
+
"\033[#{n}m" if $stdout.tty?
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/suppository.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'fakefs/spec_helpers'
|
3
|
+
require 'rspec/mocks/standalone'
|
4
|
+
require 'stringio'
|
5
|
+
require 'simplecov'
|
6
|
+
require "codeclimate-test-reporter"
|
7
|
+
CodeClimate::TestReporter.start
|
8
|
+
|
9
|
+
SimpleCov.start do
|
10
|
+
SimpleCov.minimum_coverage 100
|
11
|
+
SimpleCov.add_filter "/spec/"
|
12
|
+
end
|
13
|
+
|
14
|
+
lib = File.expand_path('../lib', __FILE__)
|
15
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
16
|
+
|
17
|
+
RSpec.configure do |config|
|
18
|
+
|
19
|
+
config.before do
|
20
|
+
$stdout = StringIO.new
|
21
|
+
end
|
22
|
+
|
23
|
+
config.after(:all) do
|
24
|
+
$stdout = STDOUT
|
25
|
+
end
|
26
|
+
|
27
|
+
config.filter_run :focus => true
|
28
|
+
config.run_all_when_everything_filtered = true
|
29
|
+
config.color = true
|
30
|
+
config.mock_with :rspec
|
31
|
+
config.order = 'random'
|
32
|
+
config.raise_errors_for_deprecations!
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def get_exception
|
37
|
+
e_message = ""
|
38
|
+
begin
|
39
|
+
yield
|
40
|
+
rescue => e
|
41
|
+
e_message = e.message
|
42
|
+
end
|
43
|
+
e_message
|
44
|
+
end
|
45
|
+
|
46
|
+
def deb_file
|
47
|
+
File.expand_path(File.dirname(__FILE__)+"../../fixtures/curl_7.22.0-3ubuntu4.11_amd64.deb")
|
48
|
+
end
|
49
|
+
|
50
|
+
def deb_file_glob
|
51
|
+
File.expand_path(File.dirname(__FILE__)+"../../fixtures/*.deb")
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
|
@@ -0,0 +1,141 @@
|
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'suppository/add_command'
|
4
|
+
require 'suppository/repository'
|
5
|
+
require 'suppository/release'
|
6
|
+
require 'suppository/create_command'
|
7
|
+
require 'suppository/exceptions'
|
8
|
+
|
9
|
+
describe Suppository::AddCommand do
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
repository_path = "/tmp/supposotory_test_#{Time.now.to_f}"
|
13
|
+
@file_name = 'e5ca0a9797acda4bfe8404524f0976b3_b37ce9b17405d93c323c0b8bbe167c6f2dccfe02_5a315c56bc34f1ffed365f9aa50bbb36916e5a8fae8614f00d952983d4316555.deb'
|
14
|
+
@second_file = '2f860ed12d2ad99bacc78d95fb9e7989_323ee30c17a0ca4bbb2b95032fc79f84f4ca26f2_66bce137768403d517468a1f70bd98644558cd000f250dd8cc2faeedda5d4b2f.deb'
|
15
|
+
@repository = Suppository::Repository.new(repository_path)
|
16
|
+
Suppository::CreateCommand.new([@repository.path]).run
|
17
|
+
@dist = 'trusty'
|
18
|
+
@component = 'internal'
|
19
|
+
@adder = Suppository::AddCommand.new([@repository.path, @dist, @component, deb_file])
|
20
|
+
end
|
21
|
+
|
22
|
+
after(:each) do
|
23
|
+
FileUtils.rm_r @repository.path
|
24
|
+
end
|
25
|
+
|
26
|
+
it "add the same package again" do
|
27
|
+
release = double(Suppository::Release)
|
28
|
+
expect(release).to receive(:create).twice
|
29
|
+
expect(Suppository::Release).to receive(:new).twice.with(@repository.path, @dist, false) { release }
|
30
|
+
@adder.run
|
31
|
+
@adder.run
|
32
|
+
expect(File.file?("#{@repository.suppository}/#{@file_name}")).to be_truthy
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "expects release to work -" do
|
36
|
+
before(:each) do
|
37
|
+
release = double(Suppository::Release)
|
38
|
+
expect(release).to receive(:create)
|
39
|
+
expect(Suppository::Release).to receive(:new).with(@repository.path, @dist, false) { release }
|
40
|
+
end
|
41
|
+
|
42
|
+
it "add suppository file" do
|
43
|
+
@adder.run
|
44
|
+
expect(File.file?("#{@repository.suppository}/#{@file_name}")).to be_truthy
|
45
|
+
end
|
46
|
+
|
47
|
+
it "supports globs for deb file" do
|
48
|
+
@adder = Suppository::AddCommand.new([@repository.path, @dist, @component, deb_file_glob])
|
49
|
+
@adder.run
|
50
|
+
expect(File.file?("#{@repository.suppository}/#{@file_name}")).to be_truthy
|
51
|
+
expect(File.file?("#{@repository.suppository}/#{@second_file}")).to be_truthy
|
52
|
+
end
|
53
|
+
|
54
|
+
it "adds package to dists" do
|
55
|
+
@adder.run
|
56
|
+
@repository.dists.each do |dist|
|
57
|
+
@repository.archs.each do |arch|
|
58
|
+
if dist == @dist
|
59
|
+
expect(File.file?("#{@repository.path}/dists/#{dist}/#{@component}/binary-#{arch}/curl_7.22.0-3ubuntu4.11_amd64.deb")).to be_truthy
|
60
|
+
else
|
61
|
+
expect(File.file?("#{@repository.path}/dists/#{dist}/#{@component}/binary-#{arch}/curl_7.22.0-3ubuntu4.11_amd64.deb")).to be_falsy
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
it "updates Packages file" do
|
69
|
+
supository_file = "#{@repository.suppository}/#{@file_name}"
|
70
|
+
@adder.run
|
71
|
+
@repository.archs.each do |arch|
|
72
|
+
internal_path = "dists/#{@dist}/#{@component}/binary-#{arch}"
|
73
|
+
path = "#{@repository.path}/#{internal_path}"
|
74
|
+
packages_path = "#{path}/Packages"
|
75
|
+
deb = Suppository::MasterDeb.new(supository_file)
|
76
|
+
content = Suppository::Package.new(internal_path, deb).content
|
77
|
+
expect(File.read(packages_path)).to match content
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
it "updates Packages.gz file" do
|
82
|
+
supository_file = "#{@repository.suppository}/#{@file_name}"
|
83
|
+
@adder.run
|
84
|
+
@repository.archs.each do |arch|
|
85
|
+
internal_path = "dists/#{@dist}/#{@component}/binary-#{arch}"
|
86
|
+
path = "#{@repository.path}/#{internal_path}"
|
87
|
+
packages_path = "#{path}/Packages.gz"
|
88
|
+
deb = Suppository::MasterDeb.new(supository_file)
|
89
|
+
content = Suppository::Package.new(internal_path,deb).content
|
90
|
+
result =""
|
91
|
+
Zlib::GzipReader.open(packages_path) {|gz|
|
92
|
+
result << gz.read
|
93
|
+
}
|
94
|
+
|
95
|
+
expect(result).to match content
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
it "cant add package to new dists" do
|
101
|
+
adder = Suppository::AddCommand.new([@repository.path, 'new_dist', @component, deb_file])
|
102
|
+
expect {
|
103
|
+
adder.run
|
104
|
+
}.to raise_error(InvalidDistribution)
|
105
|
+
end
|
106
|
+
|
107
|
+
it "cant add package to new component" do
|
108
|
+
adder = Suppository::AddCommand.new([@repository.path, @dist, 'testing', deb_file])
|
109
|
+
expect {
|
110
|
+
adder.run
|
111
|
+
}.to raise_error(InvalidComponent)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "cant add package to non existant repository" do
|
115
|
+
adder = Suppository::AddCommand.new(['boom', @dist, 'testing', deb_file])
|
116
|
+
|
117
|
+
expect {
|
118
|
+
adder.run
|
119
|
+
}.to raise_error(InvalidRepositoryError)
|
120
|
+
end
|
121
|
+
|
122
|
+
it "needs non nil arguments" do
|
123
|
+
expect {
|
124
|
+
Suppository::AddCommand.new(nil)
|
125
|
+
}.to raise_error(UsageError)
|
126
|
+
end
|
127
|
+
|
128
|
+
it "needs arguments" do
|
129
|
+
expect {
|
130
|
+
Suppository::AddCommand.new([])
|
131
|
+
}.to raise_error(UsageError)
|
132
|
+
end
|
133
|
+
|
134
|
+
it "needs four arguments" do
|
135
|
+
expect {
|
136
|
+
Suppository::AddCommand.new([@repository.path, @dist, 'testing'])
|
137
|
+
}.to raise_error(UsageError)
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'suppository/version'
|
4
|
+
require 'suppository/cli'
|
5
|
+
require 'suppository/repository'
|
6
|
+
require 'suppository/create_command'
|
7
|
+
require 'suppository/add_command'
|
8
|
+
|
9
|
+
describe Suppository::CLI do
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
@path = '/tmp/repo123'
|
13
|
+
@repository = double(Suppository::Repository)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "shows current version" do
|
17
|
+
command = double(Suppository::VersionCommand)
|
18
|
+
expect(Suppository::VersionCommand).to receive(:new).with([]) {command}
|
19
|
+
expect(command).to receive(:run)
|
20
|
+
Suppository::CLI.run(['version'])
|
21
|
+
end
|
22
|
+
|
23
|
+
it "can create new repository" do
|
24
|
+
creator = double(Suppository::CreateCommand)
|
25
|
+
expect(Suppository::CreateCommand).to receive(:new).with([@path]) {creator}
|
26
|
+
expect(creator).to receive(:run)
|
27
|
+
Suppository::CLI.run(['create', @path])
|
28
|
+
end
|
29
|
+
|
30
|
+
it "can add deb repository" do
|
31
|
+
adder = double(Suppository::AddCommand)
|
32
|
+
expect(Suppository::AddCommand).to receive(:new).with([@path, 'trusty', '/tmp/example.deb']) {adder}
|
33
|
+
expect(adder).to receive(:run)
|
34
|
+
Suppository::CLI.run(['add', @path , 'trusty', '/tmp/example.deb'])
|
35
|
+
end
|
36
|
+
|
37
|
+
it "rase usage error for empty args" do
|
38
|
+
expect {
|
39
|
+
Suppository::CLI.run([])
|
40
|
+
}.to raise_error(UsageError)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "rase usage error for invalid command" do
|
44
|
+
expect {
|
45
|
+
Suppository::CLI.run(['bla'])
|
46
|
+
}.to raise_error(UsageError)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'suppository/command_runner'
|
4
|
+
require 'suppository/exceptions'
|
5
|
+
|
6
|
+
describe Suppository::CommandRunner do
|
7
|
+
|
8
|
+
it "run command" do
|
9
|
+
runner = Suppository::CommandRunner.new('echo', '1234')
|
10
|
+
expect(runner.run).to eql("1234\n")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "command not found" do
|
14
|
+
runner = Suppository::CommandRunner.new('notavalidcommand')
|
15
|
+
expect { runner.run }.to raise_error(CommandMissingError)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "command error" do
|
19
|
+
runner = Suppository::CommandRunner.new('man', '--invalidoption')
|
20
|
+
expect { runner.run }.to raise_error(CommandError)
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
|
@@ -0,0 +1,80 @@
|
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'suppository/create_command'
|
4
|
+
require 'suppository/repository'
|
5
|
+
|
6
|
+
describe Suppository::CreateCommand do
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
repository_path = "/tmp/suppository_test_#{Time.now.to_f}"
|
10
|
+
@repository = Suppository::Repository.new(repository_path)
|
11
|
+
@creator = Suppository::CreateCommand.new([@repository.path])
|
12
|
+
end
|
13
|
+
|
14
|
+
after(:each) do
|
15
|
+
FileUtils.rm_r(@repository.path) if File.directory?(@repository.path)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "can create new repository" do
|
19
|
+
expect{@creator.run}.to output("==> Created new Repository - #{@repository.path}\n").to_stdout
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
it "creates repository root folder" do
|
24
|
+
@creator.run
|
25
|
+
expect(File.directory?(@repository.path)).to be_truthy
|
26
|
+
end
|
27
|
+
|
28
|
+
it "creates a .supository file" do
|
29
|
+
@creator.run
|
30
|
+
expect(File.directory?("#{@repository.path}/.suppository")).to be_truthy
|
31
|
+
end
|
32
|
+
|
33
|
+
it "creates a Packages file" do
|
34
|
+
@creator.run
|
35
|
+
@repository.dists.each do |dist|
|
36
|
+
@repository.archs.each do |arch|
|
37
|
+
expect(File.file?("#{@repository.path}/dists/#{dist}/internal/binary-#{arch}/Packages")).to be_truthy
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it "creates a Packages.gz file" do
|
43
|
+
@creator.run
|
44
|
+
@repository.dists.each do |dist|
|
45
|
+
@repository.archs.each do |arch|
|
46
|
+
file_name = "#{@repository.path}/dists/#{dist}/internal/binary-#{arch}/Packages.gz"
|
47
|
+
expect(Zlib::GzipReader.open(file_name)).to be_truthy
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
it "aborts if file suppository already exists" do
|
54
|
+
FileUtils.mkdir_p @repository.suppository
|
55
|
+
expect(get_exception{@creator.run}).to eql "#{@repository.path} is already a repository"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "creates folder structure" do
|
59
|
+
@creator.run
|
60
|
+
@repository.dists.each do |dist|
|
61
|
+
@repository.archs.each do |arch|
|
62
|
+
expect(File.directory?("#{@repository.path}/dists/#{dist}/internal/binary-#{arch}")).to be_truthy
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it "needs non nil arguments" do
|
68
|
+
expect {
|
69
|
+
Suppository::CreateCommand.new(nil)
|
70
|
+
}.to raise_error(UsageError)
|
71
|
+
end
|
72
|
+
|
73
|
+
it "needs arguments" do
|
74
|
+
expect {
|
75
|
+
Suppository::CreateCommand.new([])
|
76
|
+
}.to raise_error(UsageError)
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'suppository/dpkg_deb_line'
|
4
|
+
|
5
|
+
describe Suppository::DpkgDebLine do
|
6
|
+
|
7
|
+
it "field" do
|
8
|
+
line = 'Depends: libc6 (>= 2.14), libcurl3 (>= 7.16.2-1), zlib1g (>= 1:1.1.4)'
|
9
|
+
values = Suppository::DpkgDebLine.new(line).attributes
|
10
|
+
expect(values['Depends']).to eql 'libc6 (>= 2.14), libcurl3 (>= 7.16.2-1), zlib1g (>= 1:1.1.4)'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "description first line" do
|
14
|
+
line = 'Description: Get a file from an HTTP, HTTPS or FTP server'
|
15
|
+
values = Suppository::DpkgDebLine.new(line).attributes
|
16
|
+
expect(values['Description']).to eql 'Get a file from an HTTP, HTTPS or FTP server'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "description other line" do
|
20
|
+
line = ' curl is a client to get files from servers using any of the supported'
|
21
|
+
values = Suppository::DpkgDebLine.new(line).attributes
|
22
|
+
expect(values['Description']).to eql ' curl is a client to get files from servers using any of the supported'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "dot" do
|
26
|
+
line = ' .'
|
27
|
+
values = Suppository::DpkgDebLine.new(line).attributes
|
28
|
+
expect(values['Description']).to eql ' .'
|
29
|
+
end
|
30
|
+
|
31
|
+
it "handles invalid" do
|
32
|
+
expect(get_exception{Suppository::DpkgDebLine.new "Boom Bang"}).to eql "can't parse line - 'Boom Bang'"
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
@@ -0,0 +1,65 @@
|
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'suppository/dpkg_deb'
|
4
|
+
|
5
|
+
describe Suppository::DpkgDeb do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@instance = Suppository::DpkgDeb.new deb_file
|
9
|
+
end
|
10
|
+
|
11
|
+
it "package" do
|
12
|
+
expect(@instance.attibutes['Package']).to eql 'curl'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "version" do
|
16
|
+
expect(@instance.attibutes['Version']).to eql '7.22.0-3ubuntu4.11'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "architecture" do
|
20
|
+
expect(@instance.attibutes['Architecture']).to eql 'amd64'
|
21
|
+
end
|
22
|
+
|
23
|
+
it "maintainer" do
|
24
|
+
expect(@instance.attibutes['Maintainer']).to eql 'Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>'
|
25
|
+
end
|
26
|
+
|
27
|
+
it "installed size" do
|
28
|
+
expect(@instance.attibutes['Installed-Size']).to eql '345'
|
29
|
+
end
|
30
|
+
|
31
|
+
it "depends" do
|
32
|
+
expect(@instance.attibutes['Depends']).to eql 'libc6 (>= 2.14), libcurl3 (>= 7.16.2-1), zlib1g (>= 1:1.1.4)'
|
33
|
+
end
|
34
|
+
|
35
|
+
it "replaces" do
|
36
|
+
expect(@instance.attibutes['Replaces']).to eql 'curl-ssl'
|
37
|
+
end
|
38
|
+
|
39
|
+
it "provides" do
|
40
|
+
expect(@instance.attibutes['Provides']).to eql 'curl-ssl'
|
41
|
+
end
|
42
|
+
|
43
|
+
it "section" do
|
44
|
+
expect(@instance.attibutes['Section']).to eql 'web'
|
45
|
+
end
|
46
|
+
|
47
|
+
it "priority" do
|
48
|
+
expect(@instance.attibutes['Priority']).to eql 'optional'
|
49
|
+
end
|
50
|
+
|
51
|
+
it "homepage" do
|
52
|
+
expect(@instance.attibutes['Homepage']).to eql 'http://curl.haxx.se'
|
53
|
+
end
|
54
|
+
|
55
|
+
it "description" do
|
56
|
+
expect(@instance.attibutes['Description']).to eql "Get a file from an HTTP, HTTPS or FTP server curl is a client to get files from servers using any of the supported\n protocols. The command is designed to work without user interaction\n or any kind of interactivity.\n .\n curl offers a busload of useful tricks like proxy support, user\n authentication, FTP upload, HTTP post, file transfer resume and more.\n"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "original_maintainer" do
|
60
|
+
expect(@instance.attibutes['Original-Maintainer']).to eql 'Ramakrishnan Muthukrishnan <rkrishnan@debian.org>'
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
end
|
65
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'suppository/gzip'
|
4
|
+
|
5
|
+
describe Suppository::Gzip do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@file = "/tmp/gzip_test_#{Time.now.to_f}.txt"
|
9
|
+
@file_gz = "#{@file}.gz"
|
10
|
+
end
|
11
|
+
|
12
|
+
after(:each) do
|
13
|
+
FileUtils.rm @file if File.exist? @file
|
14
|
+
FileUtils.rm @file_gz if File.exist? @file_gz
|
15
|
+
end
|
16
|
+
|
17
|
+
it "compress" do
|
18
|
+
Suppository::Gzip.compress @file
|
19
|
+
expect(Zlib::GzipReader.open(@file_gz)).to be_truthy
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'suppository/help'
|
4
|
+
|
5
|
+
describe Suppository do
|
6
|
+
|
7
|
+
it "has usage string" do
|
8
|
+
expect(Suppository.help).to eql("Example usage:\n\n suppository help\n - Display this Help message\n\n suppository version\n - Display version\n\n suppository create <REPOSITORY_PATH>\n - Create new empty repository in REPOSITORY_PATH\n\n suppository add <REPOSITORY_PATH> <DIST> <COMPONENT> <DEB_FILE> [--unsigned]\n - Add DEB_FILE to DIST and COMPONENT of repository at REPOSITORY_PATH\n\n")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
|