ratch 0.4.1 → 1.0.0

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/COPYING +17 -669
  2. data/HISTORY +6 -0
  3. data/MANIFEST +36 -0
  4. data/METADATA +14 -0
  5. data/NEWS +7 -0
  6. data/README +67 -17
  7. data/bin/ratch +5 -78
  8. data/demo/tryme-task.ratch +12 -0
  9. data/demo/tryme1.ratch +6 -0
  10. data/lib/ratch/core_ext.rb +6 -0
  11. data/lib/ratch/core_ext/facets.rb +1 -0
  12. data/lib/ratch/core_ext/filetest.rb +52 -0
  13. data/lib/ratch/core_ext/object.rb +8 -0
  14. data/lib/ratch/core_ext/pathname.rb +38 -0
  15. data/lib/ratch/core_ext/string.rb +44 -0
  16. data/lib/ratch/{dsl/console.rb → core_ext/to_console.rb} +2 -76
  17. data/lib/ratch/core_ext/to_list.rb +29 -0
  18. data/lib/ratch/dsl.rb +494 -49
  19. data/lib/ratch/index.rb +4 -0
  20. data/lib/ratch/io.rb +116 -0
  21. data/lib/ratch/pathglob.rb +73 -0
  22. data/lib/ratch/plugin.rb +55 -0
  23. data/lib/ratch/runmode.rb +69 -0
  24. data/lib/ratch/script.rb +52 -0
  25. data/lib/ratch/service.rb +33 -0
  26. data/lib/ratch/task.rb +249 -0
  27. data/lib/ratch/task2.rb +298 -0
  28. data/test/README +1 -0
  29. data/test/test_helper.rb +4 -0
  30. data/test/test_task.rb +46 -0
  31. metadata +90 -150
  32. data/CHANGES +0 -22
  33. data/TODO +0 -2
  34. data/bin/lt +0 -56
  35. data/bin/ludo +0 -14
  36. data/bin/manifest +0 -451
  37. data/bin/ratch-find +0 -21
  38. data/demo/WILMA +0 -1
  39. data/demo/XR +0 -9
  40. data/demo/lib/foo/foo.rb +0 -7
  41. data/demo/p.rb +0 -9
  42. data/demo/r.rb +0 -6
  43. data/demo/t.rb +0 -3
  44. data/demo/task/config.yaml +0 -4
  45. data/demo/task/one +0 -6
  46. data/demo/task/simplebuild +0 -15
  47. data/demo/task/stats +0 -4
  48. data/demo/task/task +0 -6
  49. data/demo/task/tryme +0 -10
  50. data/lib/ratch/dsl/argv.rb +0 -112
  51. data/lib/ratch/dsl/batch.rb +0 -232
  52. data/lib/ratch/dsl/build.rb +0 -174
  53. data/lib/ratch/dsl/email.rb +0 -108
  54. data/lib/ratch/dsl/file.rb +0 -205
  55. data/lib/ratch/dsl/meta.rb +0 -125
  56. data/lib/ratch/dsl/options.rb +0 -98
  57. data/lib/ratch/dsl/setup.rb +0 -124
  58. data/lib/ratch/dsl/sign.rb +0 -243
  59. data/lib/ratch/dsl/stage.rb +0 -147
  60. data/lib/ratch/dsl/task.rb +0 -139
  61. data/lib/ratch/dsl/upload.rb +0 -436
  62. data/lib/ratch/dsl/zip.rb +0 -59
  63. data/lib/ratch/extra/email.rb +0 -5
  64. data/lib/ratch/extra/stage.rb +0 -5
  65. data/lib/ratch/extra/zip.rb +0 -5
  66. data/lib/ratch/manager.rb +0 -53
  67. data/lib/ratch/manifest.rb +0 -540
  68. data/lib/ratch/metadata/information.rb +0 -258
  69. data/lib/ratch/metadata/package.rb +0 -108
  70. data/lib/ratch/metadata/project.rb +0 -523
  71. data/lib/ratch/metadata/release.rb +0 -108
  72. data/lib/ratch/support/errors.rb +0 -4
  73. data/lib/ratch/support/filename.rb +0 -18
  74. data/lib/ratch/support/filetest.rb +0 -29
  75. data/lib/ratch/toolset/ruby/announce +0 -224
  76. data/lib/ratch/toolset/ruby/compile +0 -49
  77. data/lib/ratch/toolset/ruby/install +0 -77
  78. data/lib/ratch/toolset/ruby/notes +0 -185
  79. data/lib/ratch/toolset/ruby/pack/gem +0 -93
  80. data/lib/ratch/toolset/ruby/pack/tgz +0 -46
  81. data/lib/ratch/toolset/ruby/pack/zip +0 -46
  82. data/lib/ratch/toolset/ruby/publish +0 -57
  83. data/lib/ratch/toolset/ruby/release +0 -8
  84. data/lib/ratch/toolset/ruby/setup +0 -1616
  85. data/lib/ratch/toolset/ruby/stamp +0 -33
  86. data/lib/ratch/toolset/ruby/stats +0 -138
  87. data/lib/ratch/toolset/ruby/test/crosstest +0 -305
  88. data/lib/ratch/toolset/ruby/test/extest +0 -129
  89. data/lib/ratch/toolset/ruby/test/isotest +0 -293
  90. data/lib/ratch/toolset/ruby/test/load +0 -39
  91. data/lib/ratch/toolset/ruby/test/loadtest +0 -28
  92. data/lib/ratch/toolset/ruby/test/syntax +0 -29
  93. data/lib/ratch/toolset/ruby/test/test +0 -26
  94. data/lib/ratch/toolset/sandbox/query +0 -11
  95. data/man/ratch.man +0 -73
  96. data/meta/MANIFEST +0 -130
  97. data/meta/config.yaml +0 -9
  98. data/meta/icli.yaml +0 -16
  99. data/meta/project.yaml +0 -20
  100. data/meta/ratch.roll +0 -2
  101. data/meta/xProjectInfo +0 -41
  102. data/task/clobber/package +0 -10
  103. data/task/man +0 -14
  104. data/task/publish +0 -57
  105. data/task/release +0 -9
  106. data/task/setup +0 -1616
  107. data/task/stats +0 -138
@@ -1,258 +0,0 @@
1
- # = TITLE:
2
- #
3
- # Information
4
- #
5
- # = COPYING:
6
- #
7
- # Copyright (c) 2007 Psi T Corp.
8
- #
9
- # This file is part of the ProUtils' Ratch program.
10
- #
11
- # Ratch is free software: you can redistribute it and/or modify
12
- # it under the terms of the GNU General Public License as published by
13
- # the Free Software Foundation, either version 3 of the License, or
14
- # (at your option) any later version.
15
- #
16
- # Ratch is distributed in the hope that it will be useful,
17
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- # GNU General Public License for more details.
20
- #
21
- # You should have received a copy of the GNU General Public License
22
- # along with Ratch. If not, see <http://www.gnu.org/licenses/>.
23
-
24
- require 'yaml'
25
- require 'facets/hash/rekey'
26
-
27
-
28
- module Ratch
29
-
30
- # Validation Error
31
- class ValidationError < Exception
32
- end
33
-
34
- #
35
-
36
- class Information
37
-
38
- class << self
39
-
40
- def instance_attributes
41
- @attributes ||= []
42
- end
43
-
44
- # Define an attribute.
45
-
46
- def attr_accessor(name, *aliases, &blk)
47
- instance_attributes << name.to_s
48
- instance_attributes.uniq!
49
- if blk
50
- define_method(name, &blk)
51
- attr_writer(name)
52
- else
53
- super(name)
54
- end
55
- aliases.each{ |aliaz| alias_accessor(aliaz, name) }
56
- end
57
-
58
- # Define an attribute alias.
59
-
60
- def alias_accessor(aliaz, name)
61
- alias_method aliaz, name
62
- alias_method "#{aliaz}=", "#{name}="
63
- end
64
-
65
- def validation
66
- @validation ||= []
67
- end
68
-
69
- def validate(message, &block)
70
- validation << [message, block]
71
- end
72
-
73
- # Does this class provide open access?
74
- #
75
- #def open_access?
76
- # false
77
- #end
78
-
79
- end
80
-
81
-
82
- def instance_data
83
- @instance_data ||= {}
84
- end
85
-
86
- # List attributes. (Needed?)
87
-
88
- def attributes
89
- self.class.instance_attributes
90
- end
91
-
92
-
93
- # Initialize
94
- ####################
95
-
96
- def initialize(data={})
97
- update(data)
98
- end
99
-
100
- def update(data)
101
- instance_data.update(data.rekey(:to_s))
102
-
103
- data.each do |k,v|
104
- send("#{k}=", v) rescue nil
105
- end
106
-
107
- # TODO Could add yield(self) via:
108
- #yld.to_h.each do |k,v|
109
- # send( "#{k}=", v ) rescue nil
110
- #end
111
- end
112
-
113
-
114
- # Access
115
- ####################
116
-
117
- # Fetch attribute value, but return nil if it doesn't exist.
118
- #--
119
- # TODO Use in method missing instead?
120
- #++
121
-
122
- def [](name)
123
- begin
124
- h = send(name)
125
- rescue NoMethodError
126
- h = nil
127
- end
128
- end
129
-
130
- # Gathers a group of info hash entries into a merged hash.
131
- # The +names+ are taken in most to least significant order.
132
- #
133
- # gather(:package)
134
- #
135
- # TODO Change name of this method to something better?
136
-
137
- def gather( *names )
138
- result = names.inject({}) do |hash,name|
139
- attributes.each do |n|
140
- if n.to_s =~ /^#{name}_(.*?)$/
141
- hash[$1] = self[n.to_s] if self[n.to_s]
142
- end
143
- end
144
- hash
145
- end
146
- result
147
- end
148
-
149
- # Collects a group of info entries into a hash.
150
- # Arguments are a list of info entry names and/or
151
- # a hash or new name to info entry name.
152
- #
153
- # select(:name, :version, :date => :released)
154
- #
155
- # This is used to collect info to pass to tools.
156
-
157
- def select( *args )
158
- maps = (Hash === args.last ? args.pop : {})
159
- h = {}
160
- args.each{ |k| h[k.to_s] = self[k] }
161
- maps.each{ |k, i| h[k.to_s] = self[i] }
162
- h
163
- end
164
-
165
-
166
- # Validation
167
- ######################
168
-
169
- #
170
- def valid?
171
- begin
172
- validate
173
- return true
174
- rescue ValidationError
175
- return false
176
- end
177
- end
178
-
179
- #
180
- def validate
181
- self.class.validation.each do |message, block|
182
- raise(ValidationError, message) unless instance_eval(&block)
183
- end
184
- end
185
-
186
- alias_method :assert_valid, :validate
187
-
188
-
189
- # Conversion
190
- #################
191
-
192
- # Order of attributes for yaml conversion.
193
-
194
- def to_yaml_properties
195
- attributes.collect{ |a| "@#{a}" }
196
- end
197
-
198
- # Use YAML format.
199
-
200
- def to_yaml( opts={} )
201
- require 'yaml'
202
- super
203
- end
204
-
205
- # For yaml conversion, no tag.
206
-
207
- def taguri; nil; end
208
-
209
- # Convert to hash.
210
-
211
- def to_hash
212
- attributes.inject({}) do |h, a|
213
- v = self[a.to_s] #send(a)
214
- h[a] = v unless v.nil?
215
- h
216
- end
217
- end
218
- alias_method :to_h, :to_hash
219
-
220
- # Use generic XML format.
221
-
222
- def to_xml( opts={} )
223
- raise "not yet implemented"
224
- end
225
-
226
- # # Use XOXO microformat.
227
- #
228
- # def to_xoxo( opts={} )
229
- # begin
230
- # require 'blow/xoxo' # EXTERNAL DEPENDENCY!
231
- # rescue LoadError
232
- # puts 'Blow (http://blow.rubyforge.org) is required to use XOXO format'
233
- # end
234
- # XOXO.dump(self.to_hash, opts)
235
- # end
236
-
237
-
238
- # Arbitrary information
239
- ############################
240
-
241
- # # TODO Perhaps not define this at all if open_access? is false.
242
- #
243
- # def method_missing( s, *a, &b )
244
- # super unless self.class.open_access?
245
- # s = s.to_s
246
- # if s[-1,1] == '='
247
- # (class << self; self; end).class_eval do
248
- # attr_accessor s.chomp('=')
249
- # end
250
- # send(s,*a,&b)
251
- # else
252
- # nil #super
253
- # end
254
- # end
255
-
256
- end
257
-
258
- end
@@ -1,108 +0,0 @@
1
- # = TITLE:
2
- #
3
- # Package
4
- #
5
- # = COPYING:
6
- #
7
- # Copyright (c) 2007 Psi T Corp.
8
- #
9
- # This file is part of the ProUtils' Ratch program.
10
- #
11
- # Ratch is free software: you can redistribute it and/or modify
12
- # it under the terms of the GNU General Public License as published by
13
- # the Free Software Foundation, either version 3 of the License, or
14
- # (at your option) any later version.
15
- #
16
- # Ratch is distributed in the hope that it will be useful,
17
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- # GNU General Public License for more details.
20
- #
21
- # You should have received a copy of the GNU General Public License
22
- # along with Ratch. If not, see <http://www.gnu.org/licenses/>.
23
-
24
- require 'ratch/metadata/project'
25
- require 'ratch/metadata/release'
26
-
27
-
28
- module Ratch
29
-
30
- # = Package Class
31
- #
32
- # Package class contains projectinformation but also
33
- # release information such as current version and release date.
34
- #
35
- # Release information is delgated to the Release class via method_missing.
36
-
37
- class Package < Project
38
-
39
- def self.load
40
- package = super
41
- package.release = Release.load
42
- package
43
- end
44
-
45
- # Overrides Project#name.
46
- # TODO: Is this what we want ?
47
-
48
- def name
49
- @name ||= release.name
50
- end
51
-
52
- # List of project files included in package.
53
- #
54
- # TODO: Read from MANIFEST ?
55
-
56
- #attr_accessor :filelist
57
-
58
- # Package format of this package (tar.gz, zip, gem, deb, etc.)
59
- # For a package this is purely informational.
60
-
61
- attr_accessor :format, :type
62
-
63
- # Release information.
64
-
65
- attr_accessor :release
66
-
67
- # Delegate to release.
68
-
69
- def method_missing(s, *a, &b)
70
- if release.respond_to?(s)
71
- release.send(s, *a, &b)
72
- else
73
- super
74
- end
75
- end
76
-
77
- # Package name is generally in the form of +name-version+, or
78
- # +name-version-platform+ if +platform+ is specified.
79
- #
80
- # Template can be used to modify the name via sprintf. The defaults
81
- # is "%s-%s" for name-version or "%s-%s-%s for name-version-platform.
82
-
83
- def package_name(template=nil)
84
- unless template
85
- template = platform ? "%s-%s-%s" : "%s-%s"
86
- end
87
-
88
- if buildno # TODO Make this better.
89
- buildno = Time.now.strftime("%H*60+%M")
90
- versnum = "#{version}.#{buildno}"
91
- else
92
- versnum = version
93
- end
94
-
95
- template % [ name, versnum, platform ]
96
- end
97
-
98
- alias_method :stage_name, :package_name
99
-
100
- #
101
-
102
- #validate "release isnt valid" do
103
- # release.validate
104
- #end
105
-
106
- end
107
-
108
- end
@@ -1,523 +0,0 @@
1
- # = TITLE:
2
- #
3
- # Project
4
- #
5
- # = COPYING:
6
- #
7
- # Copyright (c) 2007 Psi T Corp.
8
- #
9
- # This file is part of the ProUtils' Ratch program.
10
- #
11
- # Ratch is free software: you can redistribute it and/or modify
12
- # it under the terms of the GNU General Public License as published by
13
- # the Free Software Foundation, either version 3 of the License, or
14
- # (at your option) any later version.
15
- #
16
- # Ratch is distributed in the hope that it will be useful,
17
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- # GNU General Public License for more details.
20
- #
21
- # You should have received a copy of the GNU General Public License
22
- # along with Ratch. If not, see <http://www.gnu.org/licenses/>.
23
-
24
- require 'facets/filelist'
25
- require 'ratch/metadata/information'
26
-
27
-
28
- module Ratch
29
-
30
- # = Project class
31
- #
32
- # The Project class contains three sets of metadata. The first is the
33
- # typical general information about a project --title, description, homepage, etc.
34
- # This information is essentially static. Once set, it will probably never vary.
35
- # The second is default packaging informaiton. These both come from the General base
36
- # class. The third set is default build information, which may vary well for various
37
- # packages types, as this information may need to be overridden for specific
38
- # platform builds and package formats. This information describes how to
39
- # pack this project into various packages. Hecne it does not belong to the Package
40
- # class itself.
41
- #
42
- # General class is the base class of both the Project and Package classes.
43
- # The class contains typical general information about a project/package, such
44
- # as title, description, homepage, etc. This information is essentially static.
45
- # Once set, it will probably will never vary. The class also contains *defaults*
46
- # for package informaiton --information that is often static, but may vary
47
- # for a partciular package platform or format. A good example is the platform
48
- # attribute.
49
-
50
- class Project < Information
51
-
52
- PROJECT_FILE = '{,meta/}{project,package,index}{.yaml,.yml,}'
53
-
54
- def self.load
55
- location = Dir.pwd # ???
56
- file = Dir.glob(PROJECT_FILE, File::FNM_CASEFOLD).first
57
- if file
58
- data = YAML::load(File.open(file))
59
- new(location, data)
60
- else
61
- raise LoadError, "project file required -- #{PROJECT_FILE}"
62
- end
63
- end
64
-
65
- # New Project.
66
-
67
- def initialize(location, data={})
68
- @location = location
69
- super(data)
70
- end
71
-
72
- # Location is needed to calculate some conventional defaults.
73
-
74
- attr_accessor :location
75
-
76
-
77
- # General
78
- #------------------------------------------------------------------------
79
-
80
- # The title of the project (free-form, defaults to name).
81
- attr_accessor :title do
82
- @title || (
83
- name if respond_to?(:name)
84
- )
85
- end
86
-
87
- # Subtitle is limited to 60 characters.
88
- attr_accessor :subtitle do
89
- @subtitle.to_s[0..59]
90
- end
91
-
92
- # Brief one-line description of the package (Max 80 chars.)
93
- attr_accessor :summary, :brief do
94
- if @summary
95
- @summary.to_s[0..79]
96
- else
97
- i = @description.index('.') || 79
98
- i = 79 if i > 79
99
- @description[0..i]
100
- end
101
- end
102
-
103
- # More detailed description of the package.
104
- attr_accessor :description
105
-
106
- # "Unix" name of the project/package.
107
- attr_accessor :name
108
-
109
- # "Unix" name of master project this "sub-project" may belong.
110
- # (Default is the same as name).
111
- attr_accessor :project do
112
- @project || name
113
- end
114
-
115
- # The date the project was started.
116
- attr_accessor :created
117
-
118
- # Copyright notice.
119
- attr_accessor :copyright do
120
- @copyright || "Copyright (c) #{Time.now.strftime('%Y')} #{author}"
121
- end
122
-
123
- # Distribution License.
124
- attr_accessor :license do
125
- @license || 'GPLv3'
126
- end
127
-
128
- # Slogan or "trademark" phrase.
129
- attr_accessor :slogan
130
-
131
- # General one-word software category.
132
- attr_accessor :category
133
-
134
- # Author(s) of this project.
135
- # (Usually in "name <email>" format.)
136
- attr_accessor :author
137
-
138
- # Contact(s) (defaults to authors).
139
- # TODO Move to Variants?
140
- attr_accessor :contact do
141
- @contact || author
142
- end
143
-
144
- # Gerneral email address.
145
- attr_accessor :email
146
-
147
- # Official domain associated with this package.
148
- attr_accessor :domain
149
-
150
- # Project's homepage.
151
- attr_accessor :homepage
152
-
153
- # Project's development site.
154
- attr_accessor :development, :devsite
155
-
156
- # Internet address(es) to documentation pages.
157
- attr_accessor :documentation, :docs
158
-
159
- # Internet address(es) to downloadable packages.
160
- attr_accessor :download
161
-
162
- # Internet address for project wiki.
163
- attr_accessor :wiki
164
-
165
- # Project's mailing list.
166
- attr_accessor :userlist, :mailinglist, :list
167
-
168
- # Developer's mailing list.
169
- attr_accessor :devlist do
170
- @devlist || @userlist
171
- end
172
-
173
- # Returns a standard taguri id for the library and release.
174
- def project_taguri
175
- "tag:#{name}.#{domain},#{created}" # or released?
176
- end
177
-
178
-
179
- # # Version
180
- # #------------------------------------------------------------------------
181
- #
182
- # # Version number (eg. '1.0.0').
183
- # attr_accessor :version
184
- #
185
- # # Current version code name.
186
- # attr_accessor :codename
187
- #
188
- # # Build number can br set to an arbitrar number, or if set to true,
189
- # # it will defaults to a number based on current date-time.
190
- #
191
- # attr_accessor :buildno do
192
- # @buildno = Time.now.strftime("%y%m%d%H%M") if TrueClass === @buildno
193
- # @buildno
194
- # end
195
-
196
-
197
-
198
- # Content Classification
199
- #------------------------------------------------------------------------
200
-
201
- # Files in this package that are executables.
202
- # These files must in the packages bin/ directory.
203
- # If left blank all bin/ files are included.
204
-
205
- attr_accessor :executable, :executables do
206
- return [@executable].flatten.compact if @executable
207
- exes = []
208
- dir = File.join(location, 'bin')
209
- if File.directory?(dir)
210
- Dir.chdir(dir) do
211
- exes = Dir.glob('*')
212
- end
213
- end
214
- @executable = exes
215
- end
216
-
217
- # Library files in this package that are *public*.
218
- # This is akin to load_path but specifies specific files
219
- # that can be loaded from the outside --where as those
220
- # not listed are considerd *private*.
221
- #
222
- # NOTE: This is not enforced --and may never be. It
223
- # complicates library loading. Ie. how to distinguish public
224
- # loading from external loading. But it something that can be
225
- # consider more carfully in the future. For now it can serve
226
- # as an optional reference.
227
- attr_accessor :library, :libraries do
228
- [@library || 'lib/**/*'].flatten
229
- end
230
-
231
- # Location(s) of executables.
232
- attr_accessor :bin_path, :bin_paths
233
-
234
- # Root location(s) of libraries (used by Rolls).
235
- # If you plan to support Gems, this would be something like:
236
- #
237
- # 'lib/facets'
238
- #
239
- # If not, then the default ('lib') is nice b/c it means one less
240
- # layer in your project heirarchy.
241
- attr_accessor :lib_path, :lib_paths, :load_path, :load_paths do
242
- [@lib_path || 'lib'].flatten
243
- end
244
-
245
- # Traditional load path (used by RubyGems).
246
- # The default is 'lib', which is usually fine.
247
- attr_accessor :gem_path, :gem_paths do
248
- [@gem_path || 'lib'].flatten
249
- end
250
-
251
-
252
- # Security
253
- #------------------------------------------------------------------------
254
-
255
- # Encryption digest type used.
256
- # (md5, sha1, sha128, sha256, sha512).
257
- attr_accessor :digest do
258
- @digest || 'md5'
259
- end
260
-
261
- # Public key file associated with this library. This is useful
262
- # for security purposes especially remote loading. [pubkey.pem]
263
- attr_accessor :public_key do
264
- @public_key || 'pubkey.pem'
265
- end
266
-
267
- # Private key file associated with this library. This is useful
268
- # for security purposes especially remote loading. [_privkey.pem]
269
- attr_accessor :private_key
270
- # @private_key || '_privkey.pem'
271
- # end
272
-
273
-
274
- # Source Management
275
- #------------------------------------------------------------------------
276
-
277
- # Specify which verison control system is being used.
278
- # Sometimes this is autmatically detectable, but it
279
- # is better to specify it.
280
-
281
- # Specifices the type of revision control system used.
282
- # darcs, svn, cvs, etc.
283
- # Will try to determine which version control system is being used.
284
- attr_accessor :scm do
285
- return @scm unless @scm.nil?
286
- @scm = if File.directory?('.svn')
287
- 'svn'
288
- elsif File.directory?('_darcs')
289
- 'darcs'
290
- else
291
- false
292
- end
293
- end
294
-
295
- # Files that are tracked under revision control.
296
- # Default is all less standard exceptions.
297
- # '+' and '-' prefixes can be used to augment the list
298
- # rather than fully override it.
299
- attr_accessor :track, :scm_files
300
-
301
- # Internet address to source code repository.
302
- # (http://, ftp://, etc.)
303
- attr_accessor :repository, :repo
304
-
305
- # Changelog file.
306
- attr_accessor :changelog
307
-
308
- # Manifest file. Defaults to 'MANIFEST'.
309
- # (I like to put it in meta/MANIFEST, personally.)
310
- attr_accessor :manifest do
311
- @manifest ||= 'MANIFEST'
312
- end
313
-
314
-
315
- # Dependencies
316
- #------------------------------------------------------------------------
317
- # Package inter-relationship data. Generally refered to as package
318
- # "dependencies", but also includes +recommendations+, +suggestions+,
319
- # +replacements+, +provisions+, and +build-dependencies+, as well
320
- # as a few other fields that set a package apart.
321
- #------------------------------------------------------------------------
322
-
323
- # What other packages *must* this package have in order to function.
324
- attr_accessor :dependency, :dependencies do
325
- @dependency || []
326
- end
327
-
328
- # What other packages *should* be used with this package.
329
- attr_accessor :recommend, :recommends, :recommendations do
330
- @recommend || []
331
- end
332
-
333
- # What other packages *could* be useful with this package.
334
- attr_accessor :suggest, :suggests, :suggestions do
335
- @suggest || []
336
- end
337
-
338
- # What other packages does this package conflict.
339
- attr_accessor :conflict, :conflicts do
340
- @conflict || []
341
- end
342
-
343
- # What other packages does this package replace.
344
- attr_accessor :replace, :replaces, :replacements do
345
- @replace || []
346
- end
347
-
348
- # What other package(s) does this package provide the same dependency fulfilment.
349
- # For example, a package 'bar-plus' might fulfill the same dependency criteria
350
- # as package 'bar', so 'bar-plus' is said to provide 'bar'.
351
- attr_accessor :provide, :provides, :provisions do
352
- @provide || []
353
- end
354
-
355
- # Abirtary information about what might be needed to use this package.
356
- # This is strictly information for the end-user to consider.
357
- # Eg. "Fast graphics card"
358
- attr_accessor :requirement, :requirements do
359
- @requirement || []
360
- end
361
-
362
- # What packages does this package need to build? (eg. 'rake', 'ratch', etc.)
363
- attr_accessor :build_dependency, :build_dependencies do
364
- @build_dependency || []
365
- end
366
-
367
- # Abirtary information about what might be needed to build this package.
368
- attr_accessor :build_requirement, :build_requirements do
369
- @build_requirement || []
370
- end
371
-
372
-
373
- # Packaging
374
- #------------------------------------------------------------------------
375
-
376
- # Platform. The default is nil, which is considered cross-platform.
377
- # This tends to only change for special builds.
378
- #
379
- # TODO: if current?
380
-
381
- attr_accessor :platform
382
-
383
- # Architecture(s) this package can be run on: any, i386, i686, ppc, etc.
384
- # This is strictly informational and is inteded to indicate the possiblities,
385
- # not the particular platform this package runs on.
386
-
387
- #attr_accessor :arch, :architecture do
388
- # @arch || "any"
389
- #end
390
-
391
- # Script to run prior to build. No entry indicates no compilation.
392
- attr_accessor :compile
393
-
394
- # Packages that are intended to compile on install may need this. It is a list
395
- # of "extension scripts" which generate Makefiles for use in compilation.
396
- attr_accessor :extensions do
397
- [@extensions || Dir.glob(File.join(location, 'ext/**/extconf.rb'))].flatten.compact
398
- end
399
-
400
- #
401
- #validate "compile script not found" do
402
- # compile ? File.file?(compile) : true
403
- #end
404
-
405
- # Package name. This defaults to name, but is here b/c it may
406
- # vary under different packagings (deb vs. gem).
407
- attr_accessor :package do
408
- @package || (
409
- name if respond_to?(:name)
410
- )
411
- end
412
-
413
- # Generate documentation on installation?
414
- attr_accessor :document
415
-
416
-
417
- # Distribution
418
- #------------------------------------------------------------------------
419
-
420
- # Files to be distributed in a package. Defaults to all files.
421
- # If an entry is a directory then all it's contents are also included.
422
- # This along with @exclude@ and @ignore@ is used to generate a manifest.
423
- attr_accessor :distribute, :include do
424
- [@distribute || '**/*'].flatten.compact
425
- end
426
-
427
- # File to exclude from package. This is usually more useful than
428
- # @distribute@, as it allows you to remove from all files, rather then
429
- # explicitly designate everything to be included. Exlcusions have priority
430
- # over dsitribute's inclusions. If an entry is a directory then all
431
- # it's contents are also excluded.
432
- attr_accessor :exclude do
433
- [@exclude].flatten.compact
434
- end
435
-
436
- # Files to generally ignore, mainly used for manifest collection. Ignore
437
- # has priority over @exclude@ and @distribute@.
438
- attr_accessor :ignore do
439
- @ignore || %w{ **/.svn _darcs .config .installed }
440
- end
441
-
442
- # Add version tiers to package? If true a package's lib/ and ext/ files
443
- # will be wrapped in a version folder. (This is specialized transfer rule.)
444
- #attr_accessor :tier
445
-
446
- # Manifest file.
447
- #def manifest
448
- # @manifest #||= Manifest.open
449
- #end
450
-
451
- # Set manifest file, which will load it.
452
- #def manifest=(file)
453
- # @manifest = file
454
- # @filelist = File.read_list(file) #Manifest.open(file)
455
- # return file
456
- #end
457
-
458
- # List of file included in a package. This is generated using
459
- # @distribute@, @exlude@ and @ignore@.
460
- def filelist
461
- @filelist ||= collect_files(true)
462
- end
463
-
464
- # Validate that the files in the manifest actually exist.
465
- #def validate_manifest
466
- # missing = []
467
- # filelist.each do |f|
468
- # missing << f unless File.exist?(f)
469
- # end
470
- # unless missing.empty?
471
- # raise ValidationError, "manifest lists non-existent files -- " + missing.join(" ")
472
- # end
473
- #end
474
-
475
- private
476
-
477
- # Collect distribution files.
478
-
479
- def collect_files(with_dirs=false)
480
- files = FileList.new
481
-
482
- Dir.chdir(location) do
483
- files.include(*distribute)
484
- files.exclude(*exclude)
485
- files.exclude(*ignore)
486
- end
487
-
488
- files = files.to_a
489
-
490
- # TODO: is there a way to do this with FileList?
491
- unless with_dirs
492
- files = files.select{ |f| !File.directory?(f) }
493
- end
494
-
495
- return files
496
- end
497
-
498
-
499
- # Validation
500
- #------------------------------------------------------------------------
501
-
502
- public
503
-
504
- #
505
- validate "location is required" do
506
- location
507
- end
508
-
509
- #
510
- validate "executables do not exist" do
511
- exes = []
512
- dir = File.join(location, 'bin')
513
- if File.directory?(dir)
514
- Dir.chdir(dir) do
515
- exes = Dir.glob('*')
516
- end
517
- end
518
- (executables - exes).empty?
519
- end
520
-
521
- end
522
-
523
- end