File: Rakefile

package info (click to toggle)
gem2deb 0.33.1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 992 kB
  • sloc: ruby: 4,942; perl: 81; ansic: 66; makefile: 35; sh: 33
file content (96 lines) | stat: -rw-r--r-- 2,614 bytes parent folder | download | duplicates (4)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
require 'rake/testtask'

ENV['LANG'] = 'C'

task :default => :test

task :test => :version_check do
  puts '=> Unit tests'
  Rake::Task['test:unit'].invoke
  puts '=> Integration tests'
  Rake::Task['test:integration'].invoke
end

Rake::TestTask.new('test:unit') do |t|
  t.libs << "test"
  t.test_files = FileList['test/unit/*_test.rb']
  t.verbose = true
end

Rake::TestTask.new('test:integration') do |t|
  t.libs << 'test'
  t.test_files = FileList['test/integration/*_test.rb']
  t.verbose = true
end

desc "Run tests in debug mode (e.g. don't delete temporary files)"
task 'test:debug' do
  ENV['DEBUG'] = 'yes'
  Rake::Task['test'].invoke
end

desc "Builds the Debian package and installs it on your system"
task :install do
  sh 'dpkg-buildpackage -us -uc'
  sh "sudo debi"
end

desc "Builds a git snapshot package"
task 'snapshot:build', :install do |task,args|
  if !system('git diff-index --quiet HEAD')
    fail "Can't build package; you have uncommitted changes"
  end

  date = `date --iso=seconds |sed 's/+.*//' |sed 's/[-T:]//g'`.chomp
  branch = `git symbolic-ref --short HEAD`.strip
  newbranch = 'snapshot-' + date

  sh 'git checkout -b ' + newbranch
  sh "sed -i '1 s/)/~git#{date})/' debian/changelog"
  sh 'git commit -a -m snapshot-' + date
  begin
    sh 'DEB_BUILD_OPTIONS=nocheck gbp buildpackage --git-ignore-branch -us -uc'
    if args[:install]
      sh 'debi'
    end
  ensure
    sh 'git checkout ' + branch
  end
end

desc "Installs a git snapshot package"
task 'snapshot:install' do
  Rake::Task['snapshot:build'].invoke(true)
end


desc "Checks for inconsistencies between version numbers in the code and in debian/changelog"
task :version_check do
  $code_version = `ruby -Ilib -rgem2deb/version -e 'puts Gem2Deb::VERSION'`.strip
  $debian_version = `dpkg-parsechangelog | grep '^Version: ' | cut -d ' ' -f 2`.strip
  if $code_version != $debian_version
    msg ="W: Inconsistent version numbers: lib/gem2deb/version.rb says #{$code_version}, debian/changelog says #{$debian_version}"
    if STDIN.isatty && STDOUT.isatty && STDERR.isatty
      # highlight the message in red
      puts("\033[31;40m%s\033[m" % msg)
    else
      puts msg
    end
    fail if ENV.has_key?('VERSION_CHECK_FATAL')
  end
end

namespace :release do
  desc "Releases to Debian (very much tied to terceiro's workflow)"
  task :debian do
    ENV['VERSION_CHECK_FATAL'] = 'yes'
    Rake::Task['version_check'].invoke

    sh 'gbp buildpackage --git-builder=sbuild'
    sh 'gbp buildpackage --git-tag-only'
    sh 'debsign'
    sh 'git push --all'
    sh 'git push --tags'
    sh 'debrelease'
  end
end