dodebui 0.0.1 → 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 +4 -4
- data/.rubocop.yml +1 -1
- data/README.md +41 -6
- data/lib/dodebui/build.rb +50 -3
- data/lib/dodebui/cli.rb +20 -4
- data/lib/dodebui/distribution.rb +16 -2
- data/lib/dodebui/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7c7448d8bf5f96444aa24bf6c0a450bba189772
|
4
|
+
data.tar.gz: c4318110ee5b9ff37ca363862e4d5105a580c6cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6d2e32bbe71cd8b9440843665749e3ff91edbb14bbad398516ca738fdc7f31f528f6037cbd77ec4dafcf42f4ca05c7e4ad65ca8b2295839a0617405e82734e6
|
7
|
+
data.tar.gz: a23cacd8f986ae8f33365c7ebcab6dd73860ab3bae9a03d198c8feb026302332ed514b6297848dcf1dd2a41c36be71efc881ed09a738469306ee412015cc5878
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -1,26 +1,61 @@
|
|
1
1
|
# Dodebui
|
2
2
|
|
3
|
-
|
3
|
+
Debian Docker builder
|
4
|
+
|
5
|
+
This tool helps to build Debian binary packages for multiple distribution
|
6
|
+
releases.
|
7
|
+
|
8
|
+
## Features
|
9
|
+
|
10
|
+
### Implemented
|
11
|
+
|
12
|
+
* build multiple a package for multiple releases in parallel
|
13
|
+
* use docker containers for isolation
|
14
|
+
* install dependencies automatically
|
15
|
+
* use a apt cache for minimizing download times
|
16
|
+
|
17
|
+
### Planned
|
18
|
+
|
19
|
+
* Cache images after dependency installation for faster build times
|
4
20
|
|
5
21
|
## Installation
|
6
22
|
|
7
|
-
Add this
|
23
|
+
Add this Gemfile to your debian packge:
|
8
24
|
|
9
25
|
```ruby
|
26
|
+
source 'https://rubygems.org'
|
10
27
|
gem 'dodebui'
|
11
28
|
```
|
12
29
|
|
13
30
|
And then execute:
|
14
31
|
|
15
|
-
$ bundle
|
32
|
+
$ bundle install
|
16
33
|
|
17
|
-
|
34
|
+
Now create your Dodebuifile in project root:
|
18
35
|
|
19
|
-
|
36
|
+
```ruby
|
37
|
+
# vim: ft=ruby
|
38
|
+
|
39
|
+
# Configure distributions to build
|
40
|
+
@build_distributions = [
|
41
|
+
'debian:wheezy',
|
42
|
+
'debian:jessie',
|
43
|
+
'debian:squeeze',
|
44
|
+
'ubuntu:precise',
|
45
|
+
'ubuntu:trusty',
|
46
|
+
]
|
47
|
+
|
48
|
+
# Configure a apt-proxy (warmly recommended)
|
49
|
+
#@apt_proxy = 'http://my-apt-proxy.com/'
|
50
|
+
```
|
20
51
|
|
21
52
|
## Usage
|
22
53
|
|
23
|
-
|
54
|
+
$ bundle exec dodebui
|
55
|
+
|
56
|
+
## Example project
|
57
|
+
|
58
|
+
https://github.com/simonswine/dodebui-package-hello
|
24
59
|
|
25
60
|
## Contributing
|
26
61
|
|
data/lib/dodebui/build.rb
CHANGED
@@ -46,7 +46,6 @@ module Dodebui
|
|
46
46
|
)
|
47
47
|
logger.info("Starting container #{@distribution.codename}")
|
48
48
|
@container.start('Binds' => [
|
49
|
-
"#{File.join(cache_dir, 'archives')}:/var/cache/apt/archives",
|
50
49
|
"#{build_dir}:/_build"
|
51
50
|
])
|
52
51
|
end
|
@@ -77,18 +76,65 @@ module Dodebui
|
|
77
76
|
logger.info("Finished building package #{@distribution.codename}")
|
78
77
|
end
|
79
78
|
|
79
|
+
def build_apt_proxy
|
80
|
+
return if @cli.apt_proxy.nil?
|
81
|
+
logger.info("Setting apt_proxy #{@distribution.codename}")
|
82
|
+
stdout, stderr, ret_val = @container.exec([
|
83
|
+
'bash',
|
84
|
+
'-c',
|
85
|
+
@distribution.apt_proxy
|
86
|
+
])
|
87
|
+
write_log('apt_proxy', stdout, stderr)
|
88
|
+
logger.warn(
|
89
|
+
"Failed setting apt proxy #{@distribution.codename}"
|
90
|
+
) if ret_val != 0
|
91
|
+
end
|
92
|
+
|
93
|
+
def build_chown
|
94
|
+
uid = Process.uid
|
95
|
+
gid = Process.gid
|
96
|
+
logger.info(
|
97
|
+
'Changing owner of build dir to' \
|
98
|
+
" uid=#{uid} gid=#{gid} #{@distribution.codename}"
|
99
|
+
)
|
100
|
+
stdout, stderr, ret_val = @container.exec([
|
101
|
+
'chown',
|
102
|
+
'-R',
|
103
|
+
format('%d:%d', uid, gid),
|
104
|
+
'/_build'
|
105
|
+
])
|
106
|
+
write_log('chown', stdout, stderr)
|
107
|
+
logger.warn(
|
108
|
+
"Failed changing owner of build dir #{@distribution.codename}"
|
109
|
+
) if ret_val != 0
|
110
|
+
end
|
111
|
+
|
112
|
+
def build_error(e)
|
113
|
+
logger.warn("Error building #{@distribution.image_name}: #{e}")
|
114
|
+
return false if @container.nil?
|
115
|
+
logger.warn("Use container id=#{@container.id} to debug")
|
116
|
+
@container.stop
|
117
|
+
false
|
118
|
+
end
|
119
|
+
|
80
120
|
def build
|
81
121
|
build_container_create_start
|
82
122
|
|
123
|
+
build_apt_proxy
|
124
|
+
|
83
125
|
build_dependencies
|
84
126
|
|
85
127
|
build_package
|
86
128
|
|
129
|
+
build_chown
|
130
|
+
|
87
131
|
@container.stop
|
88
132
|
|
133
|
+
@container.remove
|
134
|
+
|
89
135
|
true
|
90
|
-
rescue RuntimeError
|
91
|
-
|
136
|
+
rescue RuntimeError => e
|
137
|
+
build_error(e)
|
92
138
|
end
|
93
139
|
|
94
140
|
def cache_dir
|
@@ -144,6 +190,7 @@ module Dodebui
|
|
144
190
|
end
|
145
191
|
|
146
192
|
def source_templates
|
193
|
+
return if @cli.source_templates.nil?
|
147
194
|
@cli.source_templates.each do |template|
|
148
195
|
src = File.join(source_dir, template)
|
149
196
|
dest = src[0...-4]
|
data/lib/dodebui/cli.rb
CHANGED
@@ -6,7 +6,7 @@ require 'docker'
|
|
6
6
|
module Dodebui
|
7
7
|
## commandline interface for dodebui
|
8
8
|
class Cli
|
9
|
-
attr_accessor :source_templates, :build_distributions
|
9
|
+
attr_accessor :source_templates, :build_distributions, :apt_proxy
|
10
10
|
attr_reader :wd
|
11
11
|
|
12
12
|
def self.logger
|
@@ -16,6 +16,7 @@ module Dodebui
|
|
16
16
|
def initialize
|
17
17
|
@dodebuifiles ||= ['Dodebuifile']
|
18
18
|
@original_dir = Dir.getwd
|
19
|
+
@distributions_sem = Mutex.new
|
19
20
|
end
|
20
21
|
|
21
22
|
def dodebuifile?
|
@@ -92,10 +93,18 @@ module Dodebui
|
|
92
93
|
threads = []
|
93
94
|
@distributions.each do |dist|
|
94
95
|
threads << Thread.new do
|
95
|
-
|
96
|
+
begin
|
97
|
+
dist.ensure_image_updated
|
98
|
+
rescue => e
|
99
|
+
logger.warn(
|
100
|
+
"Failed ensuring a updated image '#{dist.image_name}': #{e}"
|
101
|
+
)
|
102
|
+
@distributions_sem.synchronize do
|
103
|
+
@distributions -= [dist]
|
104
|
+
end
|
105
|
+
end
|
96
106
|
end
|
97
107
|
end
|
98
|
-
|
99
108
|
# wait for all threads
|
100
109
|
threads.each(&:join)
|
101
110
|
end
|
@@ -110,7 +119,14 @@ module Dodebui
|
|
110
119
|
threads = []
|
111
120
|
@distributions.each do |dist|
|
112
121
|
threads << Thread.new do
|
113
|
-
|
122
|
+
begin
|
123
|
+
dist.build.build
|
124
|
+
rescue => e
|
125
|
+
logger.warn("Failed building on image '#{dist.image_name}': #{e}")
|
126
|
+
@distributions_sem.synchronize do
|
127
|
+
@distributions -= [dist]
|
128
|
+
end
|
129
|
+
end
|
114
130
|
end
|
115
131
|
end
|
116
132
|
# wait for all threads
|
data/lib/dodebui/distribution.rb
CHANGED
@@ -90,9 +90,23 @@ module Dodebui
|
|
90
90
|
'/usr/lib/pbuilder'
|
91
91
|
end
|
92
92
|
|
93
|
+
def apt_proxy
|
94
|
+
(
|
95
|
+
'echo ' \
|
96
|
+
'"Acquire::http::Proxy ' \
|
97
|
+
'\"%s\";" ' \
|
98
|
+
'> ' \
|
99
|
+
'/etc/apt/apt.conf.d/01proxy'
|
100
|
+
) % @cli.apt_proxy
|
101
|
+
end
|
102
|
+
|
93
103
|
def create_image_dockerfile_contents
|
94
|
-
dockerfile =
|
95
|
-
|
104
|
+
dockerfile = "FROM #{base_image_name}\n"
|
105
|
+
|
106
|
+
# append proxy if needed
|
107
|
+
dockerfile += "RUN #{apt_proxy}\n" unless @cli.apt_proxy.nil?
|
108
|
+
|
109
|
+
dockerfile += (
|
96
110
|
"ENV DEBIAN_FRONTEND=noninteractive\n" \
|
97
111
|
"RUN apt-get update && \\ \n" \
|
98
112
|
" apt-get -y dist-upgrade && \\ \n" \
|
data/lib/dodebui/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dodebui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Simon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docker-api
|