fpm 0.3.4 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELIST CHANGED
@@ -22,6 +22,6 @@
22
22
  Example:
23
23
  --python-bin=/usr/bin/python2.7
24
24
  --python-easyinstall=/usr/bin/easy_install2.7
25
-
25
+
26
26
  0.2.26 and earlier
27
27
  No changelist tracked. My bad, yo.
data/bin/fpm CHANGED
File without changes
@@ -61,8 +61,8 @@ Dir.glob("#{builddir}/usr/lib/node/.npm/*/*") do |path|
61
61
  # So we'll specify deps of {v}-1 <= x <= {v}-999999....
62
62
  depends = Dir.glob("#{path}/dependson/*@*") \
63
63
  .collect { |p| PACKAGEPREFIX + File.basename(p) } \
64
- .collect { |p| n,v = p.split("@");
65
- ["#{n} (>= #{v}-1)", "#{n} (<= #{v}-99999999999999)"]
64
+ .collect { |p| n,v = p.split("@");
65
+ ["#{n} (>= #{v}-1)", "#{n} (<= #{v}-99999999999999)"]
66
66
  }.flatten
67
67
 
68
68
  if package["author"]
@@ -73,7 +73,7 @@ Dir.glob("#{builddir}/usr/lib/node/.npm/*/*") do |path|
73
73
  maintainer = "#{m["name"]} <#{m["email"]}>"
74
74
  end
75
75
 
76
- pkgcmd = [ "fpm",
76
+ pkgcmd = [ "fpm",
77
77
  "-n", "#{PACKAGEPREFIX}#{package["name"]}",
78
78
  "-v", package["version"],
79
79
  "-m", maintainer,
@@ -13,7 +13,7 @@ class FPM::Builder
13
13
  o = @package.default_output
14
14
  if o[0,1] == "/"
15
15
  o
16
- else
16
+ else
17
17
  File.join(@working_dir, o)
18
18
  end
19
19
  end
@@ -47,6 +47,7 @@ class FPM::Builder
47
47
  :maintainer => settings.maintainer,
48
48
  :provides => [],
49
49
  :replaces => [],
50
+ :conflicts => [],
50
51
  :description => settings.description,
51
52
  :url => settings.url,
52
53
  :settings => settings.source
@@ -55,7 +56,7 @@ class FPM::Builder
55
56
  @edit = !!settings.edit
56
57
 
57
58
  @paths = paths
58
- @package = package_class_for(settings.package_type).new(@source,
59
+ @package = package_class_for(settings.package_type).new(@source,
59
60
  :settings => settings.target
60
61
  )
61
62
  # Append dependencies given from settings (-d flag for fpm)
@@ -63,13 +64,16 @@ class FPM::Builder
63
64
  # Append provides given from settings (--provides flag for fpm)
64
65
  @package.provides += settings.provides if settings.provides
65
66
  @package.replaces += settings.replaces if settings.replaces
67
+ @package.conflicts += settings.conflicts if settings.conflicts
66
68
  @package.architecture = settings.architecture if settings.architecture
69
+ @package.category = settings.category if settings.category
67
70
  @package.scripts = settings.scripts
71
+ @package.config_files = settings.config_files
68
72
 
69
73
  @output = settings.package_path
70
74
  @recurse_dependencies = settings.recurse_dependencies
71
75
  end # def initialize
72
-
76
+
73
77
  def tar_path
74
78
  @tar_path ||= "#{builddir}/data.tar"
75
79
  end
@@ -10,7 +10,7 @@ class FPM::Flags
10
10
  def on(*args, &block)
11
11
  fixed_args = args.collect do |arg|
12
12
  if arg =~ /^--/
13
- "--#{@flag_prefix}-#{arg.gsub(/^--/, "")}"
13
+ "--#{@flag_prefix}-#{arg.gsub(/^--/, "")}"
14
14
  else
15
15
  "(#{@help_prefix}) #{arg}"
16
16
  end
@@ -3,7 +3,7 @@ require "socket" # for Socket.gethostname
3
3
  require "logger"
4
4
  require "find" # for Find.find (directory walking)
5
5
 
6
- class FPM::Package
6
+ class FPM::Package
7
7
  # The name of this package
8
8
  attr_accessor :name
9
9
 
@@ -18,7 +18,7 @@ class FPM::Package
18
18
  # The iteration of this package.
19
19
  # Debian calls this 'release' and is the last '-NUMBER' in the version
20
20
  # RedHat has this as 'Release' in the .spec file
21
- # FreeBSD calls this 'PORTREVISION'
21
+ # FreeBSD calls this 'PORTREVISION'
22
22
  # If left unpicked, it defaults to 1.
23
23
  attr_accessor :iteration
24
24
 
@@ -49,6 +49,10 @@ class FPM::Package
49
49
  # (Not all packages support this)
50
50
  attr_accessor :provides
51
51
 
52
+ # Array of things this package conflicts with.
53
+ # (Not all packages support this)
54
+ attr_accessor :conflicts
55
+
52
56
  # Array of things this package replaces.
53
57
  # (Not all packages support this)
54
58
  attr_accessor :replaces
@@ -59,6 +63,9 @@ class FPM::Package
59
63
  # hash of paths for maintainer/package scripts (postinstall, etc)
60
64
  attr_accessor :scripts
61
65
 
66
+ # Array of configuration files
67
+ attr_accessor :config_files
68
+
62
69
  # target-specific settings
63
70
  attr_accessor :settings
64
71
 
@@ -76,7 +83,7 @@ class FPM::Package
76
83
  @dependencies = source[:dependencies] || []
77
84
  # Iteration can be nil. If nil, the fpm package implementation is expected
78
85
  # to handle any default value that should be instead.
79
- @iteration = source[:iteration]
86
+ @iteration = source[:iteration]
80
87
  @url = source[:url] || "http://nourlgiven.example.com/no/url/given"
81
88
  @category = source[:category] || "default"
82
89
  @license = source[:license] || "unknown"
@@ -108,10 +115,12 @@ class FPM::Package
108
115
  @description = source[:description] || "no description given"
109
116
  @provides = source[:provides] || []
110
117
  @replaces = source[:replaces] || []
118
+ @conflicts = source[:conflicts] || []
111
119
  @scripts = source[:scripts]
120
+ @config_files = source[:config_files] || []
112
121
 
113
- # Target-specific settings, mirrors :settings metadata in FPM::Source
114
- @settings = params[:settings] || {}
122
+ # Target-specific settings, mirrors :settings metadata in FPM::Source
123
+ @settings = params[:settings] || {}
115
124
  end # def initialize
116
125
 
117
126
  # nobody needs md5sums by default.
@@ -158,7 +167,7 @@ class FPM::Package
158
167
  end # def default_output
159
168
 
160
169
  def fixpath(path)
161
- if path[0,1] != "/"
170
+ if path[0,1] != "/"
162
171
  path = File.join(@source.root, path)
163
172
  end
164
173
  return path if File.symlink?(path)
@@ -14,11 +14,13 @@ class FPM::Program
14
14
  @settings.exclude = [] # Paths to exclude in packaging
15
15
  @settings.provides = []
16
16
  @settings.replaces = []
17
+ @settings.conflicts = []
17
18
  @settings.source = {} # source settings
18
19
  @settings.target = {} # target settings
20
+ @settings.config_files ||= []
19
21
 
20
22
  # Maintainer scripts - https://github.com/jordansissel/fpm/issues/18
21
- @settings.scripts ||= {}
23
+ @settings.scripts ||= {}
22
24
 
23
25
  @help = nil
24
26
  end # def initialize
@@ -40,7 +42,7 @@ class FPM::Program
40
42
 
41
43
  if !ok
42
44
  $stderr.puts "There were errors; see above."
43
- $stderr.puts
45
+ $stderr.puts
44
46
  $stderr.puts @help
45
47
  return 1
46
48
  end
@@ -59,14 +61,14 @@ class FPM::Program
59
61
  FPM::Source::Gem.flags(FPM::Flags.new(opts, "gem", "gem source only"), @settings)
60
62
  FPM::Source::Python.flags(FPM::Flags.new(opts, "python", "python source only"),
61
63
  @settings)
62
- FPM::Target::Deb.flags(FPM::Flags.new(opts, "deb", "deb target only"), @settings)
63
-
64
+ FPM::Target::Deb.flags(FPM::Flags.new(opts, "deb", "deb target only"), @settings)
65
+
64
66
  # Process fpmrc first
65
67
  fpmrc(opts)
66
68
 
67
69
  # Proces normal flags now.
68
70
  remaining = opts.parse(args)
69
-
71
+
70
72
  # need to print help in a different scope
71
73
  @help = opts.help
72
74
 
@@ -78,7 +80,7 @@ class FPM::Program
78
80
  return if !ENV.include?("HOME")
79
81
  rcpath = File.expand_path("~/.fpmrc")
80
82
  return if !File.exists?(rcpath)
81
-
83
+
82
84
  # fpmrc exists, read it as flags, one per line.
83
85
  File.new(rcpath, "r").each do |line|
84
86
  flag = line.chomp
@@ -109,7 +111,7 @@ class FPM::Program
109
111
 
110
112
  opts.on("-v VERSION", "--version VERSION",
111
113
  "version to give the package") do |version|
112
- @settings.version = version
114
+ @settings.version = version
113
115
  end # --version
114
116
 
115
117
  opts.on("--iteration ITERATION",
@@ -126,14 +128,27 @@ class FPM::Program
126
128
  @settings.dependencies << dep
127
129
  end # --depends
128
130
 
131
+ opts.on("--category SECTION_OR_GROUP") do |thing|
132
+ @settings.category = thing
133
+ end # --category
134
+
129
135
  opts.on("--provides PROVIDES") do |thing|
130
136
  @settings.provides << thing
131
137
  end # --provides
132
138
 
139
+ opts.on("--conflicts CONFLICTS") do |thing|
140
+ @settings.conflicts << thing
141
+ end # --conflicts
142
+
133
143
  opts.on("--replaces REPLACES") do |thing|
134
144
  @settings.replaces << thing
135
145
  end # --replaces
136
146
 
147
+ opts.on("--config-files PATH",
148
+ "(optional) Treat path as a configuration file. Uses conffiles in deb or %config in rpm. (/etc/package.conf)") do |thing|
149
+ @settings.config_files << thing
150
+ end
151
+
137
152
  opts.on("-a ARCHITECTURE", "--architecture ARCHITECTURE") do |arch|
138
153
  @settings.architecture = arch
139
154
  end # --architecture
@@ -152,7 +167,7 @@ class FPM::Program
152
167
 
153
168
  opts.on("-s SOURCE_TYPE", "what to build the package from") do |st|
154
169
  @settings.source_type = st
155
- end # -s
170
+ end # -s
156
171
 
157
172
  opts.on("-S PACKAGE_SUFFIX", "which suffix to append to package and dependencies") do |sfx|
158
173
  @settings.suffix = sfx
@@ -87,11 +87,11 @@ class FPM::Source
87
87
  paths = [ paths ] if paths.is_a? String
88
88
  paths.each do |path|
89
89
  while path != "/" and path != "."
90
- dirs << path if !dirs.include?(path)
90
+ dirs << path if !dirs.include?(path)
91
91
  path = File.dirname(path)
92
92
  end
93
93
  end # paths.each
94
-
94
+
95
95
  # Want directories to be sorted thusly: [ "/usr", "/usr/bin" ]
96
96
  # Why? tar and some package managers sometimes fail if the tar is created
97
97
  # like: [ "/opt/fizz", "/opt" ]
@@ -136,7 +136,7 @@ class FPM::Source
136
136
  end
137
137
  end # def tar
138
138
 
139
- def tar_cmd
139
+ def tar_cmd
140
140
  # Rely on gnu tar for solaris.
141
141
  case %x{uname -s}.chomp
142
142
  when "SunOS"
@@ -16,7 +16,7 @@ class FPM::Source::Dir < FPM::Source
16
16
  @paths.each do |path|
17
17
  # Trim @root (--chdir)
18
18
  if @root != "." and path.start_with?(@root)
19
- path = path[@root.size .. -1]
19
+ path = path[@root.size .. -1]
20
20
  end
21
21
 
22
22
  # Copy to self[:prefix] (aka --prefix)
@@ -50,7 +50,7 @@ class get_metadata(Command):
50
50
  dependencies = self.distribution.install_requires
51
51
  except:
52
52
  pass
53
-
53
+
54
54
  # In some cases (Mysql-Python) 'dependencies' is none, not empty.
55
55
  if dependencies is None:
56
56
  dependencies = []
@@ -30,7 +30,7 @@ class FPM::Source::Python < FPM::Source
30
30
  return
31
31
  end
32
32
 
33
- if !File.exists?(package)
33
+ if !File.exists?(package)
34
34
  download(package, params[:version])
35
35
  else
36
36
  @paths = [ File.expand_path(package) ]
@@ -34,7 +34,7 @@ class FPM::Target::Deb < FPM::Package
34
34
  # Debian calls x86_64 "amd64"
35
35
  @architecture = "amd64"
36
36
  end
37
-
37
+
38
38
  return @architecture
39
39
  end # def architecture
40
40
 
@@ -80,7 +80,12 @@ class FPM::Target::Deb < FPM::Package
80
80
  else raise "Unsupported script name '#{name}' (path: #{path})"
81
81
  end # case name
82
82
  end # self.scripts.each
83
-
83
+
84
+ if self.config_files.any?
85
+ File.open('conffiles', 'w'){ |f| f.puts(config_files.join("\n")) }
86
+ control_files << 'conffiles'
87
+ end
88
+
84
89
  # Make the control
85
90
  system("tar -zcf control.tar.gz #{control_files.join(" ")}")
86
91
 
@@ -92,30 +97,26 @@ class FPM::Target::Deb < FPM::Package
92
97
  end # def build
93
98
 
94
99
  def default_output
95
- v = version
96
- v = "#{epoch}:#{v}" if epoch
97
100
  if iteration
98
- "#{name}_#{v}-#{iteration}_#{architecture}.#{type}"
101
+ "#{name}_#{version}-#{iteration}_#{architecture}.#{type}"
99
102
  else
100
- "#{name}_#{v}_#{architecture}.#{type}"
103
+ "#{name}_#{version}_#{architecture}.#{type}"
101
104
  end
102
105
  end # def default_output
103
106
 
104
107
  def fix_dependency(dep)
105
- # Convert strings 'foo >= bar' to 'foo (>= bar)'
106
- if dep =~ /\(/
107
- # nothing
108
+ if dep =~ /[\(,\|]/
109
+ # Don't "fix" ones that could appear well formed already.
108
110
  else
109
- # If the dependency is simply a name, turn it into 'name (>= 0)'
110
111
  da = dep.split(/ +/)
111
- if da.size == 1
112
- da += [">=", "0"]
112
+ if da.size > 1
113
+ # Convert strings 'foo >= bar' to 'foo (>= bar)'
114
+ dep = "#{da[0]} (#{da[1]} #{da[2]})"
113
115
  end
114
- dep = "#{da[0]} (#{da[1]} #{da[2]})"
115
116
  end
116
117
 
117
118
  name_re = /^[^ \(]+/
118
- name = dep[name_re]
119
+ name = dep[name_re]
119
120
  if name =~ /[A-Z]/
120
121
  @logger.warn("Downcasing dependency '#{name}' because deb packages " \
121
122
  " don't work so good with uppercase names")
@@ -149,4 +150,3 @@ class FPM::Target::Deb < FPM::Package
149
150
  end
150
151
  end # def fix_dependency
151
152
  end # class FPM::Target::Deb
152
-
@@ -36,7 +36,7 @@ class FPM::Target::Puppet < FPM::Package
36
36
  dir = File.join(builddir, "manifests", File.dirname(manifest))
37
37
  @logger.info("manifests targeting: #{dir}")
38
38
  ::Dir.mkdir(dir) if !File.directory?(dir)
39
-
39
+
40
40
  File.open(File.join(builddir, "manifests", manifest), "w") do |f|
41
41
  @logger.info("manifest: #{f.path}")
42
42
  template = template(File.join("puppet", "#{manifest}.erb"))
@@ -10,7 +10,7 @@ class FPM::Target::Rpm < FPM::Package
10
10
  when "all"
11
11
  # Translate fpm "all" arch to what it means in RPM.
12
12
  return "noarch"
13
- else
13
+ else
14
14
  return @architecture
15
15
  end
16
16
  end # def architecture
@@ -30,7 +30,7 @@ class FPM::Target::Rpm < FPM::Package
30
30
  end
31
31
 
32
32
  %w(BUILD RPMS SRPMS SOURCES SPECS).each { |d| Dir.mkdir(d) }
33
- args = ["rpmbuild", "-ba",
33
+ args = ["rpmbuild", "-ba",
34
34
  "--define", "buildroot #{Dir.pwd}/BUILD",
35
35
  "--define", "_topdir #{Dir.pwd}",
36
36
  "--define", "_sourcedir #{Dir.pwd}",
@@ -11,7 +11,7 @@ class FPM::Target::Solaris < FPM::Package
11
11
  when nil, "native"
12
12
  @architecture = %x{uname -p}.chomp
13
13
  end
14
- # "all" is a valid arch according to
14
+ # "all" is a valid arch according to
15
15
  # http://www.bolthole.com/solaris/makeapackage.html
16
16
 
17
17
  return @architecture
@@ -23,11 +23,11 @@ class RPMFile::Header
23
23
  # At this point assume we've read and consumed the lead and signature.
24
24
  #len = @rpm.signature.index_length + @rpm.signature
25
25
  #
26
- # header size is
26
+ # header size is
27
27
  # ( @rpm.signature.index_length * size of a header entry )
28
28
  # + @rpm.signature.data_length
29
29
  #
30
- # header 'entries' are an
30
+ # header 'entries' are an
31
31
  # int32 (tag id), int32 (tag type), int32 (offset), uint32 (count)
32
32
  #
33
33
  # See rpm's header.c, the headerLoad method function for reference.
@@ -43,7 +43,7 @@ class RPMFile::Header
43
43
  @index_size = @index_count * entry_size
44
44
  tag_data = @rpm.file.read(@index_size)
45
45
  data = @rpm.file.read(@data_length)
46
-
46
+
47
47
  #ap :data => data
48
48
 
49
49
  (0 ... @index_count).each do |i|
@@ -55,7 +55,7 @@ class RPMFile::Header
55
55
  @tags << tag
56
56
 
57
57
  #ap tag.tag => {
58
- #:type => tag.type,
58
+ #:type => tag.type,
59
59
  #:offset => tag.offset,
60
60
  #:count => tag.count,
61
61
  #:value => (tag.value rescue "???"),
@@ -2,7 +2,7 @@ require File.join(File.dirname(__FILE__), "namespace")
2
2
 
3
3
  class RPMFile::Lead
4
4
  #struct rpmlead {
5
- attr_accessor :magic #unsigned char magic[4];
5
+ attr_accessor :magic #unsigned char magic[4];
6
6
  attr_accessor :major #unsigned char major;
7
7
  attr_accessor :minor #unsigned char minor;
8
8
  attr_accessor :type #short type;
@@ -12,7 +12,7 @@ class RPMFile::Lead
12
12
  attr_accessor :signature_type #short signature_type;
13
13
  attr_accessor :reserved #char reserved[16];
14
14
  #}
15
-
15
+
16
16
  attr_accessor :length
17
17
 
18
18
  def initialize(rpm)
@@ -29,7 +29,7 @@ class RPMFile::Lead
29
29
  raise "Unknown package 'type' value #{@type}"
30
30
  end
31
31
  end # def type
32
-
32
+
33
33
  def read
34
34
  # Use 'A' here instead of 'a' to trim nulls.
35
35
  @length = 96
@@ -8,7 +8,7 @@ require File.join(File.dirname(__FILE__), "tag")
8
8
  # source code, but mostly it started making more sense after reading this site:
9
9
  # http://www.rpm.org/max-rpm/s1-rpm-file-format-rpm-file-format.html
10
10
 
11
- class RPMFile
11
+ class RPMFile
12
12
  attr_reader :file
13
13
 
14
14
  def initialize(file)
@@ -6,21 +6,24 @@ Maintainer: <%= maintainer or "<unknown>" %>
6
6
  <% properdeps = dependencies.collect { |d| fix_dependency(d) }.flatten -%>
7
7
  Depends: <%= properdeps.flatten.join(", ") %>
8
8
  <% end -%>
9
+ <% if !conflicts.empty? -%>
10
+ Conflicts: <%= conflicts.join(", ") %>
11
+ <% end -%>
9
12
  <% if !provides.empty? -%>
10
- Provides: <%= provides.join(", ") -%>
13
+ Provides: <%= provides.join(", ") %>
11
14
  <% end -%>
12
15
  <% if !replaces.empty? -%>
13
16
  <% properrepl = replaces.collect { |d| fix_dependency(d) }.flatten -%>
14
17
  Replaces: <%= properrepl.flatten.join(", ") %>
15
18
  <% end -%>
16
19
  Standards-Version: 3.9.1
17
- Section: <%= category or "unknown" %>
20
+ Section: <%= category or "unknown" %>
18
21
  Priority: extra
19
22
  Homepage: <%= url or "http://nourlgiven.example.com/" %>
20
- Description: <%= name %> (FPM-generated package)
21
- <% max_len = 74 -%>
22
- <% if description -%>
23
- <%= description.gsub(/^$/, ".").gsub(/(.{1,#{max_len}})( +|$)\n?|(.{#{max_len}})/," \\1\\3\n") -%>
24
- <% else -%>
25
- <%= "no description given" %>
23
+ <% lines = (description or "no description given").split("\n") -%>
24
+ <% firstline = lines.first -%>
25
+ <% remainder = lines[1..-1] -%>
26
+ Description: <%= firstline %>
27
+ <% if !remainder.nil? -%>
28
+ <%= remainder.collect { |l| l =~ /^ *$/ ? " ." : " #{l}" }.join("\n") %>
26
29
  <% end -%>
@@ -14,7 +14,7 @@ Group: <%= category %>
14
14
  TODO: [Jay] rpms require a license
15
15
  let's detect it intelligently
16
16
  -%>
17
- License: <%= license %>
17
+ License: <%= license %>
18
18
  URL: <%= url or "http://nourlgiven.example.com/" %>
19
19
  Source0: %{_sourcedir}/data.tar.gz
20
20
  BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
@@ -28,7 +28,7 @@ BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
28
28
  nextversion = version.split(".").collect { |v| v.to_i }
29
29
  l = nextversion.length
30
30
  nextversion[l-2] += 1
31
- nextversion[l-1] = 0
31
+ nextversion[l-1] = 0
32
32
  nextversion = nextversion.join(".")
33
33
  ["#{name} >= #{version}", "#{name} < #{nextversion}"]
34
34
  # Convert gem >= A.B.C <= X.Y.Z to '>= A.B.C' and '<= X.Y.Z'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fpm
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 4
10
- version: 0.3.4
9
+ - 6
10
+ version: 0.3.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jordan Sissel
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-07 00:00:00 -07:00
18
+ date: 2011-07-08 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency