summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorТомас2022-04-08 15:22:15 -0500
committerТомас2022-04-08 15:22:15 -0500
commit3bed9ae66d5b7689ac83a3d31aa97d7b266b5a2d (patch)
tree53e7c5df8df02dbeff344e9d73443283b4670b19
parent81653cde970df8dd25107469a1e83ef39d231c66 (diff)
downloadaur-3bed9ae66d5b7689ac83a3d31aa97d7b266b5a2d.tar.gz
Added Rakefile
-rw-r--r--Rakefile93
1 files changed, 93 insertions, 0 deletions
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 00000000000..db03c07daa6
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,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-server',
+ platform: "ubuntu",
+ platform_version: "18.04",
+ 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
+