2017-07-10 00:05:36 +02:00
|
|
|
require 'rugged'
|
2017-07-10 18:28:51 +02:00
|
|
|
require 'pty'
|
2017-07-10 00:05:36 +02:00
|
|
|
|
|
|
|
task default: %w[build]
|
|
|
|
|
2017-10-02 16:54:53 +02:00
|
|
|
task :build, [:options] do |t, args|
|
2017-07-10 00:05:36 +02:00
|
|
|
repo = Rugged::Repository.new('.')
|
|
|
|
commit = repo.head.target
|
|
|
|
parent = commit.parents.first
|
2017-07-10 18:28:51 +02:00
|
|
|
pkgs = commit.diff(parent).deltas.map { |d| d.new_file[:path] }
|
|
|
|
# Split paths into arrays
|
|
|
|
pkgs.map! { |p| Pathname.new(p).each_filename.to_a }
|
|
|
|
# looking for [disabled-]packages/(package_name)/...
|
|
|
|
pkgs.select! { |p| p.length > 2 and p[0] =~ /(?<disabled->)packages/ }
|
|
|
|
# Get package_name
|
|
|
|
pkgs.map! { |p| p[1] }
|
|
|
|
# Remove duplicate packages
|
|
|
|
pkgs.uniq!
|
|
|
|
pkgs.each do |pkg|
|
|
|
|
puts "Building #{pkg}"
|
|
|
|
begin
|
|
|
|
# Start blocking build loop
|
2017-10-02 16:54:53 +02:00
|
|
|
PTY.spawn("./scripts/run-docker.sh ./build-package.sh #{args[:options]} -a $TRAVIS_ARCH #{pkg}") do |stdout, stdin, pid|
|
2017-07-10 18:28:51 +02:00
|
|
|
begin
|
2017-10-02 16:54:53 +02:00
|
|
|
stdout.sync
|
2017-07-10 18:28:51 +02:00
|
|
|
stdout.each { |line| print line }
|
2017-10-02 16:54:53 +02:00
|
|
|
rescue Errno::EIO => e
|
|
|
|
puts e
|
|
|
|
ensure
|
|
|
|
::Process.wait pid
|
2017-07-10 18:28:51 +02:00
|
|
|
end
|
|
|
|
end
|
2017-10-02 16:54:53 +02:00
|
|
|
rescue PTY::ChildExited => e
|
|
|
|
puts e
|
2017-07-10 18:28:51 +02:00
|
|
|
puts "Process exited"
|
|
|
|
end
|
|
|
|
# Exit if PTY return a non-zero code
|
|
|
|
if $?.exitstatus != 0
|
|
|
|
STDERR.puts("Error building #{pkg}")
|
|
|
|
exit($?.exitstatus)
|
|
|
|
end
|
2017-07-10 00:05:36 +02:00
|
|
|
end
|
|
|
|
end
|