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
|
# AUR User: This file exists to aid the package maintainer and is not needed to
# build or to run the package.
require 'mixlib/install'
# Upstream source options
chefio_options = {
channel: :stable,
product_name: 'chef-workstation',
platform: "debian",
platform_version: "11",
architecture: "x86_64"
}
# Release struct used to model a new release
Release = Struct.new(:version, :url, :sha256, keyword_init: true)
release = nil
task default: [:build]
task prep: [:clean, :vet] do
sh 'rm -rf Gemfile.lock'
sh 'bundle install'
end
task :clean do
sh 'git clean -fd'
sh 'rm -rf pkg src *.deb *.tar.xz'
end
task vet: [:namcap, :shellcheck]
task :namcap do
sh 'namcap PKGBUILD'
end
task :shellcheck do
sh 'shellcheck PKGBUILD'
end
task :lookup_current_release do
artifact = Mixlib::Install.new(chefio_options).artifact_info
if ! artifact.version
puts "Unable to get release info from Chef.io"
exit(1)
end
release = Release.new({
version: artifact.version,
url: artifact.url,
sha256: artifact.sha256
})
end
task update_pkgbuild: [:lookup_current_release] do
pkgbuild = File.read 'PKGBUILD'
pkgbuild.split("\n").each do |line|
if line =~ /pkgver=(.*)/
if $1 == release.version
puts "#{$1}: This version is already current!"
exit 1
end
File.write '.commit_msg', "#{$1} → #{release.version}"
break
end
end
pkgbuild = pkgbuild
.gsub(/pkgver=.*/, "pkgver=#{release.version}")
.gsub(/source=.*/, "source=('#{release.url}')")
.gsub(/sha256sums=.*/, "sha256sums=('#{release.sha256}')")
File.write 'PKGBUILD', pkgbuild
end
task build: [:prep, :update_pkgbuild] do
sh 'makepkg'
sh 'makepkg --printsrcinfo > .SRCINFO'
end
file commit: ['.commit_msg'] do
sh 'echo "Committing: "'
sh 'cat .commit_msg'
sh 'git add .SRCINFO'
sh 'git add PKGBUILD'
sh 'git commit -S -s -F .commit_msg'
sh 'rm .commit_msg'
end
|