Class: FPM::Fry::Source::Archive::TarCache
- Defined in:
- lib/fpm/fry/source/archive.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Cache
Instance Method Summary collapse
Methods inherited from Cache
Instance Method Details
#copy_to(dst) ⇒ Object
156 157 158 159 |
# File 'lib/fpm/fry/source/archive.rb', line 156 def copy_to(dst) update! Exec['tar','-xf',tempfile,'-C',dst, logger: logger] end |
#prefix ⇒ Object
161 162 163 164 |
# File 'lib/fpm/fry/source/archive.rb', line 161 def prefix update! @prefix ||= prefix! end |
#prefix! ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/fpm/fry/source/archive.rb', line 166 def prefix! longest = nil Exec.popen('tar','-tf',tempfile, logger: logger).each_line.map do |line| line = line.chomp parts = line.split('/') parts.pop unless line[-1] == '/' if longest.nil? longest = parts else longest.each_with_index do | e, i | if parts[i] != e longest = longest[0...i] break end end break if longest.none? end end return Array(longest).join('/') end |
#tar_io ⇒ Object
151 152 153 154 |
# File 'lib/fpm/fry/source/archive.rb', line 151 def tar_io update! ioclass.open(tempfile) end |