packo 0.0.1.alpha.1

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.
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,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/modules/misc/fetching/gnu'
21
+ require 'packo/rbuild/modules/misc/fetching/sourceforge'
22
+ require 'packo/rbuild/modules/misc/fetching/github'
@@ -0,0 +1,57 @@
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 Misc; module Fetching
21
+
22
+ class Git < Module
23
+ def initialize (package)
24
+ super(package)
25
+
26
+ package.avoid [Fetcher, Unpacker]
27
+
28
+ package.stages.add :fetch, self.method(:fetch), after: :beginning
29
+ end
30
+
31
+ def finalize
32
+ package.stages.delete :fetch, self.method(:fetch)
33
+ end
34
+
35
+ def fetch
36
+ package.stages.callbacks(:fetch).do {
37
+ whole, url, branch, commit = package.source.match(%r[^(\w+://.*?)(?::(.*?))?(?:@(.*?))?$]).to_a
38
+
39
+ package.clean!
40
+ package.create!
41
+
42
+ options = []
43
+ options << '--branch' << branch if branch
44
+ options << '--depth' << '1' if !commit
45
+
46
+ Packo.sh 'git', 'clone', *options, url, package.workdir
47
+
48
+ Do.cd package.workdir
49
+
50
+ if commit
51
+ Packo.sh 'git', 'checkout', commit
52
+ end
53
+ }
54
+ end
55
+ end
56
+
57
+ end; end; end; end; end
@@ -0,0 +1,31 @@
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 Misc
21
+
22
+ Fetcher.register :github do |url, package|
23
+ whole, user, project, file = url.interpolate(package).match(%r{^(.*?)/(.*?)/(.*?)$}).to_a
24
+
25
+ CLI.warn 'Github has problems with certificates in the download page.'
26
+ CLI.warn 'If you are using wget you must add --no-check-certificate to the options.'
27
+
28
+ ["https://github.com/#{user}/#{project}/tarball/#{file}", "#{project}-#{file}.tar.gz"]
29
+ end
30
+
31
+ end; end; end; end
@@ -0,0 +1,59 @@
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 'net/http'
21
+
22
+ module Packo; module RBuild; module Modules; module Misc
23
+
24
+ Fetcher.register :gnu do |url, package|
25
+ whole, name, version = url.interpolate(package).match(%r{^(.*?)/(.*?)$}).to_a
26
+
27
+ packs = Net::HTTP.get(URI.parse("http://ftp.gnu.org/gnu/#{name}/")).scan(
28
+ %r{href="(#{name}-#{version}.*?)"}
29
+ ).flatten.map {|pack|
30
+ URI.decode(pack)
31
+ }.select {|pack|
32
+ !pack.match(%r{(\.sig|/)$})
33
+ }
34
+
35
+ if packs.empty?
36
+ packs = Net::HTTP.get(URI.parse("http://ftp.gnu.org/gnu/#{name}/#{name}-#{version}/")).scan(
37
+ %r{href="(#{name}-#{version}.*?)"}
38
+ ).flatten.map {|pack|
39
+ URI.decode("#{name}-#{version}/#{pack}")
40
+ }.select {|pack|
41
+ !pack.match(%r{(\.sig|/)$})
42
+ }
43
+ end
44
+
45
+ pack = nil
46
+ ['xz', 'lzma', 'bz2', 'gz'].each {|compression|
47
+ pack = packs.find {|pack|
48
+ pack.match(/\.#{compression}$/)
49
+ }
50
+
51
+ break if pack
52
+ }
53
+
54
+ raise RuntimeError.new "No download URL for #{name}-#{version}" if !pack
55
+
56
+ "http://ftp.gnu.org/gnu/#{name}/#{pack}"
57
+ end
58
+
59
+ end; end; end; end
@@ -0,0 +1,51 @@
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 Misc; module Fetching
21
+
22
+ class Mercurial < Module
23
+ def initialize (package)
24
+ super(package)
25
+
26
+ package.avoid [Fetcher, Unpacker]
27
+
28
+ package.stages.add :fetch, self.method(:fetch), after: :beginning
29
+ end
30
+
31
+ def finalize
32
+ package.stages.delete :fetch, self.method(:fetch)
33
+ end
34
+
35
+ def fetch
36
+ package.stages.callbacks(:fetch).do {
37
+ whole, url = package.source.match(%r[^(\w+://.*?)$]).to_a
38
+
39
+ package.clean!
40
+ package.create!
41
+
42
+ options = []
43
+
44
+ Packo.sh 'hg', 'clone', *options, url, package.workdir
45
+
46
+ Do.cd package.workdir
47
+ }
48
+ end
49
+ end
50
+
51
+ end; end; end; end; end
@@ -0,0 +1,47 @@
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 'net/http'
21
+
22
+ module Packo; module RBuild; module Modules; module Misc
23
+
24
+ Fetcher.register :sourceforge, do |url, package|
25
+ whole, project, path = url.interpolate(package).match(%r{^(.*?)/(.*?)$}).to_a
26
+
27
+ body = Net::HTTP.get(URI.parse("http://sourceforge.net/projects/#{project}/files/#{File.dirname(path)}/"))
28
+
29
+ urls = body.scan(%r{href="(.*?#{project}/files/#{path}\..*?/download)"}).select {|(url)|
30
+ url.match(%r{((tar\.(lzma|xz|bz2|gz))|tgz|zip|rar)/download$})
31
+ }.map {|(url)| url}
32
+
33
+ url = nil
34
+ %w(xz lzma bz2 gz tgz zip rar).each {|compression|
35
+ url = urls.find {|url|
36
+ url.match(%r{\.#{compression}/download$})
37
+ }
38
+
39
+ break if url
40
+ }
41
+
42
+ next unless url
43
+
44
+ URI.decode(Net::HTTP.get(URI.parse(url)).match(%r{href="(http://downloads.sourceforge.net.*?)"})[1])
45
+ end
46
+
47
+ end; end; end; end
@@ -0,0 +1,51 @@
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 Misc; module Fetching
21
+
22
+ class Subversion < Module
23
+ def initialize (package)
24
+ super(package)
25
+
26
+ package.avoid [Fetcher, Unpacker]
27
+
28
+ package.stages.add :fetch, self.method(:fetch), after: :beginning
29
+ end
30
+
31
+ def finalize
32
+ package.stages.delete :fetch, self.method(:fetch)
33
+ end
34
+
35
+ def fetch
36
+ package.stages.callbacks(:fetch).do {
37
+ whole, url = package.source.match(%r[^(\w+://.*?)$]).to_a
38
+
39
+ package.clean!
40
+ package.create!
41
+
42
+ options = []
43
+
44
+ Packo.sh 'svn', 'checkout', *options, url, package.workdir
45
+
46
+ Do.cd package.workdir
47
+ }
48
+ end
49
+ end
50
+
51
+ end; end; end; end; end
@@ -0,0 +1,57 @@
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 Fetching
21
+
22
+ class Wget < Module
23
+ def self.fetch (path, to, package={})
24
+ Packo.sh 'wget', '-c', '-O', to, path
25
+ end
26
+
27
+ def self.url (url, package={})
28
+ Packo.interpolate(url, package)
29
+ end
30
+
31
+ def initialize (package)
32
+ super(package)
33
+
34
+ package.stages.add :fetch, self.method(:fetch), after: :beginning
35
+ end
36
+
37
+ def fetch
38
+ version = package.version
39
+
40
+ distfiles = []
41
+ sources = [package.source].flatten.compact.map {|s|
42
+ Wget.url(s, package)
43
+ }
44
+
45
+ package.stages.callbacks(:fetch).do(sources) {
46
+ sources.each {|source|
47
+ distfiles << "#{package.fetchdir || '/tmp'}/#{File.basename(source)}"
48
+
49
+ Wget.fetch source, distfiles.last, package
50
+ }
51
+ }
52
+
53
+ package.distfiles distfiles
54
+ end
55
+ end
56
+
57
+ end; end; end; end
@@ -0,0 +1,70 @@
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 Misc
21
+
22
+ class Unpacker < Module
23
+ @@formats = {}
24
+
25
+ def self.register (type, &block)
26
+ @@formats[type] = block
27
+ end
28
+
29
+ def self.do (path, to=nil)
30
+ block = @@formats.find {|regexp, block|
31
+ path.match(regexp)
32
+ }.last rescue nil
33
+
34
+ if block
35
+ FileUtils.mkpath(to) rescue nil
36
+ block.call(path, to)
37
+ else
38
+ Packo.debug 'Archive format unsupported'
39
+ path
40
+ end
41
+ end
42
+
43
+ def initialize (package)
44
+ super(package)
45
+
46
+ package.stages.add :unpack, self.method(:unpack), after: :fetch, strict: true
47
+
48
+ before :initialize do |package|
49
+ package.define_singleton_method :unpack, &Unpacker.method(:do)
50
+ end
51
+ end
52
+
53
+ def finalize
54
+ package.stages.delete :unpack, self.method(:unpack)
55
+ end
56
+
57
+ def unpack
58
+ package.stages.callbacks(:unpack).do {
59
+ Unpacker.do((package.ditfiles.is_a?(Hash) ?
60
+ package.distfiles[:default] :
61
+ package.distfiles.first
62
+ ).path, "#{package.directory}/work")
63
+
64
+ Dir.chdir package.workdir
65
+ Dir.chdir "#{package.name}-#{package.version}" rescue false
66
+ }
67
+ end
68
+ end
69
+
70
+ end; end; end; end