class Yast::TarballServlet

a webrick servlet which dynamically creates a tarball with the content of the current Git checkout

Public Instance Methods

do_GET(_request, response) click to toggle source
# File lib/yast/tarball_servlet.rb, line 27
def do_GET(_request, response)
  response.status = 200
  response.content_type = "application/gzip"
  response.body = source_archive
end

Private Instance Methods

gzip() click to toggle source

find which gzip is installed, use the faster parallel gzip (“pigz”) if it is available @return [String] “pigz or ”gzip“

# File lib/yast/tarball_servlet.rb, line 48
def gzip
  return @gzip if @gzip

  # parallel gzip installed?
  @gzip = system("which pigz") ? "pigz" : "gzip"
end
source_archive() click to toggle source

compress the current sources into a tarball, no caching to ensure we always provide the latest content

# File lib/yast/tarball_servlet.rb, line 37
def source_archive
  # pack all Git files (including the non-tracked files (-o),
  # use --ignore-failed-read to not fail for removed files)
  # -z and --null: NUL-delimited
  git = "git ls-files --cached --others --exclude-standard -z"
  tar = "tar --create --ignore-failed-read --null --files-from -"
  `#{git} | #{tar} | #{gzip}`
end