Check-in [d80d7e6df3]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Merge pull request #414 from r4um/auto_rpm_dirs Fix #199 Auto add directories for rpm. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
d80d7e6df32e5fd48d145c4c2479bb82 |
User & Date: | jls@semicomplete.com 2013-04-19 15:42:02 |
Context
2013-04-22
| ||
15:43 | Merge pull request #420 from r4um/fix_258 #258 Make root/root as owner of control files check-in: 710c018141 user: jls@semicomplete.com tags: trunk | |
09:42 | #258 Make root/root as owner of control files check-in: d7ed65f844 user: pranay.kanwar@gmail.com tags: trunk | |
05:49 | #411 Translate noarch architecture to all for debian check-in: 618e87df21 user: pranay.kanwar@gmail.com tags: trunk | |
05:42 | Do no generate empty prefix check-in: ace42aee1b user: pranay.kanwar@gmail.com tags: trunk | |
2013-04-19
| ||
15:42 | Merge pull request #414 from r4um/auto_rpm_dirs Fix #199 Auto add directories for rpm. check-in: d80d7e6df3 user: jls@semicomplete.com tags: trunk | |
15:41 | Merge pull request #417 from rafacas/master Fixed an error showed by puppet if the EMPTY file is very large check-in: 1445d61281 user: jls@semicomplete.com tags: trunk | |
2013-04-17
| ||
16:10 | #353 Remove trailing slash from prefix check-in: 3514279ff8 user: pranay.kanwar@gmail.com tags: trunk | |
Changes
Changes to lib/fpm/package.rb.
︙ | ︙ | |||
308 309 310 311 312 313 314 | # but requires the 'backports' gem (which is used in other places in fpm) return Enumerator.new { |y| Find.find(staging_path) { |path| y << path } } \ .select { |path| path != staging_path } \ .select { |path| is_leaf.call(path) } \ .collect { |path| path[staging_path.length + 1.. -1] } end # def files | | | > > > | 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | # but requires the 'backports' gem (which is used in other places in fpm) return Enumerator.new { |y| Find.find(staging_path) { |path| y << path } } \ .select { |path| path != staging_path } \ .select { |path| is_leaf.call(path) } \ .collect { |path| path[staging_path.length + 1.. -1] } end # def files def template_dir File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "templates")) end def template(path) template_path = File.join(template_dir, path) template_code = File.read(template_path) @logger.info("Reading template", :path => template_path) erb = ERB.new(template_code, nil, "-") erb.filename = template_path return erb end # def template |
︙ | ︙ |
Changes to lib/fpm/package/rpm.rb.
︙ | ︙ | |||
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | option "--changelog", "FILEPATH", "Add changelog from FILEPATH contents" do |file| File.read(File.expand_path(file)) end option "--sign", :flag, "Pass --sign to rpmbuild" private def rpm_file_entry(file) return file unless attributes[:rpm_use_file_permissions?] stat = File.stat( file.gsub(/\"/, '') ) user = Etc.getpwuid(stat.uid).name group = Etc.getgrgid(stat.gid).name mode = stat.mode return sprintf("%%attr(%o, %s, %s) %s\n", mode & 4095 , user, group, file) | > > > > > > > > > > > > > > > > | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | option "--changelog", "FILEPATH", "Add changelog from FILEPATH contents" do |file| File.read(File.expand_path(file)) end option "--sign", :flag, "Pass --sign to rpmbuild" option "--auto-add-directories", :flag, "Auto add directories not part of filesystem" private # Fix path name # Replace [ with [\[] to make rpm not use globs # Replace * with [*] to make rpm not use globs # Replace ? with [?] to make rpm not use globs # Replace % with [%] to make rpm not expand macros def rpm_fix_name(name) name = "\"#{name}\"" if name[/\s/] name = name.gsub("[", "[\\[]") name = name.gsub("*", "[*]") name = name.gsub("?", "[?]") name = name.gsub("%", "[%]") end def rpm_file_entry(file) file = rpm_fix_name(file) return file unless attributes[:rpm_use_file_permissions?] stat = File.stat( file.gsub(/\"/, '') ) user = Etc.getpwuid(stat.uid).name group = Etc.getgrgid(stat.gid).name mode = stat.mode return sprintf("%%attr(%o, %s, %s) %s\n", mode & 4095 , user, group, file) |
︙ | ︙ | |||
261 262 263 264 265 266 267 268 269 270 271 272 273 274 | "--define", "_topdir #{build_path}", "--define", "_sourcedir #{build_path}", "--define", "_rpmdir #{build_path}/RPMS", ] args += ["--sign"] if attributes[:rpm_sign?] (attributes[:rpm_rpmbuild_define] or []).each do |define| args += ["--define", define] end rpmspec = template("rpm.erb").result(binding) specfile = File.join(build_path("SPECS"), "#{name}.spec") File.write(specfile, rpmspec) | > > > > > > > > > > > > > > > > > > > > > > > > > > | 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | "--define", "_topdir #{build_path}", "--define", "_sourcedir #{build_path}", "--define", "_rpmdir #{build_path}/RPMS", ] args += ["--sign"] if attributes[:rpm_sign?] if attributes[:rpm_auto_add_directories?] fs_dirs_list = File.join(template_dir, "rpm", "filesystem_list") fs_dirs = File.readlines(fs_dirs_list).reject { |x| x =~ /^\s*#/}.map { |x| x.chomp } Find.find(staging_path) do |path| next if path == staging_path if File.directory? path add_path = path.gsub(/^#{staging_path}/,'') self.directories << add_path if not fs_dirs.include? add_path end end else self.directories = self.directories.map { |x| File.join(self.prefix, x) } alldirs = [] self.directories.each do |path| Find.find(File.join(staging_path, path)) do |subpath| if File.directory? subpath alldirs << subpath.gsub(/^#{staging_path}/, '') end end end self.directories = alldirs end self.config_files = self.config_files.map { |x| File.join(self.prefix, x) } (attributes[:rpm_rpmbuild_define] or []).each do |define| args += ["--define", define] end rpmspec = template("rpm.erb").result(binding) specfile = File.join(build_path("SPECS"), "#{name}.spec") File.write(specfile, rpmspec) |
︙ | ︙ |
Changes to templates/rpm.erb.
︙ | ︙ | |||
23 24 25 26 27 28 29 30 | <%# use the first line of the description as the summary -%> Summary: <%= description.split("\n").first.empty? ? "_" : description.split("\n").first %> BuildArch: <%= architecture %> AutoReqProv: no # Seems specifying BuildRoot is required on older rpmbuild (like on CentOS 5) # fpm passes '--define buildroot ...' on the commandline, so just reuse that. BuildRoot: %buildroot <% if !prefix.nil? and !prefix.empty? %> | > | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | <%# use the first line of the description as the summary -%> Summary: <%= description.split("\n").first.empty? ? "_" : description.split("\n").first %> BuildArch: <%= architecture %> AutoReqProv: no # Seems specifying BuildRoot is required on older rpmbuild (like on CentOS 5) # fpm passes '--define buildroot ...' on the commandline, so just reuse that. BuildRoot: %buildroot # Add prefix, must not end with / <% if !prefix.nil? and !prefix.empty? %> Prefix: <%= prefix.gsub(/\/$/, '') %> <% end -%> Group: <%= category %> <%# Sometimes the 'license' field has multiple lines... Hack around it. # While technically yes this means we are 'modifying' the license, # since the job of FPM is to get shit done and that this is only # modifying whitespace, it should be reasonably OK. -%> |
︙ | ︙ | |||
111 112 113 114 115 116 117 | <% end -%> <% end -%> %files %defattr(-,<%= attributes[:rpm_user] %>,<%= attributes[:rpm_group] %>,-) <%# Output config files and then regular files. -%> <% config_files.each do |path| -%> | | | | < < < < < < < | | | < < < < < < | | | < < < < < | < < | | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | <% end -%> <% end -%> %files %defattr(-,<%= attributes[:rpm_user] %>,<%= attributes[:rpm_group] %>,-) <%# Output config files and then regular files. -%> <% config_files.each do |path| -%> %config(noreplace) <%= rpm_fix_name(path) %> <% end -%> <%# list directories %> <% directories.each do |path| -%> %dir <%= rpm_file_entry(path) %> <% end -%> <%# list only files, not directories? -%> # Reject config files already listed or parent directories, then prefix files # with "/", then make sure paths with spaces are quoted. I hate rpm so much. <% files.each do |path| -%> <% path = "/#{path}" -%> <% next if config_files.include?(path)-%> <% next if directories.include?(path)-%> <%= rpm_file_entry(path) %> <% end -%> %changelog <%= attributes[:rpm_changelog] %> |
Added templates/rpm/filesystem_list.
more than 10,000 changes