pallet 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,141 @@
1
+ pallet (1.2.1)
2
+
3
+ Improvements:
4
+
5
+ * better file slurping/gsubbing; whole-file rather than
6
+ line-by-line
7
+ * cache of replacements now efficiently reimplemented
8
+ * dh_installdocs ignores .svn directories
9
+ * new InstallSpec invocation syntax, old mode is deprecated and
10
+ will be removed later
11
+ * build-depends are forced to add pallet's build dependencies
12
+
13
+ Bugfixes:
14
+
15
+ * fixed bug where files created during the build process aren't
16
+ included into the Debian package
17
+ * fixed bug where files in directories not existing before the
18
+ project was build would not be included in the build
19
+
20
+ pallet (1.2.0)
21
+
22
+ Improvements:
23
+
24
+ * reimplemented require overloading as build_dependency and
25
+ runtime_dependency methods, with no nasty require aliasing
26
+
27
+ pallet (1.1.1)
28
+
29
+ Bugfixes:
30
+
31
+ * reverted changes to LoadError in require, since this causes
32
+ build failures on non-Linux systems
33
+ * updated Rakefile to include the Debian files in share/
34
+
35
+ pallet (1.1.0)
36
+
37
+ Improvements:
38
+
39
+ * Gem::DEFAULT_FILES no longer includes '[A-Z]*'
40
+ * better documentation
41
+ * allows calling of rake package without having libraries required
42
+ for the normal execution of Rakefile; this is disabled for any
43
+ use of the rakefile _except_ when it is called with a package
44
+ task or any task in the package namespace (mainly useful for
45
+ build hosts, to limit the needed Gem dependencies)
46
+ * debian templates directory now located in share/
47
+ * gem implementation rewritten to use core gem libraries, rather
48
+ than being a wrapper around Rake::GemSpecTask
49
+ * gem task can be renamed
50
+ * gem allows platform to be set
51
+ * gem allows dest_dir and filename to be changed
52
+ * reimplementation of InstallSpec
53
+ * more efficient case-insensitive globbing implemented
54
+ * Deb#commands.clean added
55
+ * debian/rules clean now cleans the source tree too
56
+ * rake clean doesn't remove debian directory, only rake clobber
57
+ does now
58
+ * better DRY-ness of substitution variables (no more having to
59
+ type the hashes around #FOO#)
60
+ * debhelper autogenerates entries in postrm
61
+ * debian/rules streamlined
62
+ * copyright file added to Debs
63
+ * debian/rules uses binary-indep and binary-arch smartly, based on
64
+ the configured package architecture
65
+ * pallet Rakefile is debianized
66
+ * Debian conffile support
67
+
68
+ Bugfixes:
69
+
70
+ * throws an exception when Gem#executables are not all in the same
71
+ directory
72
+ * no longer includes bin/bin/* in gems
73
+ * default Debian build-depends are overrideable, rather than being
74
+ transparently and secretly added
75
+ * fixed changelog.Debian.gz formatting
76
+ * fixed DEFAULT_DOCS and DEFAULT_CHANGELOG in Debian template
77
+ * fixed template location for debianization
78
+ * 822-date output chomped in Deb
79
+ * files generated during build process are now added correctly,
80
+ and list of files to be added are not cached before the build is
81
+ run
82
+
83
+ Known Bugs:
84
+
85
+ * replacements cache no longer as efficient
86
+ * timestamps can differ if the package is being built when the
87
+ system clock increments its second hand
88
+
89
+ pallet (1.0.2)
90
+
91
+ Improvements:
92
+
93
+ * builds packages binary-only; no source packages
94
+ * Debian packages signed with author's GPG key if available, or
95
+ the key id in $GPG_KEY_ID environment if it is set
96
+ * changelog now reports OS as unstable, stable, and testing
97
+ * Debian changelog has a better default message
98
+ * Pallet#requirements field supported by Debian packaging; pops
99
+ open a debconf warning on install
100
+ * extended description field Pallet#description added
101
+ * removed dependency on facets
102
+ * improved debianization process
103
+
104
+ Bugfixes:
105
+
106
+ * files are placed into the Debian package with the permissions
107
+ they already have on the filesystem
108
+ * fixed bug where InstallSpecs would not always report the base
109
+ destination directory as needing to exist
110
+ * default value of Pallet::Deb#docs and Pallet::Deb#files fixed
111
+ * added dpkg-dev gem requirement
112
+ * rake clobber always removes packages
113
+
114
+ -- Stephen Touset <stouset@damballa.com> Fri Feb 16 14:17:29 EST 2007
115
+
116
+ pallet (1.0.1)
117
+
118
+ Improvements:
119
+
120
+ * added a package:all task to the Rakefile, to generate all
121
+ supported package types
122
+ * added an architecture option for Debian packages, to support
123
+ scripts supported on the "all" architecture without rebuild
124
+
125
+ Bugfixes:
126
+
127
+ * added debhelper to Debian build-depends
128
+ * fewer warnings due to non-idiomatic Ruby
129
+ * adds the CHANGELOG to auto-generated documentation
130
+ * removed extraneous Rubygems dependencies
131
+
132
+ -- Stephen Touset <stouset@damballa.com> Tue, 13 Feb 2007 17:24:02 -0500
133
+
134
+ pallet (1.0.0)
135
+
136
+ * Initial release of pallet. Allows a small Rakefile-type script to
137
+ be written which can build packages in the following formats:
138
+ - Debian
139
+ - Ruby Gems
140
+
141
+ -- Stephen Touset <stouset@damballa.com> Mon, 12 Feb 2007 12:10:35 -0500
data/README ADDED
File without changes
@@ -0,0 +1,44 @@
1
+ module Kernel
2
+
3
+ #
4
+ # Tests to see if we're in rake, and any task given on the command
5
+ # line is equal to or in the namespace of _name_.
6
+ #
7
+ def in_rake_task?(name)
8
+ $0 =~ /rake/ && ARGV.grep(/\A#{name}/).length != 0
9
+ end
10
+
11
+ #
12
+ # Requires the library as a build dependency for Pallet, which
13
+ # ensures it will be loaded whenever the package task is run.
14
+ #
15
+ def build_dependency(lib)
16
+ require lib
17
+ end
18
+
19
+ #
20
+ # Requires the given library, ignoring any failures if we're in a
21
+ # package build task.
22
+ #
23
+ def runtime_dependency(lib)
24
+ if in_rake_task? Pallet::NAMESPACE
25
+ require lib rescue nil
26
+ else
27
+ require lib
28
+ end
29
+ end
30
+
31
+ end
32
+
33
+ #
34
+ # Override method_missing and const_missing if we're running a pallet
35
+ # packaging task.
36
+ #
37
+ if in_rake_task? Pallet::NAMESPACE
38
+ module Kernel #:nodoc:
39
+ def method_missing(name); nil; end
40
+ end
41
+ class Module #:nodoc:
42
+ def const_missing(name); nil; end
43
+ end
44
+ end
@@ -0,0 +1,89 @@
1
+ class InstallSpec
2
+
3
+ # The directory or file to move from.
4
+ attr_accessor :source
5
+
6
+ # The directory to move any matching files to.
7
+ attr_accessor :destination
8
+
9
+ # Extra attributes for the install specification. Supported
10
+ # attributes are +:glob+, to change the default globbing pattern, and
11
+ # +:conf+, which marks the set of files as configuration files.
12
+ attr_accessor :attributes
13
+
14
+ DEFAULT_GLOB = '**/*'
15
+ EXTRA_SEPARATORS = %r{^/+(.*)/+$}
16
+
17
+ #
18
+ # Initializes the InstallSpec, as a shortcut for InstallSpec#new
19
+ #
20
+ def self.[](source, destination, attributes = {})
21
+ new(source, destination, attributes)
22
+ end
23
+
24
+ #
25
+ # Initializes the InstallSpec. Available attributes are +:conf+ and
26
+ # +:glob+. Accepts a block for backwards compatibility, although
27
+ # this usage is deprecated.
28
+ #
29
+ def initialize(source, destination, attributes = {})
30
+
31
+ self.source = source
32
+ self.destination = destination
33
+ self.attributes = attributes
34
+
35
+ # yield for more initialization, for backwards-compatibility
36
+ # purposes
37
+ if block_given?
38
+ puts "WARNING: DEPRECATED USAGE OF INSTALLSPEC. NO LONGER ACCEPTS A BLOCK PARAMETER."
39
+ yield s = Struct.new(:source, :destination, :glob, :conffiles).new
40
+ self.source = s.source if s.source
41
+ self.destination = s.destination if s.destination
42
+ self.attributes[:glob] = s.glob
43
+ self.attributes[:conf] = s.conffiles
44
+ end
45
+
46
+
47
+ # remove any leading /'s, since we should be dealing only with
48
+ # relative directory paths
49
+ source.sub! EXTRA_SEPARATORS, '\1'
50
+ destination.sub! EXTRA_SEPARATORS, '\1'
51
+
52
+ # update attributes with the defaults if needed
53
+ self.attributes[:glob] ||= DEFAULT_GLOB
54
+ self.attributes[:conf] ||= !! destination.match(%r{/etc|etc/|\Aetc\z})
55
+
56
+ end
57
+
58
+ #
59
+ # A hash of all files in _source_ mapping to their destination.
60
+ #
61
+ def files
62
+ hash_to_dest(Dir[pattern].find_all {|f| File.file? f })
63
+ end
64
+
65
+ #
66
+ # A hash of all directories in _source_ mapped to their destination.
67
+ #
68
+ def directories
69
+ hash_to_dest(Dir[pattern].find_all {|f| File.directory? f } << source)
70
+ end
71
+
72
+ private
73
+
74
+ #
75
+ # The full search pattern to use when looking for files.
76
+ #
77
+ def pattern
78
+ File.directory?(source) ? File.join(source, attributes[:glob]) : source
79
+ end
80
+
81
+ #
82
+ # Creates a hash mapping everything in _files_ beginning with _source_
83
+ # to its corresponding location in _destination_.
84
+ #
85
+ def hash_to_dest(files)
86
+ Hash[*files.map {|f| [f, f.sub(/^#{source}/, destination)] }.flatten]
87
+ end
88
+
89
+ end
@@ -0,0 +1,109 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ require 'pallet/deb'
5
+ require 'pallet/gem'
6
+ require 'install_spec'
7
+
8
+ class Pallet
9
+
10
+ VERSION = '1.2.1'
11
+ NAMESPACE = 'package'
12
+
13
+ # The name of the project.
14
+ attr_accessor :name
15
+
16
+ # The version number of the project to tag onto the package.
17
+ attr_accessor :version
18
+
19
+ # A short description of the package function.
20
+ attr_accessor :summary
21
+
22
+ # A longer, more detailed description of the package's capabilities.
23
+ attr_accessor :description
24
+
25
+ # The name of the current project maintainer.
26
+ attr_accessor :author
27
+
28
+ # The maintainer's email address.
29
+ attr_accessor :email
30
+
31
+ # An enumerable with the package definitions for each package type
32
+ # you wish to support in your project.
33
+ attr_accessor :packages
34
+
35
+ # The preferred packaging format of your project. +rake package+
36
+ # will build this format, but others can still be built with +rake
37
+ # package:#{format}+.
38
+ attr_accessor :preferred_format
39
+
40
+ #
41
+ # Initializes the pallet to a sane state, and creates all the
42
+ # necessary Rake tasks. Passes a copy of itself to a block, if
43
+ # given, and uses that block for further initializiation. If no
44
+ # _version_ is given, defaults to the output of +svnversion+.
45
+ #
46
+ def initialize(name, version = %x{svnversion}.chomp)
47
+
48
+ # set up defaults
49
+ self.name = name
50
+ self.version = version
51
+ self.author = 'Anonymous'
52
+ self.email = 'anonymous@example.org'
53
+ self.summary = ''
54
+ self.description = ''
55
+ self.packages = []
56
+
57
+ # let block continue initialization
58
+ yield self if block_given?
59
+
60
+ # check that we have _some_ package to build
61
+ if packages.empty?
62
+ raise TypeError, 'at least one package type must be specified'
63
+ end
64
+
65
+ # if no preferred format given, use the first one specified
66
+ self.preferred_format ||= packages.first
67
+
68
+ define_rake_tasks
69
+
70
+ end
71
+
72
+ private
73
+
74
+ #
75
+ # Defines all rake tasks related to packaging.
76
+ #
77
+ def define_rake_tasks
78
+
79
+ namespace NAMESPACE do
80
+
81
+ desc 'Build all supported package types'
82
+ task :all
83
+
84
+ desc 'Remove any ephemeral files used to build packages'
85
+ task :clean
86
+
87
+ desc 'Clean up all package files'
88
+ task :clobber
89
+
90
+ # define a task for all supported packages
91
+ self.packages.each do |package|
92
+ package.define
93
+ task :all => package.task_name
94
+ end
95
+
96
+ end
97
+
98
+ # default package task redirection
99
+ desc "Build a #{preferred_format.task_name}"
100
+ task :package => "#{NAMESPACE}:#{preferred_format.task_name}"
101
+
102
+ # have clean/clobber depend on our own
103
+ %w{clean clobber}.each {|t| task t => "#{NAMESPACE}:#{t}" }
104
+
105
+ end
106
+
107
+ end
108
+
109
+ require 'dependencies'
@@ -0,0 +1,311 @@
1
+ class Pallet
2
+
3
+ #
4
+ # = Pallet::Deb
5
+ #
6
+ # Automatic builder for Debian packages. Lets users automagically
7
+ # build a deb after specifying a few customizations.
8
+ #
9
+ # == Usage
10
+ #
11
+ # At a bare minimum, users must specify lists of files, and where to
12
+ # place them. The syntax for doing so is not obvious, so we will
13
+ # demonstrate by example.
14
+ #
15
+ # To create a Debian package, moving everything under 'lib/' to
16
+ # '/usr/lib/ruby/1.8/', everything in 'bin/' to '/usr/bin/', and all
17
+ # documentation under 'doc/' to the Debian default documentation
18
+ # directory, under the subdirectory HTML, you would write the
19
+ # following:
20
+ #
21
+ # Pallet::Deb.new(pallet) do |deb|
22
+ #--
23
+ # TODO: EXAMPLE!!
24
+ #++
25
+ # end
26
+ #
27
+ # === GPG Integration
28
+ #
29
+ # Pallet::Deb will sign its built Debian packages with the GPG key
30
+ # id in the environment variable $GPG_KEY_ID, if it is set.
31
+ # Otherwise, it will sign with the key associated with the
32
+ # maintainer's email address, if it is avaialble.
33
+ #
34
+ # == Caveats
35
+ #
36
+ # * Uses dpkg-buildpackage, which is not very flexible. Should be
37
+ # rewritten later to do everything on its own.
38
+ # * Can only be used to build a single package, rather than multiple
39
+ # packages from one source.
40
+ # * Packages are installed into .., rather than pkg/
41
+ # * No doc-base integration
42
+ #
43
+ class Deb
44
+
45
+ # The name the generated rake task will use. Defaults to 'deb'.
46
+ attr_accessor :task_name
47
+
48
+ # An array of Debian build dependencies needed in order to build
49
+ # the package for this project. Defaults to any core build
50
+ # requirements introduced by pallet (currently only debhelper (>=
51
+ # 5) and dpkg-dev).
52
+ attr_accessor :build_depends
53
+
54
+ # All Debian packages this project depends on.
55
+ attr_accessor :depends
56
+
57
+ # Any additional requirements not satisfiable through the Debian
58
+ # packaging system. For instance, Ruby gems. Any requirements
59
+ # provided this way will be presented to the user through a
60
+ # Debconf dialog upon installation.
61
+ attr_accessor :requirements
62
+
63
+ # An array of any tasks which should run and complete successfully
64
+ # before the Debian package is built.
65
+ attr_accessor :prerequisites
66
+
67
+ # A struct containing a few statically-named commands that can
68
+ # replace parts of the Pallet::Deb build process. Currently
69
+ # allows assignment to the _build_, _install_, _package_,
70
+ # _document_, and _clean_ instance variables.
71
+ #
72
+ # _commands.build_ defaults to 'make', 'ant', or nil depending on
73
+ # whether or not a Makefile, build.xml, or no build file is
74
+ # detected, respectively.
75
+ #
76
+ # _commands.clean_ deafults to 'rake clean'. It can be overridden
77
+ # if you have another method of cleaning your build directory.
78
+ #
79
+ # _commands.install_ defaults to nil. If your project already
80
+ # provides a command that installs all files needed for the
81
+ # project into a prefixed directory, you can specify this rather
82
+ # than providing InstallSpecs to _Pallet::Deb#files_. However,
83
+ # this command +must+ be able to support a "DESTDIR=$DIR"-style
84
+ # parameter which determines the install prefix.
85
+ #
86
+ # _commands.package_ defaults to nil. If this is specified, the
87
+ # +entire+ build process will consist of calling this command.
88
+ # This might be desirable if your project already provides a
89
+ # _debian_ directory and a _make deb_ command to build the Debian
90
+ # package. Otherwise, leave this at its default.
91
+ #
92
+ # _commands.document_ defaults to nil. If specified, this command
93
+ # is run to build any automatically-generated documentation.
94
+ #
95
+ attr_accessor :commands
96
+
97
+
98
+ # An array of InstallSpec objects pointing to files and their
99
+ # destination in the finished package. May be omitted if
100
+ # _commands.install_ is provided.
101
+ attr_accessor :files
102
+
103
+ # A FileList, array, or other enumerable object containing a list
104
+ # of all project documentation to include in the Debian pacakge.
105
+ attr_accessor :docs
106
+
107
+ # The location on the filesystem of the project Changelog.
108
+ # Defaults to 'CHANGELOG', if one exists.
109
+ attr_accessor :changelog
110
+
111
+ # A hash pointing to the location of scripts the Debian package
112
+ # should include. The key in the hash is the debhelper-reconigzed
113
+ # type of script (cron.d, postinst, postrm, init.d, etc.). The
114
+ # value is its location in your project hierarchy.
115
+ attr_accessor :scripts
116
+
117
+ # The machine architecture the package can be built to support.
118
+ # Defaults to 'any', but 'all' should be used for languages that
119
+ # aren't compiled to a specific platform.
120
+ attr_accessor :architecture
121
+
122
+ # The version of the Debian policy we support
123
+ DEBIAN_POLICY_VERSION = '3.7.2'
124
+
125
+ # Mapping of build spec files to the command that invokes them. We
126
+ # don't include rake here, since most Ruby programs don't need
127
+ # "building", and there is no idiomatic rake task used for
128
+ # building extensions.
129
+ BUILD_COMMANDS = { 'Makefile' => 'make --silent',
130
+ 'build.xml' => 'ant', }
131
+
132
+ # Build dependencies required by pallet, which will always be
133
+ # added to the debian/control file.
134
+ BUILD_DEPENDS = ['debhelper (> 5.0)', 'dpkg-dev']
135
+
136
+ # Default places to look for documentation.
137
+ DEFAULT_DOCS = FileList[%w{README* TODO* doc*}]
138
+
139
+ # Default changelog search locations.
140
+ DEFAULT_CHANGELOG = FileList[%w{CHANGELOG*}]
141
+
142
+ #
143
+ # Creates a new specification for building a deb. Yields itself to
144
+ # the blocked passed for further initialization.
145
+ #
146
+ def initialize(pallet)
147
+
148
+ @pallet = pallet
149
+
150
+ # configure defaults
151
+ self.task_name = :deb
152
+ self.depends = []
153
+ self.build_depends = []
154
+ self.requirements = []
155
+ self.prerequisites = []
156
+ self.files = []
157
+ self.docs = DEFAULT_DOCS
158
+ self.changelog = DEFAULT_CHANGELOG.first
159
+ self.scripts = {}
160
+ self.commands = Struct.new(:build, :clean, :install, :package, :document).new
161
+ self.architecture = 'any'
162
+
163
+ # try and determine a default build command
164
+ BUILD_COMMANDS.find do |file, command|
165
+ self.commands.build = command if File.exist? file
166
+ end
167
+
168
+ # default packaging command; adds GPG key if it's in the environment
169
+ self.commands.package = "dpkg-buildpackage -rfakeroot -b"
170
+ self.commands.package << " -k#{ENV['GPG_KEY_ID']}" if ENV['GPG_KEY_ID']
171
+
172
+ # default clean command
173
+ self.commands.clean = 'rake --silent clean'
174
+
175
+ # send me off to be configured
176
+ yield self if block_given?
177
+
178
+ # append our core build-dependencies to any others specified, so
179
+ # the user doesn't have to
180
+ self.build_depends |= BUILD_DEPENDS
181
+
182
+ end
183
+
184
+ def define
185
+
186
+ desc 'Build this project into a Debian package'
187
+ task self.task_name => self.prerequisites do
188
+ debianize unless File.directory? 'debian'
189
+ packagize
190
+ end
191
+
192
+ task 'clean' => ['clean:deb']
193
+ task 'clean:deb' do
194
+ # don't call debian/rules clean if we've already been called
195
+ # through Make; this might not be entirely reliable...
196
+ ENV['MAKELEVEL'] or system 'fakeroot debian/rules clean' if File.exist? 'debian/rules'
197
+ end
198
+
199
+ task 'clobber' => ['clobber:deb']
200
+ task 'clobber:deb' do
201
+ rm_r 'debian' rescue nil
202
+ files = Dir["../#{@pallet.name}_#{@pallet.version}*.changes"] +
203
+ Dir["../#{@pallet.name}_#{@pallet.version}*.deb"]
204
+ files.each {|f| rm f if File.exist? f }
205
+ end
206
+
207
+ end
208
+
209
+ private
210
+
211
+ #
212
+ # Build the _debian/_ directory under the project root
213
+ #
214
+ def debianize
215
+
216
+ locations = [File.dirname(__FILE__) + '/../../share/debian',
217
+ '/usr/share/pallet/debian']
218
+ templates = locations.find {|f| puts f; File.directory? f }
219
+
220
+ # make the target directory
221
+ mkdir 'debian'
222
+
223
+ # copy/gsub template files into place
224
+ Dir[templates + '/**/*'].each do |file|
225
+
226
+ dest = 'debian/' + File.basename(file)
227
+
228
+ # gsub our replacements in the file in memory, then write back
229
+ # out to the destination
230
+ begin
231
+ s = File.open(file, File::RDONLY)
232
+ d = File.open(dest, File::WRONLY | File::CREAT)
233
+ d.write replacements.inject(s.readlines.join) {|contents, rep| contents.gsub %r|##{rep[0]}#|, rep[1] }
234
+ ensure
235
+ s.close
236
+ d.close
237
+ end
238
+
239
+ end
240
+
241
+ # mark debian/rules as executable
242
+ chmod 0755, 'debian/rules'
243
+
244
+ # relocate any additional scripts into the debian directory
245
+ scripts.each_pair do |type, location|
246
+ ln_sf "../#{location}", "debian/#{type}"
247
+ end
248
+
249
+ end
250
+
251
+ def packagize
252
+ system self.commands.package
253
+ end
254
+
255
+ def replacements
256
+ @replacements_cache ||= {
257
+ 'ARCHITECTURE' => lambda { self.architecture },
258
+ 'BUILD_DEPS' => lambda { self.build_depends.join ', ' },
259
+ 'CHANGELOG' => lambda { self.changelog },
260
+ 'CLEAN' => lambda { self.commands.clean },
261
+ 'CONFFILES' => lambda { conffiles },
262
+ 'DATE' => lambda { %x{822-date}.chomp },
263
+ 'DEPENDS' => lambda { self.depends.join ', ' },
264
+ 'DESCRIPTION' => lambda { @pallet.description.gsub(/\n/, "\n ") },
265
+ 'DIRECTORIES' => lambda { directories },
266
+ 'DOCS' => lambda { system self.commands.document if self.commands.document; self.docs.join "\n" },
267
+ 'EMAIL' => lambda { @pallet.email },
268
+ 'FILES' => lambda { system self.commands.build if self.commands.build; install },
269
+ 'INSTALL' => lambda { self.commands.install ? "#{self.commands.install} DESTDIR=debian/#{@pallet.name}" : nil },
270
+ 'MAKE' => lambda { self.commands.build },
271
+ 'MODE' => lambda { self.architecture == 'all' ? 'indep' : 'arch' },
272
+ 'PACKAGE' => lambda { @pallet.name },
273
+ 'POLICY' => lambda { DEBIAN_POLICY_VERSION },
274
+ 'REQUIREMENTS' => lambda { self.requirements.map {|r| ' * ' + r }.join "\n" },
275
+ 'SUMMARY' => lambda { @pallet.summary },
276
+ 'UNUSED-MODE' => lambda { self.architecture == 'all' ? 'arch' : 'indep' },
277
+ 'USERNAME' => lambda { @pallet.author },
278
+ 'VERSION' => lambda { @pallet.version },
279
+ }.instance_eval { each {|k,v| self[k] = v.call.to_s } }
280
+ end
281
+
282
+ #
283
+ # Generate the complete list of directories needed.
284
+ #
285
+ def directories
286
+ self.files.inject([]) {|m, s| m + s.directories.values }.uniq.join "\n"
287
+ end
288
+
289
+ #
290
+ # Generate a list of "install" commands to move files into the
291
+ # correct directory.
292
+ #
293
+ def install
294
+ self.files.inject([]) do |m,s|
295
+ m + s.files.map {|src, dst| "#{src} #{File.dirname(dst)}" }
296
+ end.join "\n"
297
+ end
298
+
299
+ #
300
+ # Returns a list of configuration files in _files_, from the
301
+ # perspective of the destination on the filesystem when the
302
+ # package is installed
303
+ #
304
+ def conffiles
305
+ self.files.inject([]) do |m,s|
306
+ m + (s.attributes[:conf] ? s.files.map {|src, dst| dst } : [])
307
+ end.join "\n"
308
+ end
309
+
310
+ end
311
+ end
@@ -0,0 +1,198 @@
1
+ require 'rubygems'
2
+ require 'rubygems/builder'
3
+
4
+ class Pallet
5
+
6
+ #
7
+ # = Pallet::Gem
8
+ #
9
+ # Automatic rubygem builder. Lets users automagically build a gem
10
+ # after specifying a few customizations.
11
+ #
12
+ # == Usage
13
+ #
14
+ # Uses several sane defaults, so in many cases, the specification
15
+ # could be written simply as:
16
+ #
17
+ # Pallet::Gem.new(pallet)
18
+ #
19
+ # Which is identical to the following example:
20
+ #
21
+ # Pallet::Gem.new(pallet) do |g|
22
+ # g.files = FileList['lib/**/*', '[A-Z]*']
23
+ # g.executables = FileList['bin/*']
24
+ # g.tests = FileList['test/**/*']
25
+ # g.readme = 'README'
26
+ # end
27
+ #
28
+ # These can be changed, and other attributes can be set.
29
+ #
30
+ # Pallet::Gem.new(pallet) do |g|
31
+ # g.files = FileList['**/*']
32
+ # g.readme = 'Readme.txt'
33
+ # g.depends << 'log4r' << 'rake' << 'pallet'
34
+ # g.requirements << 'Debian Linux' << 'a fast processor'
35
+ # end
36
+ #
37
+ # Dependencies are passed directly to the Gem::Specification
38
+ # backend, so they can be used as GemSpec-style arrays, if you need
39
+ # explicit version information.
40
+ #
41
+ # Pallet::Gem.new(pallet) do |g|
42
+ # g.depends << ['log4r', '>= 1.4.2']
43
+ # g.depends << ['pallet', >= 1.0.0']
44
+ # end
45
+ #
46
+ # == Caveats
47
+ #
48
+ # * Due to limitations in the gem specification format, executables
49
+ # _must_ all reside in the same directory -- by default, 'bin/'.
50
+ #
51
+ class Gem
52
+
53
+ # The name of the rake task we generate. Defaults to 'gem'.
54
+ attr_accessor :task_name
55
+
56
+ # The directory the package will be built into
57
+ attr_accessor :dest_dir
58
+
59
+ # The filename of the package, when built
60
+ attr_accessor :filename
61
+
62
+ # The target platform of the Gem. Defaults to the sane default of
63
+ # Gem::Platform::RUBY. See the rdoc for Gem::Platform for other
64
+ # reasonable values.
65
+ attr_accessor :platform
66
+
67
+ # A list of the files to be contained in the package. Does not
68
+ # have to contain files implied elsewhere (for instance,
69
+ # _docs_, _executables_, or _tests_).
70
+ attr_accessor :files
71
+
72
+ # A list of executables contained in the gem. All of these +must+
73
+ # be in the same directory. An exception will be thrown if they
74
+ # are not.
75
+ attr_accessor :executables
76
+
77
+ # A list of all test scripts which should be contained in the Gem.
78
+ attr_accessor :tests
79
+
80
+ # A list of additional documentation that should be included along
81
+ # with the automatically generated rdoc pages. The first one
82
+ # given will be the "default" rdoc page.
83
+ attr_accessor :docs
84
+
85
+ # All rubygems this Gem should depend on.
86
+ attr_accessor :depends
87
+
88
+ # Any additional requirements not satisfiable through rubygems.
89
+ # These are currently ignored.
90
+ attr_accessor :requirements
91
+
92
+ # Array of additional tasks which should be completed before the
93
+ # Gem is built.
94
+ attr_accessor :prerequisites
95
+
96
+ DEFAULT_FILES = FileList['lib/**/*']
97
+ DEFAULT_EXECUTABLES = FileList['bin/*']
98
+ DEFAULT_TESTS = FileList['test/**/*']
99
+ DEFAULT_DOCS = %w{readme todo changelog}
100
+
101
+ #
102
+ # Creates a new specification for building a Gem. Yields itself to
103
+ # the block passed for initialization.
104
+ #
105
+ def initialize(pallet)
106
+
107
+ # the name of our rake task
108
+ self.task_name = :gem
109
+ self.dest_dir = 'pkg'
110
+ self.platform = ::Gem::Platform::RUBY
111
+
112
+ # set up defaults
113
+ self.files = DEFAULT_FILES
114
+ self.executables = DEFAULT_EXECUTABLES
115
+ self.tests = DEFAULT_TESTS
116
+ self.docs = Dir['*'].find_all {|f| DEFAULT_DOCS.include? f.downcase }
117
+ self.depends = []
118
+ self.requirements = []
119
+ self.prerequisites = []
120
+
121
+ yield self if block_given?
122
+
123
+ # build the specification
124
+ @spec = ::Gem::Specification.new do |s|
125
+
126
+ # inherited values from the pallet
127
+ s.name = pallet.name
128
+ s.version = pallet.version
129
+ s.author = pallet.author
130
+ s.email = pallet.email
131
+ s.summary = pallet.summary
132
+ s.description = pallet.description
133
+
134
+ s.platform = self.platform
135
+
136
+ # aggregate list of files to include
137
+ s.files = files | executables | tests | docs
138
+
139
+ # include binary files
140
+ unless self.executables.empty?
141
+ dirs = self.executables.map {|f| File.dirname(f) }.uniq
142
+ dirs.length == 1 or raise RuntimeError, 'all binaries in a Gem must be in the same directory'
143
+ s.bindir = dirs.first
144
+ s.executables = self.executables.map {|f| File.basename(f) }
145
+ end
146
+
147
+ # include tests
148
+ s.test_files = self.tests
149
+
150
+ # include additional documentation
151
+ s.has_rdoc = true
152
+ s.extra_rdoc_files = self.docs
153
+ s.rdoc_options << '-S' << '-N'
154
+ unless self.docs.empty?
155
+ s.rdoc_options << '--main' << self.docs.first
156
+ end
157
+
158
+ # add dependencies
159
+ self.depends.each {|dependency| s.add_dependency(*dependency) }
160
+ s.requirements = self.requirements
161
+
162
+ end
163
+
164
+ end
165
+
166
+ #
167
+ # Defines the rake task for creating a gem.
168
+ #
169
+ def define
170
+
171
+ filename = @spec.full_name + '.gem'
172
+ dest = File.join(self.dest_dir, filename)
173
+
174
+ # create a task for the gem
175
+ desc 'Build this project into a gem'
176
+ task self.task_name => self.prerequisites + [dest]
177
+ directory self.dest_dir
178
+
179
+ # task to build the package
180
+ file dest => [self.dest_dir] + @spec.files do
181
+ when_writing("Building Rubygem") do
182
+ b = ::Gem::Builder.new(@spec)
183
+ b.use_ui(::Gem::SilentUI.new) { b.build }
184
+ mv filename, self.dest_dir
185
+ end
186
+ end
187
+
188
+ # clobber task
189
+ task 'clobber' => 'clobber:gem'
190
+ task 'clobber:gem' do
191
+ rm dest rescue nil
192
+ rmdir self.dest_dir rescue nil
193
+ end
194
+
195
+ end
196
+
197
+ end
198
+ end
@@ -0,0 +1,7 @@
1
+ #PACKAGE# (#VERSION#-1) unstable; urgency=low
2
+
3
+ * Automatically packaged version of #PACKAGE#, using pallet.
4
+ Please see the project changelog in /usr/share/doc/#PACKAGE#/
5
+ for more details.
6
+
7
+ -- #USERNAME# <#EMAIL#> #DATE#
@@ -0,0 +1 @@
1
+ 5
@@ -0,0 +1 @@
1
+ #CONFFILES#
@@ -0,0 +1,8 @@
1
+ #!/bin/sh -e
2
+
3
+ . /usr/share/debconf/confmodule
4
+
5
+ if [ -n "#REQUIREMENTS#" ]; then
6
+ db_input high #PACKAGE#/requirements || true
7
+ db_go || true
8
+ fi
@@ -0,0 +1,12 @@
1
+ Source: #PACKAGE#
2
+ Section: non-free/damballa
3
+ Priority: extra
4
+ Maintainer: #USERNAME# <#EMAIL#>
5
+ Build-Depends: #BUILD_DEPS#
6
+ Standards-Version: #POLICY#
7
+
8
+ Package: #PACKAGE#
9
+ Architecture: #ARCHITECTURE#
10
+ Depends: ${shlibs:Depends}, ${misc:Depends}, #DEPENDS#
11
+ Description: #SUMMARY#
12
+ #DESCRIPTION#
@@ -0,0 +1,7 @@
1
+ This package was created automatically using pallet, for #USERNAME#
2
+ <#EMAIL#> on #DATE#.
3
+
4
+ This software is for internal use at Damballa, Inc. only. Copyrights
5
+ are claimed on all components of this package owned by Damballa.
6
+
7
+ No rights to use, distribute, or modify this program are granted.
@@ -0,0 +1 @@
1
+ #DIRECTORIES#
@@ -0,0 +1 @@
1
+ #DOCS#
@@ -0,0 +1 @@
1
+ #FILES#
@@ -0,0 +1,3 @@
1
+ #!/bin/sh -e
2
+
3
+ . /usr/share/debconf/confmodule
@@ -0,0 +1,3 @@
1
+ #!/bin/sh -e
2
+
3
+ #DEBHELPER#
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/make -f
2
+
3
+ # Uncomment this to turn on verbose mode.
4
+ #export DH_VERBOSE=1
5
+
6
+ # The Debhelper compatibility level to use
7
+ #export DH_COMPAT=4
8
+
9
+ # Debian policy recommended CFLAGS
10
+ CFLAGS = -g -O2 -Wall
11
+
12
+ build: build-stamp
13
+ build-stamp:
14
+ dh_testdir
15
+ #MAKE#
16
+ touch $@
17
+
18
+ clean:
19
+ dh_testdir
20
+ dh_testroot
21
+ rm -f build-stamp
22
+ exit
23
+ #CLEAN#
24
+ dh_clean
25
+
26
+ install: build
27
+ dh_testdir
28
+ dh_testroot
29
+ dh_clean
30
+ dh_installdirs
31
+ dh_install
32
+ #INSTALL#
33
+
34
+ # Either binary-indep or binary-arch, depending on which one isn't
35
+ # actually used. Both must be present.
36
+ binary-#UNUSED-MODE#: build install
37
+
38
+ # Either binary-indep or binary-arch, depending on which one is
39
+ # actually used. Both must be present.
40
+ binary-#MODE#: build install
41
+ dh_testdir
42
+ dh_testroot
43
+ dh_installchangelogs #CHANGELOG#
44
+ dh_installdocs -X.svn
45
+ dh_installdebconf
46
+ dh_installlogrotate
47
+ dh_installinit
48
+ dh_installcron
49
+ dh_installman
50
+ dh_strip
51
+ dh_compress
52
+ dh_fixperms
53
+ dh_makeshlibs
54
+ dh_installdeb
55
+ dh_shlibdeps
56
+ dh_gencontrol
57
+ dh_md5sums
58
+ dh_builddeb
59
+
60
+ binary: binary-indep binary-arch
61
+ .PHONY: build clean binary-indep binary-arch binary install
@@ -0,0 +1,10 @@
1
+ Template: #PACKAGE#/requirements
2
+ Type: note
3
+ Description: Additional requirements must be filled!
4
+ This package requires the following software or conditions which
5
+ cannot be fulfilled by apt:
6
+ .
7
+ #REQUIREMENTS#
8
+ .
9
+ Until you satisfy these requirements, this software WILL NOT WORK. So
10
+ satisfy them. Now.
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: pallet
5
+ version: !ruby/object:Gem::Version
6
+ version: 1.2.1
7
+ date: 2007-04-30 00:00:00 -04:00
8
+ summary: Automated packaging tool for different languages and OSes
9
+ require_paths:
10
+ - lib
11
+ email: stouset@damballa.com
12
+ homepage:
13
+ rubyforge_project:
14
+ description: ""
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Stephen Touset
31
+ files:
32
+ - lib/pallet
33
+ - lib/install_spec.rb
34
+ - lib/pallet.rb
35
+ - lib/dependencies.rb
36
+ - lib/pallet/gem.rb
37
+ - lib/pallet/deb.rb
38
+ - share/debian
39
+ - share/debian/changelog
40
+ - share/debian/control
41
+ - share/debian/dirs
42
+ - share/debian/compat
43
+ - share/debian/postinst
44
+ - share/debian/postrm
45
+ - share/debian/config
46
+ - share/debian/install
47
+ - share/debian/conffiles
48
+ - share/debian/copyright
49
+ - share/debian/docs
50
+ - share/debian/rules
51
+ - share/debian/templates
52
+ - CHANGELOG
53
+ - README
54
+ test_files: []
55
+
56
+ rdoc_options:
57
+ - -S
58
+ - -N
59
+ - --main
60
+ - CHANGELOG
61
+ extra_rdoc_files:
62
+ - CHANGELOG
63
+ - README
64
+ executables: []
65
+
66
+ extensions: []
67
+
68
+ requirements:
69
+ - fakeroot
70
+ - dpkg-dev
71
+ dependencies:
72
+ - !ruby/object:Gem::Dependency
73
+ name: rake
74
+ version_requirement:
75
+ version_requirements: !ruby/object:Gem::Version::Requirement
76
+ requirements:
77
+ - - ">"
78
+ - !ruby/object:Gem::Version
79
+ version: 0.0.0
80
+ version: