Module: MSPRelease::Project::Debian

Defined in:
lib/msp_release/project/debian.rb

Defined Under Namespace

Classes: BuildResult

Constant Summary collapse

DEFAULT_PATH =
"debian/msp/changelog"

Instance Method Summary collapse

Instance Method Details

#build_command(options = {}) ⇒ Object



155
156
157
158
159
160
161
# File 'lib/msp_release/project/debian.rb', line 155

def build_command(options={})
  if cmd = config[:deb_build_command]
    cmd
  else
    "dpkg-buildpackage" + (@sign ? '' : ' -us -uc')
  end
end

#build_opts(options = {}) ⇒ Object



151
152
153
# File 'lib/msp_release/project/debian.rb', line 151

def build_opts(options={})
  @sign = options[:sign]
end

#build_result(dir) ⇒ Object



163
164
165
# File 'lib/msp_release/project/debian.rb', line 163

def build_result(dir)
  BuildResult.new(dir, self)
end

#changelogObject



79
80
81
# File 'lib/msp_release/project/debian.rb', line 79

def changelog
  Debian.new(@dir, changelog_path)
end

#changelog_pathObject



63
64
65
# File 'lib/msp_release/project/debian.rb', line 63

def changelog_path
  @changelog_path || 'debian/changelog'
end

#nameObject



75
76
77
# File 'lib/msp_release/project/debian.rb', line 75

def name
  source_package_name
end

#next_version_for_release(options = {}) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/msp_release/project/debian.rb', line 83

def next_version_for_release(options = {})
  deb_version = changelog.version
  distribution = options[:distribution] || changelog.distribution

  new_version =
    if deb_version.to_version != version
      LOG.warn "Warning: project version (#{version.to_s}) " +
        "did not match changelog version (#{deb_version.to_s}), project " +
          "version wins"
      changelog.reset_at(version)
    else
      deb_version.bump
    end

  LOG.debug "Adding new entry to changelog..."
  changelog.add(new_version, "New release", distribution)

  LOG.debug "Changelog now at #{new_version}"
  puts_changelog_info

  new_version
end

#prepare_for_build(branch_name, options = {}) ⇒ Object



118
119
120
121
122
123
124
125
# File 'lib/msp_release/project/debian.rb', line 118

def prepare_for_build(branch_name, options={})
  branch_is_release_branch = !! /^release-.+$/.match(branch_name)
  distribution = options[:distribution] || changelog.distribution

  rename_dir_for_build(branch_name, distribution)

  super if defined?(super)
end

#project_specific_push(release_name) ⇒ Object



111
112
113
114
115
116
# File 'lib/msp_release/project/debian.rb', line 111

def project_specific_push(release_name)
  # Create a release commit.
  commit_message = release_commit_message(release_name)
  exec "git add #{changelog.fname}"
  exec "git commit -m\"#{commit_message}\""
end

#puts_changelog_infoObject



106
107
108
109
# File 'lib/msp_release/project/debian.rb', line 106

def puts_changelog_info
  LOG.debug "OK, please update the change log, then run 'vershunt push' to"\
    " push your changes for building"
end

#rename_dir_for_build(branch_name, distribution) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/msp_release/project/debian.rb', line 127

def rename_dir_for_build(branch_name, distribution)
  branch_is_release_branch = !! /^release-.+$/.match(branch_name)
  new_dir = Dir.chdir(@dir) do
    if branch_is_release_branch
      first_commit_hash, commit_message =
        find_first_release_commit

      if first_commit_hash.nil?
        raise CLI::Exit, "Could not find a release commit on #{pathspec}"
      end

      clean_checkout
    else
      dev_version = Debian::Versions::Development.
        new_from_working_directory(branch_name, latest_commit_hash)

      changelog.amend(dev_version, distribution)
    end
    name + "-" + changelog.version.to_s
  end
  FileUtils.mv(@dir, new_dir)
  @dir = new_dir
end

#source_package_nameObject



67
68
69
70
71
72
73
# File 'lib/msp_release/project/debian.rb', line 67

def source_package_name
  debian_dir = File.dirname(File.join(@dir, changelog_path))
  control_file = File.join(debian_dir + '/control')
  source_line = MSPRelease::Exec.exec("grep Source: #{control_file}")
  match = /^Source: (.+)$/.match(source_line)
  match && match[1]
end

#versionObject



59
60
61
# File 'lib/msp_release/project/debian.rb', line 59

def version
  changelog.version.to_version
end

#write_version(new_version) ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/msp_release/project/debian.rb', line 50

def write_version(new_version)
  debian_version = Debian::Versions::Unreleased.new_from_version(new_version)
  changelog.add(debian_version, "New version")

  defined?(super) ?
    Array(super).push(changelog.fname) :
    [changelog.fname]
end