summarylogtreecommitdiffstats
path: root/update.rb
blob: 4df701a584f2020eaf78724ee6212cf41aacf83e (plain)
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
require 'mixlib/install'
require 'json'

options = {
  channel: :stable,
  product_name: 'chef-workstation',
  platform: "ubuntu",
  platform_version: "18.04",
  architecture: "x86_64"
}

artifact = Mixlib::Install.new(options).artifact_info
pkgbuild = File.read("PKGBUILD")
pkgbuild.split("\n").each do |line|
  if  line =~ /pkgver=(.*)/
    if $1 == artifact.version
      puts "#{$1}: This version is already current!"
      exit 1
    end
    File.open(".commit_msg", "w") do |f|
      f.write("#{$1}#{artifact.version}")
    end
    break
  end
end

pkgbuild = pkgbuild.gsub(/pkgver=.*/, "pkgver=#{artifact.version}").
  gsub(/sha256sums=.*/, "sha256sums=('#{artifact.sha256}')").
  gsub(/source=.*/, "source=('#{artifact.url}')").
  gsub(/arch=.*/, "arch=('#{artifact.architecture}')")

File.open("PKGBUILD", "w") { |f| f.write(pkgbuild) }