forked from sjackman/linuxbrew-core
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aliddns.rb
63 lines (57 loc) · 2.31 KB
/
aliddns.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
57
58
59
60
61
62
63
class Aliddns < Formula
desc "Aliyun(Alibaba Cloud) ddns for golang"
homepage "https://github.com/OpenIoTHub/aliddns"
url "https://github.com/OpenIoTHub/aliddns.git",
tag: "v0.0.9",
revision: "37e4f959092b0c286019cab29ce36a0e434c6455"
license "MIT"
head "https://github.com/OpenIoTHub/aliddns.git"
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "16e5bfb49b749adb380450cde6092020afd9ef4d6ed3fa030c8c6ede11a6bf9d"
sha256 cellar: :any_skip_relocation, big_sur: "cb06193d5ebd8d4faa2e358f6d40589653a0a593e7265e21dfc15bfc99816cab"
sha256 cellar: :any_skip_relocation, catalina: "5bb2c74ba522eaf8713fb5c04b5e726e0bca16c4cfc406d7b4523187646acfdb"
sha256 cellar: :any_skip_relocation, mojave: "a5f4c51abd1deb28e02f1dc97ea2fb4bcde0d297e0da9d6c5a3b4cfb0bf6c135"
sha256 cellar: :any_skip_relocation, x86_64_linux: "af4e4412f6c2245f20e5a8ba752c45797d25879bcf14549f6a9f4859cc08bb8b"
end
depends_on "go" => :build
def install
ldflags = %W[
-s -w
-X main.version=#{version}
-X main.commit=#{Utils.git_head}
-X main.builtBy=homebrew
]
system "go", "build", "-mod=vendor", "-ldflags", ldflags.join(" "), *std_go_args
pkgetc.install "aliddns.yaml"
end
plist_options manual: "aliddns -c #{HOMEBREW_PREFIX}/etc/aliddns/aliddns.yaml"
def plist
<<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>KeepAlive</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/aliddns</string>
<string>-c</string>
<string>#{etc}/aliddns/aliddns.yaml</string>
</array>
<key>StandardErrorPath</key>
<string>#{var}/log/aliddns.log</string>
<key>StandardOutPath</key>
<string>#{var}/log/aliddns.log</string>
</dict>
</plist>
EOS
end
test do
assert_match version.to_s, shell_output("#{bin}/aliddns -v 2>&1")
assert_match "config created", shell_output("#{bin}/aliddns init --config=aliddns.yml 2>&1")
assert_predicate testpath/"aliddns.yml", :exist?
end
end