Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add basic qnx support for train #203

Merged
merged 2 commits into from
Oct 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/train/extras.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Train::Extras
require 'train/extras/file_common'
require 'train/extras/file_unix'
require 'train/extras/file_aix'
require 'train/extras/file_qnx'
require 'train/extras/file_linux'
require 'train/extras/file_windows'
require 'train/extras/os_common'
Expand Down
34 changes: 34 additions & 0 deletions lib/train/extras/file_qnx.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# encoding: utf-8
# author: Christoph Hartmann
# author: Dominik Richter

module Train::Extras
class QnxFile < UnixFile
def content
cat = 'cat'
cat = '/proc/boot/cat' if @backend.os[:release].to_i >= 7
@content ||= case
when !exist?
nil
else
@backend.run_command("#{cat} #{@spath}").stdout || ''
end
end

def type
if @backend.run_command("file #{@spath}").stdout.include?('directory')
return :directory
else
return :file
end
end

%w{
mode owner group uid gid mtime size selinux_label link_path mounted stat
}.each do |field|
define_method field.to_sym do
fail NotImplementedError, "QNX does not implement the #{m}() method yet."
end
end
end
end
2 changes: 1 addition & 1 deletion lib/train/extras/os_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def to_hash

OS['linux'] = %w{linux alpine arch coreos exherbo gentoo slackware fedora amazon} + OS['redhat'] + OS['debian'] + OS['suse']

OS['unix'] = %w{unix aix hpux} + OS['linux'] + OS['solaris'] + OS['bsd']
OS['unix'] = %w{unix aix hpux qnx} + OS['linux'] + OS['solaris'] + OS['bsd']

# Helper methods to check the OS type
# Provides methods in the form of: linux?, unix?, solaris? ...
Expand Down
6 changes: 6 additions & 0 deletions lib/train/extras/os_detect_unix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ def detect_via_uname # rubocop:disable Metrics/AbcSize
@platform[:name] = uname_s.lines[0].chomp
@platform[:release] = uname_r.lines[0].chomp

when /qnx/
@platform[:family] = 'qnx'
@platform[:name] = uname_s.lines[0].chomp.downcase
@platform[:release] = uname_r.lines[0].chomp
@platform[:arch] = uname_m

when /sunos/
detect_solaris
else
Expand Down
2 changes: 2 additions & 0 deletions lib/train/transports/ssh_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def file(path)
AixFile.new(self, path)
elsif os.solaris?
UnixFile.new(self, path)
elsif os[:name] == 'qnx'
QnxFile.new(self, path)
else
LinuxFile.new(self, path)
end
Expand Down