debsacker 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +4 -0
- data/.travis.yml +9 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +37 -0
- data/LICENSE.txt +22 -0
- data/README.md +48 -0
- data/Rakefile +7 -0
- data/bin/debsacker +10 -0
- data/bin/setup +7 -0
- data/debsacker.gemspec +23 -0
- data/lib/debsacker/checkout.rb +12 -0
- data/lib/debsacker/options/version_factory.rb +14 -0
- data/lib/debsacker/options.rb +51 -0
- data/lib/debsacker/package/changelog.rb +28 -0
- data/lib/debsacker/package/control.rb +32 -0
- data/lib/debsacker/package/version.rb +64 -0
- data/lib/debsacker/package.rb +8 -0
- data/lib/debsacker/requirements.rb +50 -0
- data/lib/debsacker/system_gateway.rb +17 -0
- data/lib/debsacker/version.rb +3 -0
- data/lib/debsacker.rb +61 -0
- data/spec/debsacker/exceptions_spec.rb +23 -0
- data/spec/debsacker/package/changelog_spec.rb +15 -0
- data/spec/debsacker/package/control_spec.rb +15 -0
- data/spec/debsacker/package/version_spec.rb +72 -0
- data/spec/debsacker/packaging_spec.rb +43 -0
- data/spec/fixtures/control +12 -0
- data/spec/spec_helper.rb +14 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c44b702c36744eae7771317edc2f942e5b1dcb7b
|
4
|
+
data.tar.gz: 2cbf54f23b72990c05ee9a5d76986a890d1203f9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 038a8b82126a279445b5e32bf313e1ff4372d9e5ace6e596bf0a79455585d0365c9742e3df188c1a231df100f0fc6aa6a0f8d0494c8c248855d79180273cb19f
|
7
|
+
data.tar.gz: 5eddd59c120f948b9e2765980d33014957a9e896e3afff21b543835bab62bb348826e9c9106f80f4d899093492eca49d2e8cd34f5db3626dc3bf427d158aa911
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
debsacker (0.1.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.2.5)
|
10
|
+
rake (10.4.2)
|
11
|
+
rspec (3.2.0)
|
12
|
+
rspec-core (~> 3.2.0)
|
13
|
+
rspec-expectations (~> 3.2.0)
|
14
|
+
rspec-mocks (~> 3.2.0)
|
15
|
+
rspec-core (3.2.3)
|
16
|
+
rspec-support (~> 3.2.0)
|
17
|
+
rspec-expectations (3.2.1)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.2.0)
|
20
|
+
rspec-its (1.2.0)
|
21
|
+
rspec-core (>= 3.0.0)
|
22
|
+
rspec-expectations (>= 3.0.0)
|
23
|
+
rspec-mocks (3.2.1)
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
+
rspec-support (~> 3.2.0)
|
26
|
+
rspec-support (3.2.2)
|
27
|
+
|
28
|
+
PLATFORMS
|
29
|
+
ruby
|
30
|
+
|
31
|
+
DEPENDENCIES
|
32
|
+
bundler (~> 1.6)
|
33
|
+
debsacker!
|
34
|
+
rake
|
35
|
+
rspec
|
36
|
+
rspec-expectations
|
37
|
+
rspec-its
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Ivan Kasatenko
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Debsacker
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/debsacker.svg)](http://badge.fury.io/rb/debsacker)
|
4
|
+
[![Build status](https://travis-ci.org/konstantinous/debsacker.svg)](https://travis-ci.org/konstantinous/debsacker)
|
5
|
+
|
6
|
+
Build your application into debian package.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'debsacker'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install debsacker
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
``` sh
|
25
|
+
# create package with tag name as version and add distributive name to version
|
26
|
+
$ debsacker
|
27
|
+
|
28
|
+
# create package with custom version and without distributive name
|
29
|
+
$ debsacker -p 0.1.0 --no-distro
|
30
|
+
|
31
|
+
# create package with commit ref as version and add branch to version
|
32
|
+
$ debsacker -p commit -b
|
33
|
+
|
34
|
+
# create package with datetime as version
|
35
|
+
$ debsacker -p datetime
|
36
|
+
```
|
37
|
+
|
38
|
+
## Configure
|
39
|
+
|
40
|
+
In root path of your application should exists `debian` directory. You can read about required files here https://www.debian.org/doc/manuals/maint-guide/dreq.en.html
|
41
|
+
|
42
|
+
## Contributing
|
43
|
+
|
44
|
+
1. Fork it ( https://github.com/konstantinous/debsacker/fork )
|
45
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
46
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
47
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
48
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/debsacker
ADDED
data/bin/setup
ADDED
data/debsacker.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'debsacker/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'debsacker'
|
8
|
+
spec.version = Debsacker::VERSION
|
9
|
+
spec.authors = ['Konstantin Khokhlov', 'Aleksandr Fomin']
|
10
|
+
spec.email = %w(lazychyvak@gmail.com ll.wg.bin@gmail.com)
|
11
|
+
spec.summary = 'Debian packaging for applications'
|
12
|
+
spec.homepage = 'https://github.com/konstantinous/debsacker'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = 'debsacker'
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
21
|
+
spec.add_development_dependency 'rake'
|
22
|
+
spec.add_development_dependency 'rspec'
|
23
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'debsacker/package/version'
|
2
|
+
|
3
|
+
module Debsacker
|
4
|
+
module Options
|
5
|
+
class VersionFactory
|
6
|
+
def self.build(options)
|
7
|
+
Debsacker::Package::Version.new(options[:version]).tap do |version|
|
8
|
+
version.add_distro = options[:distro].nil? ? true : !!options[:distro]
|
9
|
+
version.add_branch = !!options[:branch]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'debsacker'
|
2
|
+
require 'debsacker/options/version_factory'
|
3
|
+
|
4
|
+
module Debsacker
|
5
|
+
module Options
|
6
|
+
class Config
|
7
|
+
|
8
|
+
def self.build
|
9
|
+
dependencies = {}
|
10
|
+
options = parse
|
11
|
+
dependencies[:version] = Debsacker::Options::VersionFactory.build(options)
|
12
|
+
dependencies[:control] = Debsacker::Package::Control.new('debian/control')
|
13
|
+
|
14
|
+
dependencies
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def self.parse
|
20
|
+
options = {}
|
21
|
+
OptionParser.new do |opts|
|
22
|
+
opts.banner = 'Usage: debsacker [options]'
|
23
|
+
|
24
|
+
opts.on('-pPACKAGE', '--package=PACKAGE', String, 'Define package version by tag, commit, datetime or explicit version name') do |v|
|
25
|
+
options[:version] = v
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on('-d', '--[no-]distro', 'Add distro name to version name (default true)') do |add|
|
29
|
+
options[:distro] = add
|
30
|
+
end
|
31
|
+
|
32
|
+
opts.on('-b', '--[no-]branch', 'Add branch name to version name (default false)') do |add|
|
33
|
+
options[:branch] = add
|
34
|
+
end
|
35
|
+
|
36
|
+
opts.on_tail('-h', '--help', 'Show this message') do
|
37
|
+
puts opts
|
38
|
+
exit
|
39
|
+
end
|
40
|
+
|
41
|
+
opts.on_tail('-v', '--version', 'Show version') do
|
42
|
+
puts Debsacker::VERSION
|
43
|
+
exit
|
44
|
+
end
|
45
|
+
end.parse!
|
46
|
+
|
47
|
+
options
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'debsacker/system_gateway'
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
module Debsacker
|
5
|
+
module Package
|
6
|
+
class Changelog
|
7
|
+
attr_writer :project_name, :author
|
8
|
+
|
9
|
+
def project_name
|
10
|
+
@project_name || File.basename(Dir.pwd)
|
11
|
+
end
|
12
|
+
|
13
|
+
def author
|
14
|
+
@author || 'Made by debsacker <info@example.com>'
|
15
|
+
end
|
16
|
+
|
17
|
+
def lines(version)
|
18
|
+
comment = Debsacker::SystemGateway.perform('git --no-pager log -1 --oneline')
|
19
|
+
date = DateTime.now.strftime('%a, %e %b %Y %T %z')
|
20
|
+
[
|
21
|
+
"#{ project_name } (#{ version }) stable; urgency=medium",
|
22
|
+
" * #{ comment }",
|
23
|
+
" -- Made by #{ author } #{ date }"
|
24
|
+
]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Debsacker
|
2
|
+
module Package
|
3
|
+
class Control
|
4
|
+
|
5
|
+
def initialize(file)
|
6
|
+
@control_content = {}
|
7
|
+
|
8
|
+
file_content(file).collect do |line|
|
9
|
+
content = line.split(': ')
|
10
|
+
|
11
|
+
@control_content[content.first.strip] = content.last.strip
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def [](attribute)
|
16
|
+
value = @control_content[attribute]
|
17
|
+
|
18
|
+
if attribute == 'Build-Depends'
|
19
|
+
value.sub('Build-Depends:', '').gsub(/\(.*\)/, '').split(',').collect(&:strip)
|
20
|
+
else
|
21
|
+
value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
|
27
|
+
def file_content(file)
|
28
|
+
File.readlines(file).collect(&:strip).reject(&:empty?)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'debsacker/system_gateway'
|
2
|
+
|
3
|
+
module Debsacker
|
4
|
+
module Package
|
5
|
+
class Version
|
6
|
+
attr_accessor :add_distro, :add_branch
|
7
|
+
|
8
|
+
def initialize(version_type)
|
9
|
+
@version_type = version_type
|
10
|
+
end
|
11
|
+
|
12
|
+
def generate
|
13
|
+
begin
|
14
|
+
case @version_type
|
15
|
+
when 'tag', nil
|
16
|
+
version = tag
|
17
|
+
when 'commit'
|
18
|
+
version = commit
|
19
|
+
when 'datetime'
|
20
|
+
version = datetime
|
21
|
+
else
|
22
|
+
version = @version_type
|
23
|
+
end
|
24
|
+
rescue
|
25
|
+
version = '0.1.0'
|
26
|
+
end
|
27
|
+
|
28
|
+
version << "-#{ branch_name }" if add_branch
|
29
|
+
version << "-#{ distro_name }" if add_distro
|
30
|
+
|
31
|
+
version
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
def distro_name
|
37
|
+
@_distro_name ||= SystemGateway.perform('lsb_release -s -c').strip || 'unknown'
|
38
|
+
end
|
39
|
+
|
40
|
+
def branch_name
|
41
|
+
@_branch_name ||= SystemGateway.perform('git rev-parse --abbrev-ref HEAD').strip.sub(/([\/\\])/,'-') || 'unknown'
|
42
|
+
end
|
43
|
+
|
44
|
+
def tag
|
45
|
+
last_ref = SystemGateway.perform('git symbolic-ref -q --short HEAD || git describe --tags --exact-match').strip
|
46
|
+
tags = SystemGateway.perform('git tag').split($/)
|
47
|
+
|
48
|
+
if tags.include? last_ref
|
49
|
+
last_ref
|
50
|
+
else
|
51
|
+
tags.last
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def commit
|
56
|
+
SystemGateway.perform('git log -n 1 --pretty=format:"%H"').strip
|
57
|
+
end
|
58
|
+
|
59
|
+
def datetime
|
60
|
+
Time.now.strftime('%Y%m%d%H%M%S')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'debsacker/system_gateway'
|
3
|
+
|
4
|
+
module Debsacker
|
5
|
+
class Requirements
|
6
|
+
|
7
|
+
CONFIG_FILES = %w(changelog compat control)
|
8
|
+
|
9
|
+
class << self
|
10
|
+
|
11
|
+
def valid?(dependencies)
|
12
|
+
config_files && packages(dependencies)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def config_files
|
18
|
+
CONFIG_FILES.each do |config_file|
|
19
|
+
file = "debian/#{ config_file }"
|
20
|
+
unless File.exist?(file)
|
21
|
+
puts "There are no such file #{ file }"
|
22
|
+
return false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
true
|
27
|
+
end
|
28
|
+
|
29
|
+
def packages(depends)
|
30
|
+
depends.reject! do |package|
|
31
|
+
command = "dpkg-query -l #{ package.strip } 2>&1 |awk 'END { if($1==\"ii\") exit 0; else exit 1; }'"
|
32
|
+
Debsacker::SystemGateway.perform_with_exit_code(command)
|
33
|
+
end
|
34
|
+
|
35
|
+
if depends.any?
|
36
|
+
puts "Installing packages...."
|
37
|
+
depends.each do |package|
|
38
|
+
command = "apt-get install -y -q #{ package.strip }"
|
39
|
+
unless Debsacker::SystemGateway.perform_with_exit_code(command)
|
40
|
+
puts "Error occurred during install package: #{ package }"
|
41
|
+
return false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Debsacker
|
3
|
+
class SystemGateway
|
4
|
+
class << self
|
5
|
+
def perform(command)
|
6
|
+
puts "\033[34mPerforming: #{ command }\033[0m"
|
7
|
+
IO.popen(command).read
|
8
|
+
end
|
9
|
+
|
10
|
+
def perform_with_exit_code(command)
|
11
|
+
puts "\033[34mPerforming: #{ command }\033[0m"
|
12
|
+
system(command)
|
13
|
+
$?.success?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/debsacker.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'debsacker/version'
|
3
|
+
require 'debsacker/requirements'
|
4
|
+
require 'debsacker/system_gateway'
|
5
|
+
require 'debsacker/package'
|
6
|
+
|
7
|
+
module Debsacker
|
8
|
+
class Creator
|
9
|
+
class << self
|
10
|
+
def go(version, control)
|
11
|
+
creator = new(version, control)
|
12
|
+
creator.create
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(version, control)
|
17
|
+
@version = version.generate
|
18
|
+
@control = control
|
19
|
+
@changelog = Debsacker::Package::Changelog.new.tap do |changelog|
|
20
|
+
changelog.project_name = @control['Package']
|
21
|
+
changelog.author = @control['Maintainer']
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def create
|
26
|
+
puts "\033[32mShow me what u got!\033[0m\n\n"
|
27
|
+
begin
|
28
|
+
File.open('debian/changelog', 'w') do |file|
|
29
|
+
@changelog.lines(@version).each do |line|
|
30
|
+
file.puts(line)
|
31
|
+
file.puts($/)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
rescue
|
35
|
+
return 'Can\'t create debian/changelog file...'
|
36
|
+
end
|
37
|
+
if Debsacker::Requirements.valid?(@control['Build-Depends'])
|
38
|
+
if Debsacker::SystemGateway.perform_with_exit_code('dpkg-buildpackage -uc -us -b')
|
39
|
+
clear
|
40
|
+
begin
|
41
|
+
File.open('current_version', 'w'){ |file| file.write(@version) }
|
42
|
+
rescue
|
43
|
+
puts "\033[31mCan't write version into version file!\033[0m"
|
44
|
+
end
|
45
|
+
puts "\033[32mYey! We have new package!\033[0m"
|
46
|
+
else
|
47
|
+
puts "\033[31mError while running 'dpkg-buildpackage'!\033[0m"
|
48
|
+
exit 1
|
49
|
+
end
|
50
|
+
else
|
51
|
+
'Requirements are not satisfied :,('
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def clear
|
56
|
+
puts 'deleting temporary files....'
|
57
|
+
Debsacker::SystemGateway.perform('git clean -fd')
|
58
|
+
Debsacker::SystemGateway.perform('git reset --hard')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
describe 'Requirements errors' do
|
3
|
+
describe 'valid?' do
|
4
|
+
it 'sholud return false' do
|
5
|
+
expect(Debsacker::Requirements.valid?([])).to be(false)
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should return false if we have no installed packages' do
|
9
|
+
allow(File).to receive(:exist?).and_return(true)
|
10
|
+
allow(Debsacker::SystemGateway).to receive(:perform_with_exit_code).and_return(false)
|
11
|
+
expect(Debsacker::Requirements.valid?(['cow', 'apt'])).to be(false)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'Creator errors' do
|
17
|
+
context 'when no permissions' do
|
18
|
+
it 'can\'t read changelog file' do
|
19
|
+
allow(File).to receive(:open).with('debian/changelog','w').and_raise(Errno::EACCES)
|
20
|
+
expect(Debsacker::Creator.new(double(generate: '0.9.0'), double(:[] => 'Package')).create).to eq('Can\'t create debian/changelog file...')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
describe Debsacker::Package::Changelog do
|
2
|
+
it 'should generate changelog file' do
|
3
|
+
allow(Debsacker::SystemGateway).to receive(:perform).and_return('bug closed #123123')
|
4
|
+
allow(File).to receive(:basename).and_return('omg-cashier')
|
5
|
+
|
6
|
+
changelog = described_class.new
|
7
|
+
changelog.project_name = 'Debsacker'
|
8
|
+
changelog.author = 'debsacker <info@debsacker.com>'
|
9
|
+
|
10
|
+
lines=[ 'Debsacker (1.2.1) stable; urgency=medium',
|
11
|
+
' * bug closed #123123',
|
12
|
+
" -- Made by debsacker <info@debsacker.com> #{ DateTime.now.strftime('%a, %e %b %Y %T %z') }"]
|
13
|
+
expect(changelog.lines('1.2.1')).to eq(lines)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
describe Debsacker::Package::Control do
|
2
|
+
subject { described_class.new('spec/fixtures/control') }
|
3
|
+
|
4
|
+
its(['Source']) { is_expected.to eq 'debsacker' }
|
5
|
+
its(['Section']) { is_expected.to eq 'misc' }
|
6
|
+
its(['Priority']) { is_expected.to eq 'optional' }
|
7
|
+
its(['Maintainer']) { is_expected.to eq 'debsacker <info@example.com>' }
|
8
|
+
its(['Build-Depends']) { is_expected.to eq ['apt', 'cow'] }
|
9
|
+
its(['Standards-Version']) { is_expected.to eq '3.8.4' }
|
10
|
+
its(['Package']) { is_expected.to eq 'debsacker' }
|
11
|
+
its(['Homepage']) { is_expected.to eq 'https://github.com/konstantinous/debsacker' }
|
12
|
+
its(['Architecture']) { is_expected.to eq 'amd64' }
|
13
|
+
its(['Depends']) { is_expected.to eq 'ruby' }
|
14
|
+
its(['Description']) { is_expected.to eq 'Build application as a debian/ubuntu package' }
|
15
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
describe Debsacker::Package::Version do
|
2
|
+
it 'should return version with tag name' do
|
3
|
+
expect(Debsacker::SystemGateway).to receive(:perform).exactly(2).times.and_return('0.10.0')
|
4
|
+
version = described_class.new('tag')
|
5
|
+
|
6
|
+
expect(version.generate).to eq '0.10.0'
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should return version with tag name by default' do
|
10
|
+
expect(Debsacker::SystemGateway).to receive(:perform).exactly(2).times.and_return('0.10.0')
|
11
|
+
version = described_class.new(nil)
|
12
|
+
|
13
|
+
expect(version.generate).to eq '0.10.0'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should return version last tag if current git ref is not tag' do
|
17
|
+
expect(Debsacker::SystemGateway).to receive(:perform).and_return('master')
|
18
|
+
expect(Debsacker::SystemGateway).to receive(:perform).and_return("0.8.0#{ $/ }0.9.0#{ $/ }")
|
19
|
+
version = described_class.new('tag')
|
20
|
+
|
21
|
+
expect(version.generate).to eq '0.9.0'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should return version with commit name' do
|
25
|
+
expect(Debsacker::SystemGateway).to receive(:perform).and_return('f232fdf23f2')
|
26
|
+
version = described_class.new('commit')
|
27
|
+
|
28
|
+
expect(version.generate).to eq 'f232fdf23f2'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should return version with datetime' do
|
32
|
+
time = Time.now.strftime('%Y%m%d%H%M%S')
|
33
|
+
version = described_class.new('datetime')
|
34
|
+
|
35
|
+
expect(version.generate).to eq time
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should return explicit version' do
|
39
|
+
version = described_class.new('1.0.0-rc2')
|
40
|
+
|
41
|
+
expect(version.generate).to eq '1.0.0-rc2'
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should add branch name' do
|
45
|
+
expect(Debsacker::SystemGateway).to receive(:perform).and_return('master')
|
46
|
+
|
47
|
+
version = described_class.new('1.0.0-rc2')
|
48
|
+
version.add_branch = true
|
49
|
+
|
50
|
+
expect(version.generate).to eq '1.0.0-rc2-master'
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should add distro name' do
|
54
|
+
expect(Debsacker::SystemGateway).to receive(:perform).and_return('debian')
|
55
|
+
|
56
|
+
version = described_class.new('1.0.0-rc2')
|
57
|
+
version.add_branch = true
|
58
|
+
|
59
|
+
expect(version.generate).to eq '1.0.0-rc2-debian'
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should add distro name and branch name' do
|
63
|
+
expect(Debsacker::SystemGateway).to receive(:perform).and_return('master')
|
64
|
+
expect(Debsacker::SystemGateway).to receive(:perform).and_return('debian')
|
65
|
+
|
66
|
+
version = described_class.new('1.0.0-rc2')
|
67
|
+
version.add_branch = true
|
68
|
+
version.add_distro = true
|
69
|
+
|
70
|
+
expect(version.generate).to eq '1.0.0-rc2-master-debian'
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
describe 'Packaging' do
|
3
|
+
|
4
|
+
it 'should install neccesarry packages' do
|
5
|
+
allow(File).to receive(:exist?).and_return(true)
|
6
|
+
allow(File).to receive(:open).and_return(true)
|
7
|
+
[
|
8
|
+
"dpkg-query -l apt 2>&1 |awk 'END { if($1==\"ii\") exit 0; else exit 1; }'",
|
9
|
+
"dpkg-query -l cow 2>&1 |awk 'END { if($1==\"ii\") exit 0; else exit 1; }'"
|
10
|
+
].each do |command|
|
11
|
+
allow(Debsacker::SystemGateway).to receive(:perform_with_exit_code).with(command).and_return(false)
|
12
|
+
end
|
13
|
+
[
|
14
|
+
"apt-get install -y -q apt",
|
15
|
+
"apt-get install -y -q cow"
|
16
|
+
].each do |command|
|
17
|
+
expect(Debsacker::SystemGateway).to receive(:perform_with_exit_code).with(command).and_return(true)
|
18
|
+
end
|
19
|
+
|
20
|
+
expect(Debsacker::SystemGateway).to receive(:perform_with_exit_code).with('dpkg-buildpackage -uc -us -b').and_return(true)
|
21
|
+
|
22
|
+
Debsacker::Creator.go(double(generate: '0.1.0'), Debsacker::Package::Control.new('spec/fixtures/control'))
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should build package' do
|
26
|
+
allow(File).to receive(:exist?).and_return(true)
|
27
|
+
allow(File).to receive(:open).and_return(true)
|
28
|
+
allow(Debsacker::SystemGateway).to receive(:perform).and_return(true)
|
29
|
+
allow(Debsacker::SystemGateway).to receive(:perform_with_exit_code).and_return(true)
|
30
|
+
|
31
|
+
[
|
32
|
+
"dpkg-query -l apt 2>&1 |awk 'END { if($1==\"ii\") exit 0; else exit 1; }'",
|
33
|
+
"dpkg-query -l cow 2>&1 |awk 'END { if($1==\"ii\") exit 0; else exit 1; }'"
|
34
|
+
].each do |command|
|
35
|
+
expect(Debsacker::SystemGateway).to receive(:perform_with_exit_code).with(command)
|
36
|
+
end
|
37
|
+
%w(changelog compat control).each do |file|
|
38
|
+
expect(File).to receive(:exist?).with("debian/#{file}")
|
39
|
+
end
|
40
|
+
|
41
|
+
Debsacker::Creator.go(double(generate: '0.1.0'), Debsacker::Package::Control.new('spec/fixtures/control'))
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Source: debsacker
|
2
|
+
Section: misc
|
3
|
+
Priority: optional
|
4
|
+
Maintainer: debsacker <info@example.com>
|
5
|
+
Build-Depends: apt (>= 7.0.50~), cow
|
6
|
+
Standards-Version: 3.8.4
|
7
|
+
|
8
|
+
Package: debsacker
|
9
|
+
Homepage: https://github.com/konstantinous/debsacker
|
10
|
+
Architecture: amd64
|
11
|
+
Depends: ruby
|
12
|
+
Description: Build application as a debian/ubuntu package
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: debsacker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Konstantin Khokhlov
|
8
|
+
- Aleksandr Fomin
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-05-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.6'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.6'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
description:
|
57
|
+
email:
|
58
|
+
- lazychyvak@gmail.com
|
59
|
+
- ll.wg.bin@gmail.com
|
60
|
+
executables:
|
61
|
+
- debsacker
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- ".gitignore"
|
66
|
+
- ".rspec"
|
67
|
+
- ".travis.yml"
|
68
|
+
- CODE_OF_CONDUCT.md
|
69
|
+
- Gemfile
|
70
|
+
- Gemfile.lock
|
71
|
+
- LICENSE.txt
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- bin/debsacker
|
75
|
+
- bin/setup
|
76
|
+
- debsacker.gemspec
|
77
|
+
- lib/debsacker.rb
|
78
|
+
- lib/debsacker/checkout.rb
|
79
|
+
- lib/debsacker/options.rb
|
80
|
+
- lib/debsacker/options/version_factory.rb
|
81
|
+
- lib/debsacker/package.rb
|
82
|
+
- lib/debsacker/package/changelog.rb
|
83
|
+
- lib/debsacker/package/control.rb
|
84
|
+
- lib/debsacker/package/version.rb
|
85
|
+
- lib/debsacker/requirements.rb
|
86
|
+
- lib/debsacker/system_gateway.rb
|
87
|
+
- lib/debsacker/version.rb
|
88
|
+
- spec/debsacker/exceptions_spec.rb
|
89
|
+
- spec/debsacker/package/changelog_spec.rb
|
90
|
+
- spec/debsacker/package/control_spec.rb
|
91
|
+
- spec/debsacker/package/version_spec.rb
|
92
|
+
- spec/debsacker/packaging_spec.rb
|
93
|
+
- spec/fixtures/control
|
94
|
+
- spec/spec_helper.rb
|
95
|
+
homepage: https://github.com/konstantinous/debsacker
|
96
|
+
licenses:
|
97
|
+
- MIT
|
98
|
+
metadata: {}
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
requirements: []
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 2.4.6
|
116
|
+
signing_key:
|
117
|
+
specification_version: 4
|
118
|
+
summary: Debian packaging for applications
|
119
|
+
test_files:
|
120
|
+
- spec/debsacker/exceptions_spec.rb
|
121
|
+
- spec/debsacker/package/changelog_spec.rb
|
122
|
+
- spec/debsacker/package/control_spec.rb
|
123
|
+
- spec/debsacker/package/version_spec.rb
|
124
|
+
- spec/debsacker/packaging_spec.rb
|
125
|
+
- spec/fixtures/control
|
126
|
+
- spec/spec_helper.rb
|