/
starnet-plus-plus.rb
56 lines (46 loc) 路 1.66 KB
/
starnet-plus-plus.rb
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
cask "starnet-plus-plus" do
version "2,03,2022"
sha256 "35f0c11f49a1bde466e317565e75beb32b57ebfead85379c23cc3953c1c42fc7"
url "https://starnetastro.com/wp-content/uploads/#{version.csv.third}/#{version.csv.second}/StarNetv#{version.csv.first}CLI_MacOS.zip"
name "starnet++"
desc "Removes stars from astrophotography images using ML models"
homepage "https://www.starnetastro.com/"
livecheck do
url "https://www.starnetastro.com/download/"
regex(%r{uploads/(\d+)/(\d+)/StarNetv?(\d+(?:\.\d+)*)CLI[._-]MacOS.zip}i)
strategy :page_match do |page, regex|
page.scan(regex).map { |match| "#{match[2]},#{match[1]},#{match[0]}" }
end
end
bin_path = "#{staged_path}/StarNetv#{version.csv.first}CLI_MacOS"
bins = [
"starnet++",
"libtensorflow.2.dylib",
"libtensorflow_framework.2.dylib",
]
shimscript = "#{staged_path}/starnet_wrapper.sh"
binary shimscript, target: "starnet++"
preflight do
File.write shimscript, <<~EOS
#!/bin/sh
# delete the symlink on process exit
cleanup() {
rm -f starnet#{version.csv.first}_weights.pb
}
trap cleanup RETURN EXIT SIGINT SIGKILL
# the binary hardcodes the weights path so we have to symlink it to the CWD
ln -sf "#{bin_path}/starnet#{version.csv.first}_weights.pb" .
# define a load path since the libs are not in the same dir as the bin
DYLD_LIBRARY_PATH=#{bin_path} command #{bin_path}/starnet++ $@
EOS
end
postflight do
set_permissions "#{bin_path}/starnet++", "0755"
bins.each do |bin|
system_command "xattr", args: ["-c", "#{bin_path}/#{bin}"]
end
end
caveats do
requires_rosetta
end
end