packo 0.0.1.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. data/bin/packo +78 -0
  2. data/bin/packo-base +24 -0
  3. data/bin/packo-build +24 -0
  4. data/bin/packo-db +24 -0
  5. data/bin/packo-env +24 -0
  6. data/bin/packo-files +24 -0
  7. data/bin/packo-profile +24 -0
  8. data/bin/packo-repository +24 -0
  9. data/bin/packo-select +24 -0
  10. data/lib/packo.rb +186 -0
  11. data/lib/packo/cli.rb +79 -0
  12. data/lib/packo/cli/base.rb +554 -0
  13. data/lib/packo/cli/build.rb +488 -0
  14. data/lib/packo/cli/database.rb +55 -0
  15. data/lib/packo/cli/database/definition.rb +65 -0
  16. data/lib/packo/cli/database/helpers.rb +20 -0
  17. data/lib/packo/cli/environment.rb +45 -0
  18. data/lib/packo/cli/files.rb +153 -0
  19. data/lib/packo/cli/profile.rb +31 -0
  20. data/lib/packo/cli/repository.rb +561 -0
  21. data/lib/packo/cli/repository/binary.rb +74 -0
  22. data/lib/packo/cli/repository/helpers.rb +20 -0
  23. data/lib/packo/cli/repository/repository.rb +48 -0
  24. data/lib/packo/cli/repository/source.rb +91 -0
  25. data/lib/packo/cli/repository/virtual.rb +53 -0
  26. data/lib/packo/cli/select.rb +61 -0
  27. data/lib/packo/do.rb +249 -0
  28. data/lib/packo/environment.rb +269 -0
  29. data/lib/packo/extensions.rb +70 -0
  30. data/lib/packo/flags.rb +64 -0
  31. data/lib/packo/host.rb +121 -0
  32. data/lib/packo/models.rb +171 -0
  33. data/lib/packo/models/installed_package.rb +190 -0
  34. data/lib/packo/models/installed_package/content.rb +50 -0
  35. data/lib/packo/models/installed_package/dependency.rb +39 -0
  36. data/lib/packo/models/repository.rb +209 -0
  37. data/lib/packo/models/repository/binary.rb +32 -0
  38. data/lib/packo/models/repository/binary/mirror.rb +35 -0
  39. data/lib/packo/models/repository/package.rb +73 -0
  40. data/lib/packo/models/repository/package/binary.rb +34 -0
  41. data/lib/packo/models/repository/package/binary/build.rb +36 -0
  42. data/lib/packo/models/repository/package/source.rb +36 -0
  43. data/lib/packo/models/repository/package/source/feature.rb +36 -0
  44. data/lib/packo/models/repository/package/source/flavor.rb +36 -0
  45. data/lib/packo/models/repository/package/virtual.rb +32 -0
  46. data/lib/packo/models/repository/source.rb +30 -0
  47. data/lib/packo/models/repository/virtual.rb +30 -0
  48. data/lib/packo/models/selector.rb +34 -0
  49. data/lib/packo/models/tag.rb +30 -0
  50. data/lib/packo/package.rb +239 -0
  51. data/lib/packo/package/blocker.rb +100 -0
  52. data/lib/packo/package/blockers.rb +40 -0
  53. data/lib/packo/package/dependencies.rb +40 -0
  54. data/lib/packo/package/dependency.rb +100 -0
  55. data/lib/packo/package/feature.rb +55 -0
  56. data/lib/packo/package/features.rb +105 -0
  57. data/lib/packo/package/flavor.rb +101 -0
  58. data/lib/packo/package/tags.rb +60 -0
  59. data/lib/packo/package/tags/expression.rb +130 -0
  60. data/lib/packo/package/tags/expression/group.rb +28 -0
  61. data/lib/packo/package/tags/expression/logic.rb +48 -0
  62. data/lib/packo/package/tags/expression/name.rb +28 -0
  63. data/lib/packo/profile.rb +174 -0
  64. data/lib/packo/rbuild.rb +22 -0
  65. data/lib/packo/rbuild/behaviors.rb +20 -0
  66. data/lib/packo/rbuild/behaviors/default.rb +27 -0
  67. data/lib/packo/rbuild/feature.rb +64 -0
  68. data/lib/packo/rbuild/features.rb +65 -0
  69. data/lib/packo/rbuild/flavor.rb +67 -0
  70. data/lib/packo/rbuild/module.rb +40 -0
  71. data/lib/packo/rbuild/modules.rb +27 -0
  72. data/lib/packo/rbuild/modules/building.rb +24 -0
  73. data/lib/packo/rbuild/modules/building/autotools.rb +315 -0
  74. data/lib/packo/rbuild/modules/building/cmake.rb +38 -0
  75. data/lib/packo/rbuild/modules/building/patch.rb +84 -0
  76. data/lib/packo/rbuild/modules/building/rake.rb +74 -0
  77. data/lib/packo/rbuild/modules/building/strip.rb +41 -0
  78. data/lib/packo/rbuild/modules/misc.rb +26 -0
  79. data/lib/packo/rbuild/modules/misc/fetcher.rb +177 -0
  80. data/lib/packo/rbuild/modules/misc/fetching.rb +22 -0
  81. data/lib/packo/rbuild/modules/misc/fetching/git.rb +57 -0
  82. data/lib/packo/rbuild/modules/misc/fetching/github.rb +31 -0
  83. data/lib/packo/rbuild/modules/misc/fetching/gnu.rb +59 -0
  84. data/lib/packo/rbuild/modules/misc/fetching/mercurial.rb +51 -0
  85. data/lib/packo/rbuild/modules/misc/fetching/sourceforge.rb +47 -0
  86. data/lib/packo/rbuild/modules/misc/fetching/subversion.rb +51 -0
  87. data/lib/packo/rbuild/modules/misc/fetching/wget.rb +57 -0
  88. data/lib/packo/rbuild/modules/misc/unpacker.rb +70 -0
  89. data/lib/packo/rbuild/modules/misc/unpacking.rb +23 -0
  90. data/lib/packo/rbuild/modules/misc/unpacking/lzma.rb +34 -0
  91. data/lib/packo/rbuild/modules/misc/unpacking/tar.rb +35 -0
  92. data/lib/packo/rbuild/modules/misc/unpacking/xz.rb +34 -0
  93. data/lib/packo/rbuild/modules/misc/unpacking/zip.rb +26 -0
  94. data/lib/packo/rbuild/modules/packaging.rb +20 -0
  95. data/lib/packo/rbuild/modules/packaging/pko.rb +78 -0
  96. data/lib/packo/rbuild/package.rb +281 -0
  97. data/lib/packo/rbuild/package/manifest.rb +169 -0
  98. data/lib/packo/rbuild/stages.rb +171 -0
  99. data/lib/packo/rbuild/stages/callbacks.rb +96 -0
  100. data/lib/packo/rbuild/stages/stage.rb +50 -0
  101. data/lib/packo/repository.rb +95 -0
  102. data/lib/packo/repository/binary.rb +116 -0
  103. data/lib/packo/repository/source.rb +77 -0
  104. data/lib/packo/repository/virtual.rb +66 -0
  105. data/lib/packo/system.rb +53 -0
  106. data/lib/packo/version.rb +26 -0
  107. metadata +276 -0
@@ -0,0 +1,74 @@
1
+ #--
2
+ # Copyleft meh. [http://meh.doesntexist.org | meh@paranoici.org]
3
+ #
4
+ # This file is part of packo.
5
+ #
6
+ # packo is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Affero General Public License as published
8
+ # by the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # packo is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Affero General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Affero General Public License
17
+ # along with packo. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+
20
+ require 'packo/models'
21
+
22
+ module Packo; module CLI; class Repository < Thor; module Helpers
23
+
24
+ class Binary < Packo::Repository::Binary
25
+ include Packo::Models
26
+ include Helpers::Repository
27
+
28
+ def initialize (model)
29
+ super(model.to_hash.merge(model: model))
30
+ end
31
+
32
+ def populate
33
+ self.packages.each {|package|
34
+ pkg = model.packages.first_or_create(
35
+ repo: model,
36
+
37
+ tags_hashed: package.tags.hashed,
38
+ name: package.name,
39
+ version: package.version,
40
+ slot: package.slot,
41
+ revision: package.revision
42
+ )
43
+
44
+ pkg.update(
45
+ features: package.features,
46
+
47
+ description: package.description,
48
+ homepage: package.homepage,
49
+ license: package.license,
50
+
51
+ maintainer: package.maintainer
52
+ )
53
+
54
+ package.tags.each {|tag|
55
+ pkg.tags << Tag.first_or_create(name: tag.to_s)
56
+ }
57
+
58
+ package.builds.each {|build|
59
+ bld = pkg.data.builds.first_or_create(
60
+ flavor: build.flavor,
61
+ features: build.features
62
+ )
63
+
64
+ bld.update(
65
+ digest: build.digest
66
+ )
67
+ }
68
+
69
+ pkg.save
70
+ }
71
+ end
72
+ end
73
+
74
+ end; end; end; end
@@ -0,0 +1,20 @@
1
+ #--
2
+ # Copyleft meh. [http://meh.doesntexist.org | meh@paranoici.org]
3
+ #
4
+ # This file is part of packo.
5
+ #
6
+ # packo is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Affero General Public License as published
8
+ # by the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # packo is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Affero General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Affero General Public License
17
+ # along with packo. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+
20
+ require 'packo/cli/repository/repository'
@@ -0,0 +1,48 @@
1
+ #--
2
+ # Copyleft meh. [http://meh.doesntexist.org | meh@paranoici.org]
3
+ #
4
+ # This file is part of packo.
5
+ #
6
+ # packo is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Affero General Public License as published
8
+ # by the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # packo is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Affero General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Affero General Public License
17
+ # along with packo. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+
20
+ module Packo; module CLI; class Repository < Thor; module Helpers
21
+
22
+ module Repository
23
+ def self.wrap (model)
24
+ unless model
25
+ raise ArgumentError.new('You passed a nil model.')
26
+ end
27
+
28
+ model.save
29
+
30
+ case model.type
31
+ when :binary; Helpers::Binary.new(model)
32
+ when :source; Helpers::Source.new(model)
33
+ when :virtual; Helpers::Virtual.new(model)
34
+ end
35
+ end
36
+
37
+ def model; @model end
38
+ def type; @model.type end
39
+ def name; @model.name end
40
+ def uri; @model.uri end
41
+ def path; @model.path end
42
+ end
43
+
44
+ require 'packo/cli/repository/binary'
45
+ require 'packo/cli/repository/source'
46
+ require 'packo/cli/repository/virtual'
47
+
48
+ end; end; end; end
@@ -0,0 +1,91 @@
1
+ #--
2
+ # Copyleft meh. [http://meh.doesntexist.org | meh@paranoici.org]
3
+ #
4
+ # This file is part of packo.
5
+ #
6
+ # packo is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Affero General Public License as published
8
+ # by the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # packo is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Affero General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Affero General Public License
17
+ # along with packo. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+
20
+ require 'packo/models'
21
+
22
+ module Packo; module CLI; class Repository < Thor; module Helpers
23
+
24
+ class Source < Packo::Repository::Source
25
+ include Packo::Models
26
+ include Helpers::Repository
27
+
28
+ def initialize (model)
29
+ super(model.to_hash.merge(model: model))
30
+ end
31
+
32
+ def populate
33
+ self.packages.each {|package|
34
+ pkg = model.packages.first_or_create(
35
+ repo: model,
36
+
37
+ tags_hashed: package.tags.hashed,
38
+ name: package.name,
39
+ version: package.version,
40
+ slot: package.slot,
41
+ revision: package.revision
42
+ )
43
+
44
+ pkg.update(
45
+ description: package.description,
46
+ homepage: [package.homepage].flatten.join(' '),
47
+ license: [package.license].flatten.join(' '),
48
+
49
+ maintainer: package.maintainer
50
+ )
51
+
52
+ package.tags.each {|tag|
53
+ pkg.tags << Tag.first_or_create(name: tag.to_s)
54
+ }
55
+
56
+ pkg.data.update(
57
+ path: File.dirname(package.path)
58
+ )
59
+
60
+ package.features.each {|f|
61
+ feature = pkg.data.features.first_or_create(
62
+ source: pkg.data,
63
+ name: f.name
64
+ )
65
+
66
+ feature.update(
67
+ description: f.description,
68
+ enabled: f.enabled?
69
+ )
70
+ }
71
+
72
+ package.flavor.each {|f|
73
+ next if [:vanilla, :documentation, :headers, :debug].member?(f.name)
74
+
75
+ flavor = pkg.data.flavor.first_or_create(
76
+ source: pkg.data,
77
+ name: f.name
78
+ )
79
+
80
+ flavor.update(
81
+ description: f.description,
82
+ enabled: f.enabled?
83
+ )
84
+ }
85
+
86
+ pkg.save
87
+ }
88
+ end
89
+ end
90
+
91
+ end; end; end; end
@@ -0,0 +1,53 @@
1
+ #--
2
+ # Copyleft meh. [http://meh.doesntexist.org | meh@paranoici.org]
3
+ #
4
+ # This file is part of packo.
5
+ #
6
+ # packo is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Affero General Public License as published
8
+ # by the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # packo is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Affero General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Affero General Public License
17
+ # along with packo. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+
20
+ module Packo; module CLI; class Repository < Thor; module Helpers
21
+
22
+ class Virtual < Packo::Repository::Virtual
23
+ include Packo::Models
24
+ include Helpers::Repository
25
+
26
+ def initialize (model)
27
+ super(model.to_hash.merge(model: model))
28
+ end
29
+
30
+ def populate
31
+ self.packages.each {|package|
32
+ pkg = model.packages.first_or_create(
33
+ repo: model,
34
+
35
+ tags_hashed: package.tags.hashed,
36
+ name: package.name,
37
+ version: package.version,
38
+ slot: package.slot,
39
+ revision: package.revision
40
+ )
41
+
42
+ package.tags.each {|tag|
43
+ pkg.tags << Tag.first_or_create(name: tag.to_s)
44
+ }
45
+
46
+ pkg.data.update(content: package.data)
47
+
48
+ pkg.save
49
+ }
50
+ end
51
+ end
52
+
53
+ end; end; end; end
@@ -0,0 +1,61 @@
1
+ #--
2
+ # Copyleft meh. [http://meh.doesntexist.org | meh@paranoici.org]
3
+ #
4
+ # This file is part of packo.
5
+ #
6
+ # packo is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Affero General Public License as published
8
+ # by the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # packo is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Affero General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Affero General Public License
17
+ # along with packo. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+
20
+ require 'packo'
21
+ require 'packo/models'
22
+
23
+ module Packo; module CLI
24
+
25
+ class Select < Thor
26
+ include Thor::Actions
27
+
28
+ class_option :help, type: :boolean, desc: 'Show help usage'
29
+
30
+ desc 'add NAME DESCRIPTION PATH', 'Add a module to the database'
31
+ def add (name, description, path)
32
+ Models::Selector.first_or_create(name: name).update(description: description, path: path)
33
+
34
+ CLI.info "#{name} added"
35
+ end
36
+
37
+ desc 'delete NAME', 'Delete a module from the database'
38
+ def delete (name)
39
+ selector = Models::Selector.first(name: name)
40
+
41
+ if !selector
42
+ fatal "#{name} doesn't exist"
43
+ exit! 30
44
+ end
45
+
46
+ selector.destroy
47
+
48
+ CLI.info "#{name} deleted"
49
+ end
50
+ end
51
+
52
+ Models::Selector.all.each {|selector|
53
+ Select.class_eval %{
54
+ desc '#{selector.name} [ARGUMENTS...]', '#{selector.description}'
55
+ def #{selector.name} (*arguments)
56
+ system(*(['#{selector.path}'] + ARGV[1, ARGV.length]).compact)
57
+ end
58
+ }
59
+ }
60
+
61
+ end; end
data/lib/packo/do.rb ADDED
@@ -0,0 +1,249 @@
1
+ #--
2
+ # Copyleft meh. [http://meh.doesntexist.org | meh@paranoici.org]
3
+ #
4
+ # This file is part of packo.
5
+ #
6
+ # packo is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Affero General Public License as published
8
+ # by the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # packo is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Affero General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Affero General Public License
17
+ # along with packo. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+
20
+ require 'fileutils'
21
+ require 'digest/sha1'
22
+
23
+ module Packo
24
+
25
+ class Do
26
+ def self.digest (path)
27
+ Digest::SHA1.hexdigest(File.read(path))
28
+ end
29
+
30
+ def self.cd (path=nil)
31
+ if block_given?
32
+ tmp = Dir.pwd
33
+
34
+ Dir.chdir(path) if path
35
+ result = yield
36
+ Dir.chdir(tmp)
37
+ result
38
+ else
39
+ Dir.chdir(path) rescue false
40
+ end
41
+ end
42
+
43
+ def self.dir (path)
44
+ FileUtils.mkpath path rescue nil
45
+ end
46
+
47
+ def self.touch (*path)
48
+ FileUtils.touch(path) rescue nil
49
+ end
50
+
51
+ def self.cp (*files, to)
52
+ files.flatten!
53
+ files.compact!
54
+
55
+ if files.length == 1
56
+ Do.dir(File.dirname(to))
57
+ FileUtils.cp_r(files.first, to)
58
+ else
59
+ Do.dir(to)
60
+ FileUtils.cp_r(files, to)
61
+ end
62
+ end
63
+
64
+ def self.mv (*files, to)
65
+ files.flatten!
66
+ files.compact!
67
+
68
+ if files.length == 1
69
+ Do.dir(File.dirname(to))
70
+ FileUtils.mv(files.first, to, force: true)
71
+ else
72
+ Do.dir(to)
73
+ FileUtils.mv(files, to, force: true)
74
+ end
75
+ end
76
+
77
+ def self.rm (*path)
78
+ path.flatten!
79
+ path.compact!
80
+
81
+ path.each {|path|
82
+ next unless File.exists?(path)
83
+
84
+ if File.directory?(path)
85
+ Dir.delete(path) rescue nil
86
+ else
87
+ FileUtils.rm_f(path) rescue nil
88
+ end
89
+ }
90
+ end
91
+
92
+ def self.clean (*path)
93
+ path.each {|dir|
94
+ begin
95
+ ndel = Dir.glob("#{dir}/**/", File::FNM_DOTMATCH).count do |d|
96
+ begin; Dir.rmdir d; rescue SystemCallError; end
97
+ end
98
+ end while ndel > 0
99
+ }
100
+ end
101
+
102
+ def self.sed (file, *seds)
103
+ content = File.read(file)
104
+
105
+ seds.each {|(regexp, sub)|
106
+ content.gsub!(regexp, sub || '')
107
+ }
108
+
109
+ File.write(file, content)
110
+ end
111
+
112
+ attr_reader :package
113
+
114
+ def initialize (package)
115
+ @package = package
116
+
117
+ @relative = '/usr'
118
+ @opts = nil
119
+ @verbose = true
120
+ end
121
+
122
+ def verbose?; @verbose end
123
+ def verbose!; @verbose = true end
124
+ def not_verbose!; @verbose = false end
125
+
126
+ def root
127
+ "#{@root ? @root : package.distdir}/#{@relative}".gsub(%r{/*/}, '/')
128
+ end
129
+
130
+ def root= (path)
131
+ FileUtils.mkpath(path)
132
+ end
133
+
134
+ def into (path)
135
+ tmp, @relative = @relative, path
136
+
137
+ Do.dir root if root != "/"
138
+
139
+ yield
140
+
141
+ @relative = tmp
142
+ end
143
+
144
+ def opts (value)
145
+ tmp, @opts = @opts, value
146
+ yield
147
+ @opts = tmp
148
+ end
149
+
150
+ def ins (*files)
151
+ files.map {|file| Dir.glob(file)}.flatten.each {|file|
152
+ FileUtils.cp_r file, "#{root}/#{File.basename(file)}", preserve: true, verbose: @verbose
153
+ FileUtils.chmod @opts || 0644, "#{root}/#{File.basename(file)}", verbose: @verbose
154
+ }
155
+ end
156
+
157
+ def dir (path)
158
+ FileUtils.mkpath "#{root}/#{path}", verbose: @verbose
159
+ FileUtils.chmod @opts || 0755, "#{root}/#{path}", verbose: @verbose
160
+ end
161
+
162
+ def bin (*bins)
163
+ FileUtils.mkpath "#{root}/bin"
164
+
165
+ bins.map {|bin| Dir.glob(bin)}.flatten.each {|(file, name)|
166
+ FileUtils.cp_r file, "#{root}/bin/#{File.basename(name || file)}", preserve: true, verbose: @verbose
167
+ FileUtils.chmod @opts || 0755, "#{root}/bin/#{File.basename(name || file)}", verbose: @verbose
168
+ }
169
+ end
170
+
171
+ def sbin (*sbins)
172
+ FileUtils.mkpath "#{root}/sbin"
173
+
174
+ sbins.map {|sbin| Dir.glob(sbin)}.flatten.each {|(file, name)|
175
+ FileUtils.cp_r file, "#{root}/sbin/#{File.basename(name || file)}", preserve: true, verbose: @verbose
176
+ FileUtils.chmod @opts || 0755, "#{root}/sbin/#{File.basename(name || file)}", verbose: @verbose
177
+ }
178
+ end
179
+
180
+ def lib (*libs)
181
+ FileUtils.mkpath "#{root}/lib"
182
+
183
+ libs.map {|lib| Dir.glob(lib)}.flatten.each {|(file, name)|
184
+ FileUtils.cp_r file, "#{root}/lib/#{File.basename(name || file)}", preserve: true, verbose: @verbose
185
+ FileUtils.chmod @opts || (file.match(/\.a(\.|$)/) ? 0644 : 0755), "#{root}/lib/#{File.basename(name || file)}", verbose: @verbose
186
+ }
187
+ end
188
+
189
+ def doc (*docs)
190
+ into("/usr/share/doc/#{package.name}-#{package.version}") {
191
+ docs.map {|doc| Dir.glob(doc)}.flatten.each {|(file, name)|
192
+ FileUtils.cp_r file, "#{root}/#{File.basename(name || file)}", preserve: true, verbose: @verbose
193
+ FileUtils.chmod @opts || 0644, "#{root}/#{File.basename(name || file)}", verbose: @verbose
194
+ }
195
+ }
196
+ end
197
+
198
+ def html (*htmls)
199
+ into("/usr/share/doc/#{package.name}-#{package.version}/html") {
200
+ htmls.map {|html| Dir.glob(html)}.flatten.each {|(file, name)|
201
+ FileUtils.cp_r file, "#{root}/#{File.basename(name || file)}", preserve: true, verbose: @verbose
202
+ FileUtils.chmod @opts || 0644, "#{root}/#{File.basename(name || file)}", verbose: @verbose
203
+ }
204
+ }
205
+ end
206
+
207
+ def man (*mans)
208
+ mans.map {|man| Dir.glob(man)}.flatten.each {|man|
209
+ into("/usr/share/man/man#{man[-1]}") {
210
+ FileUtils.cp_r man, "#{root}/#{File.basename(man)}", preserve: true, verbose: @verbose
211
+ FileUtils.chmod @opts || 0644, "#{root}/#{File.basename(man)}", verbose: @verbose
212
+ }
213
+ }
214
+ end
215
+
216
+ def info (*infos)
217
+ infos.map {|info| Dir.glob(info)}.flatten.each {|info|
218
+ into("/usr/share/info/#{info[-1]}") {
219
+ FileUtils.cp_r info, "#{root}/#{File.basename(info)}", preserve: true, verbose: @verbose
220
+ Packo.sh 'gzip', '-9', "#{root}/#{File.basename(info)}", silent: !@verbose rescue nil
221
+ FileUtils.chmod @opts || 0644, "#{root}/#{File.basename(info)}", verbose: @verbose
222
+ }
223
+ }
224
+ end
225
+
226
+ def sym (link, to)
227
+ FileUtils.mkpath "#{root}/#{File.dirname(to)}"
228
+ FileUtils.ln_sf link, "#{root}/#{to}", verbose: @verbose
229
+ end
230
+
231
+ def hard (link, to)
232
+ FileUtils.mkpath "#{root}/#{File.dirname(to)}"
233
+ FileUtils.ln_f link, "#{root}/#{to}", verbose: @verbose
234
+ end
235
+
236
+ def own (user, group, *files)
237
+ infos.map {|info| Dir.glob(info)}.flatten.each {|info|
238
+ into("/usr/share/info/#{info[-1]}") {
239
+ FileUtils.cp_r info, "#{root}/#{File.basename(info)}", preserve: true, verbose: @verbose
240
+ Packo.sh 'gzip', '-9', "#{root}/#{File.basename(info)}", silent: !@verbose rescue nil
241
+ FileUtils.chmod @opts || 0644, "#{root}/#{File.basename(info)}", verbose: @verbose
242
+ }
243
+ }
244
+ end
245
+
246
+ # TODO: wrappers
247
+ end
248
+
249
+ end