packit 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/packit +16 -0
- data/lib/packit.rb +9 -0
- data/lib/packit/cli.rb +12 -0
- data/lib/packit/config.rb +58 -0
- data/lib/packit/control.rb +54 -0
- data/lib/packit/dpkg_deb.rb +46 -0
- data/lib/packit/packager.rb +25 -0
- data/lib/packit/version.rb +3 -0
- data/man/PACKIT.1 +0 -0
- metadata +137 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 29b4a5e46ecfb1c6d3953f781932a956459f594e
|
4
|
+
data.tar.gz: 8bd0abcc0d3ca48f97bc8a15bf47a950408985b3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 28c84363ceb513c7072cbb600d41ddf27e95109ab849b808aac961be6deca8373df415b618da24450c9319794e3e7d16af8cdb40dcf2782048ae9cd31f751386
|
7
|
+
data.tar.gz: ebe0b2cf9e5e044336c16c27d132d159330faafb52c29dc84525aa12e2ec6a5de1e9fbdbcac8823c04b94f4ad177025203d6ea6c9c7a77cfd5c451ef1de232e5
|
data/bin/packit
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
|
3
|
+
require 'packit/cli'
|
4
|
+
require 'benchmark'
|
5
|
+
|
6
|
+
begin
|
7
|
+
ENV['THOR_DEBUG'] = '1'
|
8
|
+
etime = Benchmark.realtime { Packit::CLI.start(ARGV) }
|
9
|
+
$stderr.puts "Completed in #{etime}s"
|
10
|
+
rescue Thor::UndefinedCommandError, Thor::UnknownArgumentError, Thor::AmbiguousCommandError, Thor::InvocationError => e
|
11
|
+
$stderr.puts(e.message)
|
12
|
+
exit(64)
|
13
|
+
rescue Thor::Error => e
|
14
|
+
$stderr.puts(e.message)
|
15
|
+
exit(1)
|
16
|
+
end
|
data/lib/packit.rb
ADDED
data/lib/packit/cli.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'packit'
|
3
|
+
|
4
|
+
class Packit::CLI < Thor
|
5
|
+
|
6
|
+
desc 'pack', 'Create a new package'
|
7
|
+
method_option :config, type: :string, required: false, banner: 'CONFIG', desc: 'Path to config file', aliases: '-c'
|
8
|
+
def pack
|
9
|
+
opts = options.deep_symbolize_keys
|
10
|
+
Packit::Packager.pack(**opts)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
module Packit
|
5
|
+
class Config < OpenStruct
|
6
|
+
def self.load(path)
|
7
|
+
fail "Config file #{path} doesn't exist" unless File.exists?(path)
|
8
|
+
config = YAML.load(File.read(path))
|
9
|
+
self.new(config)
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(*args)
|
13
|
+
super(*args)
|
14
|
+
validate
|
15
|
+
end
|
16
|
+
|
17
|
+
def validate
|
18
|
+
fail "No build strategy provided" unless strategy
|
19
|
+
fail "No name was provided" unless name
|
20
|
+
fail "No version was provided" unless version
|
21
|
+
|
22
|
+
case strategy
|
23
|
+
when 'simple'
|
24
|
+
fail 'No globs for where to find artifacts was provided. Tell me what to package.' unless globs
|
25
|
+
fail "Globs should be an Array of glob strings, but you gave me a #{globs.class}" unless globs.is_a?(Array)
|
26
|
+
when 'pbuilder'
|
27
|
+
else
|
28
|
+
"Build strategy #{strategy} is not supported"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_binding
|
34
|
+
binding()
|
35
|
+
end
|
36
|
+
|
37
|
+
# common DEBIAN files
|
38
|
+
# reference to post / pre hook templates
|
39
|
+
# control
|
40
|
+
# copyright
|
41
|
+
# type
|
42
|
+
# dpkg-deb
|
43
|
+
# build
|
44
|
+
# binary
|
45
|
+
# simple script / makefile
|
46
|
+
# globs
|
47
|
+
# links
|
48
|
+
# prefix
|
49
|
+
# configs
|
50
|
+
# pbuilder
|
51
|
+
# generate DEBIAN files
|
52
|
+
# provide makefiles / rules, standard DH stuff
|
53
|
+
# User writes:
|
54
|
+
# yaml file
|
55
|
+
# compat
|
56
|
+
# rules file
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module Packit
|
4
|
+
module Control
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def render(config)
|
8
|
+
template = <<-eos
|
9
|
+
Package: <%= name %>
|
10
|
+
Architecture: <%= arch || 'all' %>
|
11
|
+
Maintainer: <%= author %>
|
12
|
+
Depends: <%= (depends && depends.is_a?(Array) && !depends.empty?) || 'debconf' %>
|
13
|
+
<%- if conflicts && conflicts.is_a?(Array) && !conflicts.empty? -%>
|
14
|
+
Conflicts: <%= conflicts.join(', ') %>
|
15
|
+
<%- end -%>
|
16
|
+
<%- if section -%>
|
17
|
+
Section: <%= section %>
|
18
|
+
<%- end -%>
|
19
|
+
Priority: <%= priority || 'optional' %>
|
20
|
+
Version: <%= version %>
|
21
|
+
Description: <%= description || "Awesome package" %>
|
22
|
+
eos
|
23
|
+
renderer = ERB.new(template, nil, '-')
|
24
|
+
renderer.result(config.get_binding)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
#https://github.com/Shopify/ruby/blob/debian_pbuilder/debian/control.erb
|
31
|
+
|
32
|
+
#Source: shopify-ruby-<%= version %>
|
33
|
+
#Section: ruby
|
34
|
+
#Priority: optional
|
35
|
+
#Maintainer: Shopify Ops <ops@shopify.com>
|
36
|
+
#Build-Depends: debhelper (>= 7.3), autoconf, bison, build-essential, devscripts, equivs, libreadline-gplv2-dev | libreadline-dev, ruby1.9.3|ruby, libssl-dev (>= 0.9.6b), libyaml-dev, zlib1g-dev, systemtap-sdt-dev, libffi-dev
|
37
|
+
#Standards-Version: 3.9.4
|
38
|
+
#Homepage: https://github.com/Shopify/ruby
|
39
|
+
#Vcs-Git: git://github.com/Shopify/ruby.git
|
40
|
+
#Vcs-Browser: https://github.com/Shopify/ruby
|
41
|
+
#
|
42
|
+
#Package: shopify-ruby-<%= version %>
|
43
|
+
#Architecture: any
|
44
|
+
#Depends: ${shlibs:Depends}, ${misc:Depends}
|
45
|
+
#Recommends: shopify-ruby
|
46
|
+
#Provides: shopify-ruby-any, shopify-ruby-<%= major_minor %>
|
47
|
+
#Suggests: shopify-ruby-<%= version %>-doc
|
48
|
+
#Description: Ruby <%= version %> for Shopify servers
|
49
|
+
# Built using shopify-ruby-build.
|
50
|
+
#
|
51
|
+
#Package: shopify-ruby-<%= version %>-doc
|
52
|
+
#Architecture: any
|
53
|
+
#Description: Ruby <%= version %> for Shopify servers (documentation)
|
54
|
+
# Built using shopify-ruby-build.
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'tmpdir'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module Packit
|
5
|
+
class DpkgDeb < Packager
|
6
|
+
|
7
|
+
def package
|
8
|
+
build if @debconf.script
|
9
|
+
prepare
|
10
|
+
archive
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def build
|
16
|
+
system(@debconf.script)
|
17
|
+
end
|
18
|
+
|
19
|
+
def prepare
|
20
|
+
tmpdir = Dir.mktmpdir("dpkg-#{@debconf.name}")
|
21
|
+
@pkgdir = File.join(tmpdir, "#{@debconf.name}_#{@debconf.version}")
|
22
|
+
@prefix = @debconf.prefix || "/usr/local/#{@debconf.name}"
|
23
|
+
@debconf.globs.each do |glob|
|
24
|
+
Dir[glob].each do |entry|
|
25
|
+
target = File.join(@pkgdir, @prefix, entry)
|
26
|
+
if File.directory?(entry)
|
27
|
+
FileUtils.mkdir_p(target)
|
28
|
+
elsif File.file?(entry)
|
29
|
+
FileUtils.mkdir_p(File.dirname(target))
|
30
|
+
FileUtils.cp(entry, target)
|
31
|
+
else
|
32
|
+
fail "I can't handle #{entry} it is neither a file nore a directory"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
@debdir = File.join(@pkgdir, 'DEBIAN')
|
37
|
+
FileUtils.mkdir_p(@debdir)
|
38
|
+
File.write(File.join(@debdir, 'control'), @control)
|
39
|
+
end
|
40
|
+
|
41
|
+
def archive
|
42
|
+
system("dpkg-deb --build #{@pkgdir}")
|
43
|
+
#FileUtils.mv(
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'packit/config'
|
2
|
+
require 'packit/control'
|
3
|
+
|
4
|
+
module Packit
|
5
|
+
class Packager
|
6
|
+
def self.pack(config: nil)
|
7
|
+
config ||= File.join(Dir.pwd, 'packit.yml')
|
8
|
+
debconf = Config.load(config)
|
9
|
+
|
10
|
+
case debconf.strategy
|
11
|
+
when 'simple'
|
12
|
+
DpkgDeb.new(debconf).package
|
13
|
+
when 'pbuilder'
|
14
|
+
Pbuilder.new(debconf).package
|
15
|
+
else
|
16
|
+
"Build strategy #{config.strategy} is not supported"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(debconf)
|
21
|
+
@debconf = debconf
|
22
|
+
@control = Control.render(@debconf)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/man/PACKIT.1
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: packit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dale Hamel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.19.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.19.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 4.2.5.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 4.2.5.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 10.4.2
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 10.4.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.10.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.10.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.2.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.2.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: md2man
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 4.0.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 4.0.0
|
97
|
+
description: Provides a simple means of packaging arbitrary files into a debian package.
|
98
|
+
email: dale.hamel@srvthe.net
|
99
|
+
executables:
|
100
|
+
- packit
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- bin/packit
|
105
|
+
- lib/packit.rb
|
106
|
+
- lib/packit/cli.rb
|
107
|
+
- lib/packit/config.rb
|
108
|
+
- lib/packit/control.rb
|
109
|
+
- lib/packit/dpkg_deb.rb
|
110
|
+
- lib/packit/packager.rb
|
111
|
+
- lib/packit/version.rb
|
112
|
+
- man/PACKIT.1
|
113
|
+
homepage: http://rubygems.org/gems/packit
|
114
|
+
licenses:
|
115
|
+
- MIT
|
116
|
+
metadata: {}
|
117
|
+
post_install_message:
|
118
|
+
rdoc_options: []
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
requirements: []
|
132
|
+
rubyforge_project:
|
133
|
+
rubygems_version: 2.4.6
|
134
|
+
signing_key:
|
135
|
+
specification_version: 4
|
136
|
+
summary: Glob it up, and "pack it" into a deb
|
137
|
+
test_files: []
|