lib/pdk/module/build.rb in pdk-1.11.1 vs lib/pdk/module/build.rb in pdk-1.12.0

- old
+ new

@@ -123,11 +123,11 @@ validate_ustar_path!(relative_path.to_path) FileUtils.cp(path, dest_path, preserve: true) end rescue ArgumentError => e raise PDK::CLI::ExitWithError, _( - '%{message} Please rename the file or exclude it from the package ' \ + '%{message} Rename the file or exclude it from the package ' \ 'by adding it to the .pdkignore file in your module.', ) % { message: e.message } end # Check if the given path matches one of the patterns listed in the @@ -218,11 +218,33 @@ # @return nil. def build_package FileUtils.rm_f(package_file) Dir.chdir(target_dir) do - Zlib::GzipWriter.open(package_file) do |package_fd| - Minitar.pack(release_name, package_fd) + begin + gz = Zlib::GzipWriter.new(File.open(package_file, 'wb')) + tar = Minitar::Output.new(gz) + Find.find(release_name) do |entry| + entry_meta = { + name: entry, + } + + orig_mode = File.stat(entry).mode + min_mode = Minitar.dir?(entry) ? 0o755 : 0o644 + + entry_meta[:mode] = orig_mode | min_mode + + if entry_meta[:mode] != orig_mode + PDK.logger.debug(_('Updated permissions of packaged \'%{entry}\' to %{new_mode}') % { + entry: entry, + new_mode: (entry_meta[:mode] & 0o7777).to_s(8), + }) + end + + Minitar.pack_file(entry_meta, tar) + end + ensure + tar.close end end end # Select the most appropriate ignore file in the module directory.