-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_debian.py
executable file
·52 lines (40 loc) · 1.62 KB
/
build_debian.py
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
#!/usr/bin/python3
import subprocess
import os
from os import path
import tomllib
import shutil
with open("./antelope-firewall/Cargo.toml", 'rb') as f:
data = tomllib.load(f)
subprocess.run(["cargo", "build", "--release"])
version = data["package"]["version"]
build_base = f"antelope-firewall_{version}-1"
os.makedirs(build_base, exist_ok=True)
os.makedirs(path.join(build_base, "DEBIAN"), exist_ok=True)
os.makedirs(path.join(build_base, "usr/bin"), exist_ok=True)
shutil.copyfile("target/release/antelope-firewall", path.join(build_base, "usr/bin/antelope-firewall"))
subprocess.run(["chmod", "+x", path.join(build_base, "usr/bin/antelope-firewall")])
os.makedirs(path.join(build_base, "etc/antelope-firewall"), exist_ok=True)
shutil.copyfile("default_config.toml", path.join(build_base, "etc/antelope-firewall/config.toml"))
with open(path.join(build_base, "DEBIAN", "control"), "w") as f:
f.write(f"""Package: antelope-firewall
Version: {version}-1
Section: base
Priority: optional
Architecture: amd64
Depends: openssl
Maintainer: Matthew Jurenka <[email protected]>
Description: Firewall and Rate Limiter and Load Balancer
for Antelope blockchain RPCs. For more information:
https://github.com/animuslabs/antelope-firewall
""")
os.makedirs(path.join(build_base, "etc/systemd/system"), exist_ok=True)
with open(path.join(build_base, "etc/systemd/system/antelope-firewall.service"), "w") as f:
f.write(f"""[Unit]
Description=Firewall/Rate Limiter/Load Balancer for Antelope RPC Nodes
[Service]
ExecStart=/usr/bin/antelope-firewall
[Install]
WantedBy=multi-user.target
""")
subprocess.run(["dpkg-deb", "--build", build_base])