Class: FPM::Source::Tar

Inherits:
FPM::Source show all
Defined in:
lib/fpm/source/tar.rb

Instance Attribute Summary

Attributes inherited from FPM::Source

#paths, #root

Instance Method Summary collapse

Methods inherited from FPM::Source

#[], #[]=, #dependencies, #get_source, #initialize, #metadata, #package

Constructor Details

This class inherits a constructor from FPM::Source

Instance Method Details

#get_metadataObject



7
8
9
# File 'lib/fpm/source/tar.rb', line 7

def 
  self[:name] = @paths.first.split(".").first
end

#make_tarball!(tar_path, builddir) ⇒ Object

def get_metadata



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fpm/source/tar.rb', line 11

def make_tarball!(tar_path, builddir)
  input_tarball = @paths.first

  if input_tarball =~ /\.tar\.bz2$/
    compression = :bipz2
  elsif input_tarball =~ /\.tar\.gz$/
    compression = :gzip
  elsif input_tarball =~ /\.tar\.xz$/
    compression = :lzma
  else
    compression = :none
  end

  # Unpack the tar file
  installdir = "#{builddir}/tarbuild/#{self[:prefix]}"
  FileUtils.mkdir_p(installdir)
  flags = "-xf #{input_tarball} -C #{installdir}"
  case compression
    when :bzip2; flags += " -j"
    when :gzip; flags += " -z"
    when :lzma; flags += " --lzma"
  end
  #puts("tar #{flags}")
  #sleep 5
  safesystem("tar #{flags}")

  if self[:prefix]
    @paths = [self[:prefix]]
  else
    @paths = ["."]
  end

  ::Dir.chdir("#{builddir}/tarbuild") do
    tar(tar_path, ".")
  end

  # TODO(sissel): Make a helper method.
  safesystem(*["gzip", "-f", tar_path])
end