[SCM] ci-tooling packaging branch, master, updated. 8213b54ce306a02535a1b81bc5b9a6b2359b787f

Rohan Garg rohangarg-guest at moszumanska.debian.org
Tue Oct 20 16:34:55 UTC 2015


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

The following commit has been merged in the master branch:
commit 97f311b515c79c8520f079b98155edaf9d793cf7
Author: Rohan Garg <rohan at garg.io>
Date:   Tue Oct 20 18:15:19 2015 +0200

    Wrap class inside CI module
---
 lib/ci/build_source.rb       | 245 ++++++++++++++++++++++---------------------
 test/test_ci_build_source.rb |  16 +--
 2 files changed, 135 insertions(+), 126 deletions(-)

diff --git a/lib/ci/build_source.rb b/lib/ci/build_source.rb
index 46a51ea..5d143e9 100644
--- a/lib/ci/build_source.rb
+++ b/lib/ci/build_source.rb
@@ -9,145 +9,154 @@ require_relative '../os'
 require_relative 'build_version'
 require_relative 'source'
 
-# Class to build out source package from a VCS
-class VcsSourceBuilder
-  BUILD_DIR = 'build/'
-
-  def initialize(release:)
-    @release = release
-    @flavor = OS::ID.to_sym
-    @data = YAML.load_file("#{File.dirname(__FILE__)}/data/maintainer.yaml")
-
-    @source = CI::Source.new
-    changelog = nil
-    Dir.chdir('packaging') do
-      @source.type = Debian::Source.new(Dir.pwd).format.type
-      changelog = Changelog.new
-      fail "Can't parse changelog!" if changelog.nil?
-    end
-
-    @source.name = changelog.name
-    @source.build_version = CI::BuildVersion.new(changelog)
-    @source.version = @source.build_version.base if @source.type == :native
-    @source.version = @source.build_version.full if @source.type == :quilt
-    @tar_version = @source.build_version.tar
-  end
+module CI
+  # Class to build out source package from a VCS
+  class VcsSourceBuilder
+    BUILD_DIR = 'build/'
+
+    def initialize(release:)
+      @release = release
+      @flavor = OS::ID.to_sym
+      @data = YAML.load_file("#{File.dirname(__FILE__)}/data/maintainer.yaml")
+
+      @source = CI::Source.new
+      changelog = nil
+      Dir.chdir('packaging') do
+        @source.type = Debian::Source.new(Dir.pwd).format.type
+        changelog = Changelog.new
+        fail "Can't parse changelog!" if changelog.nil?
+      end
 
-  def copy_source
-    # copy sources around
-    FileUtils.rm_r(BUILD_DIR) if File.exist?(BUILD_DIR)
-    FileUtils.mkpath("#{BUILD_DIR}/source")
+      @source.name = changelog.name
+      @source.build_version = CI::BuildVersion.new(changelog)
+      if @source.type == :quilt
+        @source.version = @source.build_version.full
+        # FIXME: This is just ewwwww
+        @source.dsc = "#{@source.name}_#{@source.build_version.tar}-0.dsc"
+      else
+        @source.version = @source.build_version.base
+        @source.dsc = "#{@source.name}_#{@source.build_version.tar}.dsc"
+      end
 
-    unless @source.type == :native
-      FileUtils.cp_r(Dir.glob('source/*'), 'build/source/', verbose: true)
+      @tar_version = @source.build_version.tar
     end
 
-    %w(.bzr .git .hg .svn debian).each do |dir|
-      FileUtils.rm_rf(Dir.glob("build/source/**/#{dir}"))
+    def copy_source
+      # copy sources around
+      FileUtils.rm_r(BUILD_DIR) if File.exist?(BUILD_DIR)
+      FileUtils.mkpath("#{BUILD_DIR}/source")
+
+      unless @source.type == :native
+        FileUtils.cp_r(Dir.glob('source/*'), 'build/source/', verbose: true)
+      end
+
+      %w(.bzr .git .hg .svn debian).each do |dir|
+        FileUtils.rm_rf(Dir.glob("build/source/**/#{dir}"))
+      end
     end
-  end
 
-  def create_orig_tar
-    Dir.chdir(BUILD_DIR) do
-      tar = "#{@source.name}_#{@tar_version}.orig.tar"
-      fail 'Failed to create a tarball' unless system("tar -cf #{tar} source")
-      r = system("pxz -6 #{tar}")
-      unless r
-        warn 'Falling back to slower single threaded compression'
-        fail 'Failed to compress the tarball' unless system("xz -6 #{tar}")
+    def create_orig_tar
+      Dir.chdir(BUILD_DIR) do
+        tar = "#{@source.name}_#{@tar_version}.orig.tar"
+        fail 'Failed to create a tarball' unless system("tar -cf #{tar} source")
+        r = system("pxz -6 #{tar}")
+        unless r
+          warn 'Falling back to slower single threaded compression'
+          fail 'Failed to compress the tarball' unless system("xz -6 #{tar}")
+        end
       end
     end
-  end
 
-  def copy_packaging
-    # Copy some more
-    FileUtils.cp_r(Dir.glob('packaging/*'), 'build/source/', verbose: true)
-  end
+    def copy_packaging
+      # Copy some more
+      FileUtils.cp_r(Dir.glob('packaging/*'), 'build/source/', verbose: true)
+    end
 
-  def log_change
-    # Create changelog entry
-    Dir.chdir("#{BUILD_DIR}/source/") do
-      ENV['DEBFULLNAME'] = @data[@flavor][:name]
-      ENV['DEBEMAIL'] = @data[@flavor][:email]
-      unless system("dch -b -v #{@source.version} -D #{@release} \
-                    'Automatic #{@flavor.capitalize} CI Build'")
-        # :nocov:
-        # dch cannot actually fail because we parse the changelog beforehand
-        # so it is of acceptable format here already.
-        fail 'Failed to create changelog entry'
-        # :nocov:
+    def log_change
+      # Create changelog entry
+      Dir.chdir("#{BUILD_DIR}/source/") do
+        ENV['DEBFULLNAME'] = @data[@flavor][:name]
+        ENV['DEBEMAIL'] = @data[@flavor][:email]
+        unless system("dch -b -v #{@source.version} -D #{@release} \
+                      'Automatic #{@flavor.capitalize} CI Build'")
+          # :nocov:
+          # dch cannot actually fail because we parse the changelog beforehand
+          # so it is of acceptable format here already.
+          fail 'Failed to create changelog entry'
+          # :nocov:
+        end
       end
     end
-  end
 
-  def build
-    # dpkg-buildpackage
-    Dir.chdir("#{BUILD_DIR}/source/") do
-      system('update-maintainer')
-      # Force -sa as reprepreo refuses to accept uploads without orig.
-      return if system('dpkg-buildpackage', '-us', '-uc', '-S', '-d', '-sa')
-      fail 'Could not run dpkg-buildpackage!'
+    def build
+      # dpkg-buildpackage
+      Dir.chdir("#{BUILD_DIR}/source/") do
+        system('update-maintainer')
+        # Force -sa as reprepreo refuses to accept uploads without orig.
+        return if system('dpkg-buildpackage', '-us', '-uc', '-S', '-d', '-sa')
+        fail 'Could not run dpkg-buildpackage!'
+      end
     end
-  end
 
-  def cleanup
-    FileUtils.rm_rf("#{BUILD_DIR}/source")
-  end
+    def cleanup
+      FileUtils.rm_rf("#{BUILD_DIR}/source")
+    end
 
-  def run
-    copy_source
-    create_orig_tar
-    copy_packaging
-    mangle!
-    log_change
-    build
-    cleanup
-    @source
-  end
+    def run
+      copy_source
+      create_orig_tar
+      copy_packaging
+      mangle!
+      log_change
+      build
+      cleanup
+      @source
+    end
 
-  private
-
-  def mangle!
-    # Rip out locale install
-    Dir.chdir('build/source/') do
-      Dir.glob('debian/*.install').each do |install_file_path|
-        # Strip localized manpages
-        # e.g.  usr /share /man /  *  /man 7 /kf5options.7
-        man_regex = %r{^.*usr/share/man/(\*|\w+)/man\d/.*$}
-        subbed = File.open(install_file_path).read.gsub(man_regex, '')
-        File.open(install_file_path, 'w') do |f|
-          f << subbed
+    private
+
+    def mangle!
+      # Rip out locale install
+      Dir.chdir('build/source/') do
+        Dir.glob('debian/*.install').each do |install_file_path|
+          # Strip localized manpages
+          # e.g.  usr /share /man /  *  /man 7 /kf5options.7
+          man_regex = %r{^.*usr/share/man/(\*|\w+)/man\d/.*$}
+          subbed = File.open(install_file_path).read.gsub(man_regex, '')
+          File.open(install_file_path, 'w') do |f|
+            f << subbed
+          end
+
+          # FIXME: bloody workaround for kconfigwidgets and kdelibs4support
+          # containing legit locale data
+          next if %w(kconfigwidgets kdelibs4support).include?(@source.name)
+
+          locale_regex = %r{^.*usr/share/locale.*$}
+          subbed = File.open(install_file_path).read.gsub(locale_regex, '')
+          File.open(install_file_path, 'w') do |f|
+            f << subbed
+          end
         end
-
-        # FIXME: bloody workaround for kconfigwidgets and kdelibs4support
-        # containing legit locale data
-        next if %w(kconfigwidgets kdelibs4support).include?(@source.name)
-
-        locale_regex = %r{^.*usr/share/locale.*$}
-        subbed = File.open(install_file_path).read.gsub(locale_regex, '')
-        File.open(install_file_path, 'w') do |f|
-          f << subbed
+        # If the package is now empty, lintian override the empty warning
+        # to avoid false positives
+        Dir.glob('debian/*.install').each do |install_file_path|
+          next unless File.open(install_file_path, 'r').read.strip.empty?
+          package_name = File.basename(install_file_path, '.install')
+          lintian_overrides_path = install_file_path.gsub('.install',
+                                                          '.lintian-overrides')
+          puts "#{package_name} is now empty, trying to add lintian override"
+          File.open(lintian_overrides_path, 'a') do |file|
+            file.write("#{package_name}: empty-binary-package
")
+          end
         end
-      end
-      # If the package is now empty, lintian override the empty warning
-      # to avoid false positives
-      Dir.glob('debian/*.install').each do |install_file_path|
-        next unless File.open(install_file_path, 'r').read.strip.empty?
-        package_name = File.basename(install_file_path, '.install')
-        lintian_overrides_path = install_file_path.gsub('.install',
-                                                        '.lintian-overrides')
-        puts "#{package_name} is now empty, trying to add lintian override"
-        File.open(lintian_overrides_path, 'a') do |file|
-          file.write("#{package_name}: empty-binary-package
")
+        # Rip out symbol files unless we are on latest
+        unless @release == KCI.latest_series
+          symbols = Dir.glob('debian/symbols') +
+                    Dir.glob('debian/*.symbols') +
+                    Dir.glob('debian/*.symbols.*')
+          symbols.each { |s| FileUtils.rm(s) }
         end
       end
-      # Rip out symbol files unless we are on latest
-      unless @release == KCI.latest_series
-        symbols = Dir.glob('debian/symbols') +
-                  Dir.glob('debian/*.symbols') +
-                  Dir.glob('debian/*.symbols.*')
-        symbols.each { |s| FileUtils.rm(s) }
-      end
     end
   end
 end
diff --git a/test/test_ci_build_source.rb b/test/test_ci_build_source.rb
index bc9d35b..484abbc 100644
--- a/test/test_ci_build_source.rb
+++ b/test/test_ci_build_source.rb
@@ -62,7 +62,7 @@ class VCSBuilderTest < TestCase
   end
 
   def test_quilt
-    s = VcsSourceBuilder.new(release: @release)
+    s = CI::VcsSourceBuilder.new(release: @release)
     r = s.run
     assert_equal(:quilt, r.type)
     assert_equal('hello', r.name)
@@ -71,7 +71,7 @@ class VCSBuilderTest < TestCase
   end
 
   def test_native
-    s = VcsSourceBuilder.new(release: @release)
+    s = CI::VcsSourceBuilder.new(release: @release)
     r = s.run
     assert_equal(:native, r.type)
     assert_equal('hello', r.name)
@@ -80,7 +80,7 @@ class VCSBuilderTest < TestCase
   end
 
   def test_empty_install
-    s = VcsSourceBuilder.new(release: @release)
+    s = CI::VcsSourceBuilder.new(release: @release)
     r = s.run
     assert_equal(:native, r.type)
     assert_equal('hello', r.name)
@@ -92,14 +92,14 @@ class VCSBuilderTest < TestCase
   end
 
   def test_build_fail
-    s = VcsSourceBuilder.new(release: @release)
+    s = CI::VcsSourceBuilder.new(release: @release)
     assert_raise RuntimeError do
       s.run
     end
   end
 
   def test_symbols_keep
-    VcsSourceBuilder.new(release: KCI.latest_series).run
+    CI::VcsSourceBuilder.new(release: KCI.latest_series).run
     Dir.chdir('build')
     tar = Dir.glob('*.tar.gz')
     assert_equal(1, tar.size)
@@ -111,7 +111,7 @@ class VCSBuilderTest < TestCase
 
   def test_symbols_strip
     oldest_series = KCI.series(sort: :descending).keys.last
-    VcsSourceBuilder.new(release: oldest_series).run
+    CI::VcsSourceBuilder.new(release: oldest_series).run
     Dir.chdir('build')
     tar = Dir.glob('*.tar.gz')
     assert_equal(1, tar.size)
@@ -123,7 +123,7 @@ class VCSBuilderTest < TestCase
 
   def assert_changelogid(osid, author)
     send("fake_os_#{osid}".to_sym)
-    source = VcsSourceBuilder.new(release: @release).run
+    source = CI::VcsSourceBuilder.new(release: @release).run
     Dir.chdir('build') do
       # FIXME: composition should be in source really
       dsc = "#{source.name}_#{source.version}.dsc"
@@ -145,7 +145,7 @@ class VCSBuilderTest < TestCase
   end
 
   def test_locale_kdelibs4support
-    source = VcsSourceBuilder.new(release: @release).run
+    source = CI::VcsSourceBuilder.new(release: @release).run
     Dir.chdir('build') do
       # FIXME: composition should be in source really
       dsc = "#{source.name}_#{source.version}.dsc"

-- 
ci-tooling packaging



More information about the pkg-kde-commits mailing list