Check-in [4ee95829d4]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | FPM::Source This is the base class for sources. Subclasses need to define two methods: def get_metadata # starting out with @paths and @root, infer as much # metadata as possible end def make_tarball!(tar_path) # turn this source into a tarball at the given path end |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
4ee95829d49610f2e955660b4384f2db |
| User & Date: | jjmadkisson@gmail.com 2011-01-06 02:00:10 |
Context
|
2011-01-06
| ||
| 02:12 | tar is owned by the source now check-in: 4651bc348e user: jjmadkisson@gmail.com tags: trunk | |
| 02:00 | FPM::Source This is the base class for sources. Subclasses need to define two methods: def get_metadata # starting out with @paths and @root, infer as much # metadata as possible end def make_tarball!(tar_path) # turn this source into a tarball at the given path end check-in: 4ee95829d4 user: jjmadkisson@gmail.com tags: trunk | |
| 01:52 | -s SOURCE_TYPE -t PACKAGE_TYPE This introduces the concept of sources and packages. A source is "something to build a package from" - i.e. something that can be turned into a versioned tarball. Easy ones to support are 'dir' (a plain directory), 'tar' (a tarball), 'npm', 'gem', etc. A package is a specified output type; deb, rpm, etc. that knows how to turn a tarball with metadata into a system package. check-in: c65be076cd user: jjmadkisson@gmail.com tags: trunk | |
Changes
Added lib/fpm/source.rb.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
require "fpm/namespace"
# Abstract class for a "thing to build a package from"
class FPM::Source
# standard package metadata
*%w(
name
version
iteration
architecture
maintainer
category
url
summary
).each do |attr|
attr = :"#{attr}"
define_method(attr) { self[attr] }
define_method(:"#{attr}=") { |v| self[attr] = v}
end
def dependencies
self[:dependencies] ||= []
end
attr_reader :paths
attr_reader :root
def initialize(paths, root, params={})
@paths = paths
@root = root
get_metadata
# override the inferred data with the passed-in data
params.each do |k,v|
self[k] = v
end
end
# this method should take the paths and root and infer as much
# about the package as it can.
def get_metadata
raise NoMethodError,
"Please subclass FPM::Source and define get_metadata"
end
def make_tarball!(tar_path)
raise NoMethodError,
"Please subclass FPM::Source and define make_tarball!(tar_path)"
end
def metadata
@metadata ||= {}
end
def [](key)
metadata[key.to_sym]
end
def []=(key,val)
metadata[key.to_sym] = val
end
# MySourceClass.new('/tmp/build').package(FPM::Deb).assemble(params)
def package(pkg_cls)
pkg_cls.new(self)
end
# make the binding public for erb templating
def render(template)
template.result(binding)
end
private
def tar(output, paths)
dirs = []
paths.each do |path|
while path != "/" and path != "."
dirs << path if !dirs.include?(path)
path = File.dirname(path)
end
end # paths.each
system(*["tar", "--owner=root", "--group=root", "-cf", output, "--no-recursion", *dirs]) if dirs.any?
system(*["tar", "--owner=root", "--group=root", "-rf", output, *paths])
end # def tar
end
|