4 def has_command(arguments
):
6 process
= subprocess
.Popen(arguments
, stdin
= subprocess
.PIPE
, stdout
= subprocess
.PIPE
, stderr
= subprocess
.PIPE
)
14 process
= subprocess
.Popen(arguments
, stdin
= subprocess
.PIPE
, stdout
= subprocess
.PIPE
, stderr
= subprocess
.PIPE
)
16 return process
.returncode
== 0
21 print 'Executing: %s' % input
22 return os
.system(input) != 0
24 def symlink(target
, link_name
):
25 if os
.path
.exists(link_name
):
28 return command('sudo ln -s %s %s' % (target
, link_name
))
30 def install_packages(packages
):
33 for package
in packages
:
34 result
= run(['dpkg', '-s', package
])
36 print 'Failed to execute package manager'
39 print 'Installing missing package %s' % package
40 os
.system('sudo apt-get install %s' % package
)
42 print 'Unable to install the specified packages (%s) - only Ubuntu and Debian are currently supported.' % packages
45 def setup_local_symlink(local_directory
, target
, link
):
46 root
= os
.path
.dirname(nil
.environment
.get_script_path())
48 target_path
= os
.path
.join(root
, target
)
49 symlink_path
= os
.path
.join('/usr/local', local_directory
, link
)
51 symlink(target_path
, symlink_path
)
54 setup_local_symlink('include', target
, target
)
57 setup_local_symlink('lib', target
, os
.path
.basename(target
))