packo 0.0.1.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/packo +78 -0
- data/bin/packo-base +24 -0
- data/bin/packo-build +24 -0
- data/bin/packo-db +24 -0
- data/bin/packo-env +24 -0
- data/bin/packo-files +24 -0
- data/bin/packo-profile +24 -0
- data/bin/packo-repository +24 -0
- data/bin/packo-select +24 -0
- data/lib/packo.rb +186 -0
- data/lib/packo/cli.rb +79 -0
- data/lib/packo/cli/base.rb +554 -0
- data/lib/packo/cli/build.rb +488 -0
- data/lib/packo/cli/database.rb +55 -0
- data/lib/packo/cli/database/definition.rb +65 -0
- data/lib/packo/cli/database/helpers.rb +20 -0
- data/lib/packo/cli/environment.rb +45 -0
- data/lib/packo/cli/files.rb +153 -0
- data/lib/packo/cli/profile.rb +31 -0
- data/lib/packo/cli/repository.rb +561 -0
- data/lib/packo/cli/repository/binary.rb +74 -0
- data/lib/packo/cli/repository/helpers.rb +20 -0
- data/lib/packo/cli/repository/repository.rb +48 -0
- data/lib/packo/cli/repository/source.rb +91 -0
- data/lib/packo/cli/repository/virtual.rb +53 -0
- data/lib/packo/cli/select.rb +61 -0
- data/lib/packo/do.rb +249 -0
- data/lib/packo/environment.rb +269 -0
- data/lib/packo/extensions.rb +70 -0
- data/lib/packo/flags.rb +64 -0
- data/lib/packo/host.rb +121 -0
- data/lib/packo/models.rb +171 -0
- data/lib/packo/models/installed_package.rb +190 -0
- data/lib/packo/models/installed_package/content.rb +50 -0
- data/lib/packo/models/installed_package/dependency.rb +39 -0
- data/lib/packo/models/repository.rb +209 -0
- data/lib/packo/models/repository/binary.rb +32 -0
- data/lib/packo/models/repository/binary/mirror.rb +35 -0
- data/lib/packo/models/repository/package.rb +73 -0
- data/lib/packo/models/repository/package/binary.rb +34 -0
- data/lib/packo/models/repository/package/binary/build.rb +36 -0
- data/lib/packo/models/repository/package/source.rb +36 -0
- data/lib/packo/models/repository/package/source/feature.rb +36 -0
- data/lib/packo/models/repository/package/source/flavor.rb +36 -0
- data/lib/packo/models/repository/package/virtual.rb +32 -0
- data/lib/packo/models/repository/source.rb +30 -0
- data/lib/packo/models/repository/virtual.rb +30 -0
- data/lib/packo/models/selector.rb +34 -0
- data/lib/packo/models/tag.rb +30 -0
- data/lib/packo/package.rb +239 -0
- data/lib/packo/package/blocker.rb +100 -0
- data/lib/packo/package/blockers.rb +40 -0
- data/lib/packo/package/dependencies.rb +40 -0
- data/lib/packo/package/dependency.rb +100 -0
- data/lib/packo/package/feature.rb +55 -0
- data/lib/packo/package/features.rb +105 -0
- data/lib/packo/package/flavor.rb +101 -0
- data/lib/packo/package/tags.rb +60 -0
- data/lib/packo/package/tags/expression.rb +130 -0
- data/lib/packo/package/tags/expression/group.rb +28 -0
- data/lib/packo/package/tags/expression/logic.rb +48 -0
- data/lib/packo/package/tags/expression/name.rb +28 -0
- data/lib/packo/profile.rb +174 -0
- data/lib/packo/rbuild.rb +22 -0
- data/lib/packo/rbuild/behaviors.rb +20 -0
- data/lib/packo/rbuild/behaviors/default.rb +27 -0
- data/lib/packo/rbuild/feature.rb +64 -0
- data/lib/packo/rbuild/features.rb +65 -0
- data/lib/packo/rbuild/flavor.rb +67 -0
- data/lib/packo/rbuild/module.rb +40 -0
- data/lib/packo/rbuild/modules.rb +27 -0
- data/lib/packo/rbuild/modules/building.rb +24 -0
- data/lib/packo/rbuild/modules/building/autotools.rb +315 -0
- data/lib/packo/rbuild/modules/building/cmake.rb +38 -0
- data/lib/packo/rbuild/modules/building/patch.rb +84 -0
- data/lib/packo/rbuild/modules/building/rake.rb +74 -0
- data/lib/packo/rbuild/modules/building/strip.rb +41 -0
- data/lib/packo/rbuild/modules/misc.rb +26 -0
- data/lib/packo/rbuild/modules/misc/fetcher.rb +177 -0
- data/lib/packo/rbuild/modules/misc/fetching.rb +22 -0
- data/lib/packo/rbuild/modules/misc/fetching/git.rb +57 -0
- data/lib/packo/rbuild/modules/misc/fetching/github.rb +31 -0
- data/lib/packo/rbuild/modules/misc/fetching/gnu.rb +59 -0
- data/lib/packo/rbuild/modules/misc/fetching/mercurial.rb +51 -0
- data/lib/packo/rbuild/modules/misc/fetching/sourceforge.rb +47 -0
- data/lib/packo/rbuild/modules/misc/fetching/subversion.rb +51 -0
- data/lib/packo/rbuild/modules/misc/fetching/wget.rb +57 -0
- data/lib/packo/rbuild/modules/misc/unpacker.rb +70 -0
- data/lib/packo/rbuild/modules/misc/unpacking.rb +23 -0
- data/lib/packo/rbuild/modules/misc/unpacking/lzma.rb +34 -0
- data/lib/packo/rbuild/modules/misc/unpacking/tar.rb +35 -0
- data/lib/packo/rbuild/modules/misc/unpacking/xz.rb +34 -0
- data/lib/packo/rbuild/modules/misc/unpacking/zip.rb +26 -0
- data/lib/packo/rbuild/modules/packaging.rb +20 -0
- data/lib/packo/rbuild/modules/packaging/pko.rb +78 -0
- data/lib/packo/rbuild/package.rb +281 -0
- data/lib/packo/rbuild/package/manifest.rb +169 -0
- data/lib/packo/rbuild/stages.rb +171 -0
- data/lib/packo/rbuild/stages/callbacks.rb +96 -0
- data/lib/packo/rbuild/stages/stage.rb +50 -0
- data/lib/packo/repository.rb +95 -0
- data/lib/packo/repository/binary.rb +116 -0
- data/lib/packo/repository/source.rb +77 -0
- data/lib/packo/repository/virtual.rb +66 -0
- data/lib/packo/system.rb +53 -0
- data/lib/packo/version.rb +26 -0
- metadata +276 -0
data/lib/packo/rbuild.rb
ADDED
@@ -0,0 +1,22 @@
|
|
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/rbuild/package'
|
21
|
+
require 'packo/rbuild/modules'
|
22
|
+
require 'packo/rbuild/behaviors'
|
@@ -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/rbuild/behaviors/default'
|
@@ -0,0 +1,27 @@
|
|
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 RBuild; module Behaviors
|
21
|
+
|
22
|
+
Default = [
|
23
|
+
Modules::Misc::Fetcher, Modules::Misc::Unpacker,
|
24
|
+
Modules::Building::Patch, Modules::Building::Autotools, Modules::Building::Strip
|
25
|
+
]
|
26
|
+
|
27
|
+
end; end; end
|
@@ -0,0 +1,64 @@
|
|
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/package/feature'
|
21
|
+
|
22
|
+
module Packo; module RBuild
|
23
|
+
|
24
|
+
class Feature < Packo::Package::Feature
|
25
|
+
include Stages::Callable
|
26
|
+
|
27
|
+
attr_reader :package, :name, :block, :dependencies
|
28
|
+
|
29
|
+
def initialize (package, name, enabled=false, &block)
|
30
|
+
super(name, enabled)
|
31
|
+
|
32
|
+
@package = package
|
33
|
+
@dependencies = []
|
34
|
+
|
35
|
+
if Features::Default[self.name.to_sym]
|
36
|
+
Features::Default[self.name.to_sym].each {|feature|
|
37
|
+
self.instance_exec(self, &feature)
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
self.do(&block)
|
42
|
+
end
|
43
|
+
|
44
|
+
def do (&block)
|
45
|
+
self.instance_exec(self, &block) if block
|
46
|
+
self
|
47
|
+
end
|
48
|
+
|
49
|
+
def needs (*names)
|
50
|
+
if names.first == :not
|
51
|
+
names[1, names.length].each {|name|
|
52
|
+
@dependencies.delete(name)
|
53
|
+
}
|
54
|
+
else
|
55
|
+
@dependencies = @dependencies.concat(names).flatten.compact.uniq
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def method_missing (id, *args, &block)
|
60
|
+
@package.send id, *args, &block
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end; end
|
@@ -0,0 +1,65 @@
|
|
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/package/features'
|
21
|
+
|
22
|
+
require 'packo/rbuild/feature'
|
23
|
+
|
24
|
+
module Packo; module RBuild
|
25
|
+
|
26
|
+
class Features < Packo::Package::Features
|
27
|
+
Default = Class.new(Hash) {
|
28
|
+
def define (name, &block)
|
29
|
+
(self[name.to_sym] ||= []) << block
|
30
|
+
end
|
31
|
+
}.new
|
32
|
+
|
33
|
+
attr_reader :package
|
34
|
+
|
35
|
+
def initialize (package, values={})
|
36
|
+
super(values)
|
37
|
+
|
38
|
+
@package = package
|
39
|
+
|
40
|
+
yield self if block_given?
|
41
|
+
end
|
42
|
+
|
43
|
+
def method_missing (id, *args, &block)
|
44
|
+
case id.to_s
|
45
|
+
when /^(.+?)\?$/ then (@values[$1.to_sym] || Feature.new(@package, $1, false)).enabled?
|
46
|
+
when /^not_(.+?)!$/ then (@values[$1.to_sym] ||= Feature.new(@package, $1, false)).disable!
|
47
|
+
when /^(.+?)!$/ then (@values[$1.to_sym] ||= Feature.new(@package, $1, false)).enable!
|
48
|
+
when /^(.+?)$/ then (@values[$1.to_sym] ||= Feature.new(@package, $1, false)).do(&block)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def set (name, &block)
|
53
|
+
@values[name.to_sym] = Feature.new(@package, name, &block)
|
54
|
+
end
|
55
|
+
|
56
|
+
def get (name)
|
57
|
+
@values[name.to_sym] ||= Feature.new(@package, name, false)
|
58
|
+
end
|
59
|
+
|
60
|
+
def delete (name)
|
61
|
+
@values.delete(name.to_sym)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end; end
|
@@ -0,0 +1,67 @@
|
|
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/package/flavor'
|
21
|
+
|
22
|
+
require 'packo/rbuild/feature'
|
23
|
+
|
24
|
+
module Packo; module RBuild
|
25
|
+
|
26
|
+
class Flavor < Packo::Package::Flavor
|
27
|
+
Default = Class.new(Hash) {
|
28
|
+
def define (name, &block)
|
29
|
+
(self[name.to_sym] ||= []) << block
|
30
|
+
end
|
31
|
+
}.new
|
32
|
+
|
33
|
+
attr_reader :package
|
34
|
+
|
35
|
+
def initialize (package, values={})
|
36
|
+
super(values)
|
37
|
+
|
38
|
+
@package = package
|
39
|
+
|
40
|
+
yield self if block_given?
|
41
|
+
end
|
42
|
+
|
43
|
+
def method_missing (id, *args, &block)
|
44
|
+
case id.to_s
|
45
|
+
when /^(.+?)\?$/ then (@values[$1.to_sym] || Feature.new(@package, $1, false)).enabled?
|
46
|
+
when /^not_(.+?)!$/ then (@values[$1.to_sym] ||= Feature.new(@package, $1, false)).disable!
|
47
|
+
when /^(.+?)!$/ then (@values[$1.to_sym] ||= Feature.new(@package, $1, false)).enable!
|
48
|
+
when /^(.+?)$/ then (@values[$1.to_sym] ||= Feature.new(@package, $1, false)).do(&block)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def set (name, &block)
|
53
|
+
@values[name.to_sym] = Feature.new(@package, name, &block)
|
54
|
+
end
|
55
|
+
|
56
|
+
def get (name)
|
57
|
+
@values[name.to_sym] ||= Feature.new(@package, name, false)
|
58
|
+
end
|
59
|
+
|
60
|
+
def delete (name)
|
61
|
+
@values.delete(name.to_sym)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
end; end
|
@@ -0,0 +1,40 @@
|
|
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 RBuild
|
21
|
+
|
22
|
+
class Module
|
23
|
+
include Stages::Callable
|
24
|
+
|
25
|
+
class Helper
|
26
|
+
attr_accessor :package
|
27
|
+
|
28
|
+
def initialize (package)
|
29
|
+
@package = package
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
attr_reader :package
|
34
|
+
|
35
|
+
def initialize (package)
|
36
|
+
@package = package
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end; end
|
@@ -0,0 +1,27 @@
|
|
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/rbuild/module'
|
21
|
+
|
22
|
+
require 'packo/rbuild/modules/building'
|
23
|
+
require 'packo/rbuild/modules/packaging'
|
24
|
+
require 'packo/rbuild/modules/misc'
|
25
|
+
|
26
|
+
require 'packo/rbuild/modules/misc/fetching'
|
27
|
+
require 'packo/rbuild/modules/misc/unpacking'
|
@@ -0,0 +1,24 @@
|
|
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/rbuild/modules/building/autotools'
|
21
|
+
require 'packo/rbuild/modules/building/cmake'
|
22
|
+
require 'packo/rbuild/modules/building/rake'
|
23
|
+
require 'packo/rbuild/modules/building/patch'
|
24
|
+
require 'packo/rbuild/modules/building/strip'
|
@@ -0,0 +1,315 @@
|
|
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 RBuild; module Modules; module Building
|
21
|
+
|
22
|
+
class Autotools < Module
|
23
|
+
class Configuration
|
24
|
+
attr_accessor :path
|
25
|
+
|
26
|
+
attr_reader :module
|
27
|
+
|
28
|
+
def initialize (mod=nil)
|
29
|
+
@module = mod
|
30
|
+
|
31
|
+
@enable = {}
|
32
|
+
@with = {}
|
33
|
+
@other = {}
|
34
|
+
|
35
|
+
@path = './configure'
|
36
|
+
end
|
37
|
+
|
38
|
+
def clear
|
39
|
+
@enable.clear
|
40
|
+
@with.clear
|
41
|
+
@other.clear
|
42
|
+
end
|
43
|
+
|
44
|
+
def with (name, value=nil)
|
45
|
+
[name].flatten.each {|name|
|
46
|
+
if value === true || value === false
|
47
|
+
@with[name.to_s] = value
|
48
|
+
else
|
49
|
+
@with[name.to_s] = value || true
|
50
|
+
end
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def without (name, value=nil)
|
55
|
+
[name].flatten.each {|name|
|
56
|
+
if value === true || value === false
|
57
|
+
@with[name.to_s] = !value
|
58
|
+
else
|
59
|
+
@with[name.to_s] = false
|
60
|
+
end
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
def enable (name, value=nil)
|
65
|
+
[name].flatten.each {|name|
|
66
|
+
if value === true || value === false
|
67
|
+
@enable[name.to_s] = value
|
68
|
+
else
|
69
|
+
@enable[name.to_s] = value || true
|
70
|
+
end
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
def disable (name, value=nil)
|
75
|
+
[name].flatten.each {|name|
|
76
|
+
if value === true || value === false
|
77
|
+
@enable[name.to_s] = !value
|
78
|
+
else
|
79
|
+
@enable[name.to_s] = false
|
80
|
+
end
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
def set (name, value)
|
85
|
+
@other[name.to_s] = value.to_s
|
86
|
+
end
|
87
|
+
|
88
|
+
def get (name)
|
89
|
+
@other[name.to_s]
|
90
|
+
end
|
91
|
+
|
92
|
+
def delete (from, *names)
|
93
|
+
names.flatten.each {|name|
|
94
|
+
case from.to_sym
|
95
|
+
when :with; @with.delete(name.to_s)
|
96
|
+
when :enable; @enable.delete(name.to_s)
|
97
|
+
when :other; @other.delete(name.to_s)
|
98
|
+
end
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
def to_s
|
103
|
+
result = ''
|
104
|
+
|
105
|
+
@enable.each {|name, value|
|
106
|
+
case value
|
107
|
+
when true; result += "--enable-#{name} "
|
108
|
+
when false; result += "--disable-#{name} "
|
109
|
+
else; result += "--enable-#{name}='#{value}' "
|
110
|
+
end
|
111
|
+
}
|
112
|
+
|
113
|
+
@with.each {|name, value|
|
114
|
+
case value
|
115
|
+
when true; result += "--with-#{name} "
|
116
|
+
when false; result += "--without-#{name} "
|
117
|
+
else; result += "--with-#{name}='#{value}' "
|
118
|
+
end
|
119
|
+
}
|
120
|
+
|
121
|
+
@other.each {|name, value|
|
122
|
+
result += "--#{name}='#{value}' "
|
123
|
+
}
|
124
|
+
|
125
|
+
return result
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def initialize (package)
|
130
|
+
super(package)
|
131
|
+
|
132
|
+
package.stages.add :configure, self.method(:configure), after: :fetch
|
133
|
+
package.stages.add :compile, self.method(:compile), after: :configure
|
134
|
+
package.stages.add :install, self.method(:install), after: :compile
|
135
|
+
|
136
|
+
if package.type == 'library'
|
137
|
+
package.filesystem.post << FFFS::File.new('ld-config-update.sh', %{
|
138
|
+
#! /bin/sh
|
139
|
+
ldconfig
|
140
|
+
})
|
141
|
+
end
|
142
|
+
|
143
|
+
before :pack do
|
144
|
+
slot = package.slot.to_s
|
145
|
+
|
146
|
+
if package.host != package.target
|
147
|
+
slot << '-' unless slot.empty?
|
148
|
+
slot << package.target.to_s
|
149
|
+
end
|
150
|
+
|
151
|
+
package.slot = slot
|
152
|
+
end
|
153
|
+
|
154
|
+
if Environment[:CROSS]
|
155
|
+
package.host = Host.new(System.env!)
|
156
|
+
else
|
157
|
+
package.host = Host.new(package.environment)
|
158
|
+
end
|
159
|
+
|
160
|
+
package.target = Host.new(package.environment)
|
161
|
+
|
162
|
+
package.environment[:CHOST] = package.host.to_s
|
163
|
+
package.environment[:CTARGET] = package.target.to_s
|
164
|
+
|
165
|
+
package.autotools = Class.new(Module::Helper) {
|
166
|
+
def initialize (package)
|
167
|
+
super(package)
|
168
|
+
|
169
|
+
@versions = {}
|
170
|
+
@enabled = true
|
171
|
+
@forced = false
|
172
|
+
end
|
173
|
+
|
174
|
+
def enabled?; @enabled end
|
175
|
+
def disabled?; !@enabled end
|
176
|
+
def enable!; @enabled = true end
|
177
|
+
def disable!; @enabled = false end
|
178
|
+
|
179
|
+
def forced?; @forced end
|
180
|
+
def force!; @forced = true end
|
181
|
+
|
182
|
+
def configure (conf)
|
183
|
+
package.environment.sandbox {
|
184
|
+
Packo.sh "#{conf.path} #{conf}"
|
185
|
+
}
|
186
|
+
end
|
187
|
+
|
188
|
+
def autogen
|
189
|
+
self.autoreconf '-i'
|
190
|
+
self.autoheader
|
191
|
+
self.automake
|
192
|
+
end
|
193
|
+
|
194
|
+
def autoreconf (*args)
|
195
|
+
version = args.last.is_a?(Numeric) ? args.pop : nil
|
196
|
+
|
197
|
+
package.environment.sandbox {
|
198
|
+
Packo.sh "autoreconf#{"-#{version}" if version}", *args
|
199
|
+
}
|
200
|
+
end
|
201
|
+
|
202
|
+
def aclocal (*args)
|
203
|
+
version = args.last.is_a?(Numeric) ? args.pop : @versions[:aclocal]
|
204
|
+
|
205
|
+
package.environment.sandbox {
|
206
|
+
Packo.sh "aclocal#{"-#{version}" if version}", *args
|
207
|
+
}
|
208
|
+
end
|
209
|
+
|
210
|
+
def autoconf (*args)
|
211
|
+
version = args.last.is_a?(Numeric) ? args.pop : @versions[:autoconf]
|
212
|
+
|
213
|
+
package.environment.sandbox {
|
214
|
+
Packo.sh "autoconf#{"-#{version}" if version}", *args
|
215
|
+
}
|
216
|
+
end
|
217
|
+
|
218
|
+
def autoheader (*args)
|
219
|
+
version = args.last.is_a?(Numeric) ? args.pop : @versions[:autoheader]
|
220
|
+
|
221
|
+
package.environment.sandbox {
|
222
|
+
Packo.sh "autoheader#{"-#{version}" if version}", *args
|
223
|
+
}
|
224
|
+
end
|
225
|
+
|
226
|
+
def automake (*args)
|
227
|
+
version = args.last.is_a?(Numeric) ? args.pop : @versions[:automake]
|
228
|
+
|
229
|
+
package.environment.sandbox {
|
230
|
+
Packo.sh "automake#{"-#{version}" if version}", *args
|
231
|
+
}
|
232
|
+
end
|
233
|
+
|
234
|
+
def autoupdate (*args)
|
235
|
+
version = args.last.is_a?(Numeric) ? args.pop : @versions[:autoupdate]
|
236
|
+
|
237
|
+
package.environment.sandbox {
|
238
|
+
Packo.sh "autoupdate#{"-#{version}" if version}", *args
|
239
|
+
}
|
240
|
+
end
|
241
|
+
|
242
|
+
def make (*args)
|
243
|
+
package.environment.sandbox {
|
244
|
+
Packo.sh 'make', *args
|
245
|
+
}
|
246
|
+
end
|
247
|
+
|
248
|
+
def install (path=nil, *args)
|
249
|
+
package.environment.sandbox(DESTDIR: path || package.distdir) {
|
250
|
+
puts ENV['DESTDIR']
|
251
|
+
|
252
|
+
self.make "DESTDIR=#{path || package.distdir}", 'install', *args
|
253
|
+
}
|
254
|
+
end
|
255
|
+
|
256
|
+
def version (name, slot=nil)
|
257
|
+
slot ? @versions[name.to_sym] = slot : @versions[name.to_sym]
|
258
|
+
end
|
259
|
+
}.new(package)
|
260
|
+
end
|
261
|
+
|
262
|
+
def finalize
|
263
|
+
package.stages.delete :configure, self.method(:configure)
|
264
|
+
package.stages.delete :compile, self.method(:compile)
|
265
|
+
package.stages.delete :install, self.method(:install)
|
266
|
+
end
|
267
|
+
|
268
|
+
def configure
|
269
|
+
@configuration = Configuration.new(self)
|
270
|
+
|
271
|
+
@configuration.set 'prefix', (System.env[:INSTALL_PATH] + '/usr').cleanpath
|
272
|
+
@configuration.set 'sysconfdir', (System.env[:INSTALL_PATH] + '/etc').cleanpath
|
273
|
+
@configuration.set 'sharedstatedir', (System.env[:INSTALL_PATH] + '/com').cleanpath
|
274
|
+
@configuration.set 'localstatedir', (System.env[:INSTALL_PATH] + '/var').cleanpath
|
275
|
+
|
276
|
+
@configuration.set 'host', package.host
|
277
|
+
@configuration.set 'build', package.host
|
278
|
+
|
279
|
+
if package.host != package.target
|
280
|
+
@configuration.set 'target', package.target
|
281
|
+
end
|
282
|
+
|
283
|
+
package.stages.callbacks(:configure).do(@configuration) {
|
284
|
+
next if package.autotools.disabled?
|
285
|
+
|
286
|
+
if !File.exists? @configuration.path
|
287
|
+
Do.cd(File.dirname(@configuration.path)) {
|
288
|
+
package.autotools.autogen
|
289
|
+
}
|
290
|
+
end
|
291
|
+
|
292
|
+
if !File.exists?('Makefile') || package.autotools.forced?
|
293
|
+
package.autotools.configure(@configuration)
|
294
|
+
end
|
295
|
+
}
|
296
|
+
end
|
297
|
+
|
298
|
+
def compile
|
299
|
+
package.stages.callbacks(:compile).do(@configuration) {
|
300
|
+
next if package.autotools.disabled?
|
301
|
+
|
302
|
+
package.autotools.make "-j#{package.environment['MAKE_JOBS']}"
|
303
|
+
}
|
304
|
+
end
|
305
|
+
|
306
|
+
def install
|
307
|
+
package.stages.callbacks(:install).do(@configuration) {
|
308
|
+
next if package.autotools.disabled?
|
309
|
+
|
310
|
+
package.autotools.install
|
311
|
+
}
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
end; end; end; end
|