Module | FPM::Util |
In: |
lib/fpm/util/tar_writer.rb
lib/fpm/util.rb lib/fpm/util/tar_writer.rb lib/fpm/util.rb |
Some utility functions
Get an array containing the recommended ‘ar’ command for this platform and the recommended options to quickly create/append to an archive without timestamps or uids (if possible).
Get an array containing the recommended ‘ar’ command for this platform and the recommended options to quickly create/append to an archive without timestamps or uids (if possible).
Return whether the command returned by ar_cmd can create deterministic archives
Return whether the command returned by ar_cmd can create deterministic archives
execmd([env,] cmd [,opts])
Execute a command as a child process. The function allows to:
—- EXAMPLE 1 (simple execution)
if execmd([‘which’, ‘python’]) == 0
p "Python is installed"
end
—- EXAMPLE 2 (custom environment variables)
execmd({:PYTHONPATH=>’/home/me/foo’}, [ ‘python’, ’-m’, ‘bar’])
—- EXAMPLE 3 (communicating via stdin, stdout and stderr)
script = <<PYTHON import sys sys.stdout.write("normal output\n") sys.stdout.write("narning or error\n") PYTHON status = execmd(‘python’) do |stdin,stdout,stderr|
stdin.write(script) stdin.close p "STDOUT: #{stdout.read}" p "STDERR: #{stderr.read}"
end p "STATUS: #{status}"
—- EXAMPLE 4 (additional options)
execmd([‘which’, ‘python’], :process=>true, :stdin=>false, :stderr=>false) do |process,stdout|
p = stdout.read.chomp process.wait if (x = process.exit_code) == 0 p "PYTHON: #{p}" else p "ERROR: #{x}" end
end
OPTIONS:
:process (default: false) -- pass process object as the first argument the to block, :stdin (default: true) -- pass stdin object of the child process to the block for writting, :stdout (default: true) -- pass stdout object of the child process to the block for reading, :stderr (default: true) -- pass stderr object of the child process to the block for reading,
execmd([env,] cmd [,opts])
Execute a command as a child process. The function allows to:
—- EXAMPLE 1 (simple execution)
if execmd([‘which’, ‘python’]) == 0
p "Python is installed"
end
—- EXAMPLE 2 (custom environment variables)
execmd({:PYTHONPATH=>’/home/me/foo’}, [ ‘python’, ’-m’, ‘bar’])
—- EXAMPLE 3 (communicating via stdin, stdout and stderr)
script = <<PYTHON import sys sys.stdout.write("normal output\n") sys.stdout.write("narning or error\n") PYTHON status = execmd(‘python’) do |stdin,stdout,stderr|
stdin.write(script) stdin.close p "STDOUT: #{stdout.read}" p "STDERR: #{stderr.read}"
end p "STATUS: #{status}"
—- EXAMPLE 4 (additional options)
execmd([‘which’, ‘python’], :process=>true, :stdin=>false, :stderr=>false) do |process,stdout|
p = stdout.read.chomp process.wait if (x = process.exit_code) == 0 p "PYTHON: #{p}" else p "ERROR: #{x}" end
end
OPTIONS:
:process (default: false) -- pass process object as the first argument the to block, :stdin (default: true) -- pass stdin object of the child process to the block for writting, :stdout (default: true) -- pass stdout object of the child process to the block for reading, :stderr (default: true) -- pass stderr object of the child process to the block for reading,
Return whether the command returned by tar_cmd can create deterministic archives
Return whether the command returned by tar_cmd can create deterministic archives