Check-in [e1cb956b73]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Auto add directories for rpm |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
e1cb956b738b1449b635f54f49dd59ed |
User & Date: | pranay.kanwar@gmail.com 2013-04-17 14:49:01 |
Context
2013-04-17
| ||
15:41 | #413 Fix name for directories and config files check-in: 6d1126357d user: pranay.kanwar@gmail.com tags: trunk | |
14:49 | Auto add directories for rpm check-in: e1cb956b73 user: pranay.kanwar@gmail.com tags: trunk | |
2013-04-11
| ||
17:12 | - fix_dependency on Conflicts and Breaks (#410) - add test coverage for #410 check-in: 00c4224e90 user: jls@semicomplete.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 | 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 | > > | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | 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 def rpm_file_entry(file) return file unless attributes[:rpm_use_file_permissions?] stat = File.stat( file.gsub(/\"/, '') ) user = Etc.getpwuid(stat.uid).name |
︙ | ︙ | |||
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) | > > > > > > > > > > > > > > > > > > > > > > > > > > | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 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 | "--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.
︙ | ︙ | |||
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| -%> | | | | < < < < < < | | 111 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 137 138 139 140 141 142 143 144 145 146 147 148 149 | <% end -%> <% end -%> %files %defattr(-,<%= attributes[:rpm_user] %>,<%= attributes[:rpm_group] %>,-) <%# Output config files and then regular files. -%> <% config_files.each do |path| -%> %config(noreplace) <%= 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' here is the method FPM::Package#files. # The 'files' section of rpm can be # 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 files.collect { |f| "/#{f}" } \ .reject { |f| config_files.include?(f) } \ .reject { |f| directories.include?(f) } \ .collect { |f| f[/\s/] and "\"#{f}\"" or f } \ .collect { |f| f.gsub("[", "[\\[]") } \ .collect { |f| f.gsub("*", "[*]") } \ .collect { |f| f.gsub("?", "[?]") } \ .collect { |f| f.gsub("%", "[%]") } \ .map { |f| rpm_file_entry(f) } \ .join("\n") #.collect { |f| File.join(prefix, f) } \ %> %changelog <%= attributes[:rpm_changelog] %> |
Added templates/rpm/filesystem_list.
more than 10,000 changes