Class: Debian::Build::Platform
Constant Summary
collapse
- @@repositories =
[]
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
build_directory, build_directory=
Constructor Details
#initialize(distribution, architecture) ⇒ Platform
Returns a new instance of Platform.
23
24
25
26
|
# File 'lib/debian/build/platform.rb', line 23
def initialize(distribution, architecture)
@distribution = distribution
@architecture = architecture
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/debian/build/platform.rb', line 15
def method_missing(method, *args, &block)
if @distribution.respond_to? method
@distribution.send method, *args
else
super
end
end
|
Instance Attribute Details
#architecture ⇒ Object
Returns the value of attribute architecture.
5
6
7
|
# File 'lib/debian/build/platform.rb', line 5
def architecture
@architecture
end
|
#distribution ⇒ Object
Returns the value of attribute distribution.
5
6
7
|
# File 'lib/debian/build/platform.rb', line 5
def distribution
@distribution
end
|
Class Method Details
.all ⇒ Object
36
37
38
39
40
41
|
# File 'lib/debian/build/platform.rb', line 36
def self.all
@@all ||=
Distribution.all.collect do |distribution|
supported_architectures.collect { |architecture| Platform.new(distribution, architecture) }
end.flatten
end
|
.each(&block) ⇒ Object
43
44
45
|
# File 'lib/debian/build/platform.rb', line 43
def self.each(&block)
all.each &block
end
|
.find_by_name(name) ⇒ Object
28
29
30
|
# File 'lib/debian/build/platform.rb', line 28
def self.find_by_name(name)
self.all.find { |p| p.to_s == name }
end
|
.repositories ⇒ Object
8
9
10
|
# File 'lib/debian/build/platform.rb', line 8
def self.repositories
@@repositories
end
|
.supported_architectures ⇒ Object
32
33
34
|
# File 'lib/debian/build/platform.rb', line 32
def self.supported_architectures
%w{i386 amd64}
end
|
Instance Method Details
#additional_mirrors ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/debian/build/platform.rb', line 59
def additional_mirrors
repositories.collect do |repository|
case repository
when String
eval '"' + repository + '"'
when Proc
repository.call self
else
repository.to_s
end
end.compact.uniq
end
|
#build_result_directory ⇒ Object
47
48
49
|
# File 'lib/debian/build/platform.rb', line 47
def build_result_directory
File.expand_path "#{Platform.build_directory}/binaries/#{distribution}/#{architecture}"
end
|
#default_hooks_directory ⇒ Object
104
105
106
|
# File 'lib/debian/build/platform.rb', line 104
def default_hooks_directory
"#{Package.build_directory}/tmp/hooks"
end
|
#other_mirrors ⇒ Object
72
73
74
|
# File 'lib/debian/build/platform.rb', line 72
def other_mirrors
["deb file:#{build_result_directory} ./"] + additional_mirrors
end
|
#pbuilder(options = {}) ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/debian/build/platform.rb', line 76
def pbuilder(options = {})
PBuilder.new do |p|
p[:basetgz] = pbuilder_base_file
p[:othermirror] = "'#{other_mirrors.join('|')}'"
p[:bindmounts] = p[:buildresult] = build_result_directory
p[:distribution] = distribution
p[:hookdir] = default_hooks_directory
p[:debootstrapopts] = [ "--arch=#{architecture}" ]
p[:debbuildopts] = [ "-a#{architecture}", '-b' ]
p[:mirror] = mirror
if flavor == :ubuntu
p[:components] = "'main universe'"
end
p.options = options
p.before_exec Proc.new {
prepare_build_result_directory
prepare_default_hooks
}
end
end
|
#pbuilder_base_file ⇒ Object
51
52
53
|
# File 'lib/debian/build/platform.rb', line 51
def pbuilder_base_file
"/var/cache/pbuilder/base-#{distribution}-#{architecture}.tgz"
end
|
#pbuilder_enabled? ⇒ Boolean
55
56
57
|
# File 'lib/debian/build/platform.rb', line 55
def pbuilder_enabled?
File.exists? pbuilder_base_file
end
|
#prepare_build_result_directory ⇒ Object
108
109
110
111
112
113
114
|
# File 'lib/debian/build/platform.rb', line 108
def prepare_build_result_directory
mkdir_p build_result_directory
Dir.chdir(build_result_directory) do
sh "/usr/bin/dpkg-scanpackages . /dev/null > Packages"
end
end
|
#prepare_default_hooks ⇒ Object
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/debian/build/platform.rb', line 116
def prepare_default_hooks
mkdir_p default_hooks_directory
apt_update_hook_file = "#{default_hooks_directory}/D80apt-get-update"
unless File.exists?(apt_update_hook_file)
File.open(apt_update_hook_file, "w") do |f|
f.puts "#!/bin/sh"
f.puts "apt-get update"
end
FileUtils.chmod 0755, apt_update_hook_file
end
end
|
#repositories ⇒ Object
11
12
13
|
# File 'lib/debian/build/platform.rb', line 11
def repositories
@@repositories
end
|
#task_name ⇒ Object
134
135
136
|
# File 'lib/debian/build/platform.rb', line 134
def task_name
to_s '_'
end
|
#to_s(separator = '/') ⇒ Object
130
131
132
|
# File 'lib/debian/build/platform.rb', line 130
def to_s(separator = '/')
"#{distribution}#{separator}#{architecture}"
end
|