summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorLevitatingBusinessMan (Rein Fernhout)2023-05-11 22:53:59 +0200
committerLevitatingBusinessMan (Rein Fernhout)2023-05-11 22:53:59 +0200
commitaf50986a978341978e6f934ce158c4b357b146d7 (patch)
treeb2b89ff06120fc4bf5d3f9d9bbf70e41eec87078
parent984587909d2f987e7aea6c26f528ce894147d996 (diff)
downloadaur-af50986a978341978e6f934ce158c4b357b146d7.tar.gz
Added update script
-rw-r--r--.SRCINFO4
-rw-r--r--PKGBUILD4
-rw-r--r--update.rb62
3 files changed, 66 insertions, 4 deletions
diff --git a/.SRCINFO b/.SRCINFO
index bd1d1393326c..162fbb0c3217 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
pkgbase = visual-paradigm-community
pkgdesc = UML design application
- pkgver = 17.0
- pkgrel = 20230401
+ pkgver = 17.0.20230401
+ pkgrel = 1
url = http://www.visual-paradigm.com/download/community.jsp
install = visual-paradigm-community.install
arch = x86_64
diff --git a/PKGBUILD b/PKGBUILD
index 8733a44e4dd8..d8e4531f48d6 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -4,8 +4,8 @@
# Contributor: Simonas Racinas <racinas at icloud.com>
# Contributor: Rein Fernhout <me@levitati.ng>
pkgname=visual-paradigm-community
-pkgver=17.0
-pkgrel=20230401
+pkgver=17.0.20230401
+pkgrel=1
pkgdesc="UML design application"
url='http://www.visual-paradigm.com/download/community.jsp'
arch=('x86_64')
diff --git a/update.rb b/update.rb
new file mode 100644
index 000000000000..09f1e4c372ab
--- /dev/null
+++ b/update.rb
@@ -0,0 +1,62 @@
+require "httparty"
+require "colorize"
+
+# Possible values: ca1 usa10 usa11 usa13 usa14 uk3 uk5 germany4 germany5 germany6 france3
+SERVER = "germany4"
+
+PKGBUILD = File.read("PKGBUILD")
+old_version = PKGBUILD.split(/\n/).find{|l| l.start_with? "pkgver="}.split("=").last
+
+abort "Version detected as #{old_version.inspect.red} which does not match the format, quitting" if !/\d+\.\d+\.\d+/.match? old_version
+
+puts "Version detected in PKGBUILD is #{old_version.blue}"
+
+print "Requesting current version...\r"
+res = HTTParty.get(
+ "https://www.visual-paradigm.com/downloads/vpce/Visual_Paradigm_CE_Linux64.sh",
+ follow_redirects: false,
+)
+
+url = res.headers[:location]
+
+version = url.match(/.*\/Visual_Paradigm_CE_(\d+)_(\d+)_(\d+)_Linux64\.sh/).captures.join(".")
+
+puts "The current version is #{version == old_version ? version.blue : version.green}"
+
+abort "Same version, quitting" if version == old_version
+
+
+puts "Downloading and hashing new file..."
+
+download_url = "https://www.visual-paradigm.com/downloads/#{SERVER}/vpce/Visual_Paradigm_CE_Linux64_InstallFree.tar.gz"
+
+length = HTTParty.head(download_url).headers["Content-Length"].to_i
+
+collected = 0
+
+digest = Digest::SHA256.new
+
+HTTParty.get(download_url, stream_body: true) do |frag|
+ collected += frag.length
+ digest << frag
+ percentage = (collected.to_f/length * 100).round
+ print "[#{('#' * (percentage / 2)).ljust 50, ' '}] #{percentage.round.to_s.rjust 2, '0'}% (#{(length/10**6).round 1}Mb)\r"
+end
+
+puts "The current hash is #{digest.hexdigest.blue}" + " " *20
+
+PKGBUILD_FILE = File.open "PKGBUILD", "w"
+
+for line in PKGBUILD.lines
+ if line.start_with? "pkgver="
+ PKGBUILD_FILE.puts "pkgver=#{version}"
+ elsif line.start_with? "pkgrel="
+ PKGBUILD_FILE.puts "pkgrel=1"
+ elsif line.start_with? "sha256sums=('"
+ PKGBUILD_FILE.puts "sha256sums=('#{digest.hexdigest}'"
+ else
+ PKGBUILD_FILE << line
+ end
+end
+
+puts "Updated PKGBUILD"