-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a Ruby library for building linux packages
- Loading branch information
Showing
5 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ SUBDIRS = \ | |
|
||
CONFIG += ordered | ||
CONFIG += c++11 | ||
CONFIG += static |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require "fileutils" | ||
require "pry" | ||
|
||
class DeployQt | ||
attr_accessor :qt_home, :executable, :dst | ||
def initialize(executable) | ||
@pwd = ENV["PWD"] | ||
@executable = File.expand_path(File.join(@pwd, executable)) | ||
@qt_home = "#{ENV['QT_HOME']}/5.4/gcc_64" | ||
@dst = File.expand_path(File.join(@pwd, "/rbkit")) | ||
remove_existing_files | ||
@platform_plugin = File.expand_path(File.join(@qt_home, "/plugins/platforms/libqxcb.so")) | ||
@sql_driver_path = File.expand_path(File.join(@qt_home, "/plugins/sqldrivers/libqsqlite.so")) | ||
FileUtils.mkdir_p(@dst) | ||
make_required_dirs | ||
end | ||
|
||
def make_required_dirs | ||
FileUtils.mkdir_p("#{dst}/fonts") | ||
FileUtils.mkdir_p("#{dst}/libs") | ||
FileUtils.mkdir_p("#{dst}/platforms") | ||
FileUtils.mkdir_p("#{dst}/sqldrivers") | ||
end | ||
|
||
def remove_existing_files | ||
FileUtils.rm_rf(dst) | ||
FileUtils.rm_rf("rbkit.tar.gz") | ||
end | ||
|
||
def create_archive | ||
copy_app_libs | ||
copy_lib_dependencies | ||
copy_sql_dependencies | ||
make_executable | ||
create_tar_file | ||
end | ||
|
||
def create_tar_file | ||
FileUtils.cd(@pwd) do | ||
system("tar -zcvf rbkit.tar.gz rbkit") | ||
end | ||
end | ||
|
||
def copy_sql_dependencies | ||
FileUtils.cp(@sql_driver_path, "#{dst}/sqldrivers") | ||
end | ||
|
||
def copy_app_libs | ||
puts "Copying application dependencies for #{executable}" | ||
`ldd #{executable}`.tap do |deps| | ||
deps_array = deps.split("\n") | ||
deps_array.each { |deps_element| verify_and_copy(deps_element) } | ||
end | ||
end | ||
|
||
def copy_lib_dependencies | ||
FileUtils.cp(@platform_plugin, "#{dst}/platforms") | ||
`ldd #{@platform_plugin}`.tap do |deps| | ||
deps_array = deps.split("\n") | ||
deps_array.each { |deps_element| verify_and_copy(deps_element) } | ||
end | ||
end | ||
|
||
def make_executable | ||
exec_string =<<-EOD | ||
#!/bin/sh | ||
export LD_LIBRARY_PATH=\`pwd\`/libs | ||
export QT_QPA_FONTDIR=\`pwd\`/fonts | ||
./#{File.basename(executable)} | ||
EOD | ||
FileUtils.cp(executable, dst) | ||
File.open("#{dst}/rbkit", "w") do |fl| | ||
fl.puts(exec_string) | ||
end | ||
system("chmod +x #{dst}/rbkit") | ||
end | ||
|
||
private | ||
|
||
def verify_and_copy(deps_element) | ||
dep_path = deps_element.split("=>").last.split("(").first.strip | ||
if !dep_path.empty? && dep_path.match(/^#{ENV['HOME']}/) | ||
FileUtils.cp(File.expand_path(dep_path), "#{dst}/libs") | ||
end | ||
end | ||
end | ||
|
||
DeployQt.new(ARGV[0]).create_archive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
executable=$1 | ||
echo $executable | ||
for dep in `ldd $executable | awk '{print $3}' | grep -v "("` | ||
do | ||
echo "Copied dependency "$dep" to "$libsdir | ||
done |