Commit | Line | Data |
---|---|---|
4559aa03 | 1 | require 'rugged' |
06e5ec1f | 2 | require 'pty' |
4559aa03 S |
3 | |
4 | task default: %w[build] | |
5 | ||
6 | task :build do | |
7 | repo = Rugged::Repository.new('.') | |
8 | commit = repo.head.target | |
9 | parent = commit.parents.first | |
06e5ec1f S |
10 | pkgs = commit.diff(parent).deltas.map { |d| d.new_file[:path] } |
11 | # Split paths into arrays | |
12 | pkgs.map! { |p| Pathname.new(p).each_filename.to_a } | |
13 | # looking for [disabled-]packages/(package_name)/... | |
14 | pkgs.select! { |p| p.length > 2 and p[0] =~ /(?<disabled->)packages/ } | |
15 | # Get package_name | |
16 | pkgs.map! { |p| p[1] } | |
17 | # Remove duplicate packages | |
18 | pkgs.uniq! | |
19 | pkgs.each do |pkg| | |
20 | puts "Building #{pkg}" | |
21 | begin | |
22 | # Start blocking build loop | |
23 | PTY.spawn("./scripts/run-docker.sh ./build-package.sh #{pkg}") do |stdout, stdin, pid| | |
24 | begin | |
25 | stdout.each { |line| print line } | |
26 | rescue Errno::EIO | |
27 | end | |
28 | end | |
29 | rescue PTY::ChildExited | |
30 | puts "Process exited" | |
31 | end | |
32 | # Exit if PTY return a non-zero code | |
33 | if $?.exitstatus != 0 | |
34 | STDERR.puts("Error building #{pkg}") | |
35 | exit($?.exitstatus) | |
36 | end | |
4559aa03 S |
37 | end |
38 | end |