forked from termux/termux-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
38 lines (36 loc) · 1.02 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'rugged'
require 'pty'
task default: %w[build]
task :build do
repo = Rugged::Repository.new('.')
commit = repo.head.target
parent = commit.parents.first
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
PTY.spawn("./scripts/run-docker.sh ./build-package.sh #{pkg}") do |stdout, stdin, pid|
begin
stdout.each { |line| print line }
rescue Errno::EIO
end
end
rescue PTY::ChildExited
puts "Process exited"
end
# Exit if PTY return a non-zero code
if $?.exitstatus != 0
STDERR.puts("Error building #{pkg}")
exit($?.exitstatus)
end
end
end