[SCM] ci-tooling packaging branch, master, updated. 2aad893ffc8d49ded174311f900a500cc48e80a0

Rohan Garg rohangarg-guest at moszumanska.debian.org
Thu Jun 11 19:00:32 UTC 2015


Gitweb-URL: http://git.debian.org/?p=pkg-kde/ci-tooling.git;a=commitdiff;h=2aad893

The following commit has been merged in the master branch:
commit 2aad893ffc8d49ded174311f900a500cc48e80a0
Author: Rohan Garg <rohan at garg.io>
Date:   Thu Jun 11 20:59:52 2015 +0200

    Initial import of the build code
---
 lib/ci/build_binary.rb | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 82 insertions(+)

diff --git a/lib/ci/build_binary.rb b/lib/ci/build_binary.rb
new file mode 100644
index 0000000..038cfc1
--- /dev/null
+++ b/lib/ci/build_binary.rb
@@ -0,0 +1,82 @@
+require 'fileutils'
+
+class Source
+  attr_reader :dsc
+  attr_reader :extract_path
+
+  def initialize(dsc)
+    @dsc = dsc
+  end
+
+  def extract(dir)
+    @extract_path = "#{dir}/build"
+    FileUtils.mkpath(@extract_path)
+    system('dpkg-source', '-x', @dsc, @extract_path)
+  end
+end
+
+class Builder
+  class DependencyResolver
+    RESOLVER_BIN = '/usr/lib/pbuilder/pbuilder-satisfydepends'
+
+    def self.resolve(source)
+      fail "Can't find #{RESOLVER_BIN}!" unless File.executable?(RESOLVER_BIN)
+      system('sudo',
+             RESOLVER_BIN,
+             '--control',
+             "#{source.extract_path}/debian/control")
+    end
+  end
+
+  def build_package
+    dpkg_buildopts = %w(-us -uc -sa)
+
+    # Only build arch independent packages on AMD64
+    dpkg_buildopts << '-B' unless RbConfig::CONFIG['host_cpu'] == 'x86_64'
+
+    Dir.chdir(@source.extract_path) do
+      system('dpkg-buildpackage', *dpkg_buildopts)
+    end
+  end
+
+  def print_contents
+    Dir.chdir('binary') do
+      debs = Dir.glob('*.deb')
+      debs.each do |deb|
+        system('lesspipe', deb)
+      end
+    end
+  end
+
+  def copy_binaries
+    Dir.mkdir('result') unless Dir.exist?('result')
+    changes = Dir.glob("#{@source.extract_path}/..")
+
+    unless changes.size == 1
+      fail "Not exactly one changes file WTF -> #{changes}"
+    end
+
+    system('dcmd', 'cp', '-v', *changes, 'result/')
+  end
+
+  def build(source)
+    @source = source
+    DependencyResolver.resolve(@source)
+
+    build_package
+    print_contents
+    copy_binaries
+  end
+end
+
+class PackageBuilder
+  def run
+    dsc = Dir.glob('*.dsc')
+    fail "Not exactly one dsc WTF -> #{dsc}" unless dsc.size == 1
+    s = Source.new(dsc)
+    s.extract('binary/')
+
+    b = Builder.new
+    b.build(s)
+  end
+end

-- 
ci-tooling packaging



More information about the pkg-kde-commits mailing list